@pecot/workflow-mcp 6.0.0 → 7.0.1-dev.19
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 +5 -58
- 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 +11 -17
- 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 +96 -17
- package/cli/dist/commands/issue-dependency.js +51 -14
- 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 +11 -5
- package/cli/dist/commands/issue-shared.js +25 -6
- package/cli/dist/commands/issue-show.js +78 -8
- package/cli/dist/commands/names.d.ts +1 -1
- package/cli/dist/commands/names.js +3 -3
- 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 +225 -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 +231 -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 +214 -111
- 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 +174 -17
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +67 -18
- package/cli/dist/commands/renamed-commands.js +0 -1
- package/cli/dist/commands/repository-match.js +7 -2
- package/cli/dist/commands/restack-reading.d.ts +45 -0
- package/cli/dist/commands/restack-reading.js +29 -0
- package/cli/dist/commands/session-finish.js +132 -28
- package/cli/dist/commands/session-start.js +31 -60
- package/cli/dist/commands/session.js +119 -135
- 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 +14 -9
- package/cli/dist/commands/work-target.js +19 -19
- package/cli/dist/commands/worktree.js +71 -5
- package/cli/dist/domain/branch-name.d.ts +7 -0
- package/cli/dist/domain/branch-name.js +23 -1
- package/cli/dist/domain/command-hint.d.ts +1 -1
- package/cli/dist/domain/issue-readout.d.ts +0 -4
- package/cli/dist/domain/pull-request.d.ts +20 -3
- package/cli/dist/domain/pull-request.js +25 -9
- package/cli/dist/domain/readiness.d.ts +17 -0
- package/cli/dist/domain/readiness.js +39 -2
- package/cli/dist/domain/restack.d.ts +66 -0
- package/cli/dist/domain/restack.js +57 -0
- package/cli/dist/domain/state.d.ts +41 -12
- package/cli/dist/domain/state.js +30 -14
- 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 +69 -0
- package/cli/dist/infra/git.js +117 -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/infra/paths.d.ts +1 -3
- package/cli/dist/infra/paths.js +2 -45
- package/cli/dist/infra/state-store.d.ts +3 -8
- package/cli/dist/infra/state-store.js +6 -24
- 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 +3 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/cli/dist/commands/pr.js
CHANGED
|
@@ -6,46 +6,45 @@ import { existsSync, statSync, writeFileSync } from 'node:fs';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { describeApiError } from '../domain/api-error-detail.js';
|
|
9
|
-
import { extractIssueNumberFromBranch } from '../domain/branch-name.js';
|
|
9
|
+
import { activeIssueFromBranch, extractIssueNumberFromBranch } from '../domain/branch-name.js';
|
|
10
10
|
import { effectiveReleaseType, findRepository, getDevelopBranch, getFieldId, getOptionId, getReleaseBranch } from '../domain/config.js';
|
|
11
11
|
import { InvalidValueError } from '../domain/errors.js';
|
|
12
12
|
import { FrontmatterError } from '../domain/frontmatter.js';
|
|
13
13
|
import { parseRemoteUrl } from '../domain/git-url.js';
|
|
14
14
|
import { isEpicIssue } from '../domain/issue-kind.js';
|
|
15
15
|
import { jsonField } from '../domain/json.js';
|
|
16
|
-
import { appendIssueCloseIfNeeded, collectPreflightWarnings, decidePullRequestBase, describeBaseStop, describePushStatus, formatPreflightWarning, formatPullRequestMarkdown, formatPullRequestWithReviewsMarkdown, isReleasePullRequest, pickLowerPullRequest, validatePullRequestContent } from '../domain/pull-request.js';
|
|
16
|
+
import { appendIssueCloseIfNeeded, collectPreflightWarnings, decidePullRequestBase, describeBaseStop, describePushStatus, DIVERGED_FIX_HINT, formatPreflightWarning, formatPullRequestMarkdown, formatPullRequestWithReviewsMarkdown, isReleasePullRequest, pickLowerPullRequest, pushFixHintOf, validatePullRequestContent } from '../domain/pull-request.js';
|
|
17
17
|
import { parsePythonInteger, pythonStrip } from '../domain/python-format.js';
|
|
18
|
-
import {
|
|
19
|
-
import { AmbiguousRepositoryError, resolveRepository, splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
20
|
-
import { FLAG_PECOT_ACTIVE, FLAG_PR_CREATE_SLASH_PENDING } from '../domain/state.js';
|
|
18
|
+
import { splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
21
19
|
import { loadActiveConfig } from '../infra/config-store.js';
|
|
22
20
|
import { parsePullRequestFile } from '../infra/frontmatter-file.js';
|
|
23
|
-
import { gitCurrentBranch, gitRemoteUrl,
|
|
21
|
+
import { gitCurrentBranch, gitRemoteUrl, gitStdout, gitToplevel, primaryRemoteName, remoteBranchHead, runGit } from '../infra/git.js';
|
|
24
22
|
import { TransportFailure } from '../infra/github/client.js';
|
|
25
23
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
26
24
|
import { changedFiles, expectedScope, nxProjects, parseTitleScope } from '../infra/nx-scope.js';
|
|
27
25
|
import { isFileNotFound } from '../infra/os-error.js';
|
|
28
26
|
import { outputDirectory, OutputPathReservationError, resolveRealPath, withReservedOutputPath } from '../infra/paths.js';
|
|
29
|
-
import {
|
|
27
|
+
import { readBaseRecord } from '../infra/state-store.js';
|
|
30
28
|
import { readTemplateSections, templateFile } from '../infra/template-store.js';
|
|
31
29
|
import { readTextFile } from '../infra/text-file.js';
|
|
32
30
|
import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './command-hint.js';
|
|
33
31
|
import { requireActiveConfigPlain, stopWith } from './command-stop.js';
|
|
34
32
|
import { kindOfFailure } from './failure.js';
|
|
35
|
-
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
36
33
|
import { directorySchema } from './directory-option.js';
|
|
37
34
|
import { createGitHubClient } from './github-client.js';
|
|
38
|
-
import { createOutput } from './output.js';
|
|
35
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
39
36
|
import { CommandExit, defineCommand } from './command-definition.js';
|
|
37
|
+
import { BOARD_MOVE_JSON, moveJson } from './issue-board.js';
|
|
38
|
+
import { PR_MERGE_COMMAND } from './pr-merge.js';
|
|
39
|
+
import { parseReference, PR_REFERENCE_DESCRIPTION } from './pr-reference.js';
|
|
40
|
+
import { readRestackDecision } from './restack-reading.js';
|
|
40
41
|
import { moveWaitingIssues } from './pr-waiting.js';
|
|
41
|
-
export
|
|
42
|
+
export { parseReference, PR_REFERENCE_DESCRIPTION } from './pr-reference.js';
|
|
42
43
|
// 本文の検証の失敗。1(通信・設定・引数)と 2(preflight)と区別する
|
|
43
44
|
const VALIDATION_EXIT_CODE = 3;
|
|
44
45
|
const PREFLIGHT_EXIT_CODE = 2;
|
|
45
46
|
// 下の段の PR が開いておらず、マージもされていない
|
|
46
47
|
const NO_OPEN_BASE_EXIT_CODE = 2;
|
|
47
|
-
// git ls-remote --exit-code が、一致する参照が無いときに返す
|
|
48
|
-
const LS_REMOTE_NOT_FOUND = 2;
|
|
49
48
|
// Python の `{e}` に当たる、例外の文
|
|
50
49
|
export function reasonOf(error) {
|
|
51
50
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -125,13 +124,30 @@ function titleScopeErrors(query, out) {
|
|
|
125
124
|
return [`PR title scope must be ${expected.join(',')} (given: ${shown}; computed from the tags of the changed nx projects)`];
|
|
126
125
|
}
|
|
127
126
|
// pr create
|
|
127
|
+
const PR_CREATE_OUTPUT = z.strictObject({
|
|
128
|
+
url: z.string().optional().describe('URL of the created PR (omitted on dry_run and prepare)'),
|
|
129
|
+
number: z.int().optional().describe('Number of the created PR (omitted on dry_run and prepare, or when the response has none)'),
|
|
130
|
+
head: z.string().optional().describe('Head branch of the PR (omitted on prepare)'),
|
|
131
|
+
base: z.string().optional().describe('Base branch of the PR. On prepare, the base filled into the draft (omitted when it was not filled)'),
|
|
132
|
+
title: z.string().optional().describe('Title of the PR (omitted on prepare)'),
|
|
133
|
+
inReview: z.int().optional().describe('Issue number whose status was set to In Review (omitted when not set)'),
|
|
134
|
+
stack: z.strictObject({
|
|
135
|
+
lower: z.int().describe('PR number of the lower stage the new PR is stacked on'),
|
|
136
|
+
registered: z.boolean().optional().describe('Whether the new PR was registered to the stack (omitted on dry_run)'),
|
|
137
|
+
number: z.int().optional().describe('Stack number (omitted when not registered)'),
|
|
138
|
+
}).optional().describe('Stack of the PR (omitted when the PR is not stacked)'),
|
|
139
|
+
moves: z.array(BOARD_MOVE_JSON).optional().describe('Issues waiting for this PR whose column or Status was written (omitted on dry_run and prepare)'),
|
|
140
|
+
file: z.string().optional().describe('Absolute path of the draft file written on prepare'),
|
|
141
|
+
dryRun: DRY_RUN_FIELD,
|
|
142
|
+
});
|
|
128
143
|
function inReviewOperation(issueNumber) {
|
|
129
144
|
return { verb: 'set', target: `Issue #${String(issueNumber)} status to In Review` };
|
|
130
145
|
}
|
|
146
|
+
// Status を In Review にした Issue の番号を返す。書かなかったら undefined
|
|
131
147
|
async function updateIssueStatusToInReview(config, client, location, headBranch, out) {
|
|
132
148
|
const issueNumber = extractIssueNumberFromBranch(headBranch);
|
|
133
149
|
if (issueNumber === undefined)
|
|
134
|
-
return;
|
|
150
|
+
return undefined;
|
|
135
151
|
const label = `Issue #${String(issueNumber)}`;
|
|
136
152
|
let itemId;
|
|
137
153
|
try {
|
|
@@ -163,6 +179,7 @@ async function updateIssueStatusToInReview(config, client, location, headBranch,
|
|
|
163
179
|
return;
|
|
164
180
|
}
|
|
165
181
|
out.done(inReviewOperation(issueNumber));
|
|
182
|
+
return issueNumber;
|
|
166
183
|
}
|
|
167
184
|
const LINK_PATH = ['project', 'link'];
|
|
168
185
|
const PR_CREATE_PATH = ['pr', 'create'];
|
|
@@ -220,15 +237,15 @@ function getStashList(cwd) {
|
|
|
220
237
|
return stdout === undefined ? '(git stash list failed)' : pythonStrip(stdout) || '(no stash)';
|
|
221
238
|
}
|
|
222
239
|
function getPushStatus(branch, cwd, remote) {
|
|
223
|
-
const failed = { isPushed: false, message: '(git rev-list failed)' };
|
|
240
|
+
const failed = { isPushed: false, message: '(git rev-list failed)', isDiverged: false };
|
|
224
241
|
try {
|
|
225
242
|
if (runGit(['rev-parse', '--verify', `${remote}/${branch}`], { cwd }).exitCode !== 0) {
|
|
226
|
-
return { isPushed: false, message: `${remote}/${branch} does not exist (not pushed)
|
|
243
|
+
return { isPushed: false, message: `${remote}/${branch} does not exist (not pushed)`, isDiverged: false };
|
|
227
244
|
}
|
|
228
245
|
}
|
|
229
246
|
catch (error) {
|
|
230
247
|
if (isFileNotFound(error))
|
|
231
|
-
return { isPushed: false, message: '(git rev-parse failed)' };
|
|
248
|
+
return { isPushed: false, message: '(git rev-parse failed)', isDiverged: false };
|
|
232
249
|
throw error;
|
|
233
250
|
}
|
|
234
251
|
const ahead = gitStdout(['rev-list', '--count', `${remote}/${branch}..${branch}`], { cwd });
|
|
@@ -238,7 +255,7 @@ function getPushStatus(branch, cwd, remote) {
|
|
|
238
255
|
return aheadCount === undefined || behindCount === undefined ? failed : describePushStatus(remote, branch, aheadCount, behindCount);
|
|
239
256
|
}
|
|
240
257
|
// pr create の早い確認と pr check が共有する前提。満たさなければ終了コード 1
|
|
241
|
-
function validatePullRequestContext(directory, out) {
|
|
258
|
+
export function validatePullRequestContext(directory, out) {
|
|
242
259
|
if (gitToplevel({ cwd: directory }) === undefined)
|
|
243
260
|
stopWith(out, 'not a git repository', 'git-unresolved');
|
|
244
261
|
const found = primaryRemote(directory);
|
|
@@ -251,10 +268,29 @@ function validatePullRequestContext(directory, out) {
|
|
|
251
268
|
return stopWith(out, 'cannot read repository info from the remote URL\ncheck it with: git remote -v', 'git-unresolved');
|
|
252
269
|
return { remoteUrl: found.url, currentBranch, location: found.location, remoteName: found.name };
|
|
253
270
|
}
|
|
254
|
-
|
|
271
|
+
// diverged のときの Push Status の直し方。積んでいれば載せ直しが要るかを読んで決める。diverged でなければ undefined(git push)
|
|
272
|
+
async function pushFixHintFor(push, reading, target) {
|
|
273
|
+
if (!push.isDiverged)
|
|
274
|
+
return undefined;
|
|
275
|
+
if (reading?.kind !== 'stacked')
|
|
276
|
+
return DIVERGED_FIX_HINT;
|
|
277
|
+
const { config, location, directory, remote, client, lowerPullRequest } = target;
|
|
278
|
+
const developBranch = getDevelopBranch(config, location.owner, location.repository) ?? '';
|
|
279
|
+
try {
|
|
280
|
+
const read = await readRestackDecision({ client, owner: location.owner, repository: location.repository, cwd: directory, remote, reading, developBranch, lowerPullRequest });
|
|
281
|
+
return pushFixHintOf(read.kind === 'decided' ? read.decision : undefined);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (error instanceof TransportFailure)
|
|
285
|
+
return pushFixHintOf(undefined);
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function runPreflightChecksOrExit(directory, base, config, client, out) {
|
|
255
290
|
const context = validatePullRequestContext(directory, out);
|
|
256
291
|
const push = getPushStatus(context.currentBranch, directory, context.remoteName);
|
|
257
|
-
const
|
|
292
|
+
const pushFixHint = await pushFixHintFor(push, base.reading, { config, location: context.location, directory, remote: context.remoteName, client, lowerPullRequest: base.lowerPullRequest });
|
|
293
|
+
const warnings = collectPreflightWarnings({ gitStatus: getGitStatus(directory), stashList: getStashList(directory), isPushed: push.isPushed, pushMessage: push.message, pushFixHint });
|
|
258
294
|
if (warnings.length === 0)
|
|
259
295
|
return;
|
|
260
296
|
out.error('preflight found warnings; fix them before creating a PR');
|
|
@@ -278,9 +314,10 @@ function lazyClient(config, out) {
|
|
|
278
314
|
}
|
|
279
315
|
// 下の段の PR が入っているスタックに足す。無ければ下の段と新しい PR で作る。失敗は warning にとどめる
|
|
280
316
|
async function registerStack(client, location, lower, created, out) {
|
|
317
|
+
const unregistered = { lower, registered: false };
|
|
281
318
|
if (created === undefined) {
|
|
282
319
|
out.warning('could not register stack: the PR creation response has no PR number');
|
|
283
|
-
return;
|
|
320
|
+
return unregistered;
|
|
284
321
|
}
|
|
285
322
|
try {
|
|
286
323
|
const stack = await client.getStackOfPullRequest(location.owner, location.repository, lower);
|
|
@@ -288,22 +325,25 @@ async function registerStack(client, location, lower, created, out) {
|
|
|
288
325
|
// GitHub は一番上にしか足せないので、同じ下の段に 2 つ目を積んだときは 422 を待たずに知らせる
|
|
289
326
|
if (stack !== undefined && top !== lower) {
|
|
290
327
|
out.warning(`could not register stack: PR #${String(lower)} is not the top of stack #${String(stack.number)} (top: PR #${String(top)}); PR #${String(created)} was not added`);
|
|
291
|
-
return;
|
|
328
|
+
return unregistered;
|
|
292
329
|
}
|
|
293
330
|
const registered = stack === undefined
|
|
294
331
|
? await client.createStack(location.owner, location.repository, [lower, created])
|
|
295
332
|
: await client.addToStack(location.owner, location.repository, stack.number, [created]);
|
|
296
333
|
out.done({ verb: 'add', target: `PR #${String(created)} to stack #${String(registered.number)}` });
|
|
334
|
+
return { lower, registered: true, number: registered.number };
|
|
297
335
|
}
|
|
298
336
|
catch (error) {
|
|
299
337
|
if (!isRequestFailure(error))
|
|
300
338
|
throw error;
|
|
301
339
|
out.warning(`could not register stack: ${describeRequestFailure(error)}`);
|
|
340
|
+
return unregistered;
|
|
302
341
|
}
|
|
303
342
|
}
|
|
304
|
-
|
|
343
|
+
// moves に、書けた列と札を足していく。例外で止まっても、それまでの分が残る
|
|
344
|
+
async function moveWaitingIssuesSafely(client, config, location, issueNumber, pullRequest, out, moves) {
|
|
305
345
|
try {
|
|
306
|
-
await moveWaitingIssues(out, client, config, { repository: location, issueNumber, pullRequest });
|
|
346
|
+
await moveWaitingIssues(out, client, config, { repository: location, issueNumber, pullRequest }, moves);
|
|
307
347
|
}
|
|
308
348
|
catch (error) {
|
|
309
349
|
if (!isRequestFailure(error))
|
|
@@ -311,8 +351,8 @@ async function moveWaitingIssuesSafely(client, config, location, issueNumber, pu
|
|
|
311
351
|
out.warning(`could not move the Issues waiting for #${String(issueNumber)}: ${describeRequestFailure(error)}`);
|
|
312
352
|
}
|
|
313
353
|
}
|
|
314
|
-
async function submitPullRequest(config, client, directory, draft, stackOn, out) {
|
|
315
|
-
runPreflightChecksOrExit(directory, out);
|
|
354
|
+
async function submitPullRequest(config, client, directory, draft, stackOn, base, out) {
|
|
355
|
+
await runPreflightChecksOrExit(directory, base, config, client, out);
|
|
316
356
|
let created;
|
|
317
357
|
try {
|
|
318
358
|
created = await client().createPullRequest(draft.location.owner, draft.location.repository, draft.title, draft.body, draft.head, draft.base, draft.isDraft);
|
|
@@ -325,20 +365,28 @@ async function submitPullRequest(config, client, directory, draft, stackOn, out)
|
|
|
325
365
|
out.done(createOperation(draft));
|
|
326
366
|
const createdNumber = jsonField(created, 'number');
|
|
327
367
|
const pullRequest = typeof createdNumber === 'number' ? createdNumber : undefined;
|
|
328
|
-
|
|
329
|
-
|
|
368
|
+
const url = jsonField(created, 'html_url');
|
|
369
|
+
// url は先に渡す。後の処理が例外で止まっても、作った PR を結果から読める
|
|
370
|
+
out.result({ head: draft.head, base: draft.base, title: draft.title, ...pullRequest !== undefined && { number: pullRequest }, ...typeof url === 'string' && { url } });
|
|
371
|
+
const inReview = draft.isRelease ? undefined : await updateIssueStatusToInReview(config, client(), draft.location, draft.head, out);
|
|
372
|
+
if (inReview !== undefined)
|
|
373
|
+
out.result({ inReview });
|
|
330
374
|
if (stackOn !== undefined)
|
|
331
|
-
await registerStack(client(), draft.location, stackOn, pullRequest, out);
|
|
375
|
+
out.result({ stack: await registerStack(client(), draft.location, stackOn, pullRequest, out) });
|
|
332
376
|
const issueNumber = extractIssueNumberFromBranch(draft.head);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
377
|
+
const moves = [];
|
|
378
|
+
try {
|
|
379
|
+
if (!draft.isRelease && isPositive(issueNumber))
|
|
380
|
+
await moveWaitingIssuesSafely(client(), config, draft.location, issueNumber, pullRequest, out, moves);
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
out.result({ moves: moves.map(move => moveJson(move)) });
|
|
384
|
+
}
|
|
337
385
|
if (typeof url !== 'string')
|
|
338
386
|
return stopWith(out, 'PR was created, but the response has no html_url; find it on GitHub', 'other');
|
|
339
387
|
out.data(url);
|
|
340
388
|
}
|
|
341
|
-
function stopOnMalformedRecord(reading, out) {
|
|
389
|
+
export function stopOnMalformedRecord(reading, out) {
|
|
342
390
|
if (reading.kind === 'malformed')
|
|
343
391
|
stopWith(out, describeBaseStop({ kind: 'stop', reason: 'malformed', content: reading.content }).join('\n'), 'content-invalid');
|
|
344
392
|
}
|
|
@@ -363,13 +411,14 @@ function readBaseRecordFor(head, template, directory, out) {
|
|
|
363
411
|
async function decideBase(input, client, developBranch, out) {
|
|
364
412
|
const { reading, base, location } = input;
|
|
365
413
|
if (reading === undefined)
|
|
366
|
-
return { kind: 'use', base, stackOn: undefined, stackedBase: undefined, isLowerMerged: false };
|
|
414
|
+
return { decision: { kind: 'use', base, stackOn: undefined, stackedBase: undefined, isLowerMerged: false }, lowerPullRequest: undefined };
|
|
367
415
|
if (reading.kind !== 'stacked')
|
|
368
|
-
return decidePullRequestBase({ reading, base, developBranch });
|
|
416
|
+
return { decision: decidePullRequestBase({ reading, base, developBranch }), lowerPullRequest: undefined };
|
|
369
417
|
const { branch } = reading.record;
|
|
370
418
|
try {
|
|
371
419
|
const found = await client().listPullRequestsByHead(location.owner, location.repository, branch);
|
|
372
|
-
|
|
420
|
+
const lower = pickLowerPullRequest(found.pullRequests);
|
|
421
|
+
return { decision: decidePullRequestBase({ reading, base, developBranch, lowerPullRequest: lower }), lowerPullRequest: { pullRequest: lower } };
|
|
373
422
|
}
|
|
374
423
|
catch (error) {
|
|
375
424
|
if (error instanceof GitHubAPIError)
|
|
@@ -403,7 +452,8 @@ async function validateAndSubmit(input, out) {
|
|
|
403
452
|
const developBranch = getDevelopBranch(config, location.owner, location.repository);
|
|
404
453
|
const releaseBranch = getReleaseBranch(config, location.owner, location.repository);
|
|
405
454
|
exitOnUnsetBranch(template, input.base, head, developBranch, releaseBranch, out);
|
|
406
|
-
const
|
|
455
|
+
const decided = await decideBase(input, client, developBranch ?? '', out);
|
|
456
|
+
const { use, errors: baseErrors } = useOrStop(decided.decision, out);
|
|
407
457
|
const base = use?.base ?? input.base;
|
|
408
458
|
const stacked = stackedScopeOf(input.reading, use);
|
|
409
459
|
const requiredSections = readTemplateSections(templateFile('pr', templateKindOf(template)));
|
|
@@ -427,7 +477,7 @@ async function validateAndSubmit(input, out) {
|
|
|
427
477
|
const isRelease = template === 'release';
|
|
428
478
|
const draft = { location, title, body: input.body, head, base, isDraft: input.isDraft, isRelease };
|
|
429
479
|
if (!input.dryRun) {
|
|
430
|
-
await submitPullRequest(config, client, directory, draft, use?.stackOn, out);
|
|
480
|
+
await submitPullRequest(config, client, directory, draft, use?.stackOn, { reading: input.reading, lowerPullRequest: decided.lowerPullRequest }, out);
|
|
431
481
|
return;
|
|
432
482
|
}
|
|
433
483
|
out.planned(createOperation(draft));
|
|
@@ -436,6 +486,7 @@ async function validateAndSubmit(input, out) {
|
|
|
436
486
|
out.planned(inReviewOperation(issueNumber));
|
|
437
487
|
if (use?.stackOn !== undefined)
|
|
438
488
|
out.planned({ verb: 'add', target: `the new PR to the stack of PR #${String(use.stackOn)}` });
|
|
489
|
+
out.result({ head, base, title, ...use?.stackOn !== undefined && { stack: { lower: use.stackOn } } });
|
|
439
490
|
}
|
|
440
491
|
function requireRepository(value, out) {
|
|
441
492
|
return splitOwnerRepository(value) ?? stopWith(out, `invalid repository format: ${value} (expected: owner/repo)`, 'invalid-input');
|
|
@@ -529,22 +580,11 @@ function addScopeHint(content, config, location, base, directory, stacked, out)
|
|
|
529
580
|
return hinted;
|
|
530
581
|
}
|
|
531
582
|
async function fillClosesInTemplate(content, config, directory, location, out) {
|
|
532
|
-
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
const [activeOwner, activeRepository, digits] = segments;
|
|
536
|
-
const activeNumber = digits !== undefined && /^\p{Nd}+$/u.test(digits) ? parsePythonInteger(digits) : undefined;
|
|
537
|
-
if (activeOwner !== undefined && activeRepository !== undefined && activeNumber !== undefined)
|
|
538
|
-
target = { owner: activeOwner, repository: activeRepository, number: activeNumber };
|
|
539
|
-
}
|
|
540
|
-
if (target === undefined && location !== undefined) {
|
|
541
|
-
const branch = gitCurrentBranch(directory);
|
|
542
|
-
const branchNumber = branch === undefined || branch === '' ? undefined : extractIssueNumberFromBranch(branch);
|
|
543
|
-
if (isPositive(branchNumber))
|
|
544
|
-
target = { owner: location.owner, repository: location.repository, number: branchNumber };
|
|
545
|
-
}
|
|
546
|
-
if (target === undefined || target.owner === '' || target.repository === '')
|
|
583
|
+
// 作業中の Issue は remote とブランチ名から決める。古い .pecot-active は読まない
|
|
584
|
+
const active = activeIssueFromBranch(location, gitCurrentBranch(directory));
|
|
585
|
+
if (active === undefined)
|
|
547
586
|
return content;
|
|
587
|
+
const target = { owner: active.repository.owner, repository: active.repository.repository, number: active.number };
|
|
548
588
|
const label = `Issue #${String(target.number)}`;
|
|
549
589
|
try {
|
|
550
590
|
const kind = await createGitHubClient(out, config?.host).getIssueKind(target.owner, target.repository, target.number);
|
|
@@ -585,6 +625,7 @@ async function prepareTemplate(directory, out, template) {
|
|
|
585
625
|
const base = record?.branch ?? developBranch;
|
|
586
626
|
content = content.replace(/^base:\s*"[^"]*"/mu, () => `base: "${base}"`);
|
|
587
627
|
out.done({ verb: 'set', target: `base to ${base}` });
|
|
628
|
+
out.result({ base });
|
|
588
629
|
content = addScopeHint(content, config, { owner: location.owner, repository: location.repository }, base, directory, record === undefined ? undefined : { sha: record.sha }, out);
|
|
589
630
|
}
|
|
590
631
|
}
|
|
@@ -594,6 +635,7 @@ async function prepareTemplate(directory, out, template) {
|
|
|
594
635
|
try {
|
|
595
636
|
withReservedOutputPath(outputDirectory(), timestamp => `${prefix}-${timestamp}.md`, (reserved) => {
|
|
596
637
|
writeFileSync(reserved, content, 'utf8');
|
|
638
|
+
out.result({ file: path.resolve(reserved) });
|
|
597
639
|
out.data(reserved);
|
|
598
640
|
});
|
|
599
641
|
}
|
|
@@ -651,33 +693,68 @@ async function runCreate(input, io) {
|
|
|
651
693
|
}
|
|
652
694
|
}
|
|
653
695
|
// pr show
|
|
654
|
-
// グローバルの --repo か、いまの git の repository。決められなければ undefined
|
|
655
|
-
function resolveBaseRepository(globalRepository) {
|
|
656
|
-
try {
|
|
657
|
-
return resolveRepository(globalRepository, gitRunnerFor(process.cwd())).repository;
|
|
658
|
-
}
|
|
659
|
-
catch (error) {
|
|
660
|
-
if (error instanceof AmbiguousRepositoryError)
|
|
661
|
-
return undefined;
|
|
662
|
-
throw error;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
export function parseReference(reference, globalRepository, out) {
|
|
666
|
-
try {
|
|
667
|
-
const parsed = parsePullRequestReference(reference, resolveBaseRepository(globalRepository), { repositoryFlag: true });
|
|
668
|
-
return { owner: parsed.repository.owner, repository: parsed.repository.repository, number: parsed.number };
|
|
669
|
-
}
|
|
670
|
-
catch (error) {
|
|
671
|
-
if (error instanceof ReferenceParseError)
|
|
672
|
-
return stopWith(out, error.hintedText ?? error.message, 'invalid-input', USAGE_EXIT_CODE);
|
|
673
|
-
throw error;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
696
|
const ShowInputSchema = z.strictObject({
|
|
677
697
|
pr_ref: z.string().describe(PR_REFERENCE_DESCRIPTION),
|
|
678
698
|
json: z.boolean().default(false).describe('Output as JSON'),
|
|
679
699
|
reviews: z.boolean().default(false).describe('Include review details (bodies and line comments)'),
|
|
680
700
|
});
|
|
701
|
+
const ISSUE_LINK_JSON = z.strictObject({
|
|
702
|
+
number: z.int().describe('Issue number'),
|
|
703
|
+
title: z.string().describe('Title of the Issue (empty for referenced_issues)'),
|
|
704
|
+
});
|
|
705
|
+
const REVIEW_JSON = z.strictObject({
|
|
706
|
+
state: z.string().describe('State of the review'),
|
|
707
|
+
author: z.string().nullable().describe('Login of the reviewer (null when deleted)'),
|
|
708
|
+
body: z.string().optional().describe('Body of the review (only with reviews)'),
|
|
709
|
+
submitted_at: z.string().nullable().optional().describe('Submission time (only with reviews)'),
|
|
710
|
+
});
|
|
711
|
+
const REVIEW_COMMENT_JSON = z.strictObject({
|
|
712
|
+
author: z.string().nullable().describe('Login of the author (null when deleted)'),
|
|
713
|
+
body: z.string().describe('Body of the comment'),
|
|
714
|
+
created_at: z.string().nullable().describe('Creation time'),
|
|
715
|
+
});
|
|
716
|
+
const REVIEW_THREAD_JSON = z.strictObject({
|
|
717
|
+
is_resolved: z.boolean().describe('Whether the thread is resolved'),
|
|
718
|
+
path: z.string().nullable().describe('File path of the thread'),
|
|
719
|
+
line: z.int().nullable().describe('Line of the thread'),
|
|
720
|
+
comments: z.array(REVIEW_COMMENT_JSON).describe('Comments in the thread'),
|
|
721
|
+
});
|
|
722
|
+
const PR_SHOW_OUTPUT = z.strictObject({
|
|
723
|
+
number: z.int().describe('PR number'),
|
|
724
|
+
state: z.string().describe('State of the PR (OPEN, CLOSED or MERGED)'),
|
|
725
|
+
title: z.string().describe('Title of the PR'),
|
|
726
|
+
body: z.string().describe('Body of the PR'),
|
|
727
|
+
head_ref: z.string().describe('Head branch'),
|
|
728
|
+
base_ref: z.string().describe('Base branch'),
|
|
729
|
+
is_draft: z.boolean().describe('Whether the PR is a draft'),
|
|
730
|
+
mergeable: z.string().describe('Mergeability (MERGEABLE, CONFLICTING or UNKNOWN)'),
|
|
731
|
+
comments: z.int().describe('Number of comments'),
|
|
732
|
+
closing_issues: z.array(ISSUE_LINK_JSON).describe('Issues the PR closes'),
|
|
733
|
+
referenced_issues: z.array(ISSUE_LINK_JSON).describe('Issues referenced by Refs in the body and not in closing_issues'),
|
|
734
|
+
reviews: z.array(REVIEW_JSON).describe('Reviews'),
|
|
735
|
+
review_threads: z.array(REVIEW_THREAD_JSON).optional().describe('Line comment threads (only with reviews)'),
|
|
736
|
+
});
|
|
737
|
+
/**
|
|
738
|
+
--json の標準出力と MCP の data の中身。キーを並べた順が --json の出力の順になる
|
|
739
|
+
*/
|
|
740
|
+
function pullRequestJson(pr) {
|
|
741
|
+
// 項目を手で並べるので、satisfies で PR の型の項目の過不足を tsc に止めさせる
|
|
742
|
+
const base = {
|
|
743
|
+
number: pr.number,
|
|
744
|
+
state: pr.state,
|
|
745
|
+
title: pr.title,
|
|
746
|
+
body: pr.body,
|
|
747
|
+
head_ref: pr.head_ref,
|
|
748
|
+
base_ref: pr.base_ref,
|
|
749
|
+
is_draft: pr.is_draft,
|
|
750
|
+
mergeable: pr.mergeable,
|
|
751
|
+
comments: pr.comments,
|
|
752
|
+
closing_issues: pr.closing_issues.map(issue => ({ ...issue })),
|
|
753
|
+
referenced_issues: pr.referenced_issues.map(issue => ({ ...issue })),
|
|
754
|
+
reviews: pr.reviews.map(review => ({ ...review })),
|
|
755
|
+
};
|
|
756
|
+
return 'review_threads' in pr ? { ...base, review_threads: pr.review_threads.map(thread => ({ ...thread, comments: thread.comments.map(comment => ({ ...comment })) })) } : base;
|
|
757
|
+
}
|
|
681
758
|
async function runShow(input, io) {
|
|
682
759
|
const out = createOutput(false, io);
|
|
683
760
|
const config = requireActiveConfigPlain(out);
|
|
@@ -686,11 +763,15 @@ async function runShow(input, io) {
|
|
|
686
763
|
const client = createGitHubClient(out, config.host);
|
|
687
764
|
if (input.reviews) {
|
|
688
765
|
const pr = await client.getPullRequestWithReviews(owner, repository, number);
|
|
689
|
-
|
|
766
|
+
const json = pullRequestJson(pr);
|
|
767
|
+
out.result(json);
|
|
768
|
+
out.data(`${input.json ? JSON.stringify(json, undefined, 2) : formatPullRequestWithReviewsMarkdown(pr, owner, repository)}\n`);
|
|
690
769
|
}
|
|
691
770
|
else {
|
|
692
771
|
const pr = await client.getPullRequestSlim(owner, repository, number);
|
|
693
|
-
|
|
772
|
+
const json = pullRequestJson(pr);
|
|
773
|
+
out.result(json);
|
|
774
|
+
out.data(`${input.json ? JSON.stringify(json, undefined, 2) : formatPullRequestMarkdown(pr)}\n`);
|
|
694
775
|
}
|
|
695
776
|
}
|
|
696
777
|
catch (error) {
|
|
@@ -703,27 +784,18 @@ async function runShow(input, io) {
|
|
|
703
784
|
function hasBranch(branch, cwd) {
|
|
704
785
|
return runGit(['rev-parse', '--verify', branch], { cwd }).exitCode === 0;
|
|
705
786
|
}
|
|
706
|
-
// pr check の ls-remote は、認証の入力を待たずに、この時間で諦める
|
|
707
|
-
const LS_REMOTE_TIMEOUT_MILLISECONDS = 10_000;
|
|
708
|
-
// 端末で尋ねさせない。ssh は GIT_SSH_COMMAND で BatchMode にすると利用者の GIT_SSH と core.sshCommand を上書きするので、askpass を失敗させる
|
|
709
|
-
const NON_INTERACTIVE_GIT = { GIT_TERMINAL_PROMPT: '0', SSH_ASKPASS: 'false', SSH_ASKPASS_REQUIRE: 'force' };
|
|
710
787
|
// 下の段のブランチがマージで消えた後は、開発ブランチと比べる。追跡参照は fetch --prune まで残るので、
|
|
711
|
-
// remote
|
|
788
|
+
// remote に尋ね、無いと答えたときだけ消えたとみなす。届かないか時間切れなら追跡参照で決める
|
|
712
789
|
function isOnRemote(branch, cwd, remote, out) {
|
|
713
|
-
const
|
|
714
|
-
if (
|
|
790
|
+
const head = remoteBranchHead(cwd, remote, branch);
|
|
791
|
+
if (head.isReachable && head.sha === undefined)
|
|
715
792
|
return false;
|
|
716
793
|
const isTracked = hasBranch(`${remote}/${branch}`, cwd);
|
|
717
|
-
if (!isTracked &&
|
|
794
|
+
if (!isTracked && head.isReachable)
|
|
718
795
|
out.warning(`base branch ${branch} is on ${remote}, but ${remote}/${branch} is not fetched; compared with the develop branch\nrun: git fetch ${remote} ${branch}`);
|
|
719
796
|
return isTracked;
|
|
720
797
|
}
|
|
721
|
-
function determineBaseBranch(location, cwd, remote, out) {
|
|
722
|
-
const config = loadActiveConfig();
|
|
723
|
-
if (config === undefined)
|
|
724
|
-
return stopWith(out, hinted `project config not found\nactivate a project with: ${commandHint(['project', 'activate'], { project: placeholder('PROJECT') })}`, 'no-active-project');
|
|
725
|
-
const reading = readBaseRecord();
|
|
726
|
-
stopOnMalformedRecord(reading, out);
|
|
798
|
+
function determineBaseBranch(config, reading, location, cwd, remote, out) {
|
|
727
799
|
if (reading.kind === 'stacked' && isOnRemote(reading.record.branch, cwd, remote, out))
|
|
728
800
|
return `${remote}/${reading.record.branch}`;
|
|
729
801
|
const developBranch = getDevelopBranch(config, location.owner, location.repository);
|
|
@@ -759,33 +831,60 @@ function readGitExclude(cwd) {
|
|
|
759
831
|
return '(read error)';
|
|
760
832
|
}
|
|
761
833
|
}
|
|
762
|
-
|
|
834
|
+
const PR_CHECK_OUTPUT = z.strictObject({
|
|
835
|
+
remoteUrl: z.string().describe('URL of the primary git remote'),
|
|
836
|
+
currentBranch: z.string().describe('Current branch'),
|
|
837
|
+
pushed: z.boolean().describe('Whether the current branch is pushed and even with its remote branch'),
|
|
838
|
+
pushStatus: z.string().describe('Push status as shown in the Push Status section'),
|
|
839
|
+
baseBranch: z.string().describe('Remote branch compared against (remote/branch): the lower stage when stacked, else the develop branch'),
|
|
840
|
+
gitStatus: z.string().describe('Output of git status'),
|
|
841
|
+
commits: z.string().describe('Commits since the base branch, as shown in the Commits section'),
|
|
842
|
+
diffSummary: z.string().describe('Diff stat against the base branch, as shown in the Diff Summary section'),
|
|
843
|
+
worktree: z.strictObject({
|
|
844
|
+
list: z.string().describe('Output of git worktree list'),
|
|
845
|
+
directoryName: z.string().describe('Name of the current directory'),
|
|
846
|
+
isWorktree: z.boolean().optional().describe('Whether the directory is a linked worktree (omitted when it could not be determined)'),
|
|
847
|
+
}).describe('Worktree information'),
|
|
848
|
+
stashList: z.string().describe('Stash list, as shown in the Stash List section'),
|
|
849
|
+
});
|
|
850
|
+
function readWorktreeInfo(cwd) {
|
|
763
851
|
const listed = gitStdout(['worktree', 'list'], { cwd });
|
|
764
|
-
const
|
|
852
|
+
const list = listed === undefined ? '(git worktree list failed)' : pythonStrip(listed);
|
|
853
|
+
const directoryName = path.basename(cwd);
|
|
765
854
|
const gitDirectory = gitStdout(['rev-parse', '--git-dir'], { cwd });
|
|
766
855
|
const commonDirectory = gitDirectory === undefined ? undefined : gitStdout(['rev-parse', '--git-common-dir'], { cwd });
|
|
767
|
-
if (gitDirectory === undefined || commonDirectory === undefined)
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
return
|
|
856
|
+
if (gitDirectory === undefined || commonDirectory === undefined)
|
|
857
|
+
return { list, directoryName };
|
|
858
|
+
const isWorktree = resolveRealPath(path.resolve(cwd, pythonStrip(gitDirectory))) !== resolveRealPath(path.resolve(cwd, pythonStrip(commonDirectory)));
|
|
859
|
+
return { list, directoryName, isWorktree };
|
|
860
|
+
}
|
|
861
|
+
function formatWorktreeInfo(info) {
|
|
862
|
+
const worktreeText = info.isWorktree === undefined ? '(unknown)' : String(info.isWorktree);
|
|
863
|
+
return [info.list, '', `Current directory name: ${info.directoryName}`, `Is worktree environment: ${worktreeText}`].join('\n');
|
|
775
864
|
}
|
|
776
865
|
const CheckInputSchema = z.strictObject({
|
|
777
866
|
directory: directorySchema,
|
|
778
867
|
});
|
|
779
|
-
function runCheck(input, io) {
|
|
868
|
+
async function runCheck(input, io) {
|
|
780
869
|
const out = createOutput(false, io);
|
|
781
870
|
const directory = input.directory;
|
|
782
871
|
const context = validatePullRequestContext(directory, out);
|
|
783
|
-
const
|
|
872
|
+
const config = loadActiveConfig();
|
|
873
|
+
if (config === undefined)
|
|
874
|
+
return stopWith(out, hinted `project config not found\nactivate a project with: ${commandHint(['project', 'activate'], { project: placeholder('PROJECT') })}`, 'no-active-project');
|
|
875
|
+
const reading = readBaseRecord();
|
|
876
|
+
stopOnMalformedRecord(reading, out);
|
|
877
|
+
const baseBranch = determineBaseBranch(config, reading, context.location, directory, context.remoteName, out);
|
|
784
878
|
const gitStatus = getGitStatus(directory);
|
|
785
879
|
const commits = gitStdout(['log', '--oneline', `${baseBranch}..HEAD`], { cwd: directory });
|
|
786
880
|
const diffSummary = gitStdout(['diff', '--stat', `${baseBranch}...HEAD`], { cwd: directory });
|
|
787
881
|
const push = getPushStatus(context.currentBranch, directory, context.remoteName);
|
|
788
882
|
const stashList = getStashList(directory);
|
|
883
|
+
const commitsText = commits === undefined ? '(git log failed)' : pythonStrip(commits) || '(no commits)';
|
|
884
|
+
const diffText = diffSummary === undefined ? '(git diff failed)' : pythonStrip(diffSummary) || '(no diff)';
|
|
885
|
+
const worktree = readWorktreeInfo(directory);
|
|
886
|
+
// preflight の warning で失敗に終わっても、集めた値を data に残す
|
|
887
|
+
out.result({ remoteUrl: context.remoteUrl, currentBranch: context.currentBranch, pushed: push.isPushed, pushStatus: push.message, baseBranch, gitStatus, commits: commitsText, diffSummary: diffText, worktree, stashList });
|
|
789
888
|
const sections = [
|
|
790
889
|
['=== Git Remote ===', context.remoteUrl],
|
|
791
890
|
['=== Current Branch ===', context.currentBranch],
|
|
@@ -794,9 +893,9 @@ function runCheck(input, io) {
|
|
|
794
893
|
['=== Git Status ===', gitStatus],
|
|
795
894
|
['=== .gitignore ===', readGitignore(directory)],
|
|
796
895
|
['=== Git Exclude ===', readGitExclude(directory)],
|
|
797
|
-
[`=== Commits (vs ${baseBranch}) ===`,
|
|
798
|
-
[`=== Diff Summary (vs ${baseBranch}) ===`,
|
|
799
|
-
['=== Worktree Info ===',
|
|
896
|
+
[`=== Commits (vs ${baseBranch}) ===`, commitsText],
|
|
897
|
+
[`=== Diff Summary (vs ${baseBranch}) ===`, diffText],
|
|
898
|
+
['=== Worktree Info ===', formatWorktreeInfo(worktree)],
|
|
800
899
|
['=== Stash List ===', stashList],
|
|
801
900
|
];
|
|
802
901
|
for (const [index, [heading, content]] of sections.entries()) {
|
|
@@ -805,7 +904,8 @@ function runCheck(input, io) {
|
|
|
805
904
|
out.data(`${heading}\n`);
|
|
806
905
|
out.data(`${content}\n`);
|
|
807
906
|
}
|
|
808
|
-
const
|
|
907
|
+
const pushFixHint = await pushFixHintFor(push, reading, { config, location: context.location, directory, remote: context.remoteName, client: lazyClient(config, out) });
|
|
908
|
+
const warnings = collectPreflightWarnings({ gitStatus, stashList, isPushed: push.isPushed, pushMessage: push.message, pushFixHint });
|
|
809
909
|
out.count('preflight warnings', warnings.length);
|
|
810
910
|
printPreflightWarnings(out, warnings);
|
|
811
911
|
if (warnings.length > 0)
|
|
@@ -815,6 +915,7 @@ const prCreate = defineCommand({
|
|
|
815
915
|
path: PR_CREATE_PATH,
|
|
816
916
|
description: 'Create a PR (pull request)',
|
|
817
917
|
input: CreateInputSchema,
|
|
918
|
+
output: PR_CREATE_OUTPUT,
|
|
818
919
|
positional: ['file'],
|
|
819
920
|
shortFlags: { message: '-m', title: '-t', base: '-b', draft: '-d', prepare: '-p', dry_run: '-n', repo: '-r' },
|
|
820
921
|
hasOwnRepo: true,
|
|
@@ -828,6 +929,7 @@ const prShow = defineCommand({
|
|
|
828
929
|
path: ['pr', 'show'],
|
|
829
930
|
description: 'Get PR details efficiently (GraphQL, only the needed fields)',
|
|
830
931
|
input: ShowInputSchema,
|
|
932
|
+
output: PR_SHOW_OUTPUT,
|
|
831
933
|
positional: ['pr_ref'],
|
|
832
934
|
shortFlags: { json: '-j', reviews: '-r' },
|
|
833
935
|
interactive: false,
|
|
@@ -840,13 +942,14 @@ const prCheck = defineCommand({
|
|
|
840
942
|
path: ['pr', 'check'],
|
|
841
943
|
description: 'Show all the information to check before creating a PR',
|
|
842
944
|
input: CheckInputSchema,
|
|
945
|
+
output: PR_CHECK_OUTPUT,
|
|
843
946
|
positional: [],
|
|
844
947
|
shortFlags: { directory: '-D' },
|
|
845
948
|
interactive: false,
|
|
846
|
-
run: (input, io) => {
|
|
847
|
-
runCheck(input, io);
|
|
848
|
-
return
|
|
949
|
+
run: async (input, io) => {
|
|
950
|
+
await runCheck(input, io);
|
|
951
|
+
return 0;
|
|
849
952
|
},
|
|
850
953
|
});
|
|
851
|
-
export const PR_COMMANDS = [prCreate, prShow, prCheck];
|
|
954
|
+
export const PR_COMMANDS = [prCreate, prShow, prCheck, PR_MERGE_COMMAND];
|
|
852
955
|
//# sourceMappingURL=pr.js.map
|
|
@@ -77,7 +77,15 @@ export interface RepositoryParts {
|
|
|
77
77
|
*/
|
|
78
78
|
export declare function buildRepository(parts: Readonly<RepositoryParts>): Repository;
|
|
79
79
|
/**
|
|
80
|
-
|
|
80
|
+
syncProjectConfig の結果。行に出した値と同じ。change は設定ファイルの扱い、activeProject はアクティブにした(dry-run では、する)設定の名前で、unchanged なら undefined
|
|
81
|
+
*/
|
|
82
|
+
export interface SyncedProjectConfig {
|
|
83
|
+
readonly configPath: string;
|
|
84
|
+
readonly change: 'create' | 'update' | 'unchanged';
|
|
85
|
+
readonly activeProject: string | undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
GitHub Projects V2 の情報から設定ファイルを作るか更新し、アクティブにする。設定ファイルのパスと、行に出した扱いを返す。
|
|
81
89
|
pecot-workflow に合うプロジェクトだけを扱う。suffix はその名前の workflow フィールドを使う。
|
|
82
90
|
skipIfUnchanged は、設定ファイルの内容が同じなら何も書かない。isDryRun は読むだけで、書く操作を planned で出す
|
|
83
91
|
*/
|
|
@@ -88,5 +96,5 @@ export declare function syncProjectConfig(out: Readonly<Output>, client: Readonl
|
|
|
88
96
|
suffix?: string | undefined;
|
|
89
97
|
skipIfUnchanged?: boolean | undefined;
|
|
90
98
|
isDryRun?: boolean | undefined;
|
|
91
|
-
}>): Promise<
|
|
99
|
+
}>): Promise<SyncedProjectConfig>;
|
|
92
100
|
//# sourceMappingURL=project-sync.d.ts.map
|