@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
|
@@ -110,12 +110,46 @@ export function transformItems(rawItems, workflowFieldName) {
|
|
|
110
110
|
}
|
|
111
111
|
return transformed;
|
|
112
112
|
}
|
|
113
|
+
function countMember(value, key) {
|
|
114
|
+
const found = member(member(value, key), 'totalCount');
|
|
115
|
+
return typeof found === 'number' ? found : undefined;
|
|
116
|
+
}
|
|
117
|
+
function parentOf(content) {
|
|
118
|
+
const parent = member(content, 'parent');
|
|
119
|
+
const repository = extractRepository(parent);
|
|
120
|
+
const number = member(parent, 'number');
|
|
121
|
+
return repository === '' || typeof number !== 'number' ? undefined : { repository, number };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
一覧の応答から、Issue ごとの着手の判定の入力を取る。キーは boardItemKey と同じ。Issue 以外と、番号の無いものは含めない
|
|
125
|
+
*/
|
|
126
|
+
export function readBoardProgress(rawItems, labelFieldName) {
|
|
127
|
+
const progress = new Map();
|
|
128
|
+
for (const item of rawItems) {
|
|
129
|
+
const content = member(item, 'content');
|
|
130
|
+
if (isEmptyValue(content) || member(content, 'blockedBy') === undefined)
|
|
131
|
+
continue;
|
|
132
|
+
const key = boardItemKey({ content: { number: member(content, 'number'), repository: extractRepository(content) } });
|
|
133
|
+
if (key === undefined)
|
|
134
|
+
continue;
|
|
135
|
+
const issueType = member(member(content, 'issueType'), 'name');
|
|
136
|
+
const blockedBy = member(member(content, 'blockedBy'), 'totalCount');
|
|
137
|
+
progress.set(key, {
|
|
138
|
+
issueType: typeof issueType === 'string' ? issueType : undefined,
|
|
139
|
+
subIssues: countMember(content, 'subIssues') ?? 0,
|
|
140
|
+
parent: parentOf(content),
|
|
141
|
+
blockedBy: typeof blockedBy === 'number' ? blockedBy : undefined,
|
|
142
|
+
label: extractWorkflowStatus(item, labelFieldName),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return progress;
|
|
146
|
+
}
|
|
113
147
|
/**
|
|
114
|
-
1 アイテムを Markdown 表の行 `| Ref | Title |` にする。
|
|
148
|
+
1 アイテムを Markdown 表の行 `| Ref | Title |` にする。extraCells は、Title の後ろに足すセル。
|
|
115
149
|
Ref は GitHub 慣習に倣い `owner/repo#N` で合成する。
|
|
116
150
|
リポジトリ情報または番号が欠落している場合は可能な範囲で埋め、両方欠落しているときは `-` を表示する
|
|
117
151
|
*/
|
|
118
|
-
export function formatTableRow(item) {
|
|
152
|
+
export function formatTableRow(item, extraCells = []) {
|
|
119
153
|
const { number } = item.content;
|
|
120
154
|
const repository = item.content.repository ?? '';
|
|
121
155
|
const numberText = number === undefined || number === null ? '' : displayText(number);
|
|
@@ -128,7 +162,7 @@ export function formatTableRow(item) {
|
|
|
128
162
|
reference = `#${numberText}`;
|
|
129
163
|
const { title } = item;
|
|
130
164
|
const titleText = title === undefined || isEmptyValue(title) ? '-' : displayText(title);
|
|
131
|
-
return `| ${reference
|
|
165
|
+
return `| ${[reference, titleText, ...extraCells].join(' | ')} |`;
|
|
132
166
|
}
|
|
133
167
|
function updatedAtOf(item) {
|
|
134
168
|
return typeof item.updatedAt === 'string' ? item.updatedAt : '';
|
|
@@ -141,10 +175,27 @@ function newestFirst(first, second) {
|
|
|
141
175
|
return a < b ? 1 : -1;
|
|
142
176
|
}
|
|
143
177
|
/**
|
|
178
|
+
判定の文の表(readiness 引数)を引くキー。`owner/repo#N` の小文字で、issueReferenceKey と同じ形になる。
|
|
179
|
+
リポジトリか番号が欠けたアイテムは undefined
|
|
180
|
+
*/
|
|
181
|
+
export function boardItemKey(item) {
|
|
182
|
+
const { number } = item.content;
|
|
183
|
+
const repository = item.content.repository ?? '';
|
|
184
|
+
return repository === '' || number === undefined || number === null ? undefined : `${repository}#${displayText(number)}`.toLowerCase();
|
|
185
|
+
}
|
|
186
|
+
// 判定の列を足す節(Ready・Blocked)
|
|
187
|
+
const READINESS_STATUSES = new Set(['Ready', 'Blocked']);
|
|
188
|
+
function readinessCell(item, readiness) {
|
|
189
|
+
const key = boardItemKey(item);
|
|
190
|
+
return (key === undefined ? undefined : readiness.get(key)) ?? '-';
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
144
193
|
プロジェクトボードを Markdown 形式で出力する。件数が 0 のステータスは出さない。
|
|
145
|
-
Archived は 6 件以上あるとき、更新が新しい直近 5
|
|
194
|
+
Archived は 6 件以上あるとき、更新が新しい直近 5 件だけを出す。
|
|
195
|
+
readiness(boardItemKey → 判定の文)を渡したときだけ、Ready と Blocked の節に Readiness の列を足す。
|
|
196
|
+
表に無いアイテムのセルは `-`
|
|
146
197
|
*/
|
|
147
|
-
export function formatBoardOutput(items) {
|
|
198
|
+
export function formatBoardOutput(items, readiness) {
|
|
148
199
|
const sections = [];
|
|
149
200
|
for (const status of STATUS_ORDER) {
|
|
150
201
|
const patterns = STATUS_PATTERNS.get(status) ?? [];
|
|
@@ -155,11 +206,26 @@ export function formatBoardOutput(items) {
|
|
|
155
206
|
const isTruncated = status === 'Archived' && totalCount > ARCHIVED_DISPLAY_LIMIT;
|
|
156
207
|
const displayItems = isTruncated ? statusItems.toSorted(newestFirst).slice(0, ARCHIVED_DISPLAY_LIMIT) : statusItems;
|
|
157
208
|
const heading = isTruncated ? `### ${status} (latest ${String(ARCHIVED_DISPLAY_LIMIT)} of ${String(totalCount)})` : `### ${status} (${String(totalCount)})`;
|
|
158
|
-
|
|
209
|
+
if (readiness !== undefined && READINESS_STATUSES.has(status)) {
|
|
210
|
+
const rows = displayItems.map(item => formatTableRow(item, [readinessCell(item, readiness)]));
|
|
211
|
+
sections.push([heading, '| Ref | Title | Readiness |', '|-----|----------|-----------|', ...rows]);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
sections.push([heading, '| Ref | Title |', '|-----|----------|', ...displayItems.map(item => formatTableRow(item))]);
|
|
215
|
+
}
|
|
159
216
|
}
|
|
160
217
|
return sections.length === 0 ? '_No items_' : sections.map(section => section.join('\n')).join('\n\n');
|
|
161
218
|
}
|
|
162
219
|
/**
|
|
220
|
+
`## Stackable chains` の節を作る。1 行が 1 つの並びで、並びが無ければ undefined
|
|
221
|
+
*/
|
|
222
|
+
export function formatStackableChains(chains) {
|
|
223
|
+
if (chains.length === 0)
|
|
224
|
+
return undefined;
|
|
225
|
+
const lines = chains.map(({ epic = '(no epic)', chain }) => `- ${epic}: ${chain.join(' -> ')}`);
|
|
226
|
+
return ['## Stackable chains', '', ...lines].join('\n');
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
163
229
|
アイテムリストを JSON 出力用の辞書にする
|
|
164
230
|
*/
|
|
165
231
|
export function formatItemsJson(items) {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { PecotError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
コマンドが契約の文を作る誤り。`parallel` は使えなくなった項目、`merge-without-reason` は理由の無い `wait: merge`
|
|
5
|
+
*/
|
|
6
|
+
export type FrontmatterErrorKind = 'parallel' | 'merge-without-reason';
|
|
3
7
|
export declare class FrontmatterError extends PecotError {
|
|
8
|
+
readonly kind: FrontmatterErrorKind | undefined;
|
|
9
|
+
constructor(message: string, options?: Readonly<ErrorOptions & {
|
|
10
|
+
kind?: FrontmatterErrorKind;
|
|
11
|
+
}>);
|
|
4
12
|
}
|
|
5
13
|
declare const IssueFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
|
|
6
14
|
title: z.ZodString;
|
|
@@ -18,7 +26,7 @@ declare const IssueFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
18
26
|
tracker: "tracker";
|
|
19
27
|
}>>>, z.ZodTransform<"bug" | "epic" | "task" | "task-implement" | "tracker" | undefined, "bug" | "epic" | "task" | "task-implement" | "tracker" | null | undefined>>, unknown>;
|
|
20
28
|
repository: z.ZodString;
|
|
21
|
-
status: z.ZodEnum<{
|
|
29
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
22
30
|
active: "active";
|
|
23
31
|
archived: "archived";
|
|
24
32
|
backlog: "backlog";
|
|
@@ -26,7 +34,15 @@ declare const IssueFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
26
34
|
in_review: "in_review";
|
|
27
35
|
pending: "pending";
|
|
28
36
|
ready: "ready";
|
|
29
|
-
}
|
|
37
|
+
}>>;
|
|
38
|
+
blocked_by: z.ZodPreprocess<z.ZodPrefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
39
|
+
issue: z.ZodPreprocess<z.ZodString, unknown>;
|
|
40
|
+
wait: z.ZodPrefault<z.ZodEnum<{
|
|
41
|
+
merge: "merge";
|
|
42
|
+
stack: "stack";
|
|
43
|
+
}>>;
|
|
44
|
+
reason: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>, unknown>;
|
|
45
|
+
}, z.core.$strip>>>>>, unknown>;
|
|
30
46
|
priority: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
31
47
|
high: "high";
|
|
32
48
|
low: "low";
|
|
@@ -41,7 +57,6 @@ declare const IssueFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
41
57
|
labels: z.ZodPrefault<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
42
58
|
parent_epic: z.ZodPreprocess<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | number | undefined, unknown>>, unknown>;
|
|
43
59
|
order: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>, unknown>;
|
|
44
|
-
parallel: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>, unknown>;
|
|
45
60
|
}, z.core.$strip>>;
|
|
46
61
|
declare const CommentFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
|
|
47
62
|
issue_ref: z.ZodString;
|
|
@@ -10,12 +10,18 @@ import { PecotError } from './errors.js';
|
|
|
10
10
|
import { normalizeNewlines, parsePythonInteger, pythonStrip, pythonStringRepr } from './python-format.js';
|
|
11
11
|
import { parseYamlDocument } from './yaml-document.js';
|
|
12
12
|
export class FrontmatterError extends PecotError {
|
|
13
|
+
kind;
|
|
14
|
+
constructor(message, options) {
|
|
15
|
+
super(message, options);
|
|
16
|
+
this.kind = options?.kind;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
// 検証のエラー文
|
|
15
20
|
const REQUIRED_MESSAGE = 'Field required';
|
|
16
21
|
const STRING_MESSAGE = 'Input should be a valid string';
|
|
17
22
|
const LIST_MESSAGE = 'Input should be a valid list';
|
|
18
|
-
const
|
|
23
|
+
const SINGLE_LINE_MESSAGE = 'Value error, reason must be a single line';
|
|
24
|
+
const NOT_EMPTY_MESSAGE = 'String should have at least 1 character';
|
|
19
25
|
function quotedChoices(values) {
|
|
20
26
|
const quoted = values.map(value => pythonStringRepr(String(value)));
|
|
21
27
|
const last = quoted.at(-1);
|
|
@@ -86,12 +92,21 @@ function normalizeParentEpic(value) {
|
|
|
86
92
|
const IntegerSchema = z.number({ error: issue => integerMessage(issue.input) }).refine(Number.isSafeInteger, { error: issue => integerMessage(issue.input) });
|
|
87
93
|
const IssueTypeSchema = z.enum(['task', 'bug', 'epic', 'tracker'], { error: choiceMessage });
|
|
88
94
|
const WorkflowStatusSchema = z.enum(WORKFLOW_STATUSES, { error: choiceMessage });
|
|
95
|
+
function stripString(value) {
|
|
96
|
+
return typeof value === 'string' ? pythonStrip(value) : value;
|
|
97
|
+
}
|
|
98
|
+
const BlockedByEntrySchema = z.object({
|
|
99
|
+
issue: z.preprocess(stripString, z.string({ error: stringMessage }).min(1, { error: NOT_EMPTY_MESSAGE })),
|
|
100
|
+
wait: z.enum(['stack', 'merge'], { error: choiceMessage }).prefault('stack'),
|
|
101
|
+
reason: z.preprocess(normalizeOptionalText, z.string({ error: stringMessage }).refine(value => !/[\r\n]/u.test(value), { error: SINGLE_LINE_MESSAGE }).nullish().transform(value => value ?? undefined)),
|
|
102
|
+
}).readonly();
|
|
89
103
|
const IssueFrontmatterSchema = z.object({
|
|
90
104
|
title: z.string({ error: stringMessage }),
|
|
91
105
|
type: IssueTypeSchema,
|
|
92
106
|
template: z.preprocess(emptyStringToUndefined, z.enum(['task', 'bug', 'epic', 'tracker', 'task-implement'], { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
|
|
93
107
|
repository: z.string({ error: stringMessage }),
|
|
94
|
-
status: WorkflowStatusSchema,
|
|
108
|
+
status: WorkflowStatusSchema.optional(),
|
|
109
|
+
blocked_by: z.preprocess(value => value === null ? undefined : value, z.array(BlockedByEntrySchema, { error: listMessage }).readonly().prefault([])),
|
|
95
110
|
priority: z.preprocess(emptyStringToUndefined, z.enum(PRIORITIES, { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
|
|
96
111
|
size: z.preprocess(emptyStringToUndefined, z.enum(SIZES, { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
|
|
97
112
|
labels: z.array(z.string({ error: STRING_MESSAGE }), { error: listMessage }).readonly().prefault([]),
|
|
@@ -103,7 +118,6 @@ const IssueFrontmatterSchema = z.object({
|
|
|
103
118
|
return z.NEVER;
|
|
104
119
|
})),
|
|
105
120
|
order: z.preprocess(value => convertToInteger(emptyStringToUndefined(value)), IntegerSchema.nullish().transform(value => value ?? undefined)),
|
|
106
|
-
parallel: z.preprocess(emptyStringToUndefined, z.string({ error: STRING_MESSAGE }).regex(/^[a-z]$/u, { error: PARALLEL_MESSAGE }).nullish().transform(value => value ?? undefined)),
|
|
107
121
|
}).readonly();
|
|
108
122
|
const CommentFrontmatterSchema = z.object({
|
|
109
123
|
issue_ref: z.string({ error: stringMessage }),
|
|
@@ -127,29 +141,41 @@ function validationError(lines) {
|
|
|
127
141
|
function fieldErrors(issues) {
|
|
128
142
|
return validationError(issues.map(issue => issueLine(issue)));
|
|
129
143
|
}
|
|
130
|
-
// parent_epic
|
|
131
|
-
function
|
|
132
|
-
const { parent_epic: parentEpic, order,
|
|
144
|
+
// parent_epic・order・blocked_by・status の相互検証。項目の誤りが無いときだけ行う
|
|
145
|
+
function checkCrossFields(frontmatter) {
|
|
146
|
+
const { parent_epic: parentEpic, order, blocked_by: blockedBy, status, type } = frontmatter;
|
|
147
|
+
if (blockedBy.some(entry => entry.wait === 'merge' && entry.reason === undefined)) {
|
|
148
|
+
throw new FrontmatterError('blocked_by needs reason for wait: merge', { kind: 'merge-without-reason' });
|
|
149
|
+
}
|
|
133
150
|
let message;
|
|
134
|
-
if (parentEpic
|
|
135
|
-
message = 'order is required when parent_epic is set';
|
|
136
|
-
else if (parentEpic === undefined && order !== undefined)
|
|
151
|
+
if (parentEpic === undefined && order !== undefined)
|
|
137
152
|
message = 'parent_epic is required when order is set';
|
|
138
153
|
else if (order !== undefined && order <= 0)
|
|
139
154
|
message = `order must be an integer of 1 or more: ${String(order)}`;
|
|
140
|
-
else if (
|
|
141
|
-
message =
|
|
155
|
+
else if (blockedBy.length > 0 && (type === 'epic' || type === 'tracker'))
|
|
156
|
+
message = `blocked_by cannot be set for type ${type}`;
|
|
157
|
+
else if (status === 'ready' && blockedBy.length > 0)
|
|
158
|
+
message = 'status: ready cannot be set together with blocked_by';
|
|
159
|
+
else if (status === 'blocked' && blockedBy.length === 0)
|
|
160
|
+
message = 'status: blocked requires blocked_by';
|
|
142
161
|
if (message !== undefined)
|
|
143
162
|
throw validationError([` - : Value error, ${message}`]);
|
|
144
163
|
}
|
|
164
|
+
function hasParallel(data) {
|
|
165
|
+
const value = typeof data === 'object' && data !== null && 'parallel' in data ? data.parallel : undefined;
|
|
166
|
+
return typeof value === 'string' ? value !== '' : value !== undefined && value !== null;
|
|
167
|
+
}
|
|
145
168
|
/**
|
|
146
169
|
値から Issue のフロントマターを作る。不正なら FrontmatterError
|
|
147
170
|
*/
|
|
148
171
|
export function validateIssueFrontmatter(data) {
|
|
172
|
+
// 使えなくなった項目の案内は、ほかの誤りと重なっても先に出す
|
|
173
|
+
if (hasParallel(data))
|
|
174
|
+
throw new FrontmatterError('parallel is no longer supported', { kind: 'parallel' });
|
|
149
175
|
const result = IssueFrontmatterSchema.safeParse(data);
|
|
150
176
|
if (!result.success)
|
|
151
177
|
throw fieldErrors(result.error.issues);
|
|
152
|
-
|
|
178
|
+
checkCrossFields(result.data);
|
|
153
179
|
return result.data;
|
|
154
180
|
}
|
|
155
181
|
/**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface SubIssueTitle {
|
|
2
|
+
readonly number: number;
|
|
3
|
+
readonly state: string;
|
|
4
|
+
readonly title: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UsedOrder {
|
|
7
|
+
readonly number: number;
|
|
8
|
+
readonly state: string;
|
|
9
|
+
readonly title: string;
|
|
10
|
+
/**
|
|
11
|
+
タイトルの番号。枝の文字は数えない
|
|
12
|
+
*/
|
|
13
|
+
readonly order: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
サブタスクのうち、タイトルが親 Epic の番号付きのものを、使われた番号にする
|
|
17
|
+
*/
|
|
18
|
+
export declare function usedOrdersOf(subIssues: readonly SubIssueTitle[], parentEpic: number): readonly UsedOrder[];
|
|
19
|
+
export interface OrderRequest {
|
|
20
|
+
readonly file: string;
|
|
21
|
+
/**
|
|
22
|
+
明示の番号。省いたら undefined
|
|
23
|
+
*/
|
|
24
|
+
readonly order: number | undefined;
|
|
25
|
+
}
|
|
26
|
+
export type OrderPlan = {
|
|
27
|
+
readonly kind: 'planned';
|
|
28
|
+
readonly orders: readonly number[];
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'duplicate-in-batch';
|
|
31
|
+
readonly order: number;
|
|
32
|
+
readonly files: readonly string[];
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: 'duplicate-existing';
|
|
35
|
+
readonly order: number;
|
|
36
|
+
readonly existing: UsedOrder;
|
|
37
|
+
readonly nextAvailable: number;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'unreadable-parent';
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
一括の中で明示の番号が重なるものを返す。ネットワークを使わずに確かめられる
|
|
43
|
+
*/
|
|
44
|
+
export declare function findBatchDuplicate(requests: readonly OrderRequest[]): {
|
|
45
|
+
readonly order: number;
|
|
46
|
+
readonly files: readonly string[];
|
|
47
|
+
} | undefined;
|
|
48
|
+
/**
|
|
49
|
+
同じ親 Epic のファイルに番号を振る。requests はファイルの順。
|
|
50
|
+
使われた番号は、親のサブタスクのタイトルから読んだもの(読めなければ undefined)。
|
|
51
|
+
明示の番号は、既存の番号とも、ほかのファイルの明示の番号とも重ねない。
|
|
52
|
+
省いたファイルには、既存の番号と明示の番号の最大の次から、ファイルの順に振る。省いたファイルがあって使われた番号を読めなければ、決められない
|
|
53
|
+
*/
|
|
54
|
+
export declare function planOrders(used: readonly UsedOrder[] | undefined, requests: readonly OrderRequest[]): OrderPlan;
|
|
55
|
+
//# sourceMappingURL=issue-order.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// タイトルの通し番号(specs/024 の R13)。サブタスクのタイトルと明示の番号から、使われた番号・重複・次の番号を決める。I/O を持たない。
|
|
2
|
+
// タイトルの先頭の `#123-01:` と `#123-01a:` から、Epic 番号・番号・枝の文字を取る。`[Task] ` のような接頭辞は許す
|
|
3
|
+
const ORDER_PATTERN = /^#(\d+)-(\d+)([a-z])?:/u;
|
|
4
|
+
const TITLE_PREFIX_PATTERN = /^\[[^\]]*\] ?/u;
|
|
5
|
+
/**
|
|
6
|
+
サブタスクのうち、タイトルが親 Epic の番号付きのものを、使われた番号にする
|
|
7
|
+
*/
|
|
8
|
+
export function usedOrdersOf(subIssues, parentEpic) {
|
|
9
|
+
const used = [];
|
|
10
|
+
for (const sub of subIssues) {
|
|
11
|
+
const [, epic, order] = ORDER_PATTERN.exec(sub.title.replace(TITLE_PREFIX_PATTERN, '')) ?? [];
|
|
12
|
+
if (epic === undefined || order === undefined || Number(epic) !== parentEpic)
|
|
13
|
+
continue;
|
|
14
|
+
used.push({ number: sub.number, state: sub.state, title: sub.title, order: Number(order) });
|
|
15
|
+
}
|
|
16
|
+
return used;
|
|
17
|
+
}
|
|
18
|
+
function explicitOrders(requests) {
|
|
19
|
+
const explicit = new Map();
|
|
20
|
+
for (const { file, order } of requests) {
|
|
21
|
+
if (order !== undefined)
|
|
22
|
+
explicit.set(order, [...explicit.get(order) ?? [], file]);
|
|
23
|
+
}
|
|
24
|
+
return explicit;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
一括の中で明示の番号が重なるものを返す。ネットワークを使わずに確かめられる
|
|
28
|
+
*/
|
|
29
|
+
export function findBatchDuplicate(requests) {
|
|
30
|
+
for (const [order, files] of explicitOrders(requests)) {
|
|
31
|
+
if (files.length > 1)
|
|
32
|
+
return { order, files };
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
同じ親 Epic のファイルに番号を振る。requests はファイルの順。
|
|
38
|
+
使われた番号は、親のサブタスクのタイトルから読んだもの(読めなければ undefined)。
|
|
39
|
+
明示の番号は、既存の番号とも、ほかのファイルの明示の番号とも重ねない。
|
|
40
|
+
省いたファイルには、既存の番号と明示の番号の最大の次から、ファイルの順に振る。省いたファイルがあって使われた番号を読めなければ、決められない
|
|
41
|
+
*/
|
|
42
|
+
export function planOrders(used, requests) {
|
|
43
|
+
const explicit = explicitOrders(requests);
|
|
44
|
+
// 省いたファイルへの番号と、重複のときの案内は、同じ「既存と明示の最大の次」
|
|
45
|
+
const first = Math.max(0, ...(used ?? []).map(entry => entry.order), ...explicit.keys()) + 1;
|
|
46
|
+
for (const [order, files] of explicit) {
|
|
47
|
+
if (files.length > 1)
|
|
48
|
+
return { kind: 'duplicate-in-batch', order, files };
|
|
49
|
+
const existing = used?.find(entry => entry.order === order);
|
|
50
|
+
if (existing !== undefined)
|
|
51
|
+
return { kind: 'duplicate-existing', order, existing, nextAvailable: first };
|
|
52
|
+
}
|
|
53
|
+
if (used === undefined && requests.some(({ order }) => order === undefined))
|
|
54
|
+
return { kind: 'unreadable-parent' };
|
|
55
|
+
let next = first;
|
|
56
|
+
const orders = requests.map(({ order }) => {
|
|
57
|
+
if (order !== undefined)
|
|
58
|
+
return order;
|
|
59
|
+
const assigned = next;
|
|
60
|
+
next += 1;
|
|
61
|
+
return assigned;
|
|
62
|
+
});
|
|
63
|
+
return { kind: 'planned', orders };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=issue-order.js.map
|
|
@@ -65,6 +65,13 @@ export interface IssueReadout {
|
|
|
65
65
|
}
|
|
66
66
|
export interface TargetIssueReadout extends IssueReadout {
|
|
67
67
|
readonly body: string;
|
|
68
|
+
/**
|
|
69
|
+
親の Issue(sub-issue の親)。親が無い、または応答に無ければ null
|
|
70
|
+
*/
|
|
71
|
+
readonly parent: {
|
|
72
|
+
readonly repository: RepositoryReference;
|
|
73
|
+
readonly number: number;
|
|
74
|
+
} | null;
|
|
68
75
|
}
|
|
69
76
|
/**
|
|
70
77
|
blockedBy の読み取り結果。読めない部分があるときは read-failed。
|
|
@@ -104,4 +111,33 @@ export interface PullRequestsByHeadReadout {
|
|
|
104
111
|
*/
|
|
105
112
|
readonly hasNextPage: boolean;
|
|
106
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
前提 1 件の参照。block / unblock が、付ける前の確認と輪の探索に使う
|
|
116
|
+
*/
|
|
117
|
+
export interface BlockedByReference {
|
|
118
|
+
/**
|
|
119
|
+
GraphQL の node ID
|
|
120
|
+
*/
|
|
121
|
+
readonly id: string;
|
|
122
|
+
readonly repository: RepositoryReference;
|
|
123
|
+
readonly number: number;
|
|
124
|
+
readonly state: IssueStateReadout;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
前提の参照の読み取り結果。total は件数で、issues は読めた分(total に足りないことがある)。
|
|
128
|
+
null の node と部分エラーは read-failed
|
|
129
|
+
*/
|
|
130
|
+
export type BlockedByReferences = {
|
|
131
|
+
readonly kind: 'ok';
|
|
132
|
+
readonly total: number;
|
|
133
|
+
readonly issues: readonly BlockedByReference[];
|
|
134
|
+
} | {
|
|
135
|
+
readonly kind: 'read-failed';
|
|
136
|
+
readonly reason: string;
|
|
137
|
+
};
|
|
138
|
+
export interface IssueBlockedByReferences {
|
|
139
|
+
readonly id: string;
|
|
140
|
+
readonly body: string;
|
|
141
|
+
readonly blockedBy: BlockedByReferences;
|
|
142
|
+
}
|
|
107
143
|
//# sourceMappingURL=issue-readout.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { HintedText } from './command-hint.js';
|
|
2
|
+
import type { PullRequestReadout } from './issue-readout.js';
|
|
1
3
|
import type { SectionHeading } from './sections.js';
|
|
2
|
-
|
|
4
|
+
import type { BaseReading } from './state.js';
|
|
5
|
+
export declare const SCREENSHOT_MISSING_ERROR: HintedText;
|
|
3
6
|
/**
|
|
4
7
|
本文の Closes / Fixes / Resolves に続く Issue 番号を、出てきた順に重複なしで返す
|
|
5
8
|
*/
|
|
@@ -32,11 +35,75 @@ export interface PullRequestContentOptions {
|
|
|
32
35
|
テンプレートから取り出した必須の節。空なら節の検証をしない
|
|
33
36
|
*/
|
|
34
37
|
readonly requiredSections: readonly SectionHeading[];
|
|
38
|
+
/**
|
|
39
|
+
積んで着手した記録の base(下の段のブランチ)。開発ブランチのほか、この base も通す
|
|
40
|
+
*/
|
|
41
|
+
readonly stackedBase?: string | undefined;
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
44
|
PR の内容を検証し、エラーの文を返す(無ければ空)。ブランチ設定の欠けは、呼び出し側が先に止める
|
|
38
45
|
*/
|
|
39
|
-
export declare function validatePullRequestContent(options: Readonly<PullRequestContentOptions>): readonly string[];
|
|
46
|
+
export declare function validatePullRequestContent(options: Readonly<PullRequestContentOptions>): readonly (string | HintedText)[];
|
|
47
|
+
export interface PullRequestBaseInput {
|
|
48
|
+
readonly reading: BaseReading;
|
|
49
|
+
/**
|
|
50
|
+
渡された base(テンプレートの base か --base)
|
|
51
|
+
*/
|
|
52
|
+
readonly base: string;
|
|
53
|
+
readonly developBranch: string;
|
|
54
|
+
/**
|
|
55
|
+
下の段のブランチを head に持つ PR(pickBasePullRequest で選んだもの)。積んだ記録のときだけ見る
|
|
56
|
+
*/
|
|
57
|
+
readonly lowerPullRequest?: Readonly<PullRequestReadout> | undefined;
|
|
58
|
+
}
|
|
59
|
+
export type PullRequestBaseStop = {
|
|
60
|
+
readonly kind: 'stop';
|
|
61
|
+
readonly reason: 'malformed';
|
|
62
|
+
readonly content: string;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: 'stop';
|
|
65
|
+
readonly reason: 'no-open-pr';
|
|
66
|
+
readonly branch: string;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'stop';
|
|
69
|
+
readonly reason: 'lower-open';
|
|
70
|
+
readonly branch: string;
|
|
71
|
+
readonly pullRequest: number;
|
|
72
|
+
readonly base: string;
|
|
73
|
+
};
|
|
74
|
+
export interface PullRequestBaseUse {
|
|
75
|
+
readonly kind: 'use';
|
|
76
|
+
/**
|
|
77
|
+
PR を作る base
|
|
78
|
+
*/
|
|
79
|
+
readonly base: string;
|
|
80
|
+
/**
|
|
81
|
+
新しい PR と一緒にスタックへ登録する、下の段の PR の番号。登録しなければ undefined
|
|
82
|
+
*/
|
|
83
|
+
readonly stackOn: number | undefined;
|
|
84
|
+
/**
|
|
85
|
+
内容の検証(validatePullRequestContent)に渡す記録の base
|
|
86
|
+
*/
|
|
87
|
+
readonly stackedBase: string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
下の段の PR がマージ済みか。題の scope を記録のコミットから比べるのは、マージ済みのときだけ
|
|
90
|
+
*/
|
|
91
|
+
readonly isLowerMerged: boolean;
|
|
92
|
+
}
|
|
93
|
+
export type PullRequestBaseDecision = PullRequestBaseStop | PullRequestBaseUse;
|
|
94
|
+
/**
|
|
95
|
+
base の記録と下の段の PR の状態から、PR を作る base とスタックへの登録を決める。
|
|
96
|
+
記録の base でも開発ブランチでもない base は、そのまま返して内容の検証で落とす
|
|
97
|
+
*/
|
|
98
|
+
export declare function decidePullRequestBase(input: Readonly<PullRequestBaseInput>): PullRequestBaseDecision;
|
|
99
|
+
/**
|
|
100
|
+
下の段のブランチを head に持つ PR から、base を決める 1 本を選ぶ。fork でないもののうち、開いている・マージ済み・閉じた の順(同じ状態なら渡した順の先頭)
|
|
101
|
+
*/
|
|
102
|
+
export declare function pickLowerPullRequest(pullRequests: readonly PullRequestReadout[]): PullRequestReadout | undefined;
|
|
103
|
+
/**
|
|
104
|
+
止めた理由の文(`error: ` の前置きを含まない)。下の段の PR が無いときは、直し方の行を続ける
|
|
105
|
+
*/
|
|
106
|
+
export declare function describeBaseStop(stop: Readonly<PullRequestBaseStop>): readonly string[];
|
|
40
107
|
export interface IssueSummary {
|
|
41
108
|
readonly number: number;
|
|
42
109
|
readonly title: string;
|
|
@@ -81,7 +148,7 @@ export interface PullRequestWithReviewsView extends PullRequestView {
|
|
|
81
148
|
readonly review_threads: readonly ReviewThreadView[];
|
|
82
149
|
}
|
|
83
150
|
/**
|
|
84
|
-
`pr
|
|
151
|
+
`pr show` の既定の Markdown
|
|
85
152
|
*/
|
|
86
153
|
export declare function formatPullRequestMarkdown(pr: PullRequestSlimView): string;
|
|
87
154
|
/**
|
|
@@ -93,7 +160,7 @@ export declare function formatReviewsMarkdown(reviews: readonly ReviewView[]): s
|
|
|
93
160
|
*/
|
|
94
161
|
export declare function formatReviewThreadsMarkdown(threads: readonly ReviewThreadView[]): string;
|
|
95
162
|
/**
|
|
96
|
-
`pr
|
|
163
|
+
`pr show --reviews` の Markdown。Issue ごとに詳細を見るコマンドを添え、レビュー本文と行コメントを続ける
|
|
97
164
|
*/
|
|
98
165
|
export declare function formatPullRequestWithReviewsMarkdown(pr: PullRequestWithReviewsView, owner: string, repository: string): string;
|
|
99
166
|
export interface PreflightWarning {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// PR コマンドの入出力を持たない関数。本文の検証、Closes の抽出と追記、`pr
|
|
1
|
+
// PR コマンドの入出力を持たない関数。本文の検証、Closes の抽出と追記、`pr show` の Markdown の整形、preflight の警告の判定。
|
|
2
2
|
// 引数の型は、infra/github/pulls.ts の返す値が構造として満たす形をここに持つ(domain は infra を import できない)。
|
|
3
|
+
import { hinted, inputHint, inputNameHint } from './command-hint.js';
|
|
3
4
|
import { parsePythonInteger, pythonRightStrip, pythonStrip, splitCodePoints, truncateCodePoints } from './python-format.js';
|
|
4
5
|
import { hasSummaryImage, validateBodyStyle, validateHeadingSummaries, validateSections } from './sections.js';
|
|
5
6
|
// Issue 参照(`#N`、URL 内のフラグメントは除く)。`owner/repo#N` の形も受ける
|
|
@@ -12,10 +13,8 @@ const CLOSING_KEYWORDS_PATTERN = new RegExp(String.raw `(?:close[sd]?|fix(?:e[sd
|
|
|
12
13
|
// stash の件数を数える行の区切り。str.splitlines と同じ。
|
|
13
14
|
// eslint-disable-next-line no-control-regex, security/detect-unsafe-regex -- 区切りの制御文字と誤検知
|
|
14
15
|
const LINE_BREAK = /\r\n|[\n\r\v\f\u{1C}-\u{1E}\u{85}\u{2028}\u{2029}]/u;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
+ 'take a screenshot and add it to Summary as ``. '
|
|
18
|
-
+ 'Otherwise, write the reason in the `screenshot` frontmatter field (`--screenshot` with `-m`)';
|
|
16
|
+
const PR_CREATE_PATH = ['pr', 'create'];
|
|
17
|
+
export const SCREENSHOT_MISSING_ERROR = hinted `Summary has no image and \`screenshot\` gives no reason to omit one. If the change alters a screen, Markdown the tool writes for GitHub, or CLI output text, take a screenshot and add it to Summary as \`\`. Otherwise, write the reason in the \`screenshot\` frontmatter field (\`${inputNameHint(PR_CREATE_PATH, 'screenshot')}\` with \`${inputNameHint(PR_CREATE_PATH, 'message')}\`)`;
|
|
19
18
|
/**
|
|
20
19
|
本文の Closes / Fixes / Resolves に続く Issue 番号を、出てきた順に重複なしで返す
|
|
21
20
|
*/
|
|
@@ -56,7 +55,7 @@ export function validatePullRequestContent(options) {
|
|
|
56
55
|
const errors = [];
|
|
57
56
|
const isRelease = isReleasePullRequest(options.template, base, options.head, developBranch, releaseBranch);
|
|
58
57
|
if (!isRelease && !options.skipIssueReferenceCheck && !hasIssueReference(body)) {
|
|
59
|
-
errors.push(
|
|
58
|
+
errors.push(hinted `PR body has no Issue reference \`#N\` (use \`${inputHint(PR_CREATE_PATH, 'no_issue_ref')}\` for a PR not tied to an Issue)`);
|
|
60
59
|
}
|
|
61
60
|
if (requiredSections.length > 0) {
|
|
62
61
|
const missing = validateSections(body, requiredSections);
|
|
@@ -77,10 +76,60 @@ export function validatePullRequestContent(options) {
|
|
|
77
76
|
errors.push(`release PR base branch must be ${releaseBranch} (given: ${base})`);
|
|
78
77
|
}
|
|
79
78
|
else if (developBranch !== undefined && developBranch !== '' && base !== developBranch) {
|
|
80
|
-
|
|
79
|
+
const { stackedBase } = options;
|
|
80
|
+
const isStacked = stackedBase !== undefined && stackedBase !== '' && stackedBase !== developBranch;
|
|
81
|
+
if (!isStacked)
|
|
82
|
+
errors.push(`base branch must be ${developBranch} (given: ${base})`);
|
|
83
|
+
else if (base !== stackedBase)
|
|
84
|
+
errors.push(`base branch must be ${developBranch} or ${stackedBase} (given: ${base})`);
|
|
81
85
|
}
|
|
82
86
|
return errors;
|
|
83
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
base の記録と下の段の PR の状態から、PR を作る base とスタックへの登録を決める。
|
|
90
|
+
記録の base でも開発ブランチでもない base は、そのまま返して内容の検証で落とす
|
|
91
|
+
*/
|
|
92
|
+
export function decidePullRequestBase(input) {
|
|
93
|
+
const { reading, base, developBranch } = input;
|
|
94
|
+
if (reading.kind === 'malformed')
|
|
95
|
+
return { kind: 'stop', reason: 'malformed', content: reading.content };
|
|
96
|
+
if (reading.kind === 'development')
|
|
97
|
+
return { kind: 'use', base, stackOn: undefined, stackedBase: undefined, isLowerMerged: false };
|
|
98
|
+
const { branch } = reading.record;
|
|
99
|
+
const lower = input.lowerPullRequest;
|
|
100
|
+
if (lower === undefined || lower.state === 'CLOSED')
|
|
101
|
+
return { kind: 'stop', reason: 'no-open-pr', branch };
|
|
102
|
+
const isKnownBase = base === branch || base === developBranch;
|
|
103
|
+
if (lower.state === 'MERGED')
|
|
104
|
+
return { kind: 'use', base: isKnownBase ? developBranch : base, stackOn: undefined, stackedBase: branch, isLowerMerged: true };
|
|
105
|
+
if (base === developBranch)
|
|
106
|
+
return { kind: 'stop', reason: 'lower-open', branch, pullRequest: lower.number, base };
|
|
107
|
+
return { kind: 'use', base, stackOn: base === branch ? lower.number : undefined, stackedBase: branch, isLowerMerged: false };
|
|
108
|
+
}
|
|
109
|
+
const LOWER_STATE_ORDER = ['OPEN', 'MERGED', 'CLOSED'];
|
|
110
|
+
/**
|
|
111
|
+
下の段のブランチを head に持つ PR から、base を決める 1 本を選ぶ。fork でないもののうち、開いている・マージ済み・閉じた の順(同じ状態なら渡した順の先頭)
|
|
112
|
+
*/
|
|
113
|
+
export function pickLowerPullRequest(pullRequests) {
|
|
114
|
+
const own = pullRequests.filter(pullRequest => !pullRequest.isCrossRepository);
|
|
115
|
+
return LOWER_STATE_ORDER.map(state => own.find(pullRequest => pullRequest.state === state)).find(found => found !== undefined);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
止めた理由の文(`error: ` の前置きを含まない)。下の段の PR が無いときは、直し方の行を続ける
|
|
119
|
+
*/
|
|
120
|
+
export function describeBaseStop(stop) {
|
|
121
|
+
switch (stop.reason) {
|
|
122
|
+
case 'malformed': {
|
|
123
|
+
return [`.pecot-base is malformed: ${stop.content}`];
|
|
124
|
+
}
|
|
125
|
+
case 'no-open-pr': {
|
|
126
|
+
return [`base branch ${stop.branch} has no open PR`, `reopen the PR of ${stop.branch}, or create a new one, then run pr create again`];
|
|
127
|
+
}
|
|
128
|
+
case 'lower-open': {
|
|
129
|
+
return [`base branch must be ${stop.branch} while its PR #${String(stop.pullRequest)} is open (given: ${stop.base})`];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
84
133
|
// ISO 8601 の先頭 10 文字(YYYY-MM-DD)。10 文字に満たなければ空
|
|
85
134
|
function datePart(timestamp) {
|
|
86
135
|
return timestamp !== null && splitCodePoints(timestamp).length >= 10 ? truncateCodePoints(timestamp, 10) : '';
|
|
@@ -99,7 +148,7 @@ function referencedIssueLine(issue) {
|
|
|
99
148
|
return ` - #${String(issue.number)}${issue.title === '' ? '' : ` ${issue.title}`}`;
|
|
100
149
|
}
|
|
101
150
|
/**
|
|
102
|
-
`pr
|
|
151
|
+
`pr show` の既定の Markdown
|
|
103
152
|
*/
|
|
104
153
|
export function formatPullRequestMarkdown(pr) {
|
|
105
154
|
const lines = [`## PR #${String(pr.number)} ${pr.title}`, '', metaLine(pr), '', `**Branch:** \`${pr.head_ref}\` → \`${pr.base_ref}\``, ''];
|
|
@@ -157,11 +206,11 @@ export function formatReviewThreadsMarkdown(threads) {
|
|
|
157
206
|
return lines.join('\n');
|
|
158
207
|
}
|
|
159
208
|
/**
|
|
160
|
-
`pr
|
|
209
|
+
`pr show --reviews` の Markdown。Issue ごとに詳細を見るコマンドを添え、レビュー本文と行コメントを続ける
|
|
161
210
|
*/
|
|
162
211
|
export function formatPullRequestWithReviewsMarkdown(pr, owner, repository) {
|
|
163
212
|
const lines = [`## PR #${String(pr.number)} ${pr.title}`, '', metaLine(pr), '', `**Branch:** \`${pr.head_ref}\` → \`${pr.base_ref}\``, ''];
|
|
164
|
-
const detailsLine = (issue) => ` → details:
|
|
213
|
+
const detailsLine = (issue) => ` → details: issue show ${owner}/${repository}/${String(issue.number)}`;
|
|
165
214
|
if (pr.closing_issues.length > 0) {
|
|
166
215
|
lines.push('**Closing Issues:**');
|
|
167
216
|
for (const issue of pr.closing_issues)
|