@pecot/workflow-mcp 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +4 -57
- package/cli/dist/commands/board-add.js +11 -1
- package/cli/dist/commands/board-judgment.d.ts +12 -3
- package/cli/dist/commands/board-judgment.js +12 -6
- package/cli/dist/commands/board-move.js +9 -1
- package/cli/dist/commands/board-readiness.d.ts +3 -3
- package/cli/dist/commands/board-show.js +5 -2
- package/cli/dist/commands/board-sync.js +14 -5
- package/cli/dist/commands/board-view.d.ts +94 -5
- package/cli/dist/commands/board-view.js +119 -17
- package/cli/dist/commands/branch.js +12 -1
- package/cli/dist/commands/command-definition.d.ts +19 -2
- package/cli/dist/commands/command-definition.js +9 -0
- package/cli/dist/commands/failure-kind.d.ts +1 -1
- package/cli/dist/commands/failure-kind.js +1 -0
- package/cli/dist/commands/issue-board.d.ts +31 -3
- package/cli/dist/commands/issue-board.js +28 -4
- package/cli/dist/commands/issue-comment.js +19 -2
- package/cli/dist/commands/issue-create.js +90 -7
- package/cli/dist/commands/issue-dependency.js +32 -4
- package/cli/dist/commands/issue-readiness.d.ts +30 -2
- package/cli/dist/commands/issue-readiness.js +35 -0
- package/cli/dist/commands/issue-reopen.js +18 -3
- package/cli/dist/commands/issue-shared.d.ts +3 -3
- package/cli/dist/commands/issue-shared.js +3 -2
- package/cli/dist/commands/issue-show.js +78 -8
- package/cli/dist/commands/names.js +1 -0
- package/cli/dist/commands/output.d.ts +18 -2
- package/cli/dist/commands/output.js +16 -3
- package/cli/dist/commands/pr-merge.d.ts +3 -0
- package/cli/dist/commands/pr-merge.js +230 -0
- package/cli/dist/commands/pr-reference.d.ts +8 -0
- package/cli/dist/commands/pr-reference.js +30 -0
- package/cli/dist/commands/pr-restack.d.ts +6 -0
- package/cli/dist/commands/pr-restack.js +233 -0
- package/cli/dist/commands/pr-waiting.d.ts +41 -2
- package/cli/dist/commands/pr-waiting.js +74 -37
- package/cli/dist/commands/pr.d.ts +10 -6
- package/cli/dist/commands/pr.js +160 -67
- package/cli/dist/commands/project-sync.d.ts +10 -2
- package/cli/dist/commands/project-sync.js +7 -6
- package/cli/dist/commands/project.js +173 -16
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +67 -18
- package/cli/dist/commands/repository-match.js +7 -2
- package/cli/dist/commands/session-finish.js +128 -12
- package/cli/dist/commands/session-start.js +22 -6
- package/cli/dist/commands/session.js +121 -20
- package/cli/dist/commands/tracker-sync-dependabot.js +21 -4
- package/cli/dist/commands/tracker-sync-security.js +22 -4
- package/cli/dist/commands/tracker-sync.d.ts +30 -0
- package/cli/dist/commands/tracker-sync.js +15 -0
- package/cli/dist/commands/tracker.js +2 -0
- package/cli/dist/commands/work-target.d.ts +10 -2
- package/cli/dist/commands/work-target.js +6 -4
- package/cli/dist/commands/worktree.js +71 -5
- package/cli/dist/domain/issue-readout.d.ts +0 -4
- package/cli/dist/domain/pull-request.d.ts +1 -1
- package/cli/dist/domain/readiness.d.ts +17 -0
- package/cli/dist/domain/readiness.js +39 -2
- package/cli/dist/domain/restack.d.ts +62 -0
- package/cli/dist/domain/restack.js +53 -0
- package/cli/dist/domain/state.d.ts +39 -0
- package/cli/dist/domain/state.js +28 -1
- package/cli/dist/domain/work-start.d.ts +0 -4
- package/cli/dist/domain/work-start.js +0 -7
- package/cli/dist/infra/git.d.ts +64 -0
- package/cli/dist/infra/git.js +110 -0
- package/cli/dist/infra/github/pulls.d.ts +81 -2
- package/cli/dist/infra/github/pulls.js +116 -5
- package/cli/dist/infra/github/queries.d.ts +4 -1
- package/cli/dist/infra/github/queries.js +47 -32
- package/cli/dist/infra/github/readout.js +0 -33
- package/cli/dist/mcp/result.d.ts +63 -16
- package/cli/dist/mcp/result.js +106 -30
- package/cli/dist/mcp/server.js +37 -4
- package/cli/templates/comment/plan.md +2 -2
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -22,7 +22,8 @@ import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './co
|
|
|
22
22
|
import { NO_ACTIVE_PROJECT, stopWith } from './command-stop.js';
|
|
23
23
|
import { kindOfFailure } from './failure.js';
|
|
24
24
|
import { createGitHubClient, makeClient } from './github-client.js';
|
|
25
|
-
import {
|
|
25
|
+
import { issuePath } from './issue-shared.js';
|
|
26
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
26
27
|
import { CommandExit, defineCommand } from './command-definition.js';
|
|
27
28
|
import { requireRepositoryMatch } from './repository-match.js';
|
|
28
29
|
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
@@ -80,8 +81,8 @@ function warnAlertsUnavailable(out, reason) {
|
|
|
80
81
|
const [first = ''] = reason.trim().split(/\r\n|[\n\r]/u, 1);
|
|
81
82
|
out.warning(`could not check Dependabot alerts. The release is not blocked.\nreason: ${first.trim().replace(/\.+$/u, '').trimEnd()}`);
|
|
82
83
|
}
|
|
83
|
-
// open の Dependabot alert
|
|
84
|
-
async function checkDependabotAlerts(out, config, owner, repository) {
|
|
84
|
+
// open の Dependabot alert は警告だけで、リリースを止めない。読めた状態を返し、読めなければ undefined
|
|
85
|
+
async function checkDependabotAlerts(out, config, owner, repository, skip) {
|
|
85
86
|
let status;
|
|
86
87
|
try {
|
|
87
88
|
const client = createGitHubClient(out, config.host);
|
|
@@ -90,31 +91,32 @@ async function checkDependabotAlerts(out, config, owner, repository) {
|
|
|
90
91
|
catch (error) {
|
|
91
92
|
if (error instanceof DependabotAlertError) {
|
|
92
93
|
warnAlertsUnavailable(out, error.message);
|
|
93
|
-
return;
|
|
94
|
+
return undefined;
|
|
94
95
|
}
|
|
95
96
|
if (error instanceof GitHubAPIError) {
|
|
96
97
|
warnAlertsUnavailable(out, error.message);
|
|
97
|
-
return;
|
|
98
|
+
return undefined;
|
|
98
99
|
}
|
|
99
100
|
throw error;
|
|
100
101
|
}
|
|
101
102
|
if (!status.enabled) {
|
|
102
|
-
|
|
103
|
-
return;
|
|
103
|
+
skip('Dependabot alerts (feature disabled)');
|
|
104
|
+
return status;
|
|
104
105
|
}
|
|
105
106
|
if (status.openCount === 0) {
|
|
106
107
|
out.count('open Dependabot alerts', 0);
|
|
107
|
-
return;
|
|
108
|
+
return status;
|
|
108
109
|
}
|
|
109
110
|
const severity = status.maxSeverity === undefined ? '' : ` (highest severity: ${status.maxSeverity})`;
|
|
110
111
|
const listing = status.openAlerts.map(alert => `\n${alertLabel(alert.number, alert.package, alert.severity)}`).join('');
|
|
111
112
|
const noun = status.openCount === 1 ? 'alert' : 'alerts';
|
|
112
113
|
out.warning(`${String(status.openCount)} open Dependabot ${noun}${severity}. The release is not blocked.${listing}\n→ ${status.alertsUrl}`);
|
|
114
|
+
return status;
|
|
113
115
|
}
|
|
114
116
|
/**
|
|
115
117
|
code scanning・secret scanning の open の alert があれば、false を返す。機能が無効のリポジトリは通る
|
|
116
118
|
*/
|
|
117
|
-
async function isScanningPassed(out, name, fetchStatus) {
|
|
119
|
+
async function isScanningPassed(out, name, fetchStatus, skip) {
|
|
118
120
|
let status;
|
|
119
121
|
try {
|
|
120
122
|
status = await fetchStatus();
|
|
@@ -126,7 +128,7 @@ async function isScanningPassed(out, name, fetchStatus) {
|
|
|
126
128
|
return false;
|
|
127
129
|
}
|
|
128
130
|
if (!status.enabled) {
|
|
129
|
-
|
|
131
|
+
skip(`${name} (feature disabled)`);
|
|
130
132
|
return true;
|
|
131
133
|
}
|
|
132
134
|
if (status.openCount === 0) {
|
|
@@ -140,14 +142,20 @@ async function isScanningPassed(out, name, fetchStatus) {
|
|
|
140
142
|
/**
|
|
141
143
|
3 種を確かめる。1 つが失敗しても残りを続け、最後に成否を返す
|
|
142
144
|
*/
|
|
143
|
-
async function
|
|
145
|
+
async function checkAlerts(out, config, owner, repository) {
|
|
146
|
+
const skipped = [];
|
|
147
|
+
const skip = (target) => {
|
|
148
|
+
out.done({ verb: 'skip', target, aside: true });
|
|
149
|
+
skipped.push(target);
|
|
150
|
+
};
|
|
151
|
+
let dependabot;
|
|
144
152
|
const checks = [
|
|
145
153
|
async () => {
|
|
146
|
-
await checkDependabotAlerts(out, config, owner, repository);
|
|
154
|
+
dependabot = await checkDependabotAlerts(out, config, owner, repository, skip);
|
|
147
155
|
return true;
|
|
148
156
|
},
|
|
149
|
-
async () => await isScanningPassed(out, 'code scanning', async () => await fetchCodeScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository)),
|
|
150
|
-
async () => await isScanningPassed(out, 'secret scanning', async () => await fetchSecretScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository)),
|
|
157
|
+
async () => await isScanningPassed(out, 'code scanning', async () => await fetchCodeScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository), skip),
|
|
158
|
+
async () => await isScanningPassed(out, 'secret scanning', async () => await fetchSecretScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository), skip),
|
|
151
159
|
];
|
|
152
160
|
let isPassed = true;
|
|
153
161
|
for (const check of checks) {
|
|
@@ -162,8 +170,21 @@ async function areAlertsPassed(out, config, owner, repository) {
|
|
|
162
170
|
isPassed = false;
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
|
-
return isPassed;
|
|
173
|
+
return { isPassed, skipped, dependabot };
|
|
166
174
|
}
|
|
175
|
+
const RELEASE_CHECK_OUTPUT = z.strictObject({
|
|
176
|
+
version: z.string().optional().describe('Version to release (omitted when release_type is nx, where only the alerts are checked)'),
|
|
177
|
+
tag: z.string().optional().describe('Tag to create (omitted when release_type is nx)'),
|
|
178
|
+
releaseNotes: z.string().optional().describe('Release notes from the CHANGELOG (omitted when release_type is nx)'),
|
|
179
|
+
commitCount: z.int().optional().describe('Number of commits from the release branch to the develop branch (omitted when release_type is nx)'),
|
|
180
|
+
skipped: z.array(z.string()).describe('Checks skipped because the feature is disabled, as in the skipped lines (e.g. "Dependabot alerts (feature disabled)")'),
|
|
181
|
+
dependabotAlerts: z.strictObject({
|
|
182
|
+
enabled: z.boolean().describe('Whether Dependabot alerts are enabled'),
|
|
183
|
+
openCount: z.int().describe('Number of open alerts (0 when disabled)'),
|
|
184
|
+
maxSeverity: z.string().optional().describe('Highest severity of the open alerts (omitted when there is none)'),
|
|
185
|
+
alertsUrl: z.string().describe('URL of the alert list'),
|
|
186
|
+
}).optional().describe('Dependabot alert status (omitted when it could not be read; the release is not blocked)'),
|
|
187
|
+
});
|
|
167
188
|
const releaseCheckCommand = defineCommand({
|
|
168
189
|
path: CHECK_PATH,
|
|
169
190
|
description: 'Run the pre-release checks; for an nx repository only the alerts are checked',
|
|
@@ -171,6 +192,7 @@ const releaseCheckCommand = defineCommand({
|
|
|
171
192
|
version: z.string().optional().describe('Release version (detected from the CHANGELOG when omitted)'),
|
|
172
193
|
package: z.string().optional().describe('Package name in a monorepo (required for repositories with packages configured)'),
|
|
173
194
|
}),
|
|
195
|
+
output: RELEASE_CHECK_OUTPUT,
|
|
174
196
|
positional: ['version'],
|
|
175
197
|
interactive: false,
|
|
176
198
|
run: async (input, io) => {
|
|
@@ -179,8 +201,13 @@ const releaseCheckCommand = defineCommand({
|
|
|
179
201
|
const cwd = process.cwd();
|
|
180
202
|
const context = loadReleaseContext(out, adopted, input.repo, input.package, { version: input.version, nxAlertsOnly: true });
|
|
181
203
|
const { config, owner, repository } = context;
|
|
182
|
-
const
|
|
183
|
-
|
|
204
|
+
const alerts = await checkAlerts(out, config, owner, repository);
|
|
205
|
+
const { dependabot } = alerts;
|
|
206
|
+
out.result({
|
|
207
|
+
skipped: [...alerts.skipped],
|
|
208
|
+
...dependabot !== undefined && { dependabotAlerts: { enabled: dependabot.enabled, openCount: dependabot.openCount, ...dependabot.maxSeverity !== undefined && { maxSeverity: dependabot.maxSeverity }, alertsUrl: dependabot.alertsUrl } },
|
|
209
|
+
});
|
|
210
|
+
if (!alerts.isPassed)
|
|
184
211
|
throw new CommandExit(1, 'preflight-failed');
|
|
185
212
|
if (context.repositoryConfig !== undefined && effectiveReleaseType(context.repositoryConfig) === 'nx')
|
|
186
213
|
return 0;
|
|
@@ -199,6 +226,7 @@ const releaseCheckCommand = defineCommand({
|
|
|
199
226
|
remote,
|
|
200
227
|
}, gitRunnerFor(cwd), async (base, head) => await client.countCommitsAhead(owner, repository, base, head));
|
|
201
228
|
out.count(`commits to release (${remote}/${result.developBranch} -> ${remote}/${result.releaseBranch})`, result.diffCount);
|
|
229
|
+
out.result({ version: result.version, tag: result.tagName, releaseNotes: result.releaseNotes, commitCount: result.diffCount });
|
|
202
230
|
out.data(`version: ${result.version}\ntag: ${result.tagName}\n\n${result.releaseNotes}`);
|
|
203
231
|
return 0;
|
|
204
232
|
}
|
|
@@ -212,6 +240,12 @@ const releaseCheckCommand = defineCommand({
|
|
|
212
240
|
}
|
|
213
241
|
},
|
|
214
242
|
});
|
|
243
|
+
const RELEASE_CREATE_OUTPUT = z.strictObject({
|
|
244
|
+
tag: z.string().describe('Tag of the release'),
|
|
245
|
+
url: z.string().optional().describe('URL of the created release (omitted on dry_run)'),
|
|
246
|
+
releaseNotes: z.string().describe('Release notes from the CHANGELOG'),
|
|
247
|
+
dryRun: DRY_RUN_FIELD,
|
|
248
|
+
});
|
|
215
249
|
const releaseCreateCommand = defineCommand({
|
|
216
250
|
path: ['release', 'create'],
|
|
217
251
|
description: 'Create a GitHub release and its tag (the release notes come from the CHANGELOG)',
|
|
@@ -220,6 +254,7 @@ const releaseCreateCommand = defineCommand({
|
|
|
220
254
|
dry_run: z.boolean().default(false).describe('Show what would happen without changing anything'),
|
|
221
255
|
package: z.string().optional().describe('Package name in a monorepo (required for repositories with packages configured)'),
|
|
222
256
|
}),
|
|
257
|
+
output: RELEASE_CREATE_OUTPUT,
|
|
223
258
|
positional: ['version'],
|
|
224
259
|
interactive: false,
|
|
225
260
|
run: async (input, io) => {
|
|
@@ -250,6 +285,7 @@ const releaseCreateCommand = defineCommand({
|
|
|
250
285
|
const operation = { verb: 'create', target: `release ${tagName} on ${releaseBranch}` };
|
|
251
286
|
if (input.dry_run) {
|
|
252
287
|
out.planned(operation);
|
|
288
|
+
out.result({ tag: tagName, releaseNotes });
|
|
253
289
|
out.data(releaseNotes);
|
|
254
290
|
return 0;
|
|
255
291
|
}
|
|
@@ -258,6 +294,7 @@ const releaseCreateCommand = defineCommand({
|
|
|
258
294
|
const result = await client.createRelease(owner, repository, tagName, releaseName, releaseNotes, { targetCommitish: releaseBranch });
|
|
259
295
|
out.done(operation);
|
|
260
296
|
const url = result['html_url'];
|
|
297
|
+
out.result({ tag: tagName, releaseNotes, ...typeof url === 'string' && { url } });
|
|
261
298
|
out.data(typeof url === 'string' ? url : '');
|
|
262
299
|
return 0;
|
|
263
300
|
}
|
|
@@ -268,6 +305,13 @@ const releaseCreateCommand = defineCommand({
|
|
|
268
305
|
}
|
|
269
306
|
},
|
|
270
307
|
});
|
|
308
|
+
const RELEASE_MERGE_OUTPUT = z.strictObject({
|
|
309
|
+
pullRequest: z.string().describe('Release PR (owner/repo/N)'),
|
|
310
|
+
head: z.string().describe('Head branch of the PR'),
|
|
311
|
+
base: z.string().describe('Base branch of the PR (the release branch)'),
|
|
312
|
+
deletedBranch: z.boolean().describe('Whether the remote head branch was deleted (false without delete_branch, on dry_run, or when the deletion failed)'),
|
|
313
|
+
dryRun: DRY_RUN_FIELD,
|
|
314
|
+
});
|
|
271
315
|
const releaseMergeCommand = defineCommand({
|
|
272
316
|
path: ['release', 'merge'],
|
|
273
317
|
description: 'Merge a release PR with a regular merge',
|
|
@@ -277,6 +321,7 @@ const releaseMergeCommand = defineCommand({
|
|
|
277
321
|
delete_branch: z.boolean().default(false).describe('Delete the branch after merging'),
|
|
278
322
|
admin: z.boolean().default(false).describe('Merge with admin rights (skip the mergeability check)'),
|
|
279
323
|
}),
|
|
324
|
+
output: RELEASE_MERGE_OUTPUT,
|
|
280
325
|
positional: ['pr_ref'],
|
|
281
326
|
shortFlags: { dry_run: '-n', delete_branch: '-d' },
|
|
282
327
|
interactive: false,
|
|
@@ -295,7 +340,7 @@ const releaseMergeCommand = defineCommand({
|
|
|
295
340
|
}
|
|
296
341
|
const { owner, repository } = reference.repository;
|
|
297
342
|
const number = reference.number;
|
|
298
|
-
const pullRequestName =
|
|
343
|
+
const pullRequestName = issuePath(owner, repository, number);
|
|
299
344
|
let client;
|
|
300
345
|
let pullRequest;
|
|
301
346
|
try {
|
|
@@ -322,8 +367,10 @@ const releaseMergeCommand = defineCommand({
|
|
|
322
367
|
}
|
|
323
368
|
const headBranch = pullRequest.head_ref;
|
|
324
369
|
const operation = { verb: 'merge', target: `PR ${pullRequestName} (${headBranch} -> ${pullRequest.base_ref}, merge commit)` };
|
|
370
|
+
const merged = { pullRequest: pullRequestName, head: headBranch, base: pullRequest.base_ref, deletedBranch: false };
|
|
325
371
|
if (input.dry_run) {
|
|
326
372
|
out.planned(operation);
|
|
373
|
+
out.result(merged);
|
|
327
374
|
return 0;
|
|
328
375
|
}
|
|
329
376
|
try {
|
|
@@ -335,10 +382,12 @@ const releaseMergeCommand = defineCommand({
|
|
|
335
382
|
return stopWith(out, `could not merge PR ${pullRequestName}: ${describeApiError(error)}`, kindOfFailure(error));
|
|
336
383
|
}
|
|
337
384
|
out.done(operation);
|
|
385
|
+
out.result(merged);
|
|
338
386
|
if (input.delete_branch) {
|
|
339
387
|
try {
|
|
340
388
|
await client.deleteBranch(owner, repository, headBranch);
|
|
341
389
|
out.done({ verb: 'delete', target: `remote branch ${headBranch} in ${owner}/${repository}` });
|
|
390
|
+
out.result({ deletedBranch: true });
|
|
342
391
|
}
|
|
343
392
|
catch (error) {
|
|
344
393
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -5,6 +5,7 @@ import { applyRepositoryPolicy } from '../domain/repository-policy.js';
|
|
|
5
5
|
import { AmbiguousRepositoryError, resolveRepository } from '../domain/repository-resolver.js';
|
|
6
6
|
import { gitRunnerFor } from '../infra/git.js';
|
|
7
7
|
import { CommandExit } from './command-definition.js';
|
|
8
|
+
import { WARNING_PREFIX } from './output.js';
|
|
8
9
|
/**
|
|
9
10
|
今の git remote からリポジトリを解決する。git の外・remote 無しは undefined
|
|
10
11
|
*/
|
|
@@ -25,8 +26,12 @@ export function resolveCurrentRepository(cwd) {
|
|
|
25
26
|
*/
|
|
26
27
|
export function requireRepositoryMatch(mode, explicit, io, cwd) {
|
|
27
28
|
const outcome = applyRepositoryPolicy({ explicit, resolved: resolveCurrentRepository(cwd), mode });
|
|
28
|
-
for (const line of outcome.stderr)
|
|
29
|
-
|
|
29
|
+
for (const line of outcome.stderr) {
|
|
30
|
+
const text = formatHinted(line, io.surface ?? 'cli');
|
|
31
|
+
io.stderr(`${text}\n`);
|
|
32
|
+
if (text.startsWith(WARNING_PREFIX))
|
|
33
|
+
io.warning?.(text.slice(WARNING_PREFIX.length));
|
|
34
|
+
}
|
|
30
35
|
if (outcome.kind === 'exit')
|
|
31
36
|
throw new CommandExit(outcome.exitCode, outcome.failure);
|
|
32
37
|
return outcome.adopted;
|
|
@@ -3,22 +3,53 @@
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { describeApiError } from '../domain/api-error-detail.js';
|
|
5
5
|
import { extractIssueNumberFromBranch } from '../domain/branch-name.js';
|
|
6
|
-
import { getDevelopBranch } from '../domain/config.js';
|
|
6
|
+
import { getDevelopBranch, homeRepositoryOf } from '../domain/config.js';
|
|
7
7
|
import { isEpicIssue } from '../domain/issue-kind.js';
|
|
8
8
|
import { extractClosingIssueNumbers } from '../domain/pull-request.js';
|
|
9
|
+
import { assumePullRequestState, describeReadinessChange, displayReference, hasReadinessChanged, isDone, isStackedOn } from '../domain/readiness.js';
|
|
10
|
+
import { createIssueReference } from '../domain/reference-parser.js';
|
|
9
11
|
import { FLAG_MERGE_SLASH_PENDING, FLAG_PECOT_ACTIVE, FLAG_PECOT_BASE, FLAG_PECOT_QUICK_MODE, FLAG_PECOT_SESSION_TITLE, FLAG_WIP_BRANCH_LINKED } from '../domain/state.js';
|
|
10
12
|
import { gitCurrentBranch, GitCommandError, runGit } from '../infra/git.js';
|
|
11
13
|
import { GitHubAPIError, GitHubNotFoundError, isClosedByAnotherRequest, isMissingReferenceError } from '../infra/github/errors.js';
|
|
12
14
|
import { isFileNotFound } from '../infra/os-error.js';
|
|
13
15
|
import { consumeFlag, removeFlag } from '../infra/state-store.js';
|
|
14
16
|
import { getCurrentWorktreeName, isWorktreeEnvironment } from '../infra/worktree.js';
|
|
17
|
+
import { commandHint, hinted } from './command-hint.js';
|
|
15
18
|
import { requireActiveConfigPlain, stopWith } from './command-stop.js';
|
|
19
|
+
import { createReadinessCache, judgeAssuming } from './issue-readiness.js';
|
|
20
|
+
import { moveIssuesWaitingFor, prerequisiteOf } from './pr-waiting.js';
|
|
16
21
|
import { kindOfFailure } from './failure.js';
|
|
17
22
|
import { createGitHubClient } from './github-client.js';
|
|
18
|
-
import { createOutput } from './output.js';
|
|
23
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
19
24
|
import { defineCommand } from './command-definition.js';
|
|
20
25
|
import { settle } from './tracker-sync.js';
|
|
21
26
|
import { isPositive, parseReference, PR_REFERENCE_DESCRIPTION, primaryRemote, reasonOf } from './pr.js';
|
|
27
|
+
const SKIPPED_ISSUE_DATA = z.strictObject({
|
|
28
|
+
number: z.int().describe('Issue number'),
|
|
29
|
+
reason: z.enum(['epic', 'already-closed', 'not-found', 'failed']).describe('Why it was not closed: epic (protected), already-closed, not-found, or failed (see warnings)'),
|
|
30
|
+
});
|
|
31
|
+
const DELETED_BRANCH_DATA = z.strictObject({
|
|
32
|
+
branch: z.string().describe('Name of the branch'),
|
|
33
|
+
location: z.enum(['remote', 'local']).describe('Whether the remote or the local branch was deleted'),
|
|
34
|
+
});
|
|
35
|
+
const READINESS_CHANGE_DATA = z.strictObject({
|
|
36
|
+
issue: z.string().describe('Issue waiting for a closed Issue (#N, or owner/repo#N in another repository)'),
|
|
37
|
+
from: z.string().describe('Readiness before the merge (blocked, startable, or stackable on #N)'),
|
|
38
|
+
to: z.string().describe('Readiness after the merge (blocked, startable, or stackable on #N)'),
|
|
39
|
+
});
|
|
40
|
+
const RESTACK_DATA = z.strictObject({
|
|
41
|
+
issue: z.string().describe('Started Issue stacked on a closed Issue (#N, or owner/repo#N in another repository)'),
|
|
42
|
+
branch: z.string().optional().describe('Branch linked to that Issue, to restack in its working directory (omitted when none)'),
|
|
43
|
+
});
|
|
44
|
+
const SESSION_FINISH_OUTPUT = z.strictObject({
|
|
45
|
+
closedIssues: z.array(z.int()).describe('Issue numbers closed (to be closed on dry_run)'),
|
|
46
|
+
skippedIssues: z.array(SKIPPED_ISSUE_DATA).describe('Closing Issues of the PR that this command did not close'),
|
|
47
|
+
deletedBranches: z.array(DELETED_BRANCH_DATA).describe('Branches deleted (to be deleted on dry_run)'),
|
|
48
|
+
readinessChanges: z.array(READINESS_CHANGE_DATA).describe('Issues waiting for the closed Issues whose readiness changed by the merge'),
|
|
49
|
+
restack: z.array(RESTACK_DATA).describe('Upper stacked Issues to restack with pr restack in their working directories'),
|
|
50
|
+
currentBranch: z.string().optional().describe('Current branch after the local cleanup (omitted when the local cleanup was skipped)'),
|
|
51
|
+
dryRun: DRY_RUN_FIELD,
|
|
52
|
+
});
|
|
22
53
|
async function fetchPullRequestForCleanup(config, location, out) {
|
|
23
54
|
try {
|
|
24
55
|
const client = createGitHubClient(out, config.host);
|
|
@@ -61,29 +92,37 @@ async function findEpicProtectedNumbers(client, location, issueNumbers, out) {
|
|
|
61
92
|
return protectedNumbers;
|
|
62
93
|
}
|
|
63
94
|
async function closeRelatedIssues(context, client, location, closing, epicProtected) {
|
|
64
|
-
const { out, isDryRun } = context;
|
|
95
|
+
const { out, isDryRun, record } = context;
|
|
65
96
|
const protectedOrdered = [...epicProtected].toSorted((a, b) => a - b);
|
|
66
97
|
const closingOrdered = [...closing].toSorted((a, b) => a - b);
|
|
67
|
-
for (const number of protectedOrdered)
|
|
98
|
+
for (const number of protectedOrdered) {
|
|
68
99
|
settle(out, { verb: 'skip', target: `closing Issue #${String(number)} (Epic)` });
|
|
100
|
+
record.skippedIssues.push({ number, reason: 'epic' });
|
|
101
|
+
}
|
|
69
102
|
for (const number of closingOrdered) {
|
|
70
103
|
const operation = { verb: 'close', target: `Issue #${String(number)}` };
|
|
71
104
|
out.planned(operation);
|
|
72
|
-
if (isDryRun)
|
|
105
|
+
if (isDryRun) {
|
|
106
|
+
record.closedIssues.push(number);
|
|
73
107
|
continue;
|
|
108
|
+
}
|
|
74
109
|
try {
|
|
75
110
|
await client.closeIssue(location.owner, location.repository, number);
|
|
76
111
|
out.done(operation);
|
|
112
|
+
record.closedIssues.push(number);
|
|
77
113
|
}
|
|
78
114
|
catch (error) {
|
|
79
115
|
if (error instanceof GitHubNotFoundError) {
|
|
80
116
|
out.warning(`Issue #${String(number)} not found; skipped`);
|
|
117
|
+
record.skippedIssues.push({ number, reason: 'not-found' });
|
|
81
118
|
}
|
|
82
119
|
else if (error instanceof GitHubAPIError) {
|
|
83
|
-
|
|
120
|
+
const isClosed = isClosedByAnotherRequest(error);
|
|
121
|
+
if (isClosed)
|
|
84
122
|
out.done({ verb: 'unchanged', target: `Issue #${String(number)} (already closed)` });
|
|
85
123
|
else
|
|
86
124
|
out.warning(`closing Issue #${String(number)} failed: ${describeApiError(error)}`);
|
|
125
|
+
record.skippedIssues.push({ number, reason: isClosed ? 'already-closed' : 'failed' });
|
|
87
126
|
}
|
|
88
127
|
else {
|
|
89
128
|
throw error;
|
|
@@ -91,16 +130,75 @@ async function closeRelatedIssues(context, client, location, closing, epicProtec
|
|
|
91
130
|
}
|
|
92
131
|
}
|
|
93
132
|
}
|
|
133
|
+
function mergedPullRequestOf(location, number, pr) {
|
|
134
|
+
return { repository: location, number, state: 'merged', headRefName: pr.head_ref, baseRefName: pr.base_ref, isDraft: pr.is_draft, isCrossRepository: false };
|
|
135
|
+
}
|
|
136
|
+
// 閉じた Issue のうち、判定に出ている前提がすべて済んでいるか
|
|
137
|
+
function isClosedReflected(judged, heads) {
|
|
138
|
+
const found = heads.flatMap(head => prerequisiteOf(judged, head) ?? []);
|
|
139
|
+
return found.length > 0 && found.every(({ issue }) => isDone(issue));
|
|
140
|
+
}
|
|
141
|
+
function waitingCheck(source, heads, isDryRun, cache, home) {
|
|
142
|
+
const { client, config, pullRequest } = source;
|
|
143
|
+
const names = heads.map(head => displayReference(head, home)).join(', ');
|
|
144
|
+
const unconfirmed = (name) => hinted `could not confirm that GitHub reflects the close of ${names} in the readiness of ${name}; its column was not moved; run ${commandHint(['board', 'sync'])} later to move it`;
|
|
145
|
+
if (!isDryRun)
|
|
146
|
+
return { isReflected: judged => isClosedReflected(judged, heads), unconfirmed };
|
|
147
|
+
// dry-run では Issue を閉じていないので、閉じた後を置き換えで作る
|
|
148
|
+
return {
|
|
149
|
+
isReflected: () => true,
|
|
150
|
+
unconfirmed,
|
|
151
|
+
assume: async ({ target, result }) => (result.kind === 'judged'
|
|
152
|
+
? { target, result: await judgeAssuming(client, config, result, prerequisites => assumePullRequestState(prerequisites, heads, pullRequest, 'merged'), cache) }
|
|
153
|
+
: { target, result }),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// 閉じた Issue を待つ Issue の列と札を動かし、マージの前と比べた判定の変化と、載せ直す上の段を記録する
|
|
157
|
+
async function updateWaitingIssues(context, source) {
|
|
158
|
+
const { out, isDryRun, record } = context;
|
|
159
|
+
const { client, config, location, pullRequest } = source;
|
|
160
|
+
const alreadyClosed = record.skippedIssues.filter(({ reason }) => reason === 'already-closed').map(({ number }) => number);
|
|
161
|
+
const heads = [...record.closedIssues, ...alreadyClosed].toSorted((a, b) => a - b).map(number => createIssueReference(location, number));
|
|
162
|
+
if (heads.length === 0)
|
|
163
|
+
return;
|
|
164
|
+
const home = homeRepositoryOf(config);
|
|
165
|
+
const cache = createReadinessCache();
|
|
166
|
+
const board = { out, client, config, home };
|
|
167
|
+
const judged = await moveIssuesWaitingFor(board, { heads, check: waitingCheck(source, heads, isDryRun, cache, home), isDryRun, cache });
|
|
168
|
+
for (const { target, result } of judged) {
|
|
169
|
+
if (result.kind !== 'judged' || result.readiness === undefined)
|
|
170
|
+
continue;
|
|
171
|
+
const before = await judgeAssuming(client, config, result, prerequisites => assumePullRequestState(prerequisites, heads, pullRequest, 'open'), cache);
|
|
172
|
+
if (before.kind !== 'judged' || before.readiness === undefined || !hasReadinessChanged(before.readiness, result.readiness))
|
|
173
|
+
continue;
|
|
174
|
+
const { repository } = target.ref;
|
|
175
|
+
record.readinessChanges.push({ issue: displayReference(target.ref, home), from: describeReadinessChange(before.readiness, repository), to: describeReadinessChange(result.readiness, repository) });
|
|
176
|
+
}
|
|
177
|
+
if (record.readinessChanges.length > 0)
|
|
178
|
+
out.data(['Readiness changed:', ...record.readinessChanges.map(change => `- ${change.issue} ${change.from} -> ${change.to}`)].join('\n'));
|
|
179
|
+
for (const { target, result } of judged) {
|
|
180
|
+
if (result.kind !== 'judged' || !isStackedOn(result.target, result.prerequisites, heads))
|
|
181
|
+
continue;
|
|
182
|
+
const name = displayReference(target.ref, home);
|
|
183
|
+
const lower = heads.filter(head => prerequisiteOf(result, head)?.wait === 'stack').map(head => displayReference(head, home)).join(', ');
|
|
184
|
+
const [branch] = result.target.branches;
|
|
185
|
+
record.restack.push({ issue: name, ...branch !== undefined && { branch } });
|
|
186
|
+
out.warning(hinted `${name} is stacked on ${lower}; run ${commandHint(['pr', 'restack'])} in the working directory of ${branch ?? 'its branch'}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
94
189
|
// head ブランチを消し、続けて wip ブランチを消す。head が無くても wip は試す
|
|
95
190
|
async function deleteMergedBranch(context, client, location, headBranch) {
|
|
96
|
-
const { out, isDryRun } = context;
|
|
191
|
+
const { out, isDryRun, record } = context;
|
|
97
192
|
const operation = { verb: 'delete', target: `remote branch ${headBranch}` };
|
|
98
193
|
out.planned(operation);
|
|
99
|
-
if (isDryRun)
|
|
194
|
+
if (isDryRun) {
|
|
195
|
+
record.deletedBranches.push({ branch: headBranch, location: 'remote' });
|
|
100
196
|
return;
|
|
197
|
+
}
|
|
101
198
|
try {
|
|
102
199
|
await client.deleteBranch(location.owner, location.repository, headBranch);
|
|
103
200
|
out.done(operation);
|
|
201
|
+
record.deletedBranches.push({ branch: headBranch, location: 'remote' });
|
|
104
202
|
}
|
|
105
203
|
catch (error) {
|
|
106
204
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -115,6 +213,7 @@ async function deleteMergedBranch(context, client, location, headBranch) {
|
|
|
115
213
|
try {
|
|
116
214
|
await client.deleteBranch(location.owner, location.repository, wipBranch);
|
|
117
215
|
out.done({ verb: 'delete', target: `remote branch ${wipBranch}` });
|
|
216
|
+
record.deletedBranches.push({ branch: wipBranch, location: 'remote' });
|
|
118
217
|
}
|
|
119
218
|
catch (error) {
|
|
120
219
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -200,14 +299,17 @@ function localCleanupAfterMerge(context, headBranch, config, location) {
|
|
|
200
299
|
}
|
|
201
300
|
else if (!didRunLocalStep(context, { verb: 'set', target: `current branch to ${checkoutTarget}` }, cwd, ['checkout', checkoutTarget], `checking out ${checkoutTarget}`)) {
|
|
202
301
|
// checkout が失敗したら、pull と branch -D は別のブランチに当たるので止める
|
|
302
|
+
if (currentBranch !== undefined)
|
|
303
|
+
context.record.currentBranch = currentBranch;
|
|
203
304
|
return;
|
|
204
305
|
}
|
|
306
|
+
context.record.currentBranch = checkoutTarget;
|
|
205
307
|
didRunLocalStep(context, { verb: 'update', target: `${checkoutTarget} from ${remote}/${developBranch}` }, cwd, ['pull', remote, developBranch], `pulling ${developBranch}`);
|
|
206
308
|
if (headBranch === checkoutTarget) {
|
|
207
309
|
settle(out, { verb: 'skip', target: `deleting local branch ${headBranch} (it is the checkout target)` });
|
|
208
310
|
}
|
|
209
|
-
else {
|
|
210
|
-
|
|
311
|
+
else if (didRunLocalStep(context, { verb: 'delete', target: `local branch ${headBranch}` }, cwd, ['branch', '-D', headBranch], `deleting local branch ${headBranch}`)) {
|
|
312
|
+
context.record.deletedBranches.push({ branch: headBranch, location: 'local' });
|
|
211
313
|
}
|
|
212
314
|
}
|
|
213
315
|
function removeActiveFlags(out) {
|
|
@@ -227,19 +329,32 @@ const FinishInputSchema = z.strictObject({
|
|
|
227
329
|
});
|
|
228
330
|
async function runFinish(input, io) {
|
|
229
331
|
const out = createOutput(input.dry_run, io);
|
|
230
|
-
const
|
|
332
|
+
const record = { closedIssues: [], skippedIssues: [], deletedBranches: [], readinessChanges: [], restack: [], hasStarted: false };
|
|
333
|
+
try {
|
|
334
|
+
await finish(input, { out, isDryRun: input.dry_run, record });
|
|
335
|
+
}
|
|
336
|
+
finally {
|
|
337
|
+
const { closedIssues, skippedIssues, deletedBranches, readinessChanges, restack, currentBranch } = record;
|
|
338
|
+
if (record.hasStarted)
|
|
339
|
+
out.result({ closedIssues, skippedIssues, deletedBranches, readinessChanges, restack, ...currentBranch !== undefined && { currentBranch } });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async function finish(input, context) {
|
|
343
|
+
const { out } = context;
|
|
231
344
|
const config = requireActiveConfigPlain(out);
|
|
232
345
|
const reference = parseReference(input.pr_ref, input.repo, out);
|
|
233
346
|
const location = { owner: reference.owner, repository: reference.repository };
|
|
234
347
|
const { client, pr } = await fetchPullRequestForCleanup(config, reference, out);
|
|
235
348
|
if (pr.state !== 'MERGED')
|
|
236
|
-
stopWith(out, `PR #${String(reference.number)} is not merged yet (state: ${pr.state}); merge it with
|
|
349
|
+
stopWith(out, hinted `PR #${String(reference.number)} is not merged yet (state: ${pr.state}); merge it with ${commandHint(['pr', 'merge'])} first`, 'pr-state');
|
|
350
|
+
context.record.hasStarted = true;
|
|
237
351
|
const closing = collectClosingIssueNumbers(pr);
|
|
238
352
|
const epicProtected = await findEpicProtectedNumbers(client, location, closing, out);
|
|
239
353
|
for (const number of epicProtected)
|
|
240
354
|
closing.delete(number);
|
|
241
355
|
out.count('Issues to close', closing.size);
|
|
242
356
|
await closeRelatedIssues(context, client, location, closing, epicProtected);
|
|
357
|
+
await updateWaitingIssues(context, { client, config, location, pullRequest: mergedPullRequestOf(location, reference.number, pr) });
|
|
243
358
|
if (input.delete_branch)
|
|
244
359
|
await deleteMergedBranch(context, client, location, pr.head_ref);
|
|
245
360
|
if (input.skip_local_cleanup)
|
|
@@ -255,6 +370,7 @@ const sessionFinishCommand = defineCommand({
|
|
|
255
370
|
path: ['session', 'finish'],
|
|
256
371
|
description: 'Clean up after a merged PR (close related Issues, delete branches, local cleanup)',
|
|
257
372
|
input: FinishInputSchema,
|
|
373
|
+
output: SESSION_FINISH_OUTPUT,
|
|
258
374
|
positional: ['pr_ref'],
|
|
259
375
|
shortFlags: { dry_run: '-n', delete_branch: '-d' },
|
|
260
376
|
interactive: false,
|
|
@@ -9,7 +9,8 @@ import { FLAG_PECOT_ACTIVE } from '../domain/state.js';
|
|
|
9
9
|
import { decideStart, describeBaseMismatch } from '../domain/work-start.js';
|
|
10
10
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
11
11
|
import { readFlag } from '../infra/state-store.js';
|
|
12
|
-
import {
|
|
12
|
+
import { issuePath } from './issue-shared.js';
|
|
13
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
13
14
|
import { defineCommand } from './command-definition.js';
|
|
14
15
|
import { commandHint, hinted, inputHint, joinHinted } from './command-hint.js';
|
|
15
16
|
import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
@@ -55,7 +56,7 @@ function resolveBaseBranch(out, query) {
|
|
|
55
56
|
return base;
|
|
56
57
|
const developBranch = findRepository(config, owner, repository)?.develop_branch;
|
|
57
58
|
if (developBranch === undefined || developBranch === '') {
|
|
58
|
-
const withBase = commandHint(START_PATH, { issue_ref:
|
|
59
|
+
const withBase = commandHint(START_PATH, { issue_ref: issuePath(owner, repository, issueNumber), branch, base: 'main' });
|
|
59
60
|
stopWith(out, joinHinted([`develop_branch is not set for ${owner}/${repository}`, developBranchGuide(owner, repository), hinted `or give the base: ${withBase}`]), 'repo-setting-missing');
|
|
60
61
|
}
|
|
61
62
|
return developBranch;
|
|
@@ -118,7 +119,7 @@ async function guardActiveOverwrite(out, client, issueReference) {
|
|
|
118
119
|
*/
|
|
119
120
|
async function setIssueStatusActive(out, client, config, issue) {
|
|
120
121
|
const { owner, repository, number } = issue;
|
|
121
|
-
const target = `Issue ${owner
|
|
122
|
+
const target = `Issue ${issuePath(owner, repository, number)} status active`;
|
|
122
123
|
try {
|
|
123
124
|
const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
|
|
124
125
|
if (itemId === undefined || itemId === '') {
|
|
@@ -141,6 +142,15 @@ async function setIssueStatusActive(out, client, config, issue) {
|
|
|
141
142
|
out.warning(`could not set ${target}: ${error.message}`);
|
|
142
143
|
}
|
|
143
144
|
}
|
|
145
|
+
const SESSION_START_OUTPUT = z.strictObject({
|
|
146
|
+
branch: z.string().describe('Branch created (or to be created), with the Issue number appended'),
|
|
147
|
+
repository: z.string().describe('Repository of the branch (owner/repo)'),
|
|
148
|
+
base: z.string().describe('Base branch the branch starts from'),
|
|
149
|
+
stackedOn: z.int().optional().describe('Issue number whose branch this one is stacked on (omitted when not stacked)'),
|
|
150
|
+
issue: z.string().describe('Work Issue (owner/repo/N)'),
|
|
151
|
+
workDirectory: z.string().optional().describe('Absolute path of the work directory (omitted on dry_run or when it could not be created)'),
|
|
152
|
+
dryRun: DRY_RUN_FIELD,
|
|
153
|
+
});
|
|
144
154
|
const sessionStartCommand = defineCommand({
|
|
145
155
|
path: START_PATH,
|
|
146
156
|
description: 'Create a branch linked to an Issue (shown in the Development section of the Issue)',
|
|
@@ -153,6 +163,7 @@ const sessionStartCommand = defineCommand({
|
|
|
153
163
|
force_overwrite_active: z.boolean().default(false).describe('Disable the .pecot-active overwrite guard (when sure it is stale)'),
|
|
154
164
|
dry_run: z.boolean().default(false).describe('Show what would be created and recorded without writing anything'),
|
|
155
165
|
}),
|
|
166
|
+
output: SESSION_START_OUTPUT,
|
|
156
167
|
positional: ['issue_ref', 'branch'],
|
|
157
168
|
shortFlags: { base: '-b', allow_cross_repo: '-X', force_overwrite_active: '-F', dry_run: '-n' },
|
|
158
169
|
negations: { checkout: '--no-checkout' },
|
|
@@ -182,7 +193,7 @@ const sessionStartCommand = defineCommand({
|
|
|
182
193
|
const client = createGitHubClient(out, config.host);
|
|
183
194
|
// A-2. .pecot-active 上書きガード
|
|
184
195
|
if (!input.force_overwrite_active)
|
|
185
|
-
await guardActiveOverwrite(out, client,
|
|
196
|
+
await guardActiveOverwrite(out, client, issuePath(owner, repository, issueNumber));
|
|
186
197
|
// 4. リポジトリがプロジェクトに含まれているか確認
|
|
187
198
|
if (!await isRepositoryInProject(config, owner, repository, client)) {
|
|
188
199
|
stopWith(out, `${owner}/${repository} is not in the project`, 'repo-not-in-project');
|
|
@@ -208,21 +219,26 @@ const sessionStartCommand = defineCommand({
|
|
|
208
219
|
throw error;
|
|
209
220
|
}
|
|
210
221
|
const stackedNote = decision.kind === 'stack' ? ` (stacked on ${displayReference(decision.issue, issue.repository)})` : '';
|
|
222
|
+
const started = { repository: `${owner}/${repository}`, base: baseBranch, ...decision.kind === 'stack' && { stackedOn: decision.issue.number }, issue: issuePath(owner, repository, issueNumber) };
|
|
211
223
|
if (input.dry_run) {
|
|
224
|
+
out.result({ ...started, branch: finalBranchName });
|
|
212
225
|
out.planned({ verb: 'create', target: `branch ${finalBranchName} in ${owner}/${repository} from ${baseBranch}${stackedNote}` });
|
|
213
|
-
out.planned({ verb: 'set', target: `Issue ${owner
|
|
226
|
+
out.planned({ verb: 'set', target: `Issue ${issuePath(owner, repository, issueNumber)} status active` });
|
|
214
227
|
planWorkTarget(out, owner, repository, issueNumber);
|
|
215
228
|
return 0;
|
|
216
229
|
}
|
|
217
230
|
// 7. リンクブランチ作成(ブランチ名末尾に Issue 番号を自動付与)
|
|
218
231
|
const createdBranch = await client.createLinkedBranch(issueNodeId, baseSha, finalBranchName);
|
|
219
232
|
out.done({ verb: 'create', target: `branch ${createdBranch} in ${owner}/${repository} from ${baseBranch}${stackedNote}` });
|
|
233
|
+
out.result({ ...started, branch: createdBranch });
|
|
220
234
|
// 7.5. プロジェクトアイテムのステータスを active に更新
|
|
221
235
|
await setIssueStatusActive(out, client, config, { owner, repository, number: issueNumber });
|
|
222
236
|
// 9. 作業対象を .pecot-active と .pecot-session-title に保存(hook の自動投稿とセッション名用)
|
|
223
|
-
recordWorkTarget(out, owner, repository, issueNumber, issueTitle, {
|
|
237
|
+
const recorded = recordWorkTarget(out, owner, repository, issueNumber, issueTitle, {
|
|
224
238
|
base: { branch: baseBranch, sha: baseSha, stackedOn: decision.kind === 'stack' ? decision.issue : undefined },
|
|
225
239
|
});
|
|
240
|
+
if (recorded.workDirectory !== undefined)
|
|
241
|
+
out.result({ workDirectory: recorded.workDirectory });
|
|
226
242
|
return 0;
|
|
227
243
|
}
|
|
228
244
|
catch (error) {
|