@pecot/workflow-mcp 7.0.0 → 7.0.1-dev.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/cli/dist/commands/branch.js +3 -20
- package/cli/dist/commands/issue-board.d.ts +1 -1
- package/cli/dist/commands/issue-board.js +1 -1
- package/cli/dist/commands/issue-create.js +7 -11
- package/cli/dist/commands/issue-dependency.js +21 -12
- package/cli/dist/commands/issue-shared.d.ts +8 -2
- package/cli/dist/commands/issue-shared.js +22 -4
- package/cli/dist/commands/names.d.ts +1 -1
- package/cli/dist/commands/names.js +2 -3
- package/cli/dist/commands/pr-merge.js +9 -14
- package/cli/dist/commands/pr-restack.js +47 -22
- package/cli/dist/commands/pr.js +84 -56
- package/cli/dist/commands/project.js +2 -2
- package/cli/dist/commands/renamed-commands.js +0 -1
- package/cli/dist/commands/repository-match.d.ts +6 -0
- package/cli/dist/commands/repository-match.js +20 -6
- package/cli/dist/commands/restack-reading.d.ts +45 -0
- package/cli/dist/commands/restack-reading.js +43 -0
- package/cli/dist/commands/session-finish.js +6 -18
- package/cli/dist/commands/session-start.js +10 -55
- package/cli/dist/commands/session.js +52 -169
- package/cli/dist/commands/work-target.d.ts +5 -8
- package/cli/dist/commands/work-target.js +17 -19
- package/cli/dist/domain/branch-name.d.ts +7 -0
- package/cli/dist/domain/branch-name.js +23 -1
- package/cli/dist/domain/command-hint.d.ts +1 -1
- package/cli/dist/domain/pull-request.d.ts +20 -2
- package/cli/dist/domain/pull-request.js +26 -9
- package/cli/dist/domain/repository-policy.d.ts +4 -0
- package/cli/dist/domain/repository-policy.js +5 -1
- package/cli/dist/domain/restack.d.ts +11 -0
- package/cli/dist/domain/restack.js +6 -1
- package/cli/dist/domain/state.d.ts +2 -12
- package/cli/dist/domain/state.js +3 -14
- package/cli/dist/infra/git.d.ts +13 -0
- package/cli/dist/infra/git.js +19 -0
- package/cli/dist/infra/paths.d.ts +1 -3
- package/cli/dist/infra/paths.js +2 -45
- package/cli/dist/infra/state-store.d.ts +3 -8
- package/cli/dist/infra/state-store.js +6 -24
- package/cli/templates/workflow/pecot-board-sync.yml +3 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { HintedText } from './command-hint.js';
|
|
|
2
2
|
import type { PullRequestReadout } from './issue-readout.js';
|
|
3
3
|
import type { SectionHeading } from './sections.js';
|
|
4
4
|
import type { BaseReading } from './state.js';
|
|
5
|
+
import type { RestackDecision } from './restack.js';
|
|
5
6
|
export declare const SCREENSHOT_MISSING_ERROR: HintedText;
|
|
6
7
|
/**
|
|
7
8
|
本文の Closes / Fixes / Resolves に続く Issue 番号を、出てきた順に重複なしで返す
|
|
@@ -166,7 +167,7 @@ export declare function formatPullRequestWithReviewsMarkdown(pr: PullRequestWith
|
|
|
166
167
|
export interface PreflightWarning {
|
|
167
168
|
readonly label: string;
|
|
168
169
|
readonly message: string;
|
|
169
|
-
readonly fixHint:
|
|
170
|
+
readonly fixHint: HintedText;
|
|
170
171
|
}
|
|
171
172
|
/**
|
|
172
173
|
`git status` の出力に変更があるか。空・取得失敗の印・「nothing to commit」かつ「working tree clean」は無し
|
|
@@ -179,16 +180,33 @@ export declare function hasStashEntries(stashList: string): boolean;
|
|
|
179
180
|
export interface PushStatus {
|
|
180
181
|
readonly isPushed: boolean;
|
|
181
182
|
readonly message: string;
|
|
183
|
+
/**
|
|
184
|
+
手元と remote の両方に、相手に無いコミットがあるか
|
|
185
|
+
*/
|
|
186
|
+
readonly isDiverged: boolean;
|
|
182
187
|
}
|
|
183
188
|
/**
|
|
184
189
|
ahead と behind のコミット数から、push の状態の文を作る
|
|
185
190
|
*/
|
|
186
191
|
export declare function describePushStatus(remote: string, branch: string, ahead: number, behind: number): PushStatus;
|
|
192
|
+
/**
|
|
193
|
+
diverged の直し方。fast-forward でない push は拒まれるので、取り込むか、書き換えたなら lease 付きで上書きする
|
|
194
|
+
*/
|
|
195
|
+
export declare const DIVERGED_FIX_HINT: HintedText;
|
|
196
|
+
/**
|
|
197
|
+
積んだブランチが diverged のときの直し方。載せ直しが要るか、載せ直し済みで push と記録の書き直しが残れば pr restack、
|
|
198
|
+
要らなければ diverged の直し方、決められなければ pr restack --check
|
|
199
|
+
*/
|
|
200
|
+
export declare function pushFixHintOf(decision: Readonly<RestackDecision> | undefined): HintedText;
|
|
187
201
|
export interface PreflightFacts {
|
|
188
202
|
readonly gitStatus: string;
|
|
189
203
|
readonly stashList: string;
|
|
190
204
|
readonly isPushed: boolean;
|
|
191
205
|
readonly pushMessage: string;
|
|
206
|
+
/**
|
|
207
|
+
Push Status の直し方。省くと git push
|
|
208
|
+
*/
|
|
209
|
+
readonly pushFixHint?: HintedText | undefined;
|
|
192
210
|
}
|
|
193
211
|
/**
|
|
194
212
|
警告を、未 push・変更あり・stash ありの順で返す
|
|
@@ -197,5 +215,5 @@ export declare function collectPreflightWarnings(facts: Readonly<PreflightFacts>
|
|
|
197
215
|
/**
|
|
198
216
|
警告 1 行の文
|
|
199
217
|
*/
|
|
200
|
-
export declare function formatPreflightWarning(warning: PreflightWarning):
|
|
218
|
+
export declare function formatPreflightWarning(warning: PreflightWarning): HintedText;
|
|
201
219
|
//# sourceMappingURL=pull-request.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// PR コマンドの入出力を持たない関数。本文の検証、Closes の抽出と追記、`pr show` の Markdown の整形、preflight の警告の判定。
|
|
2
2
|
// 引数の型は、infra/github/pulls.ts の返す値が構造として満たす形をここに持つ(domain は infra を import できない)。
|
|
3
|
-
import { hinted, inputHint, inputNameHint } from './command-hint.js';
|
|
3
|
+
import { commandHint, hinted, inputHint, inputNameHint, joinHinted } from './command-hint.js';
|
|
4
4
|
import { parsePythonInteger, pythonRightStrip, pythonStrip, splitCodePoints, truncateCodePoints } from './python-format.js';
|
|
5
5
|
import { hasSummaryImage, validateBodyStyle, validateHeadingSummaries, validateSections } from './sections.js';
|
|
6
|
+
import { RESTACK_PATH } from './restack.js';
|
|
6
7
|
// Issue 参照(`#N`、URL 内のフラグメントは除く)。`owner/repo#N` の形も受ける
|
|
7
8
|
const ISSUE_REFERENCE_PATTERN = /(?:^|[^/])#\d+|[\w-]+\/[\w.-]+#\d+/u;
|
|
8
9
|
// Python の `\s`(str.isspace)と同じ空白
|
|
@@ -250,12 +251,28 @@ ahead と behind のコミット数から、push の状態の文を作る
|
|
|
250
251
|
*/
|
|
251
252
|
export function describePushStatus(remote, branch, ahead, behind) {
|
|
252
253
|
if (ahead === 0 && behind === 0)
|
|
253
|
-
return { isPushed: true, message: `in sync with ${remote}/${branch}
|
|
254
|
+
return { isPushed: true, message: `in sync with ${remote}/${branch}`, isDiverged: false };
|
|
254
255
|
if (behind === 0)
|
|
255
|
-
return { isPushed: false, message: `${String(ahead)} unpushed commits
|
|
256
|
+
return { isPushed: false, message: `${String(ahead)} unpushed commits`, isDiverged: false };
|
|
256
257
|
if (ahead === 0)
|
|
257
|
-
return { isPushed: true, message: `${remote}/${branch} is ${String(behind)} commits ahead (pull recommended)
|
|
258
|
-
return { isPushed: false, message: `diverged: local is ${String(ahead)} commits ahead, ${remote}/${branch} is ${String(behind)} ahead
|
|
258
|
+
return { isPushed: true, message: `${remote}/${branch} is ${String(behind)} commits ahead (pull recommended)`, isDiverged: false };
|
|
259
|
+
return { isPushed: false, message: `diverged: local is ${String(ahead)} commits ahead, ${remote}/${branch} is ${String(behind)} ahead`, isDiverged: true };
|
|
260
|
+
}
|
|
261
|
+
// 文の中にロングオプションを書けない(lint)ので、git の引数から組む
|
|
262
|
+
const PULL_REBASE_COMMAND = ['git', 'pull', '--rebase'].join(' ');
|
|
263
|
+
const FORCE_PUSH_COMMAND = ['git', 'push', '--force-with-lease'].join(' ');
|
|
264
|
+
/**
|
|
265
|
+
diverged の直し方。fast-forward でない push は拒まれるので、取り込むか、書き換えたなら lease 付きで上書きする
|
|
266
|
+
*/
|
|
267
|
+
export const DIVERGED_FIX_HINT = hinted `${PULL_REBASE_COMMAND}, or ${FORCE_PUSH_COMMAND} if you rewrote pushed commits`;
|
|
268
|
+
/**
|
|
269
|
+
積んだブランチが diverged のときの直し方。載せ直しが要るか、載せ直し済みで push と記録の書き直しが残れば pr restack、
|
|
270
|
+
要らなければ diverged の直し方、決められなければ pr restack --check
|
|
271
|
+
*/
|
|
272
|
+
export function pushFixHintOf(decision) {
|
|
273
|
+
if (decision === undefined || decision.kind === 'gone')
|
|
274
|
+
return hinted `${commandHint(RESTACK_PATH, { check: true })}`;
|
|
275
|
+
return decision.kind === 'moved' || decision.kind === 'merged' || decision.kind === 'rebased' ? hinted `${commandHint(RESTACK_PATH)}` : DIVERGED_FIX_HINT;
|
|
259
276
|
}
|
|
260
277
|
/**
|
|
261
278
|
警告を、未 push・変更あり・stash ありの順で返す
|
|
@@ -263,12 +280,12 @@ export function describePushStatus(remote, branch, ahead, behind) {
|
|
|
263
280
|
export function collectPreflightWarnings(facts) {
|
|
264
281
|
const warnings = [];
|
|
265
282
|
if (!facts.isPushed)
|
|
266
|
-
warnings.push({ label: 'Push Status', message: facts.pushMessage, fixHint:
|
|
283
|
+
warnings.push({ label: 'Push Status', message: facts.pushMessage, fixHint: facts.pushFixHint ?? hinted `git push` });
|
|
267
284
|
if (hasStatusChanges(facts.gitStatus))
|
|
268
|
-
warnings.push({ label: 'Git Status', message: 'modified or untracked files', fixHint:
|
|
285
|
+
warnings.push({ label: 'Git Status', message: 'modified or untracked files', fixHint: hinted `commit` });
|
|
269
286
|
if (hasStashEntries(facts.stashList)) {
|
|
270
287
|
const count = facts.stashList.split(LINE_BREAK).filter(line => pythonStrip(line) !== '').length;
|
|
271
|
-
warnings.push({ label: 'Stash List', message: `${String(count)} stash entries`, fixHint:
|
|
288
|
+
warnings.push({ label: 'Stash List', message: `${String(count)} stash entries`, fixHint: hinted `check them` });
|
|
272
289
|
}
|
|
273
290
|
return warnings;
|
|
274
291
|
}
|
|
@@ -276,6 +293,6 @@ export function collectPreflightWarnings(facts) {
|
|
|
276
293
|
警告 1 行の文
|
|
277
294
|
*/
|
|
278
295
|
export function formatPreflightWarning(warning) {
|
|
279
|
-
return `${warning.label}: ${warning.message} (fix:
|
|
296
|
+
return joinHinted([`${warning.label}: ${warning.message} (fix: `, warning.fixHint, ')'], '');
|
|
280
297
|
}
|
|
281
298
|
//# sourceMappingURL=pull-request.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { HintedText } from './command-hint.js';
|
|
2
2
|
import type { RepositoryReference, ResolvedRepository } from './repository-resolver.js';
|
|
3
3
|
export type PolicyMode = 'reject' | 'warn';
|
|
4
|
+
/**
|
|
5
|
+
今の git remote からリポジトリを決められないときの 1 行目。branch delete の remote の確認も同じ行を出す
|
|
6
|
+
*/
|
|
7
|
+
export declare const AMBIGUOUS_REPOSITORY_LINE = "error: the repository is ambiguous";
|
|
4
8
|
export interface PolicyInput {
|
|
5
9
|
/**
|
|
6
10
|
グローバル `--repo` の値。無ければ undefined
|
|
@@ -19,6 +19,10 @@ import { globalRepositoryHint, hinted, placeholder } from './command-hint.js';
|
|
|
19
19
|
import { InvalidValueError } from './errors.js';
|
|
20
20
|
import { pythonStringRepr } from './python-format.js';
|
|
21
21
|
import { parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
|
|
22
|
+
/**
|
|
23
|
+
今の git remote からリポジトリを決められないときの 1 行目。branch delete の remote の確認も同じ行を出す
|
|
24
|
+
*/
|
|
25
|
+
export const AMBIGUOUS_REPOSITORY_LINE = 'error: the repository is ambiguous';
|
|
22
26
|
function exitWith(failure, ...stderr) {
|
|
23
27
|
return { kind: 'exit', exitCode: 1, failure, stderr };
|
|
24
28
|
}
|
|
@@ -39,7 +43,7 @@ export function applyRepositoryPolicy(input) {
|
|
|
39
43
|
const { explicit, resolved, mode } = input;
|
|
40
44
|
if (explicit === undefined) {
|
|
41
45
|
return resolved === undefined
|
|
42
|
-
? exitWith('git-unresolved',
|
|
46
|
+
? exitWith('git-unresolved', AMBIGUOUS_REPOSITORY_LINE, hinted ` give ${globalRepositoryHint(placeholder('owner/repo'))}`)
|
|
43
47
|
: { kind: 'proceed', adopted: undefined, stderr: [] };
|
|
44
48
|
}
|
|
45
49
|
const explicitReference = parseExplicit(explicit);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { PullRequestReadout } from './issue-readout.js';
|
|
2
2
|
import type { BaseReading } from './state.js';
|
|
3
|
+
/**
|
|
4
|
+
pr restack のコマンドの path。案内(commandHint)とコマンドの定義が共有する
|
|
5
|
+
*/
|
|
6
|
+
export declare const RESTACK_PATH: readonly string[];
|
|
3
7
|
export interface RestackInput {
|
|
4
8
|
/**
|
|
5
9
|
base の記録。形の誤りは呼び出し側が先に止める
|
|
@@ -34,6 +38,13 @@ export type RestackDecision = {
|
|
|
34
38
|
readonly kind: 'gone';
|
|
35
39
|
readonly base: string;
|
|
36
40
|
readonly pullRequest: number | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
ブランチは新しい base の上に載り終えていて、記録だけが古い。rebase は要らず、push と記録の書き直しだけが残る
|
|
44
|
+
*/
|
|
45
|
+
| {
|
|
46
|
+
readonly kind: 'rebased';
|
|
47
|
+
readonly base: string;
|
|
37
48
|
};
|
|
38
49
|
/**
|
|
39
50
|
載せ直す先を決める。base は、載せ直した後の base のブランチ(merged なら開発ブランチ)
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// 積んだブランチを載せ直す先の判断と、その表示。git と GitHub の読み取りは commands が行う。
|
|
2
2
|
/**
|
|
3
|
+
pr restack のコマンドの path。案内(commandHint)とコマンドの定義が共有する
|
|
4
|
+
*/
|
|
5
|
+
export const RESTACK_PATH = ['pr', 'restack'];
|
|
6
|
+
/**
|
|
3
7
|
載せ直す先を決める。base は、載せ直した後の base のブランチ(merged なら開発ブランチ)
|
|
4
8
|
*/
|
|
5
9
|
export function decideRestack(input) {
|
|
@@ -19,7 +23,8 @@ export function decideRestack(input) {
|
|
|
19
23
|
export function describeRestackCheck(branch, decision) {
|
|
20
24
|
switch (decision.kind) {
|
|
21
25
|
case 'not-stacked':
|
|
22
|
-
case 'up-to-date':
|
|
26
|
+
case 'up-to-date':
|
|
27
|
+
case 'rebased': {
|
|
23
28
|
return `up to date: ${branch} on ${decision.base}`;
|
|
24
29
|
}
|
|
25
30
|
case 'moved': {
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type { IssueReference } from './reference-parser.js';
|
|
2
|
-
export declare const FLAG_PECOT_ACTIVE = ".pecot-active";
|
|
3
2
|
export declare const FLAG_PECOT_SESSION_TITLE = ".pecot-session-title";
|
|
4
3
|
export declare const FLAG_PECOT_BASE = ".pecot-base";
|
|
5
4
|
export declare const FLAG_PECOT_RESTACK = ".pecot-restack";
|
|
6
5
|
export declare const FLAG_PECOT_QUICK_MODE = ".pecot-quick-mode";
|
|
7
|
-
export declare const FLAG_WIP_BRANCH_LINKED = ".wip-branch-linked";
|
|
8
|
-
export declare const FLAG_PR_CREATE_SLASH_PENDING = "pr-create-slash-pending";
|
|
9
|
-
export declare const FLAG_ISSUE_CREATE_SLASH_PENDING = "issue-create-slash-pending";
|
|
10
|
-
export declare const FLAG_MERGE_SLASH_PENDING = "merge-slash-pending";
|
|
11
|
-
export declare const FLAG_ISSUE_PENDING = "issue-pending";
|
|
12
6
|
export declare const SESSION_TITLE_MAX_CHARS = 40;
|
|
13
7
|
/**
|
|
14
8
|
セッション名 `#<番号> <Issue タイトル>` を組み立てる。
|
|
@@ -21,14 +15,10 @@ export declare function formatSessionTitle(issueNumber: number, title: string):
|
|
|
21
15
|
`.pecot/work` の直下は Issue 番号の数字だけにする規約のため、全角数字などは通さない
|
|
22
16
|
*/
|
|
23
17
|
export declare function workDirectoryName(issueReference: string): string | undefined;
|
|
24
|
-
export interface WorkTarget {
|
|
25
|
-
readonly active: string;
|
|
26
|
-
readonly sessionTitle: string;
|
|
27
|
-
}
|
|
28
18
|
/**
|
|
29
|
-
|
|
19
|
+
作業対象のセッション名(.pecot-session-title に書く内容)を決める。参照の末尾が整数でなければ InvalidValueError
|
|
30
20
|
*/
|
|
31
|
-
export declare function planWorkTarget(issueReference: string, title: string):
|
|
21
|
+
export declare function planWorkTarget(issueReference: string, title: string): string;
|
|
32
22
|
export interface BaseRecord {
|
|
33
23
|
readonly branch: string;
|
|
34
24
|
readonly sha: string;
|
package/cli/dist/domain/state.js
CHANGED
|
@@ -4,24 +4,13 @@ import { parsePythonInteger, pythonRightStrip, pythonStrip, pythonStringRepr, tr
|
|
|
4
4
|
import { createIssueReference, issueReferenceToString } from './reference-parser.js';
|
|
5
5
|
import { createRepositoryReference } from './repository-resolver.js';
|
|
6
6
|
// フラグファイル名
|
|
7
|
-
|
|
8
|
-
// セッション名(hooks の session-title.sh が Claude Code の sessionTitle に流す)。.pecot-active と同じタイミングで書く
|
|
7
|
+
// セッション名のキャッシュ(hooks の session-title.sh が Claude Code の sessionTitle に流す)。session start がブランチを作るときに書く
|
|
9
8
|
export const FLAG_PECOT_SESSION_TITLE = '.pecot-session-title';
|
|
10
9
|
// 着手のときに選んだ base(ブランチ・位置・積んだ先の Issue)。session start が書き、session finish が消す
|
|
11
10
|
export const FLAG_PECOT_BASE = '.pecot-base';
|
|
12
11
|
// 衝突で止まった載せ直しの途中の記録。pr restack が書き、続行か取りやめで消す
|
|
13
12
|
export const FLAG_PECOT_RESTACK = '.pecot-restack';
|
|
14
13
|
export const FLAG_PECOT_QUICK_MODE = '.pecot-quick-mode';
|
|
15
|
-
export const FLAG_WIP_BRANCH_LINKED = '.wip-branch-linked';
|
|
16
|
-
// スラッシュコマンド起点の外部反映免除フラグ。
|
|
17
|
-
// 設置は hooks の create-slash-flag.sh が行う。
|
|
18
|
-
// 確認は mcp-handlers/pecot-post-ask.sh(merge は pr_merge も。gh pr merge は core/external-post-check.sh)が行う。
|
|
19
|
-
// MCP ツールが実投稿成功時に削除する。
|
|
20
|
-
export const FLAG_PR_CREATE_SLASH_PENDING = 'pr-create-slash-pending';
|
|
21
|
-
export const FLAG_ISSUE_CREATE_SLASH_PENDING = 'issue-create-slash-pending';
|
|
22
|
-
export const FLAG_MERGE_SLASH_PENDING = 'merge-slash-pending';
|
|
23
|
-
// 起票未完了のリマインド用フラグ。設置は hooks、確認は pecot-issue-pending-reminder.sh。MCP ツールが起票成功時に削除する
|
|
24
|
-
export const FLAG_ISSUE_PENDING = 'issue-pending';
|
|
25
14
|
export const SESSION_TITLE_MAX_CHARS = 40;
|
|
26
15
|
const ISSUE_TYPE_PREFIX_PATTERN = /^\[(?:Task|Bug|Epic)\]\s*/u;
|
|
27
16
|
/**
|
|
@@ -50,14 +39,14 @@ export function workDirectoryName(issueReference) {
|
|
|
50
39
|
return /^\d+$/u.test(number) ? number : undefined;
|
|
51
40
|
}
|
|
52
41
|
/**
|
|
53
|
-
|
|
42
|
+
作業対象のセッション名(.pecot-session-title に書く内容)を決める。参照の末尾が整数でなければ InvalidValueError
|
|
54
43
|
*/
|
|
55
44
|
export function planWorkTarget(issueReference, title) {
|
|
56
45
|
const text = lastSegment(issueReference);
|
|
57
46
|
const number = parsePythonInteger(text);
|
|
58
47
|
if (number === undefined)
|
|
59
48
|
throw new InvalidValueError(`invalid literal for int() with base 10: ${pythonStringRepr(text)}`);
|
|
60
|
-
return
|
|
49
|
+
return formatSessionTitle(number, title);
|
|
61
50
|
}
|
|
62
51
|
// ブランチ名に空白は入らないので、空白で区切る
|
|
63
52
|
const BASE_SHA_PATTERN = /^(?:[\da-f]{40}|[\da-f]{64})$/u;
|
package/cli/dist/infra/git.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GitResult, GitRunner } from '../domain/git-runner.js';
|
|
2
2
|
import type { RemoteLocation } from '../domain/git-url.js';
|
|
3
3
|
import { BaseError } from '../domain/errors.js';
|
|
4
|
+
import type { IssueReference } from '../domain/reference-parser.js';
|
|
4
5
|
export interface GitOptions {
|
|
5
6
|
/**
|
|
6
7
|
作業ディレクトリ。省略すると呼び出し元の作業ディレクトリ
|
|
@@ -80,6 +81,10 @@ export declare function primaryRemoteRepository(cwd?: string): RemoteLocation |
|
|
|
80
81
|
*/
|
|
81
82
|
export declare function gitCurrentBranch(cwd?: string): string | undefined;
|
|
82
83
|
/**
|
|
84
|
+
作業中の Issue。主の remote のリポと現在のブランチ名の末尾の番号から決める。どちらかが読めなければ undefined
|
|
85
|
+
*/
|
|
86
|
+
export declare function activeIssueOf(directory?: string): IssueReference | undefined;
|
|
87
|
+
/**
|
|
83
88
|
指定した remote の URL から host・owner・repository を返す。remote 不在・git の外・URL 形式の不一致は undefined
|
|
84
89
|
*/
|
|
85
90
|
export declare function remoteRepository(cwd: string | undefined, remote: string): RemoteLocation | undefined;
|
|
@@ -108,6 +113,14 @@ export declare function resolveCommit(cwd: string, reference: string): string |
|
|
|
108
113
|
*/
|
|
109
114
|
export declare function mergeBase(cwd: string, a: string, b: string): string | undefined;
|
|
110
115
|
/**
|
|
116
|
+
ancestor が descendant の祖先(同じコミットを含む)か。どちらかのコミットを手元が知らなければ false
|
|
117
|
+
*/
|
|
118
|
+
export declare function isAncestor(cwd: string, ancestor: string, descendant: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
`git merge-base --fork-point <upstream> <head>`。upstream の reflog から、head が分かれた点を求める。求まらなければ undefined
|
|
121
|
+
*/
|
|
122
|
+
export declare function forkPoint(cwd: string, upstream: string, head: string): string | undefined;
|
|
123
|
+
/**
|
|
111
124
|
`git rebase --onto <newBase> <oldBase>`。利用者の rebase.updateRefs に関わらず、ほかのブランチは書き換えない
|
|
112
125
|
*/
|
|
113
126
|
export declare function rebaseOnto(cwd: string, newBase: string, oldBase: string): RebaseOutcome;
|
package/cli/dist/infra/git.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import { activeIssueFromBranch } from '../domain/branch-name.js';
|
|
6
7
|
import { parseRemoteUrl } from '../domain/git-url.js';
|
|
7
8
|
import { BaseError, InvalidValueError } from '../domain/errors.js';
|
|
8
9
|
import { normalizeNewlines, pythonRepr, pythonStrip } from '../domain/python-format.js';
|
|
@@ -129,6 +130,12 @@ export function gitCurrentBranch(cwd) {
|
|
|
129
130
|
return runForValue(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd });
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
133
|
+
作業中の Issue。主の remote のリポと現在のブランチ名の末尾の番号から決める。どちらかが読めなければ undefined
|
|
134
|
+
*/
|
|
135
|
+
export function activeIssueOf(directory) {
|
|
136
|
+
return activeIssueFromBranch(primaryRemoteRepository(directory), gitCurrentBranch(directory));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
132
139
|
指定した remote の URL から host・owner・repository を返す。remote 不在・git の外・URL 形式の不一致は undefined
|
|
133
140
|
*/
|
|
134
141
|
export function remoteRepository(cwd, remote) {
|
|
@@ -168,6 +175,18 @@ export function resolveCommit(cwd, reference) {
|
|
|
168
175
|
export function mergeBase(cwd, a, b) {
|
|
169
176
|
return runForValue(['merge-base', a, b], { cwd });
|
|
170
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
ancestor が descendant の祖先(同じコミットを含む)か。どちらかのコミットを手元が知らなければ false
|
|
180
|
+
*/
|
|
181
|
+
export function isAncestor(cwd, ancestor, descendant) {
|
|
182
|
+
return runGit(['merge-base', '--is-ancestor', ancestor, descendant], { cwd }).exitCode === 0;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
`git merge-base --fork-point <upstream> <head>`。upstream の reflog から、head が分かれた点を求める。求まらなければ undefined
|
|
186
|
+
*/
|
|
187
|
+
export function forkPoint(cwd, upstream, head) {
|
|
188
|
+
return runForValue(['merge-base', '--fork-point', upstream, head], { cwd });
|
|
189
|
+
}
|
|
171
190
|
// 失敗の後に rebase の途中なら衝突、ほかの失敗は GitCommandError
|
|
172
191
|
function rebaseOutcome(cwd, arguments_, environment) {
|
|
173
192
|
const result = runGit(arguments_, { cwd, env: environment });
|
|
@@ -32,9 +32,7 @@ export interface ProjectRootOptions {
|
|
|
32
32
|
/**
|
|
33
33
|
プロジェクトルートを取得する。
|
|
34
34
|
1. CLAUDE_PROJECT_DIR があれば使う(テスト上書き用)。
|
|
35
|
-
2.
|
|
36
|
-
worktree の .pecot/work は base への symlink で、そこでは git toplevel が base になる。
|
|
37
|
-
3. なければ git rev-parse --show-toplevel で解決する(GIT_* を除いて実行する)。
|
|
35
|
+
2. なければ git rev-parse --show-toplevel で解決する(GIT_* を除いて実行する)。
|
|
38
36
|
|
|
39
37
|
どれも得られなければ ProjectRootNotFoundError
|
|
40
38
|
*/
|
package/cli/dist/infra/paths.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable security/detect-non-literal-fs-filename -- パスは呼び出し側が決める。ここは解決と予約だけ */
|
|
2
2
|
// pecot リポジトリ基準のパス解決。`.pecot/` 配下のパス定義の唯一の置き場。
|
|
3
3
|
// projectRoot() でプロジェクトルートを解決し、一時ファイルの出力先を固定する。
|
|
4
|
-
import { closeSync,
|
|
4
|
+
import { closeSync, mkdirSync, openSync, realpathSync, unlinkSync } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { PecotError, ProjectRootNotFoundError } from '../domain/errors.js';
|
|
7
7
|
import { gitToplevel } from './git.js';
|
|
@@ -55,42 +55,6 @@ export function resolveRealPath(target) {
|
|
|
55
55
|
throw error;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
cwd がセッションの worktree の .pecot/work の実体配下なら、その worktree を返す。
|
|
60
|
-
セッション開始時の SessionStart hook が PECOT_SESSION_PROJECT_DIR に書いた値を起点にする。git は呼ばない。
|
|
61
|
-
hooks の project-root.sh と同じ判定を使う。cwd の文字列が `.pecot/work` で終わるか `.pecot/work/` を含み、実体が起点の .pecot/work の実体配下にある。
|
|
62
|
-
かつ途中に `.git` を持つディレクトリ(入れ子の git リポ)が無いときだけ対象にする
|
|
63
|
-
*/
|
|
64
|
-
function sessionWorkOwner(cwd) {
|
|
65
|
-
const sessionDirectory = process.env['PECOT_SESSION_PROJECT_DIR'];
|
|
66
|
-
if (sessionDirectory === undefined || sessionDirectory === '')
|
|
67
|
-
return undefined;
|
|
68
|
-
// 安価な文字列の判定を、realpath の解決より先に行う
|
|
69
|
-
if (!(cwd.endsWith(`/${WORK_DIR}`) || cwd.includes(`/${WORK_DIR}/`)))
|
|
70
|
-
return undefined;
|
|
71
|
-
let workReal;
|
|
72
|
-
let cwdReal;
|
|
73
|
-
try {
|
|
74
|
-
workReal = resolveRealPath(path.join(sessionDirectory, WORK_DIR));
|
|
75
|
-
cwdReal = resolveRealPath(cwd);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
if (hasErrorCode(error))
|
|
79
|
-
return undefined;
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
if (cwdReal !== workReal && !cwdReal.startsWith(`${workReal}/`))
|
|
83
|
-
return undefined;
|
|
84
|
-
for (let directory = cwdReal;; directory = path.dirname(directory)) {
|
|
85
|
-
if (directory === workReal)
|
|
86
|
-
break;
|
|
87
|
-
if (existsSync(path.join(directory, '.git')))
|
|
88
|
-
return undefined;
|
|
89
|
-
if (path.dirname(directory) === directory)
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
return resolveRealPath(sessionDirectory);
|
|
93
|
-
}
|
|
94
58
|
function currentDirectory(options) {
|
|
95
59
|
try {
|
|
96
60
|
return options.cwd ?? process.cwd();
|
|
@@ -105,9 +69,7 @@ function currentDirectory(options) {
|
|
|
105
69
|
/**
|
|
106
70
|
プロジェクトルートを取得する。
|
|
107
71
|
1. CLAUDE_PROJECT_DIR があれば使う(テスト上書き用)。
|
|
108
|
-
2.
|
|
109
|
-
worktree の .pecot/work は base への symlink で、そこでは git toplevel が base になる。
|
|
110
|
-
3. なければ git rev-parse --show-toplevel で解決する(GIT_* を除いて実行する)。
|
|
72
|
+
2. なければ git rev-parse --show-toplevel で解決する(GIT_* を除いて実行する)。
|
|
111
73
|
|
|
112
74
|
どれも得られなければ ProjectRootNotFoundError
|
|
113
75
|
*/
|
|
@@ -116,11 +78,6 @@ export function projectRoot(options = {}) {
|
|
|
116
78
|
if (fromEnvironment !== undefined && fromEnvironment !== '')
|
|
117
79
|
return normalizePath(fromEnvironment);
|
|
118
80
|
const cwd = currentDirectory(options);
|
|
119
|
-
if (cwd !== undefined) {
|
|
120
|
-
const sessionRoot = sessionWorkOwner(cwd);
|
|
121
|
-
if (sessionRoot !== undefined)
|
|
122
|
-
return sessionRoot;
|
|
123
|
-
}
|
|
124
81
|
// git push 等のフック内では GIT_DIR 等が設定され、作業ディレクトリの代わりに参照される。
|
|
125
82
|
// そのため GIT_* を除いて作業ディレクトリ基準で解決する
|
|
126
83
|
const toplevel = gitToplevel({ cwd, stripGitEnvironment: true });
|
|
@@ -11,7 +11,7 @@ export interface StateDirectoryOptions {
|
|
|
11
11
|
export declare function getStateDirectory(options?: Readonly<StateDirectoryOptions>): string;
|
|
12
12
|
/**
|
|
13
13
|
作業ディレクトリ `.pecot/work/<Issue番号>/` を作って返す。
|
|
14
|
-
|
|
14
|
+
ブランチを作るとき(session start)に呼ぶ。
|
|
15
15
|
作れないとき(プロジェクトルート不明・OS のエラー)は undefined。作業フロー自体は止めない
|
|
16
16
|
*/
|
|
17
17
|
export declare function ensureWorkDirectory(issueReference: string): string | undefined;
|
|
@@ -24,11 +24,6 @@ export declare function touchFlag(flagName: string): void;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function removeFlag(flagName: string): void;
|
|
26
26
|
/**
|
|
27
|
-
実投稿成功時にスラッシュコマンド免除フラグを消費(削除)する。
|
|
28
|
-
投稿自体は成功しているため、フラグ解決の失敗(git リポ外等)でコマンドを失敗させない
|
|
29
|
-
*/
|
|
30
|
-
export declare function consumeFlag(flagName: string): void;
|
|
31
|
-
/**
|
|
32
27
|
通常のファイルとして存在するか
|
|
33
28
|
*/
|
|
34
29
|
export declare function hasFlag(flagName: string): boolean;
|
|
@@ -47,8 +42,8 @@ export declare function writeBaseRecord(record: Readonly<BaseRecord>): void;
|
|
|
47
42
|
*/
|
|
48
43
|
export declare function readBaseRecord(): BaseReading;
|
|
49
44
|
/**
|
|
50
|
-
|
|
45
|
+
セッション名のキャッシュ(.pecot-session-title)を書く。
|
|
51
46
|
issueReference の末尾が整数でなければ InvalidValueError で、何も書かない
|
|
52
47
|
*/
|
|
53
|
-
export declare function
|
|
48
|
+
export declare function writeSessionTitle(issueReference: string, title: string): void;
|
|
54
49
|
//# sourceMappingURL=state-store.d.ts.map
|
|
@@ -4,8 +4,8 @@ import { closeSync, mkdirSync, openSync, statSync, unlinkSync, utimesSync, write
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { ProjectRootNotFoundError } from '../domain/errors.js';
|
|
6
6
|
import { pythonStrip } from '../domain/python-format.js';
|
|
7
|
-
import {
|
|
8
|
-
import { OsError, hasErrorCode, isFileNotFound
|
|
7
|
+
import { FLAG_PECOT_BASE, FLAG_PECOT_SESSION_TITLE, formatBaseRecord, interpretBaseRecord, planWorkTarget, workDirectoryName } from '../domain/state.js';
|
|
8
|
+
import { OsError, hasErrorCode, isFileNotFound } from './os-error.js';
|
|
9
9
|
import { projectRoot, STATE_DIR, WORK_DIR } from './paths.js';
|
|
10
10
|
import { readTextFile } from './text-file.js';
|
|
11
11
|
/**
|
|
@@ -19,7 +19,7 @@ export function getStateDirectory(options = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
作業ディレクトリ `.pecot/work/<Issue番号>/` を作って返す。
|
|
22
|
-
|
|
22
|
+
ブランチを作るとき(session start)に呼ぶ。
|
|
23
23
|
作れないとき(プロジェクトルート不明・OS のエラー)は undefined。作業フロー自体は止めない
|
|
24
24
|
*/
|
|
25
25
|
export function ensureWorkDirectory(issueReference) {
|
|
@@ -59,22 +59,6 @@ export function removeFlag(flagName) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
実投稿成功時にスラッシュコマンド免除フラグを消費(削除)する。
|
|
63
|
-
投稿自体は成功しているため、フラグ解決の失敗(git リポ外等)でコマンドを失敗させない
|
|
64
|
-
*/
|
|
65
|
-
export function consumeFlag(flagName) {
|
|
66
|
-
try {
|
|
67
|
-
removeFlag(flagName);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
// 握るのは OS の失敗とプロジェクトルート不明だけ。投稿は成功しているので、後始末の失敗でコマンドを失敗させない。
|
|
71
|
-
// プログラムの誤り(TypeError など)は握らない
|
|
72
|
-
if (error instanceof ProjectRootNotFoundError || isSystemCallError(error))
|
|
73
|
-
return;
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
62
|
通常のファイルとして存在するか
|
|
79
63
|
*/
|
|
80
64
|
export function hasFlag(flagName) {
|
|
@@ -119,12 +103,10 @@ export function readBaseRecord() {
|
|
|
119
103
|
return interpretBaseRecord(readFlag(FLAG_PECOT_BASE));
|
|
120
104
|
}
|
|
121
105
|
/**
|
|
122
|
-
|
|
106
|
+
セッション名のキャッシュ(.pecot-session-title)を書く。
|
|
123
107
|
issueReference の末尾が整数でなければ InvalidValueError で、何も書かない
|
|
124
108
|
*/
|
|
125
|
-
export function
|
|
126
|
-
|
|
127
|
-
writeFlag(FLAG_PECOT_ACTIVE, target.active);
|
|
128
|
-
writeFlag(FLAG_PECOT_SESSION_TITLE, target.sessionTitle);
|
|
109
|
+
export function writeSessionTitle(issueReference, title) {
|
|
110
|
+
writeFlag(FLAG_PECOT_SESSION_TITLE, planWorkTarget(issueReference, title));
|
|
129
111
|
}
|
|
130
112
|
//# sourceMappingURL=state-store.js.map
|
|
@@ -76,9 +76,10 @@ jobs:
|
|
|
76
76
|
permission-pull-requests: read
|
|
77
77
|
permission-contents: read
|
|
78
78
|
|
|
79
|
-
#
|
|
79
|
+
# The dist-tag after the package name decides the version. @latest is the newest release,
|
|
80
|
+
# and a new major version brings breaking changes. Use @<major> or @<version> to stay on one.
|
|
80
81
|
# --prefix=/ keeps npx from stopping in a repository that declares pnpm devEngines.
|
|
81
82
|
- name: Sync the board
|
|
82
83
|
env:
|
|
83
84
|
PECOT_GITHUB_COM_TOKEN: ${{ steps.app-token.outputs.token || secrets.PECOT_BOARD_SYNC_TOKEN }}
|
|
84
|
-
run: npx -y --prefix=/ @pecot/workflow-mcp@
|
|
85
|
+
run: npx -y --prefix=/ @pecot/workflow-mcp@latest board sync
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/workflow-mcp",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1-dev.20",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "7.0.
|
|
9
|
+
"version": "7.0.1-dev.20",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|