@pecot/workflow-mcp 5.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 +27 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +69 -0
- package/cli/dist/commands/board-judgment.d.ts +69 -0
- package/cli/dist/commands/board-judgment.js +150 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +65 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +75 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +120 -0
- package/cli/dist/commands/board-view.d.ts +151 -0
- package/cli/dist/commands/board-view.js +293 -0
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +111 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +39 -8
- package/cli/dist/commands/command-definition.js +20 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +35 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +61 -0
- package/cli/dist/commands/issue-board.js +85 -1
- package/cli/dist/commands/issue-comment.js +66 -30
- package/cli/dist/commands/issue-create.js +632 -92
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +310 -0
- package/cli/dist/commands/issue-readiness.d.ts +122 -0
- package/cli/dist/commands/issue-readiness.js +253 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +130 -0
- package/cli/dist/commands/issue-shared.d.ts +33 -20
- package/cli/dist/commands/issue-shared.js +84 -76
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +239 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +63 -0
- package/cli/dist/commands/output.d.ts +32 -4
- package/cli/dist/commands/output.js +28 -8
- 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 +59 -0
- package/cli/dist/commands/pr-waiting.js +143 -0
- package/cli/dist/commands/pr.d.ts +23 -0
- package/cli/dist/commands/pr.js +378 -366
- package/cli/dist/commands/project-sync.d.ts +12 -3
- package/cli/dist/commands/project-sync.js +23 -13
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +371 -177
- package/cli/dist/commands/registry.js +15 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +118 -130
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +9 -3
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +383 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/session-start.js +252 -0
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +186 -32
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +76 -68
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +71 -64
- package/cli/dist/commands/tracker-sync.d.ts +37 -0
- package/cli/dist/commands/tracker-sync.js +18 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +20 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +20 -3
- package/cli/dist/commands/work-target.js +49 -6
- package/cli/dist/commands/worktree.js +103 -33
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -4
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +44 -0
- package/cli/dist/domain/readiness.js +153 -5
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/restack.d.ts +62 -0
- package/cli/dist/domain/restack.js +53 -0
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +69 -0
- package/cli/dist/domain/state.js +67 -1
- package/cli/dist/domain/work-start.d.ts +30 -0
- package/cli/dist/domain/work-start.js +42 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +76 -0
- package/cli/dist/infra/git.js +123 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +105 -2
- package/cli/dist/infra/github/pulls.js +172 -5
- package/cli/dist/infra/github/queries.d.ts +15 -4
- package/cli/dist/infra/github/queries.js +203 -40
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -33
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +82 -7
- package/cli/dist/mcp/result.js +139 -19
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +57 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/project-info.d.ts +0 -48
- package/cli/dist/commands/project-info.js +0 -181
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/repository.js +0 -265
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// 作業対象(.pecot-active と .pecot-session-title、作業ディレクトリ)を記録して、結果の行を出す。
|
|
2
2
|
import { InvalidValueError, ProjectRootNotFoundError } from '../domain/errors.js';
|
|
3
|
+
import { FLAG_PECOT_BASE } from '../domain/state.js';
|
|
3
4
|
import { OsError, hasErrorCode, toOsError } from '../infra/os-error.js';
|
|
4
5
|
import { WORK_DIR } from '../infra/paths.js';
|
|
5
|
-
import { ensureWorkDirectory, writeWorkTarget } from '../infra/state-store.js';
|
|
6
|
+
import { ensureWorkDirectory, removeFlag, writeBaseRecord, writeWorkTarget } from '../infra/state-store.js';
|
|
6
7
|
import { stopWith } from './command-stop.js';
|
|
7
8
|
/**
|
|
8
9
|
記録の失敗として扱う例外か。OS の失敗・値の誤り・プロジェクトルート不明。プログラムの誤りは伝える
|
|
@@ -15,27 +16,69 @@ function describeFailure(error) {
|
|
|
15
16
|
return converted instanceof Error ? converted.message : error.message;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
.pecot-
|
|
19
|
-
失敗は warning
|
|
19
|
+
.pecot-base を消してから作業対象を書き、`set: work target ...` の行を出す。options.base があれば記録後に .pecot-base も書く。
|
|
20
|
+
失敗は warning の行。failWithExit なら error の行と CommandExit(1)。記録できたかと、行に出した参照・作業ディレクトリを返す
|
|
20
21
|
*/
|
|
21
22
|
export function recordWorkTarget(out, owner, repository, issueNumber, title, options = {}) {
|
|
22
23
|
const issueReference = `${owner}/${repository}/${String(issueNumber)}`;
|
|
24
|
+
clearBase(out);
|
|
23
25
|
let target;
|
|
26
|
+
let workDirectory;
|
|
24
27
|
try {
|
|
25
28
|
writeWorkTarget(issueReference, title);
|
|
26
29
|
target = `work target ${issueReference}`;
|
|
27
|
-
|
|
30
|
+
workDirectory = ensureWorkDirectory(issueReference);
|
|
31
|
+
if (workDirectory !== undefined)
|
|
28
32
|
target += ` (work directory ${WORK_DIR}/${String(issueNumber)}/)`;
|
|
29
33
|
}
|
|
30
34
|
catch (error) {
|
|
31
35
|
if (!isRecordingFailure(error))
|
|
32
36
|
throw error;
|
|
33
37
|
if (options.failWithExit === true) {
|
|
34
|
-
stopWith(out, `could not record the work target: ${describeFailure(error)}
|
|
38
|
+
stopWith(out, `could not record the work target: ${describeFailure(error)}`, 'other');
|
|
35
39
|
}
|
|
36
40
|
out.warning(`could not record the work target: ${describeFailure(error)}`);
|
|
37
|
-
return;
|
|
41
|
+
return { status: 'failed', issue: issueReference };
|
|
38
42
|
}
|
|
39
43
|
out.done({ verb: 'set', target });
|
|
44
|
+
if (options.base !== undefined)
|
|
45
|
+
recordBase(options.base, out);
|
|
46
|
+
return { status: 'recorded', issue: issueReference, workDirectory };
|
|
47
|
+
}
|
|
48
|
+
function warnBase(out, error) {
|
|
49
|
+
if (!isRecordingFailure(error))
|
|
50
|
+
throw error;
|
|
51
|
+
out.warning(`could not record the base: ${describeFailure(error)}`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
前の作業対象の .pecot-base を消す。消せなければ warning の行を出して続ける
|
|
55
|
+
*/
|
|
56
|
+
function clearBase(out) {
|
|
57
|
+
try {
|
|
58
|
+
removeFlag(FLAG_PECOT_BASE);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// 状態ディレクトリが無い(ENOTDIR)なら消すものが無い。書くほうの失敗が別に出る
|
|
62
|
+
if (hasErrorCode(error) && error.code === 'ENOTDIR')
|
|
63
|
+
return;
|
|
64
|
+
warnBase(out, error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
.pecot-base を書く。書けなければ warning の行を出して続ける
|
|
69
|
+
*/
|
|
70
|
+
function recordBase(record, out) {
|
|
71
|
+
try {
|
|
72
|
+
writeBaseRecord(record);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
warnBase(out, error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
予行の行。recordWorkTarget が書く作業対象(.pecot-active・.pecot-session-title・.pecot-base)を書かずに出す
|
|
80
|
+
*/
|
|
81
|
+
export function planWorkTarget(out, owner, repository, issueNumber) {
|
|
82
|
+
out.planned({ verb: 'set', target: `work target ${owner}/${repository}/${String(issueNumber)}` });
|
|
40
83
|
}
|
|
41
84
|
//# sourceMappingURL=work-target.js.map
|
|
@@ -11,11 +11,12 @@ import { hasErrorCode, OsError, toOsError } from '../infra/os-error.js';
|
|
|
11
11
|
import { resolveRealPath, WORKTREE_CONFIG_FILENAME, WORKTREE_IGNORE_FILENAME } from '../infra/paths.js';
|
|
12
12
|
import { createWorktree, detectProjectRoot, ensureDevcontainerEnvironment, findMainWorktree, findWorktreeConfigFile, getWorktreeDirectories, removeWorktree, WorktreeRuntimeError, } from '../infra/worktree.js';
|
|
13
13
|
import { createSymlinksSafe, DEFAULT_WORKTREEIGNORE_CONTENT, decideOverwrite, getDefaultConfig, loadConfig, planLink, saveConfig, WorktreeConfigError, } from '../infra/worktree-links.js';
|
|
14
|
-
import { createOutput, isConfirmed } from './output.js';
|
|
14
|
+
import { createOutput, DRY_RUN_FIELD, isConfirmed } from './output.js';
|
|
15
15
|
import { defineCommand } from './command-definition.js';
|
|
16
|
+
import { commandHint, hinted, hintedTextOf, inputHint, placeholder } from './command-hint.js';
|
|
17
|
+
import { stopWith } from './command-stop.js';
|
|
16
18
|
import { directorySchema } from './directory-option.js';
|
|
17
19
|
import { requireRepositoryMatch } from './repository-match.js';
|
|
18
|
-
const FAILURE = 1;
|
|
19
20
|
// click の realpath と同じく、解決できない所は字面のまま残して投げない
|
|
20
21
|
function lenientRealPath(value) {
|
|
21
22
|
try {
|
|
@@ -32,8 +33,7 @@ const dryRunInput = z.boolean().default(false).describe('Show what would happen
|
|
|
32
33
|
function reportRuntimeError(out, error) {
|
|
33
34
|
if (!(error instanceof WorktreeRuntimeError))
|
|
34
35
|
throw error;
|
|
35
|
-
out
|
|
36
|
-
return FAILURE;
|
|
36
|
+
return stopWith(out, hintedTextOf(error) ?? error.message, error.failure);
|
|
37
37
|
}
|
|
38
38
|
function countLinkResults(results, out) {
|
|
39
39
|
out.count('symlinks created', results.filter(result => result.action === 'created').length);
|
|
@@ -66,10 +66,19 @@ const worktreeAddInput = z.object({
|
|
|
66
66
|
dry_run: dryRunInput,
|
|
67
67
|
allow_existing_branch: z.boolean().default(false).describe('Allow reusing an existing branch even if its upstream differs from develop_branch'),
|
|
68
68
|
});
|
|
69
|
+
const ADD_OUTPUT = z.strictObject({
|
|
70
|
+
name: z.string().describe('Name of the worktree (the wtN it was numbered as)'),
|
|
71
|
+
path: z.string().describe('Absolute path of the worktree (on dry_run, where it would be)'),
|
|
72
|
+
branch: z.string().describe('Branch checked out in the worktree'),
|
|
73
|
+
base: z.string().describe('Base branch the worktree branch starts from'),
|
|
74
|
+
setupFailed: z.boolean().optional().describe('true when the setup command failed or timed out, false when it succeeded or was not run (omitted on dry_run)'),
|
|
75
|
+
dryRun: DRY_RUN_FIELD,
|
|
76
|
+
});
|
|
69
77
|
const worktreeAddCommand = defineCommand({
|
|
70
78
|
path: ['worktree', 'add'],
|
|
71
79
|
description: 'Create a new worktree',
|
|
72
80
|
input: worktreeAddInput,
|
|
81
|
+
output: ADD_OUTPUT,
|
|
73
82
|
positional: [],
|
|
74
83
|
shortFlags: { directory: '-D' },
|
|
75
84
|
aliases: { allow_existing_branch: '--force' },
|
|
@@ -94,6 +103,8 @@ function runAdd(input, io) {
|
|
|
94
103
|
out.planned(operation);
|
|
95
104
|
out.done(operation);
|
|
96
105
|
out.data(result.path);
|
|
106
|
+
const created = { name: result.name, path: result.path, branch: result.branch, base: result.baseBranch };
|
|
107
|
+
out.result(input.dry_run ? created : { ...created, setupFailed: result.setupResult !== undefined && result.setupResult.exitCode !== 0 });
|
|
97
108
|
if (result.linkedFiles.length > 0)
|
|
98
109
|
countLinkResults(result.linkedFiles, out);
|
|
99
110
|
if (result.copiedFiles.length > 0)
|
|
@@ -109,42 +120,65 @@ const worktreeRemoveInput = z.object({
|
|
|
109
120
|
directory: directorySchema,
|
|
110
121
|
force: z.boolean().default(false).describe('Force removal even if there are changes'),
|
|
111
122
|
keep_branch: z.boolean().default(false).describe('Keep the branch'),
|
|
123
|
+
dry_run: dryRunInput,
|
|
124
|
+
});
|
|
125
|
+
const REMOVE_OUTPUT = z.strictObject({
|
|
126
|
+
name: z.string().describe('Name of the worktree that was (on dry_run, would be) removed, as given'),
|
|
127
|
+
deletedBranch: z.boolean().describe('Whether the local branch was deleted (false when kept, when the deletion failed, and on dry_run)'),
|
|
128
|
+
dryRun: DRY_RUN_FIELD,
|
|
112
129
|
});
|
|
113
130
|
const worktreeRemoveCommand = defineCommand({
|
|
114
131
|
path: ['worktree', 'remove'],
|
|
115
132
|
description: 'Remove a worktree',
|
|
116
133
|
input: worktreeRemoveInput,
|
|
134
|
+
output: REMOVE_OUTPUT,
|
|
117
135
|
positional: ['name'],
|
|
118
|
-
shortFlags: { directory: '-D' },
|
|
136
|
+
shortFlags: { directory: '-D', dry_run: '-n' },
|
|
119
137
|
interactive: false,
|
|
120
138
|
run: (input, io) => Promise.resolve(runRemove(input, io)),
|
|
121
139
|
});
|
|
122
140
|
function runRemove(input, io) {
|
|
123
141
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
124
|
-
const out = createOutput(
|
|
142
|
+
const out = createOutput(input.dry_run, io);
|
|
125
143
|
try {
|
|
126
144
|
ensureDevcontainerEnvironment();
|
|
127
|
-
const branchError = removeWorktree(input.directory, input.name, out, { isForced: input.force, shouldKeepBranch: input.keep_branch });
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
const branchError = removeWorktree(input.directory, input.name, out, { isForced: input.force, shouldKeepBranch: input.keep_branch, isDryRun: input.dry_run });
|
|
146
|
+
const removed = { verb: 'remove', target: `worktree ${input.name}` };
|
|
147
|
+
out.planned(removed);
|
|
148
|
+
out.done(removed);
|
|
149
|
+
if (input.dry_run) {
|
|
150
|
+
if (!input.keep_branch)
|
|
151
|
+
out.planned({ verb: 'delete', target: `local branch ${input.name}` });
|
|
152
|
+
out.result({ name: input.name, deletedBranch: false });
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
const shouldDelete = !input.keep_branch;
|
|
156
|
+
if (shouldDelete) {
|
|
130
157
|
if (branchError === undefined)
|
|
131
158
|
out.done({ verb: 'delete', target: `local branch ${input.name}` });
|
|
132
159
|
else
|
|
133
160
|
out.warning(`could not delete local branch ${input.name}: ${branchError}`);
|
|
134
161
|
}
|
|
162
|
+
out.result({ name: input.name, deletedBranch: shouldDelete && branchError === undefined });
|
|
135
163
|
return 0;
|
|
136
164
|
}
|
|
137
165
|
catch (error) {
|
|
138
166
|
return reportRuntimeError(out, error);
|
|
139
167
|
}
|
|
140
168
|
}
|
|
141
|
-
const worktreeInitInput = z.object({ directory: directorySchema });
|
|
169
|
+
const worktreeInitInput = z.object({ directory: directorySchema, dry_run: dryRunInput });
|
|
170
|
+
const INIT_OUTPUT = z.strictObject({
|
|
171
|
+
configFile: z.string().describe('Absolute path of the worktree config file (on dry_run, where it would be)'),
|
|
172
|
+
ignoreFile: z.string().describe('Absolute path of the worktree ignore file (on dry_run, where it would be)'),
|
|
173
|
+
dryRun: DRY_RUN_FIELD,
|
|
174
|
+
});
|
|
142
175
|
const worktreeInitCommand = defineCommand({
|
|
143
176
|
path: ['worktree', 'init'],
|
|
144
177
|
description: 'Create the worktree config files in the main worktree',
|
|
145
178
|
input: worktreeInitInput,
|
|
179
|
+
output: INIT_OUTPUT,
|
|
146
180
|
positional: [],
|
|
147
|
-
shortFlags: { directory: '-D' },
|
|
181
|
+
shortFlags: { directory: '-D', dry_run: '-n' },
|
|
148
182
|
interactive: false,
|
|
149
183
|
run: (input, io) => Promise.resolve(runInit(input, io)),
|
|
150
184
|
});
|
|
@@ -158,9 +192,11 @@ function writeInitFiles(configFile, ignoreFile, config, out) {
|
|
|
158
192
|
try {
|
|
159
193
|
saveConfig(config, configFile);
|
|
160
194
|
out.done({ verb: 'create', target: `worktree config ${configFile}` });
|
|
195
|
+
out.result({ configFile });
|
|
161
196
|
mkdirSync(path.dirname(ignoreFile), { recursive: true });
|
|
162
197
|
writeFileSync(ignoreFile, DEFAULT_WORKTREEIGNORE_CONTENT);
|
|
163
198
|
out.done({ verb: 'create', target: `worktree ignore file ${ignoreFile}` });
|
|
199
|
+
out.result({ ignoreFile });
|
|
164
200
|
}
|
|
165
201
|
catch (error) {
|
|
166
202
|
throw hasErrorCode(error) ? toOsError(error) : error;
|
|
@@ -168,7 +204,7 @@ function writeInitFiles(configFile, ignoreFile, config, out) {
|
|
|
168
204
|
}
|
|
169
205
|
function runInit(input, io) {
|
|
170
206
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
171
|
-
const out = createOutput(
|
|
207
|
+
const out = createOutput(input.dry_run, io);
|
|
172
208
|
let mainWorktree;
|
|
173
209
|
try {
|
|
174
210
|
ensureDevcontainerEnvironment();
|
|
@@ -180,10 +216,8 @@ function runInit(input, io) {
|
|
|
180
216
|
const configFile = path.join(mainWorktree, WORKTREE_CONFIG_FILENAME);
|
|
181
217
|
const ignoreFile = path.join(mainWorktree, WORKTREE_IGNORE_FILENAME);
|
|
182
218
|
const existing = [configFile, ignoreFile].filter(file => isExistingFile(file));
|
|
183
|
-
if (existing.length > 0)
|
|
184
|
-
out
|
|
185
|
-
return FAILURE;
|
|
186
|
-
}
|
|
219
|
+
if (existing.length > 0)
|
|
220
|
+
stopWith(out, ['worktree config already exists', ...existing].join('\n'), 'already-exists');
|
|
187
221
|
let targetRepository;
|
|
188
222
|
try {
|
|
189
223
|
targetRepository = sharedLinkTarget(mainWorktree);
|
|
@@ -191,8 +225,13 @@ function runInit(input, io) {
|
|
|
191
225
|
catch (error) {
|
|
192
226
|
if (!(error instanceof InvalidValueError || error instanceof OsError || error instanceof ConfigError))
|
|
193
227
|
throw error;
|
|
194
|
-
out
|
|
195
|
-
|
|
228
|
+
return stopWith(out, `could not read the active config: ${error.message}`, 'config-invalid');
|
|
229
|
+
}
|
|
230
|
+
if (input.dry_run) {
|
|
231
|
+
out.planned({ verb: 'create', target: `worktree config ${configFile}` });
|
|
232
|
+
out.planned({ verb: 'create', target: `worktree ignore file ${ignoreFile}` });
|
|
233
|
+
out.result({ configFile, ignoreFile });
|
|
234
|
+
return 0;
|
|
196
235
|
}
|
|
197
236
|
writeInitFiles(configFile, ignoreFile, getDefaultConfig(targetRepository, path.basename(mainWorktree)), out);
|
|
198
237
|
return 0;
|
|
@@ -217,10 +256,21 @@ const worktreeLinkInput = z.object({
|
|
|
217
256
|
all: z.boolean().default(false).describe('Apply to all sub-worktrees'),
|
|
218
257
|
dry_run: dryRunInput,
|
|
219
258
|
});
|
|
259
|
+
const LINK_ROW = z.strictObject({
|
|
260
|
+
path: z.string().describe('Absolute path of the symlink'),
|
|
261
|
+
destination: z.string().describe('Absolute path the symlink points to'),
|
|
262
|
+
change: z.enum(['create', 'update', 'skip', 'error']).describe('create: a new symlink; update: an existing one was replaced; skip: left as it was; error: could not be made'),
|
|
263
|
+
reason: z.string().optional().describe('Why the link was skipped or failed (omitted for create and update)'),
|
|
264
|
+
});
|
|
265
|
+
const LINK_OUTPUT = z.strictObject({
|
|
266
|
+
links: z.array(LINK_ROW).describe('One entry per link of the config in each target worktree (an empty array when there is no sub-worktree)'),
|
|
267
|
+
dryRun: DRY_RUN_FIELD,
|
|
268
|
+
});
|
|
220
269
|
const worktreeLinkCommand = defineCommand({
|
|
221
270
|
path: ['worktree', 'link'],
|
|
222
271
|
description: 'Apply or update symlinks in existing worktrees',
|
|
223
272
|
input: worktreeLinkInput,
|
|
273
|
+
output: LINK_OUTPUT,
|
|
224
274
|
positional: [],
|
|
225
275
|
shortFlags: { directory: '-D' },
|
|
226
276
|
interactive: true,
|
|
@@ -258,18 +308,33 @@ function plannedOperation(plan, symlinkPath, destination) {
|
|
|
258
308
|
return { verb: 'update', target: `symlink ${symlinkPath} -> ${destination} (real file, asks first)` };
|
|
259
309
|
return { verb: 'skip', target: `symlink ${symlinkPath} (${skipReason(plan)})` };
|
|
260
310
|
}
|
|
311
|
+
function plannedEntry(plan, symlinkPath, destination) {
|
|
312
|
+
if (plan === 'create')
|
|
313
|
+
return { path: symlinkPath, destination, change: 'create' };
|
|
314
|
+
if (plan === 'update')
|
|
315
|
+
return { path: symlinkPath, destination, change: 'update' };
|
|
316
|
+
if (plan === 'ask')
|
|
317
|
+
return { path: symlinkPath, destination, change: 'update', reason: 'a real file exists; it is replaced only after confirmation' };
|
|
318
|
+
return { path: symlinkPath, destination, change: 'skip', reason: skipReason(plan) };
|
|
319
|
+
}
|
|
261
320
|
function previewLinks(targets, config, projectRoot, options, out) {
|
|
262
321
|
const decision = decideOverwrite({ force: options.force, allWorktrees: options.all });
|
|
322
|
+
const links = [];
|
|
263
323
|
for (const target of targets) {
|
|
264
324
|
for (const link of config.links) {
|
|
265
325
|
const destination = path.join(projectRoot, 'base', link.target_repo, link.target_path);
|
|
266
|
-
|
|
326
|
+
const plan = planLink(link, projectRoot, target, decision);
|
|
327
|
+
out.planned(plannedOperation(plan, path.join(target, link.path), destination));
|
|
328
|
+
links.push(plannedEntry(plan, path.join(target, link.path), destination));
|
|
267
329
|
}
|
|
268
330
|
}
|
|
331
|
+
out.result({ links });
|
|
269
332
|
}
|
|
270
333
|
// 1 つの worktree にリンクを作り、(作った数, 飛ばした数, 失敗した数) を返す
|
|
271
334
|
function applyLinks(target, config, projectRoot, options, io, out) {
|
|
272
335
|
const decision = decideOverwrite({ force: options.force, allWorktrees: options.all });
|
|
336
|
+
// 作る前の計画で、新しい symlink か置き換えかを分ける。結果は config.links と同じ順に返る
|
|
337
|
+
const plans = config.links.map(link => planLink(link, projectRoot, target, decision));
|
|
273
338
|
const results = createSymlinksSafe(config, projectRoot, target, out, {
|
|
274
339
|
force: decision.force,
|
|
275
340
|
confirm: decision.ask ? symlinkPath => isConfirmed(io, `real file exists: ${symlinkPath}\noverwrite it?`) : undefined,
|
|
@@ -279,7 +344,13 @@ function applyLinks(target, config, projectRoot, options, io, out) {
|
|
|
279
344
|
out.count(`symlinks created in ${target}`, created.length);
|
|
280
345
|
for (const result of skipped)
|
|
281
346
|
out.done({ verb: 'skip', target: `symlink ${result.symlinkPath} (${result.message})` });
|
|
282
|
-
|
|
347
|
+
const links = results.map((result, index) => {
|
|
348
|
+
const base = { path: result.symlinkPath, destination: result.targetPath };
|
|
349
|
+
if (result.action === 'created')
|
|
350
|
+
return { ...base, change: plans.at(index) === 'create' ? 'create' : 'update' };
|
|
351
|
+
return { ...base, change: result.action === 'skipped' ? 'skip' : 'error', reason: result.message };
|
|
352
|
+
});
|
|
353
|
+
return { counts: [created.length, skipped.length, results.filter(result => result.action === 'error').length], links };
|
|
283
354
|
}
|
|
284
355
|
function runLink(input, io) {
|
|
285
356
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
@@ -287,21 +358,18 @@ function runLink(input, io) {
|
|
|
287
358
|
try {
|
|
288
359
|
ensureDevcontainerEnvironment();
|
|
289
360
|
const configFile = findWorktreeConfigFile(input.directory);
|
|
290
|
-
if (configFile === undefined)
|
|
291
|
-
out
|
|
292
|
-
return FAILURE;
|
|
293
|
-
}
|
|
361
|
+
if (configFile === undefined)
|
|
362
|
+
stopWith(out, hinted `worktree config not found\nrun: ${commandHint(['worktree', 'init'], { directory: placeholder('directory') })}`, 'not-initialized');
|
|
294
363
|
const config = loadConfig(configFile);
|
|
295
364
|
const mainWorktree = findMainWorktree(input.directory);
|
|
296
365
|
const projectRoot = detectProjectRoot(input.directory);
|
|
297
366
|
const resolved = linkTargets(input.directory, mainWorktree, input.all);
|
|
298
|
-
if (resolved.kind === 'main-needs-all')
|
|
299
|
-
out
|
|
300
|
-
return FAILURE;
|
|
301
|
-
}
|
|
367
|
+
if (resolved.kind === 'main-needs-all')
|
|
368
|
+
stopWith(out, hinted `use ${inputHint(['worktree', 'link'], 'all')} in the main worktree`, 'invalid-input');
|
|
302
369
|
const targets = resolved.directories;
|
|
303
370
|
if (targets.length === 0) {
|
|
304
371
|
out.count('sub-worktrees', 0);
|
|
372
|
+
out.result({ links: [] });
|
|
305
373
|
return 0;
|
|
306
374
|
}
|
|
307
375
|
const options = { force: input.force, all: input.all };
|
|
@@ -310,8 +378,12 @@ function runLink(input, io) {
|
|
|
310
378
|
return 0;
|
|
311
379
|
}
|
|
312
380
|
let [created, skipped, failed] = [0, 0, 0];
|
|
381
|
+
const links = [];
|
|
313
382
|
for (const target of targets) {
|
|
314
|
-
const
|
|
383
|
+
const applied = applyLinks(target, config, projectRoot, options, io, out);
|
|
384
|
+
const [targetCreated, targetSkipped, targetFailed] = applied.counts;
|
|
385
|
+
links.push(...applied.links);
|
|
386
|
+
out.result({ links: [...links] });
|
|
315
387
|
created += targetCreated;
|
|
316
388
|
skipped += targetSkipped;
|
|
317
389
|
failed += targetFailed;
|
|
@@ -324,10 +396,8 @@ function runLink(input, io) {
|
|
|
324
396
|
return 0;
|
|
325
397
|
}
|
|
326
398
|
catch (error) {
|
|
327
|
-
if (error instanceof WorktreeConfigError)
|
|
328
|
-
out
|
|
329
|
-
return FAILURE;
|
|
330
|
-
}
|
|
399
|
+
if (error instanceof WorktreeConfigError)
|
|
400
|
+
stopWith(out, error.message, 'config-invalid');
|
|
331
401
|
return reportRuntimeError(out, error);
|
|
332
402
|
}
|
|
333
403
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Progression, Wait } from './readiness.js';
|
|
2
|
+
import type { IssueReference } from './reference-parser.js';
|
|
3
|
+
import type { RepositoryReference } from './repository-resolver.js';
|
|
4
|
+
export interface BatchEntry {
|
|
5
|
+
readonly issue: string;
|
|
6
|
+
readonly wait: Wait;
|
|
7
|
+
readonly reason: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface BatchFile {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
代表のキー。suffix があれば suffix、無ければ幹
|
|
13
|
+
*/
|
|
14
|
+
readonly key: string;
|
|
15
|
+
/**
|
|
16
|
+
前提に書けるキーすべて(幹と suffix)
|
|
17
|
+
*/
|
|
18
|
+
readonly keys: readonly string[];
|
|
19
|
+
readonly blockedBy: readonly BatchEntry[];
|
|
20
|
+
}
|
|
21
|
+
export type PrerequisiteTarget = {
|
|
22
|
+
readonly kind: 'file';
|
|
23
|
+
readonly index: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'existing';
|
|
26
|
+
readonly reference: IssueReference;
|
|
27
|
+
};
|
|
28
|
+
export interface ResolvedPrerequisite {
|
|
29
|
+
readonly target: PrerequisiteTarget;
|
|
30
|
+
/**
|
|
31
|
+
進め方の判定に使うキー。ファイルは代表のキー、既存の Issue は issueReferenceKey
|
|
32
|
+
*/
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly wait: Wait;
|
|
35
|
+
readonly reason: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
export type BatchResolution = {
|
|
38
|
+
readonly kind: 'ok';
|
|
39
|
+
/**
|
|
40
|
+
ファイルごとの、書いた順の前提
|
|
41
|
+
*/
|
|
42
|
+
readonly prerequisites: readonly (readonly ResolvedPrerequisite[])[];
|
|
43
|
+
/**
|
|
44
|
+
キー(ファイルの代表のキー、既存の Issue は issueReferenceKey)→ 進め方
|
|
45
|
+
*/
|
|
46
|
+
readonly progressions: ReadonlyMap<string, Progression>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'error';
|
|
49
|
+
readonly message: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
前提を解決して確かめる。順は、知らないキー → 輪 → 後ろのファイル → 同じ相手を 2 回指す前提。
|
|
53
|
+
輪はファイルどうしの前提だけで探す(新しい Issue を前提に持つ既存の Issue は無い)
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveBatch(files: readonly BatchFile[]): BatchResolution;
|
|
56
|
+
export interface PlanRow {
|
|
57
|
+
readonly file: string;
|
|
58
|
+
/**
|
|
59
|
+
親 Epic の無いファイルは undefined
|
|
60
|
+
*/
|
|
61
|
+
readonly order: number | undefined;
|
|
62
|
+
readonly prerequisites: readonly ResolvedPrerequisite[];
|
|
63
|
+
readonly progression: Progression | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
`--plan` の表。列は File・Number・Blocked by・Approach。既存の Issue の表記は、一括の先頭のファイルのリポジトリ home を基準にする
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatPlanTable(rows: readonly PlanRow[], home: RepositoryReference): string;
|
|
69
|
+
/**
|
|
70
|
+
積める並び。キーを label で表記に直し、並びが無ければ undefined。並びは `Stackable chains:` の見出しと `- a -> b` の行にする
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatStackableChains(progressions: ReadonlyMap<string, Progression>, label: (key: string) => string): string | undefined;
|
|
73
|
+
//# sourceMappingURL=batch-plan.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// 一括投稿の前提の確認と、進め方の表(specs/024 の contracts/cli-commands.md の `pecot issue create`)。I/O を持たない。
|
|
2
|
+
import { displayReference, planProgression, stackChains } from './readiness.js';
|
|
3
|
+
import { issueReferenceKey, issueReferenceToCliReference, parseIssueReference, ReferenceParseError } from './reference-parser.js';
|
|
4
|
+
// `owner/repo/N` の形なら既存の Issue。これに当たらない値は、一括の中のファイルのキーとして探す
|
|
5
|
+
function existingReference(raw) {
|
|
6
|
+
try {
|
|
7
|
+
return parseIssueReference(raw);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof ReferenceParseError)
|
|
11
|
+
return undefined;
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// 前提の書いたキーを、一括の中のファイルか既存の Issue に解く。どちらでもないキーがあれば、その message を返す
|
|
16
|
+
function resolveTargets(files) {
|
|
17
|
+
const owners = new Map(files.flatMap((file, index) => file.keys.map((key) => [key, { index, key: file.key }])));
|
|
18
|
+
const prerequisites = [];
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const resolved = [];
|
|
21
|
+
for (const entry of file.blockedBy) {
|
|
22
|
+
const reference = existingReference(entry.issue);
|
|
23
|
+
const owner = owners.get(entry.issue);
|
|
24
|
+
if (reference !== undefined)
|
|
25
|
+
resolved.push({ target: { kind: 'existing', reference }, key: issueReferenceKey(reference), wait: entry.wait, reason: entry.reason });
|
|
26
|
+
else if (owner === undefined)
|
|
27
|
+
return { message: `blocked_by in ${file.name} refers to unknown key ${entry.issue}` };
|
|
28
|
+
else
|
|
29
|
+
resolved.push({ target: { kind: 'file', index: owner.index }, key: owner.key, wait: entry.wait, reason: entry.reason });
|
|
30
|
+
}
|
|
31
|
+
prerequisites.push(resolved);
|
|
32
|
+
}
|
|
33
|
+
return { prerequisites };
|
|
34
|
+
}
|
|
35
|
+
// 前提を書いたキーの表記。ファイルは代表のキー、既存の Issue は `owner/repo/N`
|
|
36
|
+
function targetLabel({ target, key }) {
|
|
37
|
+
return target.kind === 'file' ? key : issueReferenceToCliReference(target.reference);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
前提を解決して確かめる。順は、知らないキー → 輪 → 後ろのファイル → 同じ相手を 2 回指す前提。
|
|
41
|
+
輪はファイルどうしの前提だけで探す(新しい Issue を前提に持つ既存の Issue は無い)
|
|
42
|
+
*/
|
|
43
|
+
export function resolveBatch(files) {
|
|
44
|
+
const resolved = resolveTargets(files);
|
|
45
|
+
if ('message' in resolved)
|
|
46
|
+
return { kind: 'error', message: resolved.message };
|
|
47
|
+
const { prerequisites } = resolved;
|
|
48
|
+
const plan = planProgression(files.map((file, index) => ({
|
|
49
|
+
key: file.key,
|
|
50
|
+
prerequisites: (prerequisites.at(index) ?? []).map(({ key, wait }) => ({ key, wait })),
|
|
51
|
+
})));
|
|
52
|
+
if (plan.kind === 'cycle')
|
|
53
|
+
return { kind: 'error', message: `blocked_by forms a cycle: ${plan.cycle.join(' -> ')}` };
|
|
54
|
+
for (const [index, file] of files.entries()) {
|
|
55
|
+
const own = prerequisites.at(index) ?? [];
|
|
56
|
+
const later = own.find(({ target }) => target.kind === 'file' && target.index > index);
|
|
57
|
+
if (later !== undefined)
|
|
58
|
+
return { kind: 'error', message: `blocked_by in ${file.name} refers to ${targetLabel(later)}, which comes later` };
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
for (const prerequisite of own) {
|
|
61
|
+
if (seen.has(prerequisite.key))
|
|
62
|
+
return { kind: 'error', message: `blocked_by in ${file.name} refers to ${targetLabel(prerequisite)} more than once` };
|
|
63
|
+
seen.add(prerequisite.key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { kind: 'ok', prerequisites, progressions: plan.progressions };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
進め方の表に出すキーの表記。ファイルは代表のキー、既存の Issue は home と同じリポジトリなら `#N`、別なら `owner/repo#N`
|
|
70
|
+
*/
|
|
71
|
+
function displayTarget({ target, key }, home) {
|
|
72
|
+
return target.kind === 'file' ? key : displayReference(target.reference, home);
|
|
73
|
+
}
|
|
74
|
+
function approachOf(row, labelOf) {
|
|
75
|
+
const { progression } = row;
|
|
76
|
+
switch (progression?.kind) {
|
|
77
|
+
case undefined:
|
|
78
|
+
case 'alone': {
|
|
79
|
+
return 'alone';
|
|
80
|
+
}
|
|
81
|
+
case 'wait-merge': {
|
|
82
|
+
return `wait for merge of ${row.prerequisites.filter(({ wait }) => wait === 'merge').map(prerequisite => labelOf(prerequisite)).join(', ')}`;
|
|
83
|
+
}
|
|
84
|
+
case 'join': {
|
|
85
|
+
return `join (wait for ${row.prerequisites.map(prerequisite => labelOf(prerequisite)).join(', ')})`;
|
|
86
|
+
}
|
|
87
|
+
case 'stack': {
|
|
88
|
+
const on = row.prerequisites.find(({ key }) => key === progression.on);
|
|
89
|
+
return `stack on ${on === undefined ? progression.on : labelOf(on)}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
`--plan` の表。列は File・Number・Blocked by・Approach。既存の Issue の表記は、一括の先頭のファイルのリポジトリ home を基準にする
|
|
95
|
+
*/
|
|
96
|
+
export function formatPlanTable(rows, home) {
|
|
97
|
+
const lines = ['| File | Number | Blocked by | Approach |', '|---|---|---|---|'];
|
|
98
|
+
const labelOf = (prerequisite) => displayTarget(prerequisite, home);
|
|
99
|
+
for (const row of rows) {
|
|
100
|
+
const blockedBy = row.prerequisites.length === 0
|
|
101
|
+
? '-'
|
|
102
|
+
: row.prerequisites.map(prerequisite => `${labelOf(prerequisite)}${prerequisite.wait === 'merge' ? ' (merge)' : ''}`).join(', ');
|
|
103
|
+
lines.push(`| ${row.file} | ${row.order === undefined ? '-' : String(row.order)} | ${blockedBy} | ${approachOf(row, labelOf)} |`);
|
|
104
|
+
}
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
積める並び。キーを label で表記に直し、並びが無ければ undefined。並びは `Stackable chains:` の見出しと `- a -> b` の行にする
|
|
109
|
+
*/
|
|
110
|
+
export function formatStackableChains(progressions, label) {
|
|
111
|
+
const chains = stackChains(progressions).filter(chain => chain.length >= 2);
|
|
112
|
+
return chains.length === 0 ? undefined : ['Stackable chains:', ...chains.map(chain => `- ${chain.map(key => label(key)).join(' -> ')}`)].join('\n');
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=batch-plan.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { BlockedByReferences } from './issue-readout.js';
|
|
2
|
+
import type { Prerequisite, Wait } from './readiness.js';
|
|
3
|
+
import type { IssueReference } from './reference-parser.js';
|
|
4
|
+
import type { RepositoryReference } from './repository-resolver.js';
|
|
5
|
+
export type BlockDecision = {
|
|
6
|
+
readonly kind: 'malformed';
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'unchanged';
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'add' | 'update';
|
|
12
|
+
readonly body: string;
|
|
13
|
+
};
|
|
14
|
+
export interface BlockInput {
|
|
15
|
+
readonly body: string;
|
|
16
|
+
/**
|
|
17
|
+
待つ側の Issue のリポジトリ。本文の `#N` が指す先
|
|
18
|
+
*/
|
|
19
|
+
readonly home: RepositoryReference;
|
|
20
|
+
readonly by: IssueReference;
|
|
21
|
+
readonly wait: Wait;
|
|
22
|
+
/**
|
|
23
|
+
wait が merge のときの理由
|
|
24
|
+
*/
|
|
25
|
+
readonly reason: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
by が、すでに blocked by に付いている
|
|
28
|
+
*/
|
|
29
|
+
readonly isLinked: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
付ける・種類を変える・何もしないのどれにするかと、書く本文を決める。
|
|
33
|
+
節が読めないときは本文を書き換えられないので malformed を返す
|
|
34
|
+
*/
|
|
35
|
+
export declare function decideBlock(input: Readonly<BlockInput>): BlockDecision;
|
|
36
|
+
export type UnblockDecision = {
|
|
37
|
+
readonly kind: 'unchanged';
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'remove';
|
|
40
|
+
readonly body: string;
|
|
41
|
+
/**
|
|
42
|
+
節が読めないときの理由。このとき body は元のまま
|
|
43
|
+
*/
|
|
44
|
+
readonly malformedReason: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
export interface UnblockInput {
|
|
47
|
+
readonly body: string;
|
|
48
|
+
readonly home: RepositoryReference;
|
|
49
|
+
readonly by: IssueReference;
|
|
50
|
+
readonly isLinked: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
外すか何もしないかを決める。付いていなければ、節に古い行が残っていても本文は書き換えない
|
|
54
|
+
*/
|
|
55
|
+
export declare function decideUnblock(input: Readonly<UnblockInput>): UnblockDecision;
|
|
56
|
+
export type ReadBlockedByLevel = (ids: readonly string[]) => Promise<ReadonlyMap<string, BlockedByReferences>>;
|
|
57
|
+
export interface CycleSearchInput {
|
|
58
|
+
readonly target: IssueReference;
|
|
59
|
+
readonly by: IssueReference;
|
|
60
|
+
readonly byId: string;
|
|
61
|
+
readonly read: ReadBlockedByLevel;
|
|
62
|
+
/**
|
|
63
|
+
たどる Issue の数の上限(by を含む)
|
|
64
|
+
*/
|
|
65
|
+
readonly limit: number;
|
|
66
|
+
}
|
|
67
|
+
export type CycleSearchResult = {
|
|
68
|
+
readonly kind: 'cycle';
|
|
69
|
+
readonly path: readonly IssueReference[];
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'none';
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: 'unverifiable';
|
|
74
|
+
readonly reason: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
by から blocked by を 1 段ずつたどり、target に戻れば輪として道(target → by → … → target)を返す。
|
|
78
|
+
読めない Issue・件数の不足・上限は unverifiable。GitHub は 3 つ以上の輪を通すので、確かめずに付けない
|
|
79
|
+
*/
|
|
80
|
+
export declare function searchCycle(input: Readonly<CycleSearchInput>): Promise<CycleSearchResult>;
|
|
81
|
+
export interface ExpectedPrerequisites {
|
|
82
|
+
/**
|
|
83
|
+
書いた後の前提のキー(issueReferenceKey)
|
|
84
|
+
*/
|
|
85
|
+
readonly keys: ReadonlySet<string>;
|
|
86
|
+
readonly by: IssueReference;
|
|
87
|
+
/**
|
|
88
|
+
by の種類と理由。外したときは undefined
|
|
89
|
+
*/
|
|
90
|
+
readonly wait: {
|
|
91
|
+
readonly wait: Wait;
|
|
92
|
+
readonly reason: string | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
書いた後の読み直しが、書いた内容と一致するか。GitHub は書いた直後の読み取りの一致を保証しない
|
|
97
|
+
*/
|
|
98
|
+
export declare function hasExpectedPrerequisites(prerequisites: readonly Prerequisite[], expected: Readonly<ExpectedPrerequisites>): boolean;
|
|
99
|
+
//# sourceMappingURL=blocked-by-change.d.ts.map
|