@pecot/workflow-mcp 8.0.1-dev.58 → 8.0.1-dev.60
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 +1 -0
- package/cli/dist/commands/base-reading.d.ts +1 -1
- package/cli/dist/commands/base-reading.js +1 -1
- package/cli/dist/commands/board-sync.js +1 -1
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +12 -4
- package/cli/dist/commands/issue-comment.js +3 -2
- package/cli/dist/commands/issue-show.js +3 -2
- package/cli/dist/commands/names.js +1 -0
- package/cli/dist/commands/output.d.ts +4 -0
- package/cli/dist/commands/output.js +1 -0
- package/cli/dist/commands/pr-merge.js +3 -2
- package/cli/dist/commands/pr-restack.js +16 -9
- package/cli/dist/commands/pr.js +18 -18
- package/cli/dist/commands/project.js +5 -3
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +8 -8
- package/cli/dist/commands/restack-reading.d.ts +4 -0
- package/cli/dist/commands/restack-reading.js +1 -1
- package/cli/dist/commands/review-finish.d.ts +3 -0
- package/cli/dist/commands/review-finish.js +276 -0
- package/cli/dist/commands/session-finish.js +18 -8
- package/cli/dist/commands/session.js +1 -1
- package/cli/dist/commands/tracker-sync-dependabot.js +1 -1
- package/cli/dist/commands/tracker-sync-security.js +1 -1
- package/cli/dist/commands/worktree.js +4 -3
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/release.d.ts +10 -1
- package/cli/dist/domain/release.js +10 -6
- package/cli/dist/domain/review-finish.d.ts +102 -0
- package/cli/dist/domain/review-finish.js +169 -0
- package/cli/dist/infra/git.d.ts +20 -16
- package/cli/dist/infra/git.js +40 -96
- package/cli/dist/infra/github/client.d.ts +12 -1
- package/cli/dist/infra/github/client.js +49 -16
- package/cli/dist/infra/github/issues.d.ts +4 -0
- package/cli/dist/infra/github/issues.js +6 -0
- package/cli/dist/infra/github/pulls.d.ts +9 -0
- package/cli/dist/infra/github/pulls.js +14 -0
- package/cli/dist/infra/github/repos.d.ts +4 -0
- package/cli/dist/infra/github/repos.js +8 -1
- package/cli/dist/infra/nx-scope.d.ts +5 -1
- package/cli/dist/infra/nx-scope.js +20 -13
- package/cli/dist/infra/process-run.d.ts +57 -0
- package/cli/dist/infra/process-run.js +168 -0
- package/cli/dist/infra/worktree-setup.d.ts +3 -6
- package/cli/dist/infra/worktree-setup.js +8 -26
- package/cli/dist/infra/worktree.d.ts +5 -1
- package/cli/dist/infra/worktree.js +4 -4
- package/cli/dist/mcp/result.d.ts +3 -3
- package/cli/dist/mcp/result.js +4 -3
- package/cli/dist/mcp/serve.d.ts +12 -0
- package/cli/dist/mcp/serve.js +30 -2
- package/cli/dist/mcp/server.d.ts +4 -0
- package/cli/dist/mcp/server.js +14 -6
- package/cli/templates/comment/review-stopped.md +28 -0
- package/cli/templates/workflow/pecot-review.yml +11 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ Claude Code では、Claude Code がサーバを起動するディレクトリ
|
|
|
111
111
|
| `pr_check` | PR を作る前に確かめる情報をまとめて表示する |
|
|
112
112
|
| `pr_merge` | PR をマージする(スタックの中の PR は最下段だけ) |
|
|
113
113
|
| `pr_restack` | 積んだブランチを、base にしたブランチの新しい位置へ載せ直す |
|
|
114
|
+
| `review_finish` | 自動レビューを終える(止まったときだけ、止まったことを知らせるコメントを PR に書く) |
|
|
114
115
|
| `release_check` | リリース前の確認をする |
|
|
115
116
|
| `release_create` | GitHub のリリースとタグを作る(ノートは CHANGELOG から取る) |
|
|
116
117
|
| `release_merge` | リリースの PR を通常のマージで取り込む |
|
|
@@ -16,7 +16,7 @@ export interface BaseQuery {
|
|
|
16
16
|
/**
|
|
17
17
|
求める前に一度だけ呼ぶ。pr restack が追跡参照を新しくするのに使う
|
|
18
18
|
*/
|
|
19
|
-
readonly beforeInfer?: (() => void) | undefined;
|
|
19
|
+
readonly beforeInfer?: (() => Promise<void> | void) | undefined;
|
|
20
20
|
}
|
|
21
21
|
export interface BaseResult {
|
|
22
22
|
readonly reading: BaseReading;
|
|
@@ -32,7 +32,7 @@ async function inferBase(query) {
|
|
|
32
32
|
const developBranch = getDevelopBranch(config, issue.repository.owner, issue.repository.repository);
|
|
33
33
|
if (developBranch === undefined || developBranch === '')
|
|
34
34
|
return notInferred(undefined, undefined);
|
|
35
|
-
query.beforeInfer?.();
|
|
35
|
+
await query.beforeInfer?.();
|
|
36
36
|
let readiness;
|
|
37
37
|
try {
|
|
38
38
|
readiness = await readIssueReadinessIfSupported(project.client(), config, issue, createReadinessCache());
|
|
@@ -64,7 +64,7 @@ const boardSyncCommand = defineCommand({
|
|
|
64
64
|
run: async (input, io) => {
|
|
65
65
|
const out = createOutput(input.dry_run, io);
|
|
66
66
|
const config = requireBoardConfig(out, input.project, ['board', 'sync']);
|
|
67
|
-
const client = makeClient(out, config);
|
|
67
|
+
const client = await makeClient(out, config);
|
|
68
68
|
const before = await client.getGraphqlRateLimit();
|
|
69
69
|
let read;
|
|
70
70
|
try {
|
|
@@ -2,15 +2,19 @@ import type { ProjectConfig } from '../domain/config.js';
|
|
|
2
2
|
import { GitHubClient } from '../infra/github/index.js';
|
|
3
3
|
import type { Output } from './output.js';
|
|
4
4
|
/**
|
|
5
|
-
host 向けのクライアントを作る。host が undefined
|
|
5
|
+
host 向けのクライアントを作る。host が undefined なら既定のホスト。環境にトークンが無いときは、最初の要求の前に gh auth token を読む
|
|
6
6
|
*/
|
|
7
7
|
export declare function createGitHubClient(out: Readonly<Output>, host: string | undefined): GitHubClient;
|
|
8
8
|
/**
|
|
9
|
+
createGitHubClient で作り、トークンまで読み終えたクライアントを返す。認証の失敗(GitHubAuthError)を、最初の要求の失敗と分けて出すときに使う
|
|
10
|
+
*/
|
|
11
|
+
export declare function createAuthenticatedGitHubClient(out: Readonly<Output>, host: string | undefined): Promise<GitHubClient>;
|
|
12
|
+
/**
|
|
9
13
|
GitHub の失敗(GitHubAPIError と、接続の失敗の TransportFailure)なら、その文を返す。それ以外は投げ直す
|
|
10
14
|
*/
|
|
11
15
|
export declare function apiFailureMessage(error: unknown): string;
|
|
12
16
|
/**
|
|
13
17
|
クライアントを作る。認証などの失敗は error の行にして終了コード 1 で止める
|
|
14
18
|
*/
|
|
15
|
-
export declare function makeClient(out: Readonly<Output>, config: Readonly<ProjectConfig>): GitHubClient
|
|
19
|
+
export declare function makeClient(out: Readonly<Output>, config: Readonly<ProjectConfig>): Promise<GitHubClient>;
|
|
16
20
|
//# sourceMappingURL=github-client.d.ts.map
|
|
@@ -4,10 +4,18 @@ import { GitHubAPIError } from '../infra/github/errors.js';
|
|
|
4
4
|
import { stopWith } from './command-stop.js';
|
|
5
5
|
import { kindOfFailure } from './failure.js';
|
|
6
6
|
/**
|
|
7
|
-
host 向けのクライアントを作る。host が undefined
|
|
7
|
+
host 向けのクライアントを作る。host が undefined なら既定のホスト。環境にトークンが無いときは、最初の要求の前に gh auth token を読む
|
|
8
8
|
*/
|
|
9
9
|
export function createGitHubClient(out, host) {
|
|
10
|
-
return new GitHubClient({ host, diagnostics: out });
|
|
10
|
+
return new GitHubClient({ host, diagnostics: out, signal: out.signal });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
createGitHubClient で作り、トークンまで読み終えたクライアントを返す。認証の失敗(GitHubAuthError)を、最初の要求の失敗と分けて出すときに使う
|
|
14
|
+
*/
|
|
15
|
+
export async function createAuthenticatedGitHubClient(out, host) {
|
|
16
|
+
const client = createGitHubClient(out, host);
|
|
17
|
+
await client.ensureToken();
|
|
18
|
+
return client;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
GitHub の失敗(GitHubAPIError と、接続の失敗の TransportFailure)なら、その文を返す。それ以外は投げ直す
|
|
@@ -20,9 +28,9 @@ export function apiFailureMessage(error) {
|
|
|
20
28
|
/**
|
|
21
29
|
クライアントを作る。認証などの失敗は error の行にして終了コード 1 で止める
|
|
22
30
|
*/
|
|
23
|
-
export function makeClient(out, config) {
|
|
31
|
+
export async function makeClient(out, config) {
|
|
24
32
|
try {
|
|
25
|
-
return
|
|
33
|
+
return await createAuthenticatedGitHubClient(out, config.host);
|
|
26
34
|
}
|
|
27
35
|
catch (error) {
|
|
28
36
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -18,7 +18,7 @@ import { defineCommand, CommandExit } from './command-definition.js';
|
|
|
18
18
|
import { commandHint, hinted, inputNameHint, placeholder } from './command-hint.js';
|
|
19
19
|
import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
|
|
20
20
|
import { kindOfFailure } from './failure.js';
|
|
21
|
-
import { createGitHubClient } from './github-client.js';
|
|
21
|
+
import { createAuthenticatedGitHubClient, createGitHubClient } from './github-client.js';
|
|
22
22
|
import { COMMENT_VALIDATION_EXIT_CODE, hasReportedTemplateViolations, issuePath, parseIssueReferenceOrExit, runWithExit, } from './issue-shared.js';
|
|
23
23
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
24
24
|
const TEMPLATE_SCHEMA = z.enum(['plan', 'merge-diff', 'review-findings', 'review-resolution', 'precede-notify']);
|
|
@@ -183,7 +183,8 @@ async function postDirect(output, project, repository, issueReference, message,
|
|
|
183
183
|
output.planned({ verb: 'create', target: `comment on ${issuePath(target.owner, target.repository, target.number)}` });
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
// 認証の失敗を、コメントを作れない文に包まないため
|
|
187
|
+
await createComment(output, await createAuthenticatedGitHubClient(output, config.host), target, message);
|
|
187
188
|
}
|
|
188
189
|
const COMMENT_PATH = ['issue', 'comment'];
|
|
189
190
|
const ISSUE_COMMENT = defineCommand({
|
|
@@ -8,7 +8,7 @@ import { DependenciesUnsupportedError, GitHubAPIError } from '../infra/github/er
|
|
|
8
8
|
import { defineCommand } from './command-definition.js';
|
|
9
9
|
import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
|
|
10
10
|
import { kindOfFailure } from './failure.js';
|
|
11
|
-
import {
|
|
11
|
+
import { createAuthenticatedGitHubClient } from './github-client.js';
|
|
12
12
|
import { ISSUE_REF_DESCRIPTION, issuePath, parseIssueReferenceOrExit, runWithExit } from './issue-shared.js';
|
|
13
13
|
import { blockedByReadCount, createReadinessCache, judgeSnapshot, READINESS_JSON, readIssueReadiness, readinessJson, snapshotWithoutPrerequisites } from './issue-readiness.js';
|
|
14
14
|
import { createOutput } from './output.js';
|
|
@@ -220,7 +220,8 @@ const ISSUE_SHOW = defineCommand({
|
|
|
220
220
|
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
221
221
|
const { config } = requireConfigFor(output, { owner, repository }, input.project, ['issue', 'show']);
|
|
222
222
|
let issue;
|
|
223
|
-
|
|
223
|
+
// 認証の失敗を、Issue を読めない文に包まないため
|
|
224
|
+
const client = await createAuthenticatedGitHubClient(output, config.host);
|
|
224
225
|
try {
|
|
225
226
|
issue = await client.getIssueSlim(owner, repository, number, input.comment_limit);
|
|
226
227
|
}
|
|
@@ -22,6 +22,7 @@ export const COMMAND_GROUPS = [
|
|
|
22
22
|
{ name: 'issue', meaning: 'Issue そのもの', help: 'Work with Issues' },
|
|
23
23
|
{ name: 'session', meaning: '1 つの Issue の作業の始まりから終わりまで', help: 'Start, show and finish the work on an Issue' },
|
|
24
24
|
{ name: 'pr', meaning: 'PR そのもの', help: 'Work with PRs' },
|
|
25
|
+
{ name: 'review', meaning: 'PR の自動レビューの実行', help: 'Work with automated reviews of PRs' },
|
|
25
26
|
{ name: 'release', meaning: 'リリース', help: 'Work with releases' },
|
|
26
27
|
{ name: 'tracker', meaning: 'Tracker の Issue の書き直し', help: 'Rewrite the list in a Tracker Issue' },
|
|
27
28
|
{ name: 'worktree', meaning: 'worktree', help: 'Work with worktrees' },
|
|
@@ -68,6 +68,10 @@ export interface Output<D extends object = Record<string, unknown>> {
|
|
|
68
68
|
dry-run のときは dryRun: true を重ねるので、output に DRY_RUN_FIELD を置く
|
|
69
69
|
*/
|
|
70
70
|
result(fields: Readonly<Partial<D>>): void;
|
|
71
|
+
/**
|
|
72
|
+
io の signal(MCP の要求の取り消し)。CLI では undefined
|
|
73
|
+
*/
|
|
74
|
+
readonly signal: Readonly<AbortSignal> | undefined;
|
|
71
75
|
}
|
|
72
76
|
/**
|
|
73
77
|
warning の行の前置き。MCP の側はこれで stderr から warning の文を拾う
|
|
@@ -8,7 +8,7 @@ import { GitHubAPIError, GitHubNotFoundError } from '../infra/github/errors.js';
|
|
|
8
8
|
import { PROJECT_INPUT, requireConfigFor, stopWith } from './command-stop.js';
|
|
9
9
|
import { defineCommand } from './command-definition.js';
|
|
10
10
|
import { kindOfFailure } from './failure.js';
|
|
11
|
-
import {
|
|
11
|
+
import { createAuthenticatedGitHubClient } from './github-client.js';
|
|
12
12
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
13
13
|
import { parseReference, PR_REFERENCE_DESCRIPTION } from './pr-reference.js';
|
|
14
14
|
// 要求を送らずに止める(ドラフト、閉じている、スタックの最下段でない)
|
|
@@ -209,7 +209,8 @@ export const PR_MERGE_COMMAND = defineCommand({
|
|
|
209
209
|
const out = createOutput(input.dry_run, io);
|
|
210
210
|
const target = parseReference(input.pr_ref, input.repo, out);
|
|
211
211
|
const config = requireConfigFor(out, target, input.project, ['pr', 'merge']).config;
|
|
212
|
-
|
|
212
|
+
// 認証の失敗を、PR を読めない文に包まないため
|
|
213
|
+
const client = await createAuthenticatedGitHubClient(out, config.host);
|
|
213
214
|
const name = `PR #${String(target.number)}`;
|
|
214
215
|
const pullRequest = await readPullRequest(out, client, target);
|
|
215
216
|
checkState(out, name, pullRequest);
|
|
@@ -79,10 +79,6 @@ function describePushFailure(push, remote, branch) {
|
|
|
79
79
|
case 'timed-out': {
|
|
80
80
|
return hinted `push timed out after ${String(PUSH_TIMEOUT_MILLISECONDS / MILLISECONDS_PER_SECOND)} seconds\n${unchanged}\npush the branch yourself: ${FORCE_PUSH_COMMAND} ${remote} ${branch}\nthen run: ${commandHint(RESTACK_PATH)}`;
|
|
81
81
|
}
|
|
82
|
-
case 'cancelled': {
|
|
83
|
-
// MCP の取り消しには応答が送られない。誰にも届かないが、記録を書かずに止める扱いとして持つ
|
|
84
|
-
return hinted `push was cancelled\n${unchanged}\nrun again: ${commandHint(RESTACK_PATH)}`;
|
|
85
|
-
}
|
|
86
82
|
case 'rejected': {
|
|
87
83
|
return hinted `push was rejected: ${push.stderr.trim()}\n${unchanged}\nrun again: ${commandHint(RESTACK_PATH)}`;
|
|
88
84
|
}
|
|
@@ -101,7 +97,15 @@ async function finishRestack(out, cwd, progress, signal) {
|
|
|
101
97
|
if (isSynced)
|
|
102
98
|
resetHardTo(cwd, remoteBranch);
|
|
103
99
|
else if (leaseSha !== undefined) {
|
|
104
|
-
|
|
100
|
+
let push;
|
|
101
|
+
try {
|
|
102
|
+
push = await pushWithLease(cwd, remote, branch, leaseSha, { signal });
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
// 取り消しでも、記録を書かずに途中の記録を消して止める
|
|
106
|
+
removeFlag(FLAG_PECOT_RESTACK);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
105
109
|
if (!push.pushed) {
|
|
106
110
|
removeFlag(FLAG_PECOT_RESTACK);
|
|
107
111
|
stopWith(out, describePushFailure(push, remote, branch), 'git-unresolved');
|
|
@@ -154,7 +158,7 @@ function hasUncommittedChanges(cwd) {
|
|
|
154
158
|
async function decideFor(out, cwd, host, target) {
|
|
155
159
|
const { remote, owner, repository, developBranch, reading } = target;
|
|
156
160
|
const { branch } = reading.record;
|
|
157
|
-
const read = await readRestackDecision({ client: () => createGitHubClient(out, host), owner, repository, cwd, remote, reading, developBranch });
|
|
161
|
+
const read = await readRestackDecision({ client: () => createGitHubClient(out, host), owner, repository, cwd, remote, reading, developBranch, signal: out.signal });
|
|
158
162
|
switch (read.kind) {
|
|
159
163
|
case 'pull-request-unreadable': {
|
|
160
164
|
return stopWith(out, `cannot read the PR of the base branch ${branch}: ${describeApiError(read.error)}`, kindOfFailure(read.error));
|
|
@@ -205,8 +209,11 @@ async function runRestack(input, io) {
|
|
|
205
209
|
const config = requireConfigFor(out, location, input.project, RESTACK_PATH).config;
|
|
206
210
|
// 記録が無ければ、求める前に fetch して、手元に無い下の段も追跡参照で見る
|
|
207
211
|
let fetched;
|
|
208
|
-
const fetchOnce = () => (fetched ??= fetchRemote(cwd, remote));
|
|
209
|
-
const
|
|
212
|
+
const fetchOnce = async () => await (fetched ??= fetchRemote(cwd, remote, out.signal));
|
|
213
|
+
const fetchBeforeInfer = async () => {
|
|
214
|
+
await fetchOnce();
|
|
215
|
+
};
|
|
216
|
+
const base = await readBaseOrInfer({ directory: cwd, project: { config, client: () => createGitHubClient(out, config.host) }, beforeInfer: fetchBeforeInfer });
|
|
210
217
|
warnUnresolved(base, out);
|
|
211
218
|
const { reading } = base;
|
|
212
219
|
stopOnMalformedRecord(reading, out);
|
|
@@ -223,7 +230,7 @@ async function runRestack(input, io) {
|
|
|
223
230
|
}
|
|
224
231
|
if (!input.check && hasUncommittedChanges(cwd))
|
|
225
232
|
stopWith(out, 'working tree has uncommitted changes', 'preflight-failed', UNCOMMITTED_EXIT_CODE);
|
|
226
|
-
const fetchResult = fetchOnce();
|
|
233
|
+
const fetchResult = await fetchOnce();
|
|
227
234
|
if (!fetchResult.succeeded)
|
|
228
235
|
stopWith(out, `cannot fetch ${remote}: ${fetchResult.stderr.trim()}`, 'git-unresolved');
|
|
229
236
|
const target = { remote, owner: location.owner, repository: location.repository, reading, developBranch };
|
package/cli/dist/commands/pr.js
CHANGED
|
@@ -101,8 +101,8 @@ function isRegularFile(file) {
|
|
|
101
101
|
return false;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function expectedTitleScope(target, head, out) {
|
|
105
|
-
const projects = nxProjects(target.toplevel);
|
|
104
|
+
async function expectedTitleScope(target, head, out) {
|
|
105
|
+
const projects = await nxProjects(target.toplevel, { signal: out.signal });
|
|
106
106
|
const files = projects === undefined ? undefined : changedFiles(target.toplevel, target.from, head);
|
|
107
107
|
if (projects === undefined || files === undefined) {
|
|
108
108
|
out.warning('cannot read nx projects or the diff; skipped the PR title scope check');
|
|
@@ -110,14 +110,14 @@ function expectedTitleScope(target, head, out) {
|
|
|
110
110
|
}
|
|
111
111
|
return expectedScope(files, projects);
|
|
112
112
|
}
|
|
113
|
-
function titleScopeErrors(query, out) {
|
|
113
|
+
async function titleScopeErrors(query, out) {
|
|
114
114
|
const { config, owner, repository, title, base, head, directory, template, developBranch, releaseBranch } = query;
|
|
115
115
|
if (isReleasePullRequest(template, base, head, developBranch, releaseBranch))
|
|
116
116
|
return [];
|
|
117
117
|
const target = nxScopeTarget(config, owner, repository, base, directory, query.stacked);
|
|
118
118
|
if (target === undefined)
|
|
119
119
|
return [];
|
|
120
|
-
const expected = expectedTitleScope(target, head, out);
|
|
120
|
+
const expected = await expectedTitleScope(target, head, out);
|
|
121
121
|
if (expected === undefined || expected.length === 0)
|
|
122
122
|
return [];
|
|
123
123
|
const given = parseTitleScope(title);
|
|
@@ -278,10 +278,10 @@ async function pushFixHintFor(push, reading, target) {
|
|
|
278
278
|
return undefined;
|
|
279
279
|
if (reading?.kind !== 'stacked')
|
|
280
280
|
return DIVERGED_FIX_HINT;
|
|
281
|
-
const { config, location, directory, remote, client, lowerPullRequest } = target;
|
|
281
|
+
const { config, location, directory, remote, client, lowerPullRequest, signal } = target;
|
|
282
282
|
const developBranch = getDevelopBranch(config, location.owner, location.repository) ?? '';
|
|
283
283
|
try {
|
|
284
|
-
const read = await readRestackDecision({ client, owner: location.owner, repository: location.repository, cwd: directory, remote, reading, developBranch, lowerPullRequest });
|
|
284
|
+
const read = await readRestackDecision({ client, owner: location.owner, repository: location.repository, cwd: directory, remote, reading, developBranch, lowerPullRequest, signal });
|
|
285
285
|
return pushFixHintOf(read.kind === 'decided' ? read.decision : undefined);
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
@@ -293,7 +293,7 @@ async function pushFixHintFor(push, reading, target) {
|
|
|
293
293
|
async function runPreflightChecksOrExit(directory, base, config, client, out) {
|
|
294
294
|
const context = validatePullRequestContext(directory, out);
|
|
295
295
|
const push = getPushStatus(context.currentBranch, directory, context.remoteName);
|
|
296
|
-
const pushFixHint = await pushFixHintFor(push, base.reading, { config, location: context.location, directory, remote: context.remoteName, client, lowerPullRequest: base.lowerPullRequest });
|
|
296
|
+
const pushFixHint = await pushFixHintFor(push, base.reading, { config, location: context.location, directory, remote: context.remoteName, client, lowerPullRequest: base.lowerPullRequest, signal: out.signal });
|
|
297
297
|
const warnings = collectPreflightWarnings({ gitStatus: getGitStatus(directory), stashList: getStashList(directory), isPushed: push.isPushed, pushMessage: push.message, pushFixHint });
|
|
298
298
|
if (warnings.length === 0)
|
|
299
299
|
return;
|
|
@@ -431,7 +431,7 @@ async function isRestackedLocally(reading, directory, target, out) {
|
|
|
431
431
|
const { config, location } = target;
|
|
432
432
|
const developBranch = getDevelopBranch(config, location.owner, location.repository) ?? '';
|
|
433
433
|
try {
|
|
434
|
-
const read = await readRestackDecision({ client: lazyClient(config, out), owner: location.owner, repository: location.repository, cwd: directory, remote: primaryRemoteName(directory), reading, developBranch });
|
|
434
|
+
const read = await readRestackDecision({ client: lazyClient(config, out), owner: location.owner, repository: location.repository, cwd: directory, remote: primaryRemoteName(directory), reading, developBranch, signal: out.signal });
|
|
435
435
|
return read.kind === 'decided' && read.decision.kind === 'rebased';
|
|
436
436
|
}
|
|
437
437
|
catch (error) {
|
|
@@ -504,7 +504,7 @@ async function validateAndSubmit(input, out) {
|
|
|
504
504
|
stackedBase: use?.stackedBase,
|
|
505
505
|
}),
|
|
506
506
|
...baseErrors,
|
|
507
|
-
...titleScopeErrors({ config, owner: location.owner, repository: location.repository, title, base, head, directory, template, developBranch, releaseBranch, stacked }, out),
|
|
507
|
+
...await titleScopeErrors({ config, owner: location.owner, repository: location.repository, title, base, head, directory, template, developBranch, releaseBranch, stacked }, out),
|
|
508
508
|
];
|
|
509
509
|
exitOnValidationErrors(errors, out);
|
|
510
510
|
const isRelease = template === 'release';
|
|
@@ -602,12 +602,12 @@ async function createDirect(input, directory, out) {
|
|
|
602
602
|
}, out);
|
|
603
603
|
}
|
|
604
604
|
// --prepare
|
|
605
|
-
function addScopeHint(content, config, location, base, directory, stacked, out) {
|
|
605
|
+
async function addScopeHint(content, config, location, base, directory, stacked, out) {
|
|
606
606
|
const target = nxScopeTarget(config, location.owner, location.repository, base, directory, stacked);
|
|
607
607
|
if (target === undefined)
|
|
608
608
|
return content;
|
|
609
609
|
const head = gitCurrentBranch(directory);
|
|
610
|
-
const expected = head === undefined || head === '' ? undefined : expectedTitleScope(target, head, out);
|
|
610
|
+
const expected = head === undefined || head === '' ? undefined : await expectedTitleScope(target, head, out);
|
|
611
611
|
if (expected === undefined || expected.length === 0)
|
|
612
612
|
return content;
|
|
613
613
|
const scope = expected.join(',');
|
|
@@ -672,7 +672,7 @@ async function prepareTemplate(directory, out, template, project) {
|
|
|
672
672
|
content = content.replace(/^base:\s*"[^"]*"/mu, () => `base: "${base}"`);
|
|
673
673
|
out.done({ verb: 'set', target: `base to ${base}` });
|
|
674
674
|
out.result({ base });
|
|
675
|
-
content = addScopeHint(content, config, { owner: location.owner, repository: location.repository }, base, directory, record === undefined ? undefined : { sha: record.sha }, out);
|
|
675
|
+
content = await addScopeHint(content, config, { owner: location.owner, repository: location.repository }, base, directory, record === undefined ? undefined : { sha: record.sha }, out);
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
678
|
content = await fillClosesInTemplate(content, config, directory, location, out);
|
|
@@ -835,8 +835,8 @@ function hasBranch(branch, cwd) {
|
|
|
835
835
|
}
|
|
836
836
|
// 下の段のブランチがマージで消えた後は、開発ブランチと比べる。追跡参照は fetch --prune まで残るので、
|
|
837
837
|
// remote に尋ね、無いと答えたときだけ消えたとみなす。届かないか時間切れなら追跡参照で決める
|
|
838
|
-
function isOnRemote(branch, cwd, remote, out) {
|
|
839
|
-
const head = remoteBranchHead(cwd, remote, branch);
|
|
838
|
+
async function isOnRemote(branch, cwd, remote, out) {
|
|
839
|
+
const head = await remoteBranchHead(cwd, remote, branch, out.signal);
|
|
840
840
|
if (head.isReachable && head.sha === undefined)
|
|
841
841
|
return false;
|
|
842
842
|
const isTracked = hasBranch(`${remote}/${branch}`, cwd);
|
|
@@ -844,8 +844,8 @@ function isOnRemote(branch, cwd, remote, out) {
|
|
|
844
844
|
out.warning(`base branch ${branch} is on ${remote}, but ${remote}/${branch} is not fetched; compared with the develop branch\nrun: git fetch ${remote} ${branch}`);
|
|
845
845
|
return isTracked;
|
|
846
846
|
}
|
|
847
|
-
function determineBaseBranch(config, reading, location, cwd, remote, out) {
|
|
848
|
-
if (reading.kind === 'stacked' && isOnRemote(reading.record.branch, cwd, remote, out))
|
|
847
|
+
async function determineBaseBranch(config, reading, location, cwd, remote, out) {
|
|
848
|
+
if (reading.kind === 'stacked' && await isOnRemote(reading.record.branch, cwd, remote, out))
|
|
849
849
|
return `${remote}/${reading.record.branch}`;
|
|
850
850
|
const developBranch = getDevelopBranch(config, location.owner, location.repository);
|
|
851
851
|
if (developBranch === undefined || developBranch === '') {
|
|
@@ -924,7 +924,7 @@ async function runCheck(input, io) {
|
|
|
924
924
|
warnUnresolved(base, out);
|
|
925
925
|
const { reading } = base;
|
|
926
926
|
stopOnMalformedRecord(reading, out);
|
|
927
|
-
const baseBranch = determineBaseBranch(config, reading, context.location, directory, context.remoteName, out);
|
|
927
|
+
const baseBranch = await determineBaseBranch(config, reading, context.location, directory, context.remoteName, out);
|
|
928
928
|
const gitStatus = getGitStatus(directory);
|
|
929
929
|
const commits = gitStdout(['log', '--oneline', `${baseBranch}..HEAD`], { cwd: directory });
|
|
930
930
|
const diffSummary = gitStdout(['diff', '--stat', `${baseBranch}...HEAD`], { cwd: directory });
|
|
@@ -954,7 +954,7 @@ async function runCheck(input, io) {
|
|
|
954
954
|
out.data(`${heading}\n`);
|
|
955
955
|
out.data(`${content}\n`);
|
|
956
956
|
}
|
|
957
|
-
const pushFixHint = await pushFixHintFor(push, reading, { config, location: context.location, directory, remote: context.remoteName, client: lazyClient(config, out) });
|
|
957
|
+
const pushFixHint = await pushFixHintFor(push, reading, { config, location: context.location, directory, remote: context.remoteName, client: lazyClient(config, out), signal: out.signal });
|
|
958
958
|
const warnings = collectPreflightWarnings({ gitStatus, stashList, isPushed: push.isPushed, pushMessage: push.message, pushFixHint });
|
|
959
959
|
out.count('preflight warnings', warnings.length);
|
|
960
960
|
printPreflightWarnings(out, warnings);
|
|
@@ -16,7 +16,7 @@ import { CommandExit, defineCommand } from './command-definition.js';
|
|
|
16
16
|
import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './command-hint.js';
|
|
17
17
|
import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
18
18
|
import { kindOfFailure } from './failure.js';
|
|
19
|
-
import { createGitHubClient } from './github-client.js';
|
|
19
|
+
import { createAuthenticatedGitHubClient, createGitHubClient } from './github-client.js';
|
|
20
20
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
21
21
|
import { BLOCKED_SPEC, NEEDS_ATTENTION_SPEC, PRIORITY_FIELD_OPTIONS, SIZE_FIELD_OPTIONS, STATUS_FIELD_NAME, WORKFLOW_FIELD_OPTIONS, buildRepository, failApi, fieldNodesOf, findProjectByTitle, hasWorkflowField, lastFieldNamed, missingRequiredOptions, stopMissingOptions, syncProjectConfig, textOf, } from './project-sync.js';
|
|
22
22
|
const DEFAULT_HOST = 'github.com';
|
|
@@ -314,7 +314,8 @@ const initCommand = defineCommand({
|
|
|
314
314
|
run: async (input, io) => {
|
|
315
315
|
const out = createOutput(input.dry_run, io);
|
|
316
316
|
const { owner, name, host, suffix } = input;
|
|
317
|
-
|
|
317
|
+
// 認証の失敗を、フィールドの初期化の失敗に包まないため
|
|
318
|
+
const client = await createAuthenticatedGitHubClient(out, host);
|
|
318
319
|
if (input.dry_run)
|
|
319
320
|
out.result({});
|
|
320
321
|
const mark = fieldReporter((fields) => {
|
|
@@ -555,7 +556,8 @@ example: ${commandHint(ACTIVATE_PATH, { host: 'github.com', owner: 'example-org'
|
|
|
555
556
|
example: ${commandHint(ACTIVATE_PATH, { host: 'ghes.example.com', owner: 'example-org' })}
|
|
556
557
|
example: ${commandHint(ACTIVATE_PATH, { project: 'ghes.example.com_example-org_example-project_example-org' })}`, 'invalid-input');
|
|
557
558
|
}
|
|
558
|
-
|
|
559
|
+
// 認証の失敗に、--owner を渡す案内を添えないため
|
|
560
|
+
const client = await createAuthenticatedGitHubClient(out, host);
|
|
559
561
|
const owner = await resolveActivationOwner(out, client, input.owner);
|
|
560
562
|
// 一覧は書き込まないので、dry_run でも data に dryRun を足さない
|
|
561
563
|
if (project === undefined)
|
|
@@ -5,6 +5,7 @@ import { BRANCH_COMMANDS } from './branch.js';
|
|
|
5
5
|
import { registerCommandHints } from './command-hint.js';
|
|
6
6
|
import { ISSUE_COMMANDS } from './issue.js';
|
|
7
7
|
import { PR_RESTACK_COMMANDS } from './pr-restack.js';
|
|
8
|
+
import { REVIEW_COMMANDS } from './review-finish.js';
|
|
8
9
|
import { PR_COMMANDS } from './pr.js';
|
|
9
10
|
import { PROJECT_COMMANDS } from './project.js';
|
|
10
11
|
import { RELEASE_COMMANDS } from './release.js';
|
|
@@ -20,6 +21,7 @@ export const COMMANDS = [
|
|
|
20
21
|
...SESSION_COMMANDS,
|
|
21
22
|
...PR_COMMANDS,
|
|
22
23
|
...PR_RESTACK_COMMANDS,
|
|
24
|
+
...REVIEW_COMMANDS,
|
|
23
25
|
...RELEASE_COMMANDS,
|
|
24
26
|
...TRACKER_COMMANDS,
|
|
25
27
|
...WORKTREE_COMMANDS,
|
|
@@ -12,7 +12,7 @@ import { ReleaseError, runPreflight } from '../domain/release.js';
|
|
|
12
12
|
import { splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
13
13
|
import { fetchCodeScanningStatus, fetchSecretScanningStatus, SecurityAlertError } from '../domain/security-alerts.js';
|
|
14
14
|
import { extractReleaseNotesFromFile, readChangelogIfExists, resolveChangelogPath } from '../infra/changelog-file.js';
|
|
15
|
-
import { gitRunnerFor, gitToplevel, primaryRemoteName, primaryRemoteRepository } from '../infra/git.js';
|
|
15
|
+
import { gitRunnerFor, gitToplevel, primaryRemoteName, primaryRemoteRepository, remoteTagExists } from '../infra/git.js';
|
|
16
16
|
import { TransportFailure } from '../infra/github/client.js';
|
|
17
17
|
import { createDependabotSource } from '../infra/github/dependabot-source.js';
|
|
18
18
|
import { GitHubAPIError, GitHubNotFoundError } from '../infra/github/errors.js';
|
|
@@ -20,7 +20,7 @@ import { createScanAlertSource } from '../infra/github/security-alerts-source.js
|
|
|
20
20
|
import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './command-hint.js';
|
|
21
21
|
import { PROJECT_INPUT, requireConfigFor, stopWith } from './command-stop.js';
|
|
22
22
|
import { kindOfFailure } from './failure.js';
|
|
23
|
-
import { createGitHubClient, makeClient } from './github-client.js';
|
|
23
|
+
import { createAuthenticatedGitHubClient, createGitHubClient, makeClient } from './github-client.js';
|
|
24
24
|
import { issuePath } from './issue-shared.js';
|
|
25
25
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
26
26
|
import { CommandExit, defineCommand } from './command-definition.js';
|
|
@@ -85,7 +85,7 @@ function warnAlertsUnavailable(out, reason) {
|
|
|
85
85
|
async function checkDependabotAlerts(out, config, owner, repository, skip) {
|
|
86
86
|
let status;
|
|
87
87
|
try {
|
|
88
|
-
const client =
|
|
88
|
+
const client = await createAuthenticatedGitHubClient(out, config.host);
|
|
89
89
|
status = await fetchDependabotAlertStatus(createDependabotSource(client), config.host, owner, repository);
|
|
90
90
|
}
|
|
91
91
|
catch (error) {
|
|
@@ -154,8 +154,8 @@ async function checkAlerts(out, config, owner, repository) {
|
|
|
154
154
|
dependabot = await checkDependabotAlerts(out, config, owner, repository, skip);
|
|
155
155
|
return true;
|
|
156
156
|
},
|
|
157
|
-
async () => await isScanningPassed(out, 'code scanning', async () => await fetchCodeScanningStatus(createScanAlertSource(
|
|
158
|
-
async () => await isScanningPassed(out, 'secret scanning', async () => await fetchSecretScanningStatus(createScanAlertSource(
|
|
157
|
+
async () => await isScanningPassed(out, 'code scanning', async () => await fetchCodeScanningStatus(createScanAlertSource(await createAuthenticatedGitHubClient(out, config.host)), config.host, owner, repository), skip),
|
|
158
|
+
async () => await isScanningPassed(out, 'secret scanning', async () => await fetchSecretScanningStatus(createScanAlertSource(await createAuthenticatedGitHubClient(out, config.host)), config.host, owner, repository), skip),
|
|
159
159
|
];
|
|
160
160
|
let isPassed = true;
|
|
161
161
|
for (const check of checks) {
|
|
@@ -216,7 +216,7 @@ const releaseCheckCommand = defineCommand({
|
|
|
216
216
|
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
217
217
|
const remote = primaryRemoteName(cwd) ?? 'origin';
|
|
218
218
|
try {
|
|
219
|
-
const client =
|
|
219
|
+
const client = await createAuthenticatedGitHubClient(out, config.host);
|
|
220
220
|
const result = await runPreflight({
|
|
221
221
|
changelogPath: context.changelogPath,
|
|
222
222
|
changelogContent: readChangelogIfExists(context.changelogPath),
|
|
@@ -225,7 +225,7 @@ const releaseCheckCommand = defineCommand({
|
|
|
225
225
|
version: input.version,
|
|
226
226
|
tagPrefix: context.tagPrefix,
|
|
227
227
|
remote,
|
|
228
|
-
}, gitRunnerFor(cwd), async (base, head) => await client.countCommitsAhead(owner, repository, base, head));
|
|
228
|
+
}, gitRunnerFor(cwd), async (name, tagName) => await remoteTagExists(cwd, name, tagName, out.signal), async (base, head) => await client.countCommitsAhead(owner, repository, base, head));
|
|
229
229
|
out.count(`commits to release (${remote}/${result.developBranch} -> ${remote}/${result.releaseBranch})`, result.diffCount);
|
|
230
230
|
out.result({ version: result.version, tag: result.tagName, releaseNotes: result.releaseNotes, commitCount: result.diffCount });
|
|
231
231
|
out.data(`version: ${result.version}\ntag: ${result.tagName}\n\n${result.releaseNotes}`);
|
|
@@ -291,7 +291,7 @@ const releaseCreateCommand = defineCommand({
|
|
|
291
291
|
out.data(releaseNotes);
|
|
292
292
|
return 0;
|
|
293
293
|
}
|
|
294
|
-
const client = makeClient(out, config);
|
|
294
|
+
const client = await makeClient(out, config);
|
|
295
295
|
try {
|
|
296
296
|
const result = await client.createRelease(owner, repository, tagName, releaseName, releaseNotes, { targetCommitish: releaseBranch });
|
|
297
297
|
out.done(operation);
|
|
@@ -26,6 +26,10 @@ export interface RestackTarget {
|
|
|
26
26
|
渡されたら、下の段の PR を読み直さない
|
|
27
27
|
*/
|
|
28
28
|
readonly lowerPullRequest?: KnownLowerPullRequest | undefined;
|
|
29
|
+
/**
|
|
30
|
+
MCP の要求の取り消し。ls-remote に渡す
|
|
31
|
+
*/
|
|
32
|
+
readonly signal: Readonly<AbortSignal> | undefined;
|
|
29
33
|
}
|
|
30
34
|
export type RestackReading = {
|
|
31
35
|
readonly kind: 'decided';
|
|
@@ -21,7 +21,7 @@ export async function readRestackDecision(target) {
|
|
|
21
21
|
}
|
|
22
22
|
if (remote === undefined)
|
|
23
23
|
return { kind: 'remote-unreachable', lowerPullRequest };
|
|
24
|
-
const lowerHead = remoteBranchHead(target.cwd, remote, reading.record.branch);
|
|
24
|
+
const lowerHead = await remoteBranchHead(target.cwd, remote, reading.record.branch, target.signal);
|
|
25
25
|
if (!lowerHead.isReachable)
|
|
26
26
|
return { kind: 'remote-unreachable', lowerPullRequest };
|
|
27
27
|
const decision = decideRestack({ reading, developBranch: target.developBranch, lowerPullRequest, lowerHead: lowerHead.sha });
|