@pecot/workflow-mcp 7.0.1-dev.27 → 7.0.1-dev.29
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/cli/dist/cli.js +2 -2
- package/cli/dist/commands/issue-shared.js +3 -17
- package/cli/dist/commands/pr-reference.js +4 -14
- package/cli/dist/commands/repository-match.d.ts +6 -2
- package/cli/dist/commands/repository-match.js +11 -11
- package/cli/dist/domain/repository-policy.d.ts +3 -3
- package/cli/dist/domain/repository-policy.js +17 -4
- package/cli/dist/domain/repository-resolver.d.ts +30 -7
- package/cli/dist/domain/repository-resolver.js +64 -25
- package/cli/dist/infra/worktree.d.ts +1 -1
- package/cli/dist/infra/worktree.js +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/cli/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { realpathSync } from 'node:fs';
|
|
16
16
|
import { pathToFileURL } from 'node:url';
|
|
17
17
|
import { InvalidValueError } from './domain/errors.js';
|
|
18
|
-
import { AmbiguousRepositoryError, parseOwnerRepository, resolveRepository } from './domain/repository-resolver.js';
|
|
18
|
+
import { AmbiguousRepositoryError, parseOwnerRepository, resolveRepository, UnreadableRemoteError } from './domain/repository-resolver.js';
|
|
19
19
|
import { readAuthoredNotes } from './infra/authored-notes.js';
|
|
20
20
|
import { gitRunnerFor } from './infra/git.js';
|
|
21
21
|
import { resolveApiUrlOverride } from './infra/github/client.js';
|
|
@@ -87,7 +87,7 @@ function showRepository(repository, context) {
|
|
|
87
87
|
// eslint-disable-next-line no-restricted-syntax -- CLI の最上位でグローバルの --repo を読むときだけ出る
|
|
88
88
|
if (error instanceof InvalidValueError)
|
|
89
89
|
context.io.stderr(`error: --repo: ${error.message}\n`);
|
|
90
|
-
else if (error instanceof AmbiguousRepositoryError)
|
|
90
|
+
else if (error instanceof AmbiguousRepositoryError || error instanceof UnreadableRemoteError)
|
|
91
91
|
context.io.stderr(`error: ${error.message}\n`);
|
|
92
92
|
else
|
|
93
93
|
throw error;
|
|
@@ -12,7 +12,7 @@ import { CommandExit } from './command-definition.js';
|
|
|
12
12
|
import { planOrders, usedOrdersOf } from '../domain/issue-order.js';
|
|
13
13
|
import { pythonStrip } from '../domain/python-format.js';
|
|
14
14
|
import { issueReferenceToCliReference, parseIssueReference, ReferenceParseError } from '../domain/reference-parser.js';
|
|
15
|
-
import {
|
|
15
|
+
import { createRepositoryReference, resolveShortReferenceBase, withUnreadableReason } from '../domain/repository-resolver.js';
|
|
16
16
|
import { CLOSED_HEADINGS_BY_TEMPLATE, FOLD_SUMMARY_BY_TEMPLATE, validateBodyStyle, validateClosedHeadings, validateFoldBalance, validateFoldSummaries, validateHeadingSummaries, validateSections, } from '../domain/sections.js';
|
|
17
17
|
import { gitRunnerFor } from '../infra/git.js';
|
|
18
18
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
@@ -90,31 +90,17 @@ export function issuePath(owner, repository, number) {
|
|
|
90
90
|
return `${owner}/${repository}/${String(number)}`;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
グローバルの --repo(run の入力の repo)か、カレントの git から base のリポジトリを決める。
|
|
94
|
-
曖昧なら undefined(`owner/repo/N` の主軸形を使う利用者のため)。--repo の形式が不正なら InvalidValueError を伝える
|
|
95
|
-
*/
|
|
96
|
-
function resolveBaseRepository(repository) {
|
|
97
|
-
try {
|
|
98
|
-
return resolveRepository(repository, gitRunnerFor()).repository;
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
if (error instanceof AmbiguousRepositoryError)
|
|
102
|
-
return undefined;
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
93
|
Issue 参照(`owner/repo/N` または短縮形 `N`)を分ける。不正、または base が決まらない短縮形なら BadParameterError
|
|
108
94
|
*/
|
|
109
95
|
function parseIssueReferenceFromContext(repository, raw) {
|
|
110
|
-
const base =
|
|
96
|
+
const { base, unreadable } = resolveShortReferenceBase(repository, gitRunnerFor());
|
|
111
97
|
try {
|
|
112
98
|
const reference = parseIssueReference(raw, base, { repositoryFlag: true });
|
|
113
99
|
return { owner: reference.repository.owner, repository: reference.repository.repository, number: reference.number };
|
|
114
100
|
}
|
|
115
101
|
catch (error) {
|
|
116
102
|
if (error instanceof ReferenceParseError)
|
|
117
|
-
throw new BadParameterError(error.hintedText ?? error.message);
|
|
103
|
+
throw new BadParameterError(withUnreadableReason(error.hintedText ?? error.message, unreadable));
|
|
118
104
|
throw error;
|
|
119
105
|
}
|
|
120
106
|
}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
// PR の参照(pr_ref)の読み方。pr show・pr merge・session finish が共有する。
|
|
2
2
|
import { ReferenceParseError, parsePullRequestReference } from '../domain/reference-parser.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveShortReferenceBase, withUnreadableReason } from '../domain/repository-resolver.js';
|
|
4
4
|
import { gitRunnerFor } from '../infra/git.js';
|
|
5
5
|
import { stopWith } from './command-stop.js';
|
|
6
6
|
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
7
7
|
export const PR_REFERENCE_DESCRIPTION = 'PR reference (`owner/repo/N`, or the short form `N` in the repository of `--repo`, or else of the git remote of the current directory)';
|
|
8
|
-
// グローバルの --repo か、いまの git の repository。決められなければ undefined
|
|
9
|
-
function resolveBaseRepository(globalRepository) {
|
|
10
|
-
try {
|
|
11
|
-
return resolveRepository(globalRepository, gitRunnerFor(process.cwd())).repository;
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
if (error instanceof AmbiguousRepositoryError)
|
|
15
|
-
return undefined;
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
8
|
export function parseReference(reference, globalRepository, out) {
|
|
9
|
+
const { base, unreadable } = resolveShortReferenceBase(globalRepository, gitRunnerFor(process.cwd()));
|
|
20
10
|
try {
|
|
21
|
-
const parsed = parsePullRequestReference(reference,
|
|
11
|
+
const parsed = parsePullRequestReference(reference, base, { repositoryFlag: true });
|
|
22
12
|
return { owner: parsed.repository.owner, repository: parsed.repository.repository, number: parsed.number };
|
|
23
13
|
}
|
|
24
14
|
catch (error) {
|
|
25
15
|
if (error instanceof ReferenceParseError)
|
|
26
|
-
return stopWith(out, error.hintedText ?? error.message, 'invalid-input', USAGE_EXIT_CODE);
|
|
16
|
+
return stopWith(out, withUnreadableReason(error.hintedText ?? error.message, unreadable), 'invalid-input', USAGE_EXIT_CODE);
|
|
27
17
|
throw error;
|
|
28
18
|
}
|
|
29
19
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { PolicyMode } from '../domain/repository-policy.js';
|
|
2
|
-
import type { RepositoryReference, ResolvedRepository } from '../domain/repository-resolver.js';
|
|
2
|
+
import type { RepositoryReference, ResolvedRepository, UnreadableRemote } from '../domain/repository-resolver.js';
|
|
3
3
|
import type { CommandIo } from './command-definition.js';
|
|
4
4
|
/**
|
|
5
|
-
今の git remote
|
|
5
|
+
今の git remote を読む。git の外・remote 無しは undefined、URL から owner/repo を読めなければ UnreadableRemote
|
|
6
|
+
*/
|
|
7
|
+
export declare function readCurrentRepository(cwd: string): ResolvedRepository | UnreadableRemote | undefined;
|
|
8
|
+
/**
|
|
9
|
+
今の git remote からリポジトリを解決する。git の外・remote 無し・URL から owner/repo を読めないときは undefined
|
|
6
10
|
*/
|
|
7
11
|
export declare function resolveCurrentRepository(cwd: string): ResolvedRepository | undefined;
|
|
8
12
|
/**
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
// 判定は domain/repository-policy.ts の applyRepositoryPolicy に任せ、ここは git の解決と行の出力、止めるときの終了コードだけを行う。
|
|
3
3
|
import { formatHinted } from '../domain/command-hint.js';
|
|
4
4
|
import { AMBIGUOUS_REPOSITORY_LINE, applyRepositoryPolicy } from '../domain/repository-policy.js';
|
|
5
|
-
import {
|
|
5
|
+
import { readCurrentGitRemote } from '../domain/repository-resolver.js';
|
|
6
6
|
import { gitRunnerFor, listRemotes } from '../infra/git.js';
|
|
7
7
|
import { CommandExit } from './command-definition.js';
|
|
8
8
|
import { WARNING_PREFIX } from './output.js';
|
|
9
9
|
/**
|
|
10
|
-
今の git remote
|
|
10
|
+
今の git remote を読む。git の外・remote 無しは undefined、URL から owner/repo を読めなければ UnreadableRemote
|
|
11
|
+
*/
|
|
12
|
+
export function readCurrentRepository(cwd) {
|
|
13
|
+
return readCurrentGitRemote(gitRunnerFor(cwd));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
今の git remote からリポジトリを解決する。git の外・remote 無し・URL から owner/repo を読めないときは undefined
|
|
11
17
|
*/
|
|
12
18
|
export function resolveCurrentRepository(cwd) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (error instanceof AmbiguousRepositoryError)
|
|
18
|
-
return undefined;
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
19
|
+
const current = readCurrentRepository(cwd);
|
|
20
|
+
return current?.source === 'unreadable-remote' ? undefined : current;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
`--repo` と今の git remote を方針(reject か warn)に従って比べる。
|
|
@@ -25,7 +25,7 @@ export function resolveCurrentRepository(cwd) {
|
|
|
25
25
|
止めるときは、stderr に行を書いて CommandExit(1) を投げる。warn の警告は stderr に書いて続ける
|
|
26
26
|
*/
|
|
27
27
|
export function requireRepositoryMatch(mode, explicit, io, cwd) {
|
|
28
|
-
const outcome = applyRepositoryPolicy({ explicit, resolved:
|
|
28
|
+
const outcome = applyRepositoryPolicy({ explicit, resolved: readCurrentRepository(cwd), mode });
|
|
29
29
|
writeLines(io, outcome.stderr);
|
|
30
30
|
if (outcome.kind === 'exit')
|
|
31
31
|
throw new CommandExit(outcome.exitCode, outcome.failure);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HintedText } from './command-hint.js';
|
|
2
|
-
import type { RepositoryReference, ResolvedRepository } from './repository-resolver.js';
|
|
2
|
+
import type { RepositoryReference, ResolvedRepository, UnreadableRemote } from './repository-resolver.js';
|
|
3
3
|
export type PolicyMode = 'reject' | 'warn';
|
|
4
4
|
/**
|
|
5
5
|
今の git remote からリポジトリを決められないときの 1 行目。branch delete の remote の確認も同じ行を出す
|
|
@@ -11,9 +11,9 @@ export interface PolicyInput {
|
|
|
11
11
|
*/
|
|
12
12
|
readonly explicit: string | undefined;
|
|
13
13
|
/**
|
|
14
|
-
カレント Git remote
|
|
14
|
+
カレント Git remote からの解決結果。git の外・remote 無しは undefined
|
|
15
15
|
*/
|
|
16
|
-
readonly resolved: ResolvedRepository | undefined;
|
|
16
|
+
readonly resolved: ResolvedRepository | UnreadableRemote | undefined;
|
|
17
17
|
readonly mode: PolicyMode;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
// 1. --repo を指定しない場合
|
|
9
9
|
// - カレント Git remote を解決できたら続行する(採用値なし)。
|
|
10
10
|
// - 解決できなければ「リポジトリが曖昧です」で終了コード 1。
|
|
11
|
+
// remote の URL から owner/repo を読めないときは、その理由の行を添える。
|
|
11
12
|
// 2. --repo を指定した場合
|
|
12
13
|
// - 形式が不正なら終了コード 1。
|
|
13
14
|
// - カレント Git remote が無い場合(Git 外・remote 無し)は、比較できないので明示値を採用して続行する。
|
|
15
|
+
// - remote の URL から owner/repo を読めない場合も比較できない。reject・warn とも警告を出して明示値を採用して続行する。
|
|
14
16
|
// - 一致なら明示値を採用して続行する。
|
|
15
17
|
// - 不一致で reject は終了コード 1、warn は警告を出して明示値を採用して続行する。
|
|
16
18
|
//
|
|
@@ -18,7 +20,7 @@
|
|
|
18
20
|
import { globalRepositoryHint, hinted, placeholder } from './command-hint.js';
|
|
19
21
|
import { InvalidValueError } from './errors.js';
|
|
20
22
|
import { pythonStringRepr } from './python-format.js';
|
|
21
|
-
import { parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
|
|
23
|
+
import { parseOwnerRepository, repositoryFullName, unreadableRemoteReason } from './repository-resolver.js';
|
|
22
24
|
/**
|
|
23
25
|
今の git remote からリポジトリを決められないときの 1 行目。branch delete の remote の確認も同じ行を出す
|
|
24
26
|
*/
|
|
@@ -42,13 +44,24 @@ function parseExplicit(explicit) {
|
|
|
42
44
|
export function applyRepositoryPolicy(input) {
|
|
43
45
|
const { explicit, resolved, mode } = input;
|
|
44
46
|
if (explicit === undefined) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const giveRepository = hinted ` give ${globalRepositoryHint(placeholder('owner/repo'))}`;
|
|
48
|
+
if (resolved === undefined)
|
|
49
|
+
return exitWith('git-unresolved', AMBIGUOUS_REPOSITORY_LINE, giveRepository);
|
|
50
|
+
if (resolved.source === 'unreadable-remote') {
|
|
51
|
+
return exitWith('git-unresolved', AMBIGUOUS_REPOSITORY_LINE, ` ${unreadableRemoteReason(resolved)}`, giveRepository);
|
|
52
|
+
}
|
|
53
|
+
return { kind: 'proceed', adopted: undefined, stderr: [] };
|
|
48
54
|
}
|
|
49
55
|
const explicitReference = parseExplicit(explicit);
|
|
50
56
|
if (explicitReference === undefined)
|
|
51
57
|
return exitWith('invalid-input', hinted `error: ${globalRepositoryHint()} has an invalid form: ${pythonStringRepr(explicit)}`);
|
|
58
|
+
if (resolved?.source === 'unreadable-remote') {
|
|
59
|
+
return {
|
|
60
|
+
kind: 'proceed',
|
|
61
|
+
adopted: explicitReference,
|
|
62
|
+
stderr: [hinted `warning: using ${globalRepositoryHint()} ${repositoryFullName(explicitReference)} (${unreadableRemoteReason(resolved)})`],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
52
65
|
// Git 外 / remote 不在は比較対象が無いので、明示値を採用する
|
|
53
66
|
if (resolved?.source !== 'current-git')
|
|
54
67
|
return { kind: 'proceed', adopted: explicitReference, stderr: [] };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HintedText } from './command-hint.js';
|
|
1
2
|
import { PecotError } from './errors.js';
|
|
2
3
|
import type { GitRunner } from './git-runner.js';
|
|
3
4
|
export interface RepositoryReference {
|
|
@@ -42,16 +43,38 @@ remote 名の一覧から主の remote を選ぶ(origin、無ければ最初
|
|
|
42
43
|
*/
|
|
43
44
|
export declare function pickPrimaryRemote(remotes: readonly string[]): string | undefined;
|
|
44
45
|
/**
|
|
45
|
-
|
|
46
|
-
URL の形式が不正なときは、InvalidValueError をそのまま伝える(バグ扱い)。
|
|
47
|
-
Python の `_detect_current_git_repo` と同じで、不正なら undefined を返す infra/git.ts の remoteRepository とは契約が違う
|
|
46
|
+
主の remote はあるが、その URL から `owner/repo` を読めないこと
|
|
48
47
|
*/
|
|
49
|
-
export
|
|
50
|
-
readonly
|
|
48
|
+
export interface UnreadableRemote {
|
|
49
|
+
readonly source: 'unreadable-remote';
|
|
51
50
|
readonly remoteName: string;
|
|
52
|
-
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
remote の URL から owner/repo を読めない理由の文
|
|
54
|
+
*/
|
|
55
|
+
export declare function unreadableRemoteReason(remote: UnreadableRemote): string;
|
|
56
|
+
/**
|
|
57
|
+
remote の URL から owner/repo を読めず、リポジトリを決められないこと。message は理由の文
|
|
58
|
+
*/
|
|
59
|
+
export declare class UnreadableRemoteError extends PecotError {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
git の remote を読む。git の外・remote 無しは undefined、URL から `owner/repo` を読めなければ UnreadableRemote
|
|
63
|
+
*/
|
|
64
|
+
export declare function readCurrentGitRemote(git: GitRunner): ResolvedRepository | UnreadableRemote | undefined;
|
|
65
|
+
/**
|
|
66
|
+
短い参照を補うリポジトリ(決められなければ base は undefined)と、remote の URL を読めなかったこと。明示値の形が不正なら InvalidValueError
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveShortReferenceBase(explicit: string | undefined, git: GitRunner): {
|
|
69
|
+
readonly base: RepositoryReference | undefined;
|
|
70
|
+
readonly unreadable: UnreadableRemote | undefined;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
短い参照の案内に、remote の URL を読めなかった理由の行を足す
|
|
74
|
+
*/
|
|
75
|
+
export declare function withUnreadableReason(text: string | HintedText, unreadable: UnreadableRemote | undefined): string | HintedText;
|
|
53
76
|
/**
|
|
54
|
-
リポジトリを解決する。明示値があれば git
|
|
77
|
+
リポジトリを解決する。明示値があれば git を呼ばずにそれを使う。remote の URL を読めなければ UnreadableRemoteError
|
|
55
78
|
*/
|
|
56
79
|
export declare function resolveRepository(explicit: string | undefined, git: GitRunner): ResolvedRepository;
|
|
57
80
|
//# sourceMappingURL=repository-resolver.d.ts.map
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// 決定木:
|
|
4
|
-
// 1. 明示値(--repo)があれば、それを owner/repo として使う(source=explicit)。
|
|
5
|
-
// 2. git のワークツリー内なら、origin の URL から取る(source=current-git)。
|
|
6
|
-
// origin が無ければ、先頭の remote を使う。
|
|
7
|
-
// 3. どちらも成り立たなければ、AmbiguousRepositoryError を投げる。
|
|
8
|
-
//
|
|
9
|
-
// 検証エラーの文は、Python の CLI の書式に揃える。
|
|
10
|
-
// 表題は元のクラス名(RepoRef・ResolvedRepo)を使う。
|
|
1
|
+
// リポジトリ解決: --repo、無ければ git の origin(無ければ先頭の remote)、どちらも無ければ AmbiguousRepositoryError。
|
|
2
|
+
// 検証エラーの文は Python の CLI の書式(表題は RepoRef・ResolvedRepo)に揃える。
|
|
11
3
|
import { formatHinted, globalRepositoryHint, hinted, placeholder } from './command-hint.js';
|
|
12
4
|
import { PecotError, InvalidValueError } from './errors.js';
|
|
13
|
-
import { parseRemoteUrl } from './git-url.js';
|
|
5
|
+
import { parseRemoteUrl, RemoteUrlFormatError } from './git-url.js';
|
|
14
6
|
import { pythonStringRepr, ValidationFailure } from './python-format.js';
|
|
15
7
|
const SEGMENT_PATTERN = /^[\w.-]+$/u;
|
|
16
8
|
export class AmbiguousRepositoryError extends PecotError {
|
|
@@ -82,12 +74,8 @@ remote 名の一覧から主の remote を選ぶ(origin、無ければ最初
|
|
|
82
74
|
export function pickPrimaryRemote(remotes) {
|
|
83
75
|
return remotes.includes('origin') ? 'origin' : remotes[0];
|
|
84
76
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
URL の形式が不正なときは、InvalidValueError をそのまま伝える(バグ扱い)。
|
|
88
|
-
Python の `_detect_current_git_repo` と同じで、不正なら undefined を返す infra/git.ts の remoteRepository とは契約が違う
|
|
89
|
-
*/
|
|
90
|
-
export function detectCurrentGitRepository(git) {
|
|
77
|
+
// 主の remote の名前と URL。git の外・remote 無し・URL を取れないときは undefined
|
|
78
|
+
function readPrimaryRemoteUrl(git) {
|
|
91
79
|
const inside = git(['rev-parse', '--is-inside-work-tree']);
|
|
92
80
|
if (inside.exitCode !== 0 || inside.stdout.trim() !== 'true')
|
|
93
81
|
return undefined;
|
|
@@ -99,22 +87,73 @@ export function detectCurrentGitRepository(git) {
|
|
|
99
87
|
if (remoteName === undefined)
|
|
100
88
|
return undefined;
|
|
101
89
|
const url = git(['remote', 'get-url', remoteName]);
|
|
102
|
-
|
|
90
|
+
return url.exitCode === 0 ? { remoteName, url: url.stdout.trim() } : undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
remote の URL から owner/repo を読めない理由の文
|
|
94
|
+
*/
|
|
95
|
+
export function unreadableRemoteReason(remote) {
|
|
96
|
+
return `could not read the repository from the URL of the Git remote ${remote.remoteName}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
remote の URL から owner/repo を読めず、リポジトリを決められないこと。message は理由の文
|
|
100
|
+
*/
|
|
101
|
+
export class UnreadableRemoteError extends PecotError {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
git の remote を読む。git の外・remote 無しは undefined、URL から `owner/repo` を読めなければ UnreadableRemote
|
|
105
|
+
*/
|
|
106
|
+
export function readCurrentGitRemote(git) {
|
|
107
|
+
const primary = readPrimaryRemoteUrl(git);
|
|
108
|
+
if (primary === undefined)
|
|
103
109
|
return undefined;
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
let location;
|
|
111
|
+
try {
|
|
112
|
+
location = parseRemoteUrl(primary.url);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof RemoteUrlFormatError)
|
|
116
|
+
return { source: 'unreadable-remote', remoteName: primary.remoteName };
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
return createResolvedRepository({
|
|
120
|
+
repository: createRepositoryReference(location.owner, location.repository),
|
|
121
|
+
source: 'current-git',
|
|
122
|
+
remoteName: primary.remoteName,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
短い参照を補うリポジトリ(決められなければ base は undefined)と、remote の URL を読めなかったこと。明示値の形が不正なら InvalidValueError
|
|
127
|
+
*/
|
|
128
|
+
export function resolveShortReferenceBase(explicit, git) {
|
|
129
|
+
if (explicit !== undefined)
|
|
130
|
+
return { base: parseOwnerRepository(explicit), unreadable: undefined };
|
|
131
|
+
const current = readCurrentGitRemote(git);
|
|
132
|
+
return current?.source === 'unreadable-remote'
|
|
133
|
+
? { base: undefined, unreadable: current }
|
|
134
|
+
: { base: current?.repository, unreadable: undefined };
|
|
106
135
|
}
|
|
107
136
|
/**
|
|
108
|
-
|
|
137
|
+
短い参照の案内に、remote の URL を読めなかった理由の行を足す
|
|
138
|
+
*/
|
|
139
|
+
export function withUnreadableReason(text, unreadable) {
|
|
140
|
+
if (unreadable === undefined)
|
|
141
|
+
return text;
|
|
142
|
+
const reason = `\n${unreadableRemoteReason(unreadable)}`;
|
|
143
|
+
return typeof text === 'string' ? text + reason : [...text, reason];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
リポジトリを解決する。明示値があれば git を呼ばずにそれを使う。remote の URL を読めなければ UnreadableRemoteError
|
|
109
147
|
*/
|
|
110
148
|
export function resolveRepository(explicit, git) {
|
|
111
149
|
if (explicit !== undefined) {
|
|
112
150
|
return createResolvedRepository({ repository: parseOwnerRepository(explicit), source: 'explicit', remoteName: undefined });
|
|
113
151
|
}
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
152
|
+
const current = readCurrentGitRemote(git);
|
|
153
|
+
if (current?.source === 'unreadable-remote')
|
|
154
|
+
throw new UnreadableRemoteError(unreadableRemoteReason(current));
|
|
155
|
+
if (current !== undefined)
|
|
156
|
+
return current;
|
|
118
157
|
// 文を出すのは CLI の最上位(src/cli.ts)だけ。ほかの呼び手は捕まえて undefined にする
|
|
119
158
|
const repositoryHint = globalRepositoryHint(placeholder('owner/repo'));
|
|
120
159
|
throw new AmbiguousRepositoryError(formatHinted(hinted `repository is ambiguous: pass ${repositoryHint}`, 'cli'));
|
|
@@ -8,7 +8,7 @@ import type { SetupResult } from './worktree-setup.js';
|
|
|
8
8
|
/**
|
|
9
9
|
WorktreeRuntimeError の原因の名前。commands の FailureKind の一部
|
|
10
10
|
*/
|
|
11
|
-
export type WorktreeFailure = 'config-invalid' | 'no-active-project' | 'not-initialized' | 'other' | 'repo-not-in-project' | 'repo-setting-missing';
|
|
11
|
+
export type WorktreeFailure = 'config-invalid' | 'git-unresolved' | 'no-active-project' | 'not-initialized' | 'other' | 'repo-not-in-project' | 'repo-setting-missing';
|
|
12
12
|
/**
|
|
13
13
|
ワークツリー操作に失敗した(Python の RuntimeError に当たる)。メッセージは利用者に見せる文
|
|
14
14
|
*/
|
|
@@ -338,7 +338,7 @@ function loadCopyExcludeSpecOrRaise(mainWorktree, diagnostics) {
|
|
|
338
338
|
function requireRegisteredRepository(cwd) {
|
|
339
339
|
const candidates = readRemoteCandidates(cwd);
|
|
340
340
|
if (candidates.length === 0)
|
|
341
|
-
throw new WorktreeRuntimeError(NO_REMOTE_MESSAGE);
|
|
341
|
+
throw new WorktreeRuntimeError(NO_REMOTE_MESSAGE, { failure: 'git-unresolved' });
|
|
342
342
|
const config = loadActiveConfig();
|
|
343
343
|
if (config === undefined) {
|
|
344
344
|
throw new WorktreeRuntimeError(hinted `project config not found\n hint: run ${commandHint(['project', 'activate'], { project: placeholder('PROJECT') })} to set the project`, { failure: 'no-active-project' });
|
|
@@ -350,7 +350,7 @@ function requireRegisteredRepository(cwd) {
|
|
|
350
350
|
}
|
|
351
351
|
const repository = candidates[0]?.repository;
|
|
352
352
|
if (repository === undefined)
|
|
353
|
-
throw new WorktreeRuntimeError(NO_REMOTE_MESSAGE);
|
|
353
|
+
throw new WorktreeRuntimeError(NO_REMOTE_MESSAGE, { failure: 'git-unresolved' });
|
|
354
354
|
const registered = config.repositories.length > 0
|
|
355
355
|
? config.repositories.map(item => ` - ${item.owner}/${item.name}`).join('\n')
|
|
356
356
|
: ' (none registered)';
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/workflow-mcp",
|
|
3
|
-
"version": "7.0.1-dev.
|
|
3
|
+
"version": "7.0.1-dev.29",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "7.0.1-dev.
|
|
9
|
+
"version": "7.0.1-dev.29",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|