@pecot/workflow-mcp 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +80 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +59 -0
- package/cli/dist/commands/board-judgment.d.ts +60 -0
- package/cli/dist/commands/board-judgment.js +144 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +57 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +72 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +111 -0
- package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
- package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +100 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +20 -6
- package/cli/dist/commands/command-definition.js +11 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +34 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +33 -0
- package/cli/dist/commands/issue-board.js +61 -1
- package/cli/dist/commands/issue-comment.js +47 -28
- package/cli/dist/commands/issue-create.js +548 -91
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +282 -0
- package/cli/dist/commands/issue-readiness.d.ts +94 -0
- package/cli/dist/commands/issue-readiness.js +218 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +115 -0
- package/cli/dist/commands/issue-shared.d.ts +32 -19
- package/cli/dist/commands/issue-shared.js +82 -75
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +169 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +62 -0
- package/cli/dist/commands/output.d.ts +14 -2
- package/cli/dist/commands/output.js +14 -7
- package/cli/dist/commands/pr-waiting.d.ts +20 -0
- package/cli/dist/commands/pr-waiting.js +106 -0
- package/cli/dist/commands/pr.d.ts +19 -0
- package/cli/dist/commands/pr.js +242 -323
- package/cli/dist/commands/project-sync.d.ts +2 -1
- package/cli/dist/commands/project-sync.js +18 -9
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +212 -175
- package/cli/dist/commands/registry.js +13 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +53 -114
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +3 -2
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +267 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/{repository.js → session-start.js} +99 -128
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +82 -29
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
- package/cli/dist/commands/tracker-sync.d.ts +7 -0
- package/cli/dist/commands/tracker-sync.js +3 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +18 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +12 -3
- package/cli/dist/commands/work-target.js +46 -5
- package/cli/dist/commands/worktree.js +32 -28
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -0
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +27 -0
- package/cli/dist/domain/readiness.js +114 -3
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +30 -0
- package/cli/dist/domain/state.js +39 -0
- package/cli/dist/domain/work-start.d.ts +34 -0
- package/cli/dist/domain/work-start.js +49 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +12 -0
- package/cli/dist/infra/git.js +13 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +24 -0
- package/cli/dist/infra/github/pulls.js +56 -0
- package/cli/dist/infra/github/queries.d.ts +12 -4
- package/cli/dist/infra/github/queries.js +156 -8
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -0
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +34 -6
- package/cli/dist/mcp/result.js +62 -18
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +24 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/issue/bug.md +1 -1
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +1 -1
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// コマンド定義の一覧。CLI と MCP の両方がこの一覧から作られる。
|
|
2
|
+
// 各コマンドは defineCommand() で定義して、グループのファイルの一覧に足す。定義の型と defineCommand は command-definition.ts にあり、ここから再公開する。
|
|
3
|
+
import { BOARD_COMMANDS } from './board.js';
|
|
4
|
+
import { BRANCH_COMMANDS } from './branch.js';
|
|
5
|
+
import { registerCommandHints } from './command-hint.js';
|
|
6
|
+
import { ISSUE_COMMANDS } from './issue.js';
|
|
3
7
|
import { PR_COMMANDS } from './pr.js';
|
|
4
8
|
import { PROJECT_COMMANDS } from './project.js';
|
|
5
9
|
import { RELEASE_COMMANDS } from './release.js';
|
|
6
|
-
import { REPOSITORY_COMMANDS } from './repository.js';
|
|
7
|
-
import { SECURITY_COMMANDS } from './security.js';
|
|
8
10
|
import { SESSION_COMMANDS } from './session.js';
|
|
11
|
+
import { TRACKER_COMMANDS } from './tracker.js';
|
|
9
12
|
import { WORKTREE_COMMANDS } from './worktree.js';
|
|
10
13
|
export { defineCommand, toolNameOf } from './command-definition.js';
|
|
11
|
-
// 並びは
|
|
14
|
+
// 並びは help の一覧の順で、names.ts の COMMAND_GROUPS の順に合わせる
|
|
12
15
|
export const COMMANDS = [
|
|
13
|
-
...ISSUE_BOARD_COMMANDS,
|
|
14
|
-
...REPOSITORY_COMMANDS,
|
|
15
16
|
...PROJECT_COMMANDS,
|
|
17
|
+
...BOARD_COMMANDS,
|
|
16
18
|
...ISSUE_COMMANDS,
|
|
17
|
-
...PR_COMMANDS,
|
|
18
19
|
...SESSION_COMMANDS,
|
|
20
|
+
...PR_COMMANDS,
|
|
19
21
|
...RELEASE_COMMANDS,
|
|
20
|
-
...
|
|
21
|
-
...DEPENDABOT_COMMANDS,
|
|
22
|
+
...TRACKER_COMMANDS,
|
|
22
23
|
...WORKTREE_COMMANDS,
|
|
24
|
+
...BRANCH_COMMANDS,
|
|
23
25
|
];
|
|
26
|
+
registerCommandHints(COMMANDS);
|
|
24
27
|
export function findCommand(path, commands = COMMANDS) {
|
|
25
28
|
return commands.find(command => command.path.join(' ') === path.join(' '));
|
|
26
29
|
}
|
|
@@ -2,9 +2,9 @@ import type { RepositoryReference } from '../domain/repository-resolver.js';
|
|
|
2
2
|
import type { Output } from './output.js';
|
|
3
3
|
import type { CommandDefinition } from './command-definition.js';
|
|
4
4
|
/**
|
|
5
|
-
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error
|
|
5
|
+
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error の行を出して終了コード 1 で止める。
|
|
6
6
|
remote は process.cwd() から読む
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function requireReleaseTargetRepository(adopted: RepositoryReference | undefined, explicit: string | undefined, out: Readonly<Output>): RepositoryReference;
|
|
9
9
|
export declare const RELEASE_COMMANDS: readonly CommandDefinition[];
|
|
10
10
|
//# sourceMappingURL=release.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// release
|
|
1
|
+
// release check・create・merge。移す元は cli/commands/release.py。
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { describeApiError } from '../domain/api-error-detail.js';
|
|
@@ -18,90 +18,58 @@ import { TransportFailure } from '../infra/github/client.js';
|
|
|
18
18
|
import { createDependabotSource } from '../infra/github/dependabot-source.js';
|
|
19
19
|
import { GitHubAPIError, GitHubNotFoundError } from '../infra/github/errors.js';
|
|
20
20
|
import { createScanAlertSource } from '../infra/github/security-alerts-source.js';
|
|
21
|
-
import {
|
|
21
|
+
import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './command-hint.js';
|
|
22
|
+
import { NO_ACTIVE_PROJECT, stopWith } from './command-stop.js';
|
|
23
|
+
import { kindOfFailure } from './failure.js';
|
|
22
24
|
import { createGitHubClient, makeClient } from './github-client.js';
|
|
23
25
|
import { createOutput } from './output.js';
|
|
24
|
-
import { defineCommand } from './command-definition.js';
|
|
26
|
+
import { CommandExit, defineCommand } from './command-definition.js';
|
|
25
27
|
import { requireRepositoryMatch } from './repository-match.js';
|
|
26
28
|
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
27
|
-
const
|
|
29
|
+
const CHECK_PATH = ['release', 'check'];
|
|
28
30
|
/**
|
|
29
|
-
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error
|
|
31
|
+
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error の行を出して終了コード 1 で止める。
|
|
30
32
|
remote は process.cwd() から読む
|
|
31
33
|
*/
|
|
32
|
-
export function
|
|
34
|
+
export function requireReleaseTargetRepository(adopted, explicit, out) {
|
|
33
35
|
if (adopted !== undefined)
|
|
34
36
|
return adopted;
|
|
35
37
|
if (explicit !== undefined) {
|
|
36
|
-
|
|
37
|
-
if (parts === undefined) {
|
|
38
|
-
out.error(`invalid --repo format: ${pythonStringRepr(explicit)}\nspecify it as owner/repo`);
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return parts;
|
|
42
|
-
}
|
|
43
|
-
const remote = primaryRemoteRepository(process.cwd());
|
|
44
|
-
if (remote === undefined) {
|
|
45
|
-
out.error('could not read the repository from the git remote');
|
|
46
|
-
return undefined;
|
|
38
|
+
return splitOwnerRepository(explicit) ?? stopWith(out, hinted `invalid ${inputNameHint(CHECK_PATH, 'repo')} format: ${pythonStringRepr(explicit)}\nspecify it as owner/repo`, 'invalid-input');
|
|
47
39
|
}
|
|
40
|
+
const remote = primaryRemoteRepository(process.cwd()) ?? stopWith(out, 'could not read the repository from the git remote', 'git-unresolved');
|
|
48
41
|
return { owner: remote.owner, repository: remote.repository };
|
|
49
42
|
}
|
|
50
|
-
// 4 つの場合(packages の有無と --package の有無)を分ける。矛盾があれば error
|
|
43
|
+
// 4 つの場合(packages の有無と --package の有無)を分ける。矛盾があれば error の行を出して止める
|
|
51
44
|
function resolvePackageContext(out, repositoryConfig, packageName, gitRoot, owner, repository) {
|
|
52
45
|
const packages = repositoryConfig?.packages ?? [];
|
|
53
46
|
if (repositoryConfig !== undefined && packages.length > 0) {
|
|
54
47
|
const names = packages.map(item => item.name).join(', ');
|
|
55
|
-
if (packageName === undefined)
|
|
56
|
-
out
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const found = findPackage(repositoryConfig, packageName);
|
|
60
|
-
if (found === undefined) {
|
|
61
|
-
out.error(`package '${packageName}' is not registered in ${owner}/${repository}\navailable: ${names}`);
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
48
|
+
if (packageName === undefined)
|
|
49
|
+
stopWith(out, hinted `${owner}/${repository} is a monorepo\nspecify ${inputNameHint(['release', 'check'], 'package')} (available: ${names})`, 'invalid-input');
|
|
50
|
+
const found = findPackage(repositoryConfig, packageName) ?? stopWith(out, `package '${packageName}' is not registered in ${owner}/${repository}\navailable: ${names}`, 'invalid-input');
|
|
64
51
|
return { changelogPath: path.isAbsolute(found.changelog) ? found.changelog : path.join(gitRoot, found.changelog), tagPrefix: found.name };
|
|
65
52
|
}
|
|
66
|
-
if (packageName !== undefined)
|
|
67
|
-
out
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
53
|
+
if (packageName !== undefined)
|
|
54
|
+
stopWith(out, `${owner}/${repository} has no packages configured\n--package can only be used in a monorepo`, 'invalid-input');
|
|
70
55
|
return { changelogPath: resolveChangelogPath(gitRoot, repositoryConfig?.changelog_file), tagPrefix: undefined };
|
|
71
56
|
}
|
|
72
57
|
function requireBranchSetting(out, branch, kind, owner, repository) {
|
|
73
|
-
|
|
74
|
-
out.error(`${kind}_branch is not set for ${owner}/${repository}\nset it with: pecot project set-repo ${owner}/${repository} --${kind}-branch <branch>`);
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
return branch;
|
|
58
|
+
return branch === undefined || branch === '' ? stopWith(out, hinted `${kind}_branch is not set for ${owner}/${repository}\nset it with: ${commandHint(['project', 'link'], { repo: `${owner}/${repository}`, [`${kind}_branch`]: placeholder('branch') })}`, 'repo-setting-missing') : branch;
|
|
78
59
|
}
|
|
79
60
|
function loadReleaseContext(out, adopted, explicit, packageName, options = {}) {
|
|
80
61
|
const cwd = process.cwd();
|
|
81
|
-
const gitRoot = gitToplevel({ cwd });
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
const target = resolveReleaseTargetRepository(adopted, explicit, out);
|
|
87
|
-
if (target === undefined)
|
|
88
|
-
return undefined;
|
|
89
|
-
const { owner, repository } = target;
|
|
90
|
-
const config = loadActiveConfig();
|
|
91
|
-
if (config === undefined) {
|
|
92
|
-
out.error(NO_ACTIVE_PROJECT);
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
62
|
+
const gitRoot = gitToplevel({ cwd }) ?? stopWith(out, 'could not find the root directory of the git repository', 'git-unresolved');
|
|
63
|
+
const { owner, repository } = requireReleaseTargetRepository(adopted, explicit, out);
|
|
64
|
+
const config = loadActiveConfig() ?? stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
|
|
95
65
|
const repositoryConfig = findRepository(config, owner, repository);
|
|
96
66
|
if (repositoryConfig !== undefined && options.nxAlertsOnly === true && effectiveReleaseType(repositoryConfig) === 'nx') {
|
|
97
67
|
if (packageName !== undefined || options.version !== undefined) {
|
|
98
|
-
out
|
|
99
|
-
return undefined;
|
|
68
|
+
stopWith(out, hinted `the version argument and ${inputNameHint(CHECK_PATH, 'package')} cannot be used when release_type is nx\nrun it without arguments (Nx Release decides the version)`, 'invalid-input');
|
|
100
69
|
}
|
|
101
70
|
return { config, owner, repository, repositoryConfig, changelogPath: resolveChangelogPath(gitRoot, repositoryConfig.changelog_file), tagPrefix: undefined };
|
|
102
71
|
}
|
|
103
|
-
|
|
104
|
-
return resolved === undefined ? undefined : { config, owner, repository, repositoryConfig, ...resolved };
|
|
72
|
+
return { config, owner, repository, repositoryConfig, ...resolvePackageContext(out, repositoryConfig, packageName, gitRoot, owner, repository) };
|
|
105
73
|
}
|
|
106
74
|
function alertLabel(number, packageName, severity) {
|
|
107
75
|
const detail = [packageName, severity].filter(value => value !== undefined && value !== '').join(', ');
|
|
@@ -131,7 +99,7 @@ async function checkDependabotAlerts(out, config, owner, repository) {
|
|
|
131
99
|
throw error;
|
|
132
100
|
}
|
|
133
101
|
if (!status.enabled) {
|
|
134
|
-
out.done({ verb: 'skip', target: 'Dependabot alerts (feature disabled)' });
|
|
102
|
+
out.done({ verb: 'skip', target: 'Dependabot alerts (feature disabled)', aside: true });
|
|
135
103
|
return;
|
|
136
104
|
}
|
|
137
105
|
if (status.openCount === 0) {
|
|
@@ -158,7 +126,7 @@ async function isScanningPassed(out, name, fetchStatus) {
|
|
|
158
126
|
return false;
|
|
159
127
|
}
|
|
160
128
|
if (!status.enabled) {
|
|
161
|
-
out.done({ verb: 'skip', target: `${name} (feature disabled)
|
|
129
|
+
out.done({ verb: 'skip', target: `${name} (feature disabled)`, aside: true });
|
|
162
130
|
return true;
|
|
163
131
|
}
|
|
164
132
|
if (status.openCount === 0) {
|
|
@@ -196,9 +164,9 @@ async function areAlertsPassed(out, config, owner, repository) {
|
|
|
196
164
|
}
|
|
197
165
|
return isPassed;
|
|
198
166
|
}
|
|
199
|
-
const
|
|
200
|
-
path:
|
|
201
|
-
description: 'Run the pre-release checks
|
|
167
|
+
const releaseCheckCommand = defineCommand({
|
|
168
|
+
path: CHECK_PATH,
|
|
169
|
+
description: 'Run the pre-release checks; for an nx repository only the alerts are checked',
|
|
202
170
|
input: z.object({
|
|
203
171
|
version: z.string().optional().describe('Release version (detected from the CHANGELOG when omitted)'),
|
|
204
172
|
package: z.string().optional().describe('Package name in a monorepo (required for repositories with packages configured)'),
|
|
@@ -210,23 +178,18 @@ const preflight = defineCommand({
|
|
|
210
178
|
const out = createOutput(false, io);
|
|
211
179
|
const cwd = process.cwd();
|
|
212
180
|
const context = loadReleaseContext(out, adopted, input.repo, input.package, { version: input.version, nxAlertsOnly: true });
|
|
213
|
-
if (context === undefined)
|
|
214
|
-
return FAILURE;
|
|
215
181
|
const { config, owner, repository } = context;
|
|
216
182
|
const isAlertsPassed = await areAlertsPassed(out, config, owner, repository);
|
|
217
183
|
if (!isAlertsPassed)
|
|
218
|
-
|
|
184
|
+
throw new CommandExit(1, 'preflight-failed');
|
|
219
185
|
if (context.repositoryConfig !== undefined && effectiveReleaseType(context.repositoryConfig) === 'nx')
|
|
220
186
|
return 0;
|
|
221
187
|
const developBranch = requireBranchSetting(out, getDevelopBranch(config, owner, repository), 'develop', owner, repository);
|
|
222
|
-
if (developBranch === undefined)
|
|
223
|
-
return FAILURE;
|
|
224
188
|
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
225
|
-
if (releaseBranch === undefined)
|
|
226
|
-
return FAILURE;
|
|
227
189
|
const remote = primaryRemoteName(cwd) ?? 'origin';
|
|
228
190
|
try {
|
|
229
|
-
const
|
|
191
|
+
const client = createGitHubClient(out, config.host);
|
|
192
|
+
const result = await runPreflight({
|
|
230
193
|
changelogPath: context.changelogPath,
|
|
231
194
|
changelogContent: readChangelogIfExists(context.changelogPath),
|
|
232
195
|
developBranch,
|
|
@@ -234,20 +197,22 @@ const preflight = defineCommand({
|
|
|
234
197
|
version: input.version,
|
|
235
198
|
tagPrefix: context.tagPrefix,
|
|
236
199
|
remote,
|
|
237
|
-
}, gitRunnerFor(cwd));
|
|
200
|
+
}, gitRunnerFor(cwd), async (base, head) => await client.countCommitsAhead(owner, repository, base, head));
|
|
238
201
|
out.count(`commits to release (${remote}/${result.developBranch} -> ${remote}/${result.releaseBranch})`, result.diffCount);
|
|
239
202
|
out.data(`version: ${result.version}\ntag: ${result.tagName}\n\n${result.releaseNotes}`);
|
|
240
203
|
return 0;
|
|
241
204
|
}
|
|
242
205
|
catch (error) {
|
|
206
|
+
if (error instanceof GitHubAPIError || error instanceof TransportFailure) {
|
|
207
|
+
return stopWith(out, `could not count the commits from ${releaseBranch} to ${developBranch}: ${error.message}`, kindOfFailure(error));
|
|
208
|
+
}
|
|
243
209
|
if (!(error instanceof ReleaseError))
|
|
244
210
|
throw error;
|
|
245
|
-
out
|
|
246
|
-
return FAILURE;
|
|
211
|
+
return stopWith(out, error.message, 'preflight-failed');
|
|
247
212
|
}
|
|
248
213
|
},
|
|
249
214
|
});
|
|
250
|
-
const
|
|
215
|
+
const releaseCreateCommand = defineCommand({
|
|
251
216
|
path: ['release', 'create'],
|
|
252
217
|
description: 'Create a GitHub release and its tag (the release notes come from the CHANGELOG)',
|
|
253
218
|
input: z.object({
|
|
@@ -266,12 +231,9 @@ const create = defineCommand({
|
|
|
266
231
|
catch (error) {
|
|
267
232
|
if (!(error instanceof InvalidVersionError))
|
|
268
233
|
throw error;
|
|
269
|
-
out
|
|
270
|
-
return FAILURE;
|
|
234
|
+
return stopWith(out, error.message, 'invalid-input');
|
|
271
235
|
}
|
|
272
236
|
const context = loadReleaseContext(out, adopted, input.repo, input.package);
|
|
273
|
-
if (context === undefined)
|
|
274
|
-
return FAILURE;
|
|
275
237
|
const { config, owner, repository, tagPrefix } = context;
|
|
276
238
|
let releaseNotes;
|
|
277
239
|
try {
|
|
@@ -280,12 +242,9 @@ const create = defineCommand({
|
|
|
280
242
|
catch (error) {
|
|
281
243
|
if (!(error instanceof PecotError) && !(error instanceof ChangelogFileNotFoundError))
|
|
282
244
|
throw error;
|
|
283
|
-
out
|
|
284
|
-
return FAILURE;
|
|
245
|
+
return stopWith(out, error.message, 'preflight-failed');
|
|
285
246
|
}
|
|
286
247
|
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
287
|
-
if (releaseBranch === undefined)
|
|
288
|
-
return FAILURE;
|
|
289
248
|
const tagName = tagPrefix === undefined ? `v${input.version}` : `${tagPrefix}-v${input.version}`;
|
|
290
249
|
const releaseName = tagPrefix === undefined ? tagName : `${tagPrefix} v${input.version}`;
|
|
291
250
|
const operation = { verb: 'create', target: `release ${tagName} on ${releaseBranch}` };
|
|
@@ -295,8 +254,6 @@ const create = defineCommand({
|
|
|
295
254
|
return 0;
|
|
296
255
|
}
|
|
297
256
|
const client = makeClient(out, config);
|
|
298
|
-
if (client === undefined)
|
|
299
|
-
return FAILURE;
|
|
300
257
|
try {
|
|
301
258
|
const result = await client.createRelease(owner, repository, tagName, releaseName, releaseNotes, { targetCommitish: releaseBranch });
|
|
302
259
|
out.done(operation);
|
|
@@ -307,12 +264,11 @@ const create = defineCommand({
|
|
|
307
264
|
catch (error) {
|
|
308
265
|
if (!(error instanceof GitHubAPIError))
|
|
309
266
|
throw error;
|
|
310
|
-
out
|
|
311
|
-
return FAILURE;
|
|
267
|
+
return stopWith(out, `could not create release ${tagName} in ${owner}/${repository}: ${describeApiError(error)}`, kindOfFailure(error));
|
|
312
268
|
}
|
|
313
269
|
},
|
|
314
270
|
});
|
|
315
|
-
const
|
|
271
|
+
const releaseMergeCommand = defineCommand({
|
|
316
272
|
path: ['release', 'merge'],
|
|
317
273
|
description: 'Merge a release PR with a regular merge',
|
|
318
274
|
input: z.object({
|
|
@@ -327,11 +283,7 @@ const merge = defineCommand({
|
|
|
327
283
|
run: async (input, io) => {
|
|
328
284
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
329
285
|
const out = createOutput(input.dry_run, io);
|
|
330
|
-
const config = loadActiveConfig();
|
|
331
|
-
if (config === undefined) {
|
|
332
|
-
out.error(NO_ACTIVE_PROJECT);
|
|
333
|
-
return FAILURE;
|
|
334
|
-
}
|
|
286
|
+
const config = loadActiveConfig() ?? stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
|
|
335
287
|
let reference;
|
|
336
288
|
try {
|
|
337
289
|
reference = parsePullRequestReference(input.pr_ref);
|
|
@@ -339,8 +291,7 @@ const merge = defineCommand({
|
|
|
339
291
|
catch (error) {
|
|
340
292
|
if (!(error instanceof ReferenceParseError))
|
|
341
293
|
throw error;
|
|
342
|
-
out
|
|
343
|
-
return USAGE_EXIT_CODE;
|
|
294
|
+
return stopWith(out, error.message, 'invalid-input', USAGE_EXIT_CODE);
|
|
344
295
|
}
|
|
345
296
|
const { owner, repository } = reference.repository;
|
|
346
297
|
const number = reference.number;
|
|
@@ -352,33 +303,22 @@ const merge = defineCommand({
|
|
|
352
303
|
pullRequest = await client.getPullRequestSlim(owner, repository, number);
|
|
353
304
|
}
|
|
354
305
|
catch (error) {
|
|
355
|
-
if (error instanceof GitHubNotFoundError)
|
|
356
|
-
out
|
|
357
|
-
return FAILURE;
|
|
358
|
-
}
|
|
306
|
+
if (error instanceof GitHubNotFoundError)
|
|
307
|
+
return stopWith(out, `PR ${pullRequestName} not found`, 'github-not-found');
|
|
359
308
|
if (!(error instanceof GitHubAPIError))
|
|
360
309
|
throw error;
|
|
361
|
-
out
|
|
362
|
-
return FAILURE;
|
|
363
|
-
}
|
|
364
|
-
if (pullRequest.state === 'MERGED') {
|
|
365
|
-
out.error(`PR #${String(number)} is already merged`);
|
|
366
|
-
return FAILURE;
|
|
367
|
-
}
|
|
368
|
-
if (pullRequest.state === 'CLOSED') {
|
|
369
|
-
out.error(`PR #${String(number)} is closed`);
|
|
370
|
-
return FAILURE;
|
|
310
|
+
return stopWith(out, `could not read PR ${pullRequestName}: ${describeApiError(error)}`, kindOfFailure(error));
|
|
371
311
|
}
|
|
312
|
+
if (pullRequest.state === 'MERGED')
|
|
313
|
+
stopWith(out, `PR #${String(number)} is already merged`, 'pr-state');
|
|
314
|
+
else if (pullRequest.state === 'CLOSED')
|
|
315
|
+
stopWith(out, `PR #${String(number)} is closed`, 'pr-state');
|
|
372
316
|
if (pullRequest.mergeable === 'CONFLICTING' && !input.admin) {
|
|
373
|
-
out
|
|
374
|
-
return FAILURE;
|
|
317
|
+
stopWith(out, hinted `PR #${String(number)} has conflicts that must be resolved\nto try a forced merge, add ${inputHint(['release', 'merge'], 'admin')}`, 'pr-state');
|
|
375
318
|
}
|
|
376
319
|
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
377
|
-
if (releaseBranch === undefined)
|
|
378
|
-
return FAILURE;
|
|
379
320
|
if (pullRequest.base_ref !== releaseBranch) {
|
|
380
|
-
out
|
|
381
|
-
return FAILURE;
|
|
321
|
+
stopWith(out, `the base branch of PR #${String(number)} does not match release_branch\nbase: ${pullRequest.base_ref}\nrelease_branch: ${releaseBranch}`, 'pr-state');
|
|
382
322
|
}
|
|
383
323
|
const headBranch = pullRequest.head_ref;
|
|
384
324
|
const operation = { verb: 'merge', target: `PR ${pullRequestName} (${headBranch} -> ${pullRequest.base_ref}, merge commit)` };
|
|
@@ -392,8 +332,7 @@ const merge = defineCommand({
|
|
|
392
332
|
catch (error) {
|
|
393
333
|
if (!(error instanceof GitHubAPIError))
|
|
394
334
|
throw error;
|
|
395
|
-
out
|
|
396
|
-
return FAILURE;
|
|
335
|
+
return stopWith(out, `could not merge PR ${pullRequestName}: ${describeApiError(error)}`, kindOfFailure(error));
|
|
397
336
|
}
|
|
398
337
|
out.done(operation);
|
|
399
338
|
if (input.delete_branch) {
|
|
@@ -410,5 +349,5 @@ const merge = defineCommand({
|
|
|
410
349
|
return 0;
|
|
411
350
|
},
|
|
412
351
|
});
|
|
413
|
-
export const RELEASE_COMMANDS = [
|
|
352
|
+
export const RELEASE_COMMANDS = [releaseCheckCommand, releaseCreateCommand, releaseMergeCommand];
|
|
414
353
|
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
古い名前から新しい名前への表。キーは main のコマンド名で、値は今の名前
|
|
3
|
+
*/
|
|
4
|
+
export declare const RENAMED_COMMANDS: ReadonlyMap<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
解決が止まった path の古い名前と新しい名前。`dependabot` のように 1 語目で止まったときは、その語で始まる古い名前を返す。無ければ undefined
|
|
7
|
+
*/
|
|
8
|
+
export declare function findRenamedCommand(path: readonly string[]): readonly [string, string] | undefined;
|
|
9
|
+
/**
|
|
10
|
+
古い入力名。command はコマンド名、oldName は古い入力名、newName は今の入力名
|
|
11
|
+
*/
|
|
12
|
+
export interface RenamedInput {
|
|
13
|
+
readonly command: string;
|
|
14
|
+
readonly oldName: string;
|
|
15
|
+
readonly newName: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const RENAMED_INPUTS: readonly RenamedInput[];
|
|
18
|
+
/**
|
|
19
|
+
path のコマンドの古い入力名 name の、今の入力名。無ければ undefined
|
|
20
|
+
*/
|
|
21
|
+
export declare function findRenamedInput(path: readonly string[], name: string): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
誤りの文に添える、古い名前から今の名前への案内
|
|
24
|
+
*/
|
|
25
|
+
export declare function renamedInputNote(oldName: string, newName: string): string;
|
|
26
|
+
//# sourceMappingURL=renamed-commands.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// #412・#428 で変えた main の古いコマンド名と入力名。CLI と MCP が案内に使い、skills のテストが古い名前を拾うのに使う。次の major で消す
|
|
2
|
+
/**
|
|
3
|
+
古い名前から新しい名前への表。キーは main のコマンド名で、値は今の名前
|
|
4
|
+
*/
|
|
5
|
+
export const RENAMED_COMMANDS = new Map([
|
|
6
|
+
['add-to-project', 'board add'],
|
|
7
|
+
['update-issue-status', 'board move'],
|
|
8
|
+
['create-branch', 'session start'],
|
|
9
|
+
['delete-branch', 'branch delete'],
|
|
10
|
+
['dependabot sync', 'tracker sync dependabot'],
|
|
11
|
+
['security sync', 'tracker sync security'],
|
|
12
|
+
['project info', 'board show'],
|
|
13
|
+
['project set-repo', 'project link'],
|
|
14
|
+
['project set-aggregation-repo', 'project set aggregation_repo'],
|
|
15
|
+
['project unset-aggregation-repo', 'project unset aggregation_repo'],
|
|
16
|
+
['project show-aggregation-repo', 'project get aggregation_repo'],
|
|
17
|
+
['issue read', 'issue show'],
|
|
18
|
+
['pr read', 'pr show'],
|
|
19
|
+
['pr preflight', 'pr check'],
|
|
20
|
+
['pr cleanup', 'session finish'],
|
|
21
|
+
['release preflight', 'release check'],
|
|
22
|
+
['session status', 'session show'],
|
|
23
|
+
['issue quick', 'issue create --freeform'],
|
|
24
|
+
]);
|
|
25
|
+
/**
|
|
26
|
+
解決が止まった path の古い名前と新しい名前。`dependabot` のように 1 語目で止まったときは、その語で始まる古い名前を返す。無ければ undefined
|
|
27
|
+
*/
|
|
28
|
+
export function findRenamedCommand(path) {
|
|
29
|
+
const prefix = path.join(' ');
|
|
30
|
+
return [...RENAMED_COMMANDS].find(([oldName]) => oldName === prefix || oldName.startsWith(`${prefix} `));
|
|
31
|
+
}
|
|
32
|
+
export const RENAMED_INPUTS = [
|
|
33
|
+
{ command: 'issue comment', oldName: 'issue', newName: 'issue_ref' },
|
|
34
|
+
{ command: 'session restore', oldName: 'issue', newName: 'issue_ref' },
|
|
35
|
+
{ command: 'branch delete', oldName: 'repo_ref', newName: 'repo' },
|
|
36
|
+
{ command: 'project link', oldName: 'owner_repo', newName: 'repo' },
|
|
37
|
+
{ command: 'session start', oldName: 'branch_name', newName: 'branch' },
|
|
38
|
+
{ command: 'issue create', oldName: 'plan', newName: 'dry_run' },
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
path のコマンドの古い入力名 name の、今の入力名。無ければ undefined
|
|
42
|
+
*/
|
|
43
|
+
export function findRenamedInput(path, name) {
|
|
44
|
+
const command = path.join(' ');
|
|
45
|
+
return RENAMED_INPUTS.find(entry => entry.command === command && entry.oldName === name)?.newName;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
誤りの文に添える、古い名前から今の名前への案内
|
|
49
|
+
*/
|
|
50
|
+
export function renamedInputNote(oldName, newName) {
|
|
51
|
+
return ` ('${oldName}' was renamed to '${newName}')`;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=renamed-commands.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// グローバルの `--repo` と、今の git remote のリポジトリの食い違いを扱う(Python の `require_repo_match`)。
|
|
2
2
|
// 判定は domain/repository-policy.ts の applyRepositoryPolicy に任せ、ここは git の解決と行の出力、止めるときの終了コードだけを行う。
|
|
3
|
+
import { formatHinted } from '../domain/command-hint.js';
|
|
3
4
|
import { applyRepositoryPolicy } from '../domain/repository-policy.js';
|
|
4
5
|
import { AmbiguousRepositoryError, resolveRepository } from '../domain/repository-resolver.js';
|
|
5
6
|
import { gitRunnerFor } from '../infra/git.js';
|
|
@@ -25,9 +26,9 @@ export function resolveCurrentRepository(cwd) {
|
|
|
25
26
|
export function requireRepositoryMatch(mode, explicit, io, cwd) {
|
|
26
27
|
const outcome = applyRepositoryPolicy({ explicit, resolved: resolveCurrentRepository(cwd), mode });
|
|
27
28
|
for (const line of outcome.stderr)
|
|
28
|
-
io.stderr(`${line}\n`);
|
|
29
|
+
io.stderr(`${formatHinted(line, io.surface ?? 'cli')}\n`);
|
|
29
30
|
if (outcome.kind === 'exit')
|
|
30
|
-
throw new CommandExit(outcome.exitCode);
|
|
31
|
+
throw new CommandExit(outcome.exitCode, outcome.failure);
|
|
31
32
|
return outcome.adopted;
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=repository-match.js.map
|