@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,29 @@
|
|
|
1
1
|
// GitHub GraphQL API のクエリ・mutation 文字列。
|
|
2
2
|
// 先頭の 30 個は cli/core/github/queries.py を gql が送る形で写し、一致は infra/github/tests/queries.test.ts が固定する。
|
|
3
3
|
// 末尾の blocked by 関係の 4 個は Python に無く、graphql-js の print の出力の形で書く。
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// 着手の判定に使う、Issue の依存関係・種別・親のフィールド。Issue の依存関係に対応しない GHES では通らない
|
|
5
|
+
const ISSUE_READINESS_FIELDS = `
|
|
6
|
+
issueType {
|
|
7
|
+
name
|
|
8
|
+
}
|
|
9
|
+
subIssues(first: 1) {
|
|
10
|
+
totalCount
|
|
11
|
+
}
|
|
12
|
+
parent {
|
|
13
|
+
number
|
|
14
|
+
repository {
|
|
15
|
+
owner {
|
|
16
|
+
login
|
|
17
|
+
}
|
|
18
|
+
name
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
blockedBy(first: 1) {
|
|
22
|
+
totalCount
|
|
23
|
+
}`;
|
|
24
|
+
// 一覧のクエリ。operationName が空なら無名。readinessFields は Issue の枝に足すフィールド
|
|
25
|
+
function listProjectItemsQuery(operationName, readinessFields) {
|
|
26
|
+
return `query${operationName === '' ? ' ' : ` ${operationName}`}($projectId: ID!, $cursor: String) {
|
|
6
27
|
node(id: $projectId) {
|
|
7
28
|
... on ProjectV2 {
|
|
8
29
|
items(first: 100, after: $cursor) {
|
|
@@ -27,7 +48,7 @@ export const QUERY_LIST_PROJECT_ITEMS = `query ($projectId: ID!, $cursor: String
|
|
|
27
48
|
number
|
|
28
49
|
title
|
|
29
50
|
state
|
|
30
|
-
url
|
|
51
|
+
url${readinessFields}
|
|
31
52
|
labels(first: 10) {
|
|
32
53
|
nodes {
|
|
33
54
|
name
|
|
@@ -63,6 +84,11 @@ export const QUERY_LIST_PROJECT_ITEMS = `query ($projectId: ID!, $cursor: String
|
|
|
63
84
|
}
|
|
64
85
|
}
|
|
65
86
|
}`;
|
|
87
|
+
}
|
|
88
|
+
// プロジェクトアイテム一覧取得(ページネーション対応)
|
|
89
|
+
export const QUERY_LIST_PROJECT_ITEMS = listProjectItemsQuery('', ISSUE_READINESS_FIELDS);
|
|
90
|
+
// 上の一覧から、Issue の依存関係に対応しない GHES で通らないフィールドを除いたもの
|
|
91
|
+
export const QUERY_LIST_PROJECT_ITEMS_LEGACY = listProjectItemsQuery('ListProjectItemsLegacy', '');
|
|
66
92
|
// プロジェクトアイテム一覧取得(フィルタリング対応)
|
|
67
93
|
export const QUERY_LIST_PROJECT_ITEMS_FILTERED = `query ($projectId: ID!, $cursor: String, $filterQuery: String) {
|
|
68
94
|
node(id: $projectId) {
|
|
@@ -226,6 +252,14 @@ export const MUTATION_DELETE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId:
|
|
|
226
252
|
deletedItemId
|
|
227
253
|
}
|
|
228
254
|
}`;
|
|
255
|
+
// プロジェクトアイテムのアーカイブを解く
|
|
256
|
+
export const MUTATION_UNARCHIVE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId: ID!) {
|
|
257
|
+
unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
258
|
+
item {
|
|
259
|
+
id
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}`;
|
|
229
263
|
// サブIssue紐づけ
|
|
230
264
|
export const MUTATION_ADD_SUB_ISSUE = `mutation ($parentId: ID!, $childId: ID!) {
|
|
231
265
|
addSubIssue(input: { issueId: $parentId, subIssueId: $childId }) {
|
|
@@ -255,6 +289,7 @@ export const QUERY_GET_ISSUE_PROJECT_ITEMS = `query ($owner: String!, $repo: Str
|
|
|
255
289
|
projectItems(first: 20) {
|
|
256
290
|
nodes {
|
|
257
291
|
id
|
|
292
|
+
isArchived
|
|
258
293
|
project {
|
|
259
294
|
id
|
|
260
295
|
}
|
|
@@ -458,8 +493,9 @@ export const QUERY_GET_ISSUE_KIND_PHASE1 = `query ($owner: String!, $repo: Strin
|
|
|
458
493
|
}
|
|
459
494
|
}
|
|
460
495
|
}`;
|
|
461
|
-
// Issue
|
|
462
|
-
|
|
496
|
+
// Issue詳細取得のクエリ。blockedByCount は前提の件数のフィールド。Issue の依存関係に対応しない GHES では通らない
|
|
497
|
+
function getIssueSlimQuery(operationName, blockedByCount) {
|
|
498
|
+
return `query${operationName === '' ? ' ' : ` ${operationName}`}($owner: String!, $repo: String!, $number: Int!, $commentLimit: Int!) {
|
|
463
499
|
repository(owner: $owner, name: $repo) {
|
|
464
500
|
issue(number: $number) {
|
|
465
501
|
number
|
|
@@ -526,10 +562,18 @@ export const QUERY_GET_ISSUE_SLIM = `query ($owner: String!, $repo: String!, $nu
|
|
|
526
562
|
}
|
|
527
563
|
}
|
|
528
564
|
}
|
|
529
|
-
}
|
|
565
|
+
}${blockedByCount}
|
|
530
566
|
}
|
|
531
567
|
}
|
|
532
568
|
}`;
|
|
569
|
+
}
|
|
570
|
+
// Issue詳細取得(スリム版 - 必要なフィールドのみ。前提の件数つき)
|
|
571
|
+
export const QUERY_GET_ISSUE_SLIM = getIssueSlimQuery('', `
|
|
572
|
+
blockedBy(first: 1) {
|
|
573
|
+
totalCount
|
|
574
|
+
}`);
|
|
575
|
+
// 上のクエリから、前提の件数を除いたもの。Issue の依存関係を持たない GHES で読み直すのに使う
|
|
576
|
+
export const QUERY_GET_ISSUE_SLIM_WITHOUT_BLOCKED_BY = getIssueSlimQuery('GetIssueSlimWithoutBlockedBy', '');
|
|
533
577
|
// Python 版 queries.py の QUERY_GET_SUB_ISSUES_PAGE と逐語で一致させる。
|
|
534
578
|
export const QUERY_GET_SUB_ISSUES_PAGE = `query ($owner: String!, $repo: String!, $number: Int!, $after: String!) {
|
|
535
579
|
repository(owner: $owner, name: $repo) {
|
|
@@ -580,6 +624,32 @@ export const QUERY_GET_PULL_REQUEST_SLIM = `query ($owner: String!, $repo: Strin
|
|
|
580
624
|
}
|
|
581
625
|
}
|
|
582
626
|
}`;
|
|
627
|
+
// pr merge が読む PR の状態。GetPullRequestSlim を変えずに、マージの判断に要る項目だけを読む
|
|
628
|
+
export const QUERY_GET_PULL_REQUEST_FOR_MERGE = `query ($owner: String!, $repo: String!, $number: Int!) {
|
|
629
|
+
repository(owner: $owner, name: $repo) {
|
|
630
|
+
pullRequest(number: $number) {
|
|
631
|
+
number
|
|
632
|
+
state
|
|
633
|
+
isDraft
|
|
634
|
+
baseRefName
|
|
635
|
+
headRefOid
|
|
636
|
+
isMergeQueueEnabled
|
|
637
|
+
isInMergeQueue
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}`;
|
|
641
|
+
// 上のクエリから merge queue の項目を除いたもの。その項目を持たない GHES で読み直すのに使う
|
|
642
|
+
export const QUERY_GET_PULL_REQUEST_FOR_MERGE_WITHOUT_QUEUE = `query ($owner: String!, $repo: String!, $number: Int!) {
|
|
643
|
+
repository(owner: $owner, name: $repo) {
|
|
644
|
+
pullRequest(number: $number) {
|
|
645
|
+
number
|
|
646
|
+
state
|
|
647
|
+
isDraft
|
|
648
|
+
baseRefName
|
|
649
|
+
headRefOid
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}`;
|
|
583
653
|
// PR詳細取得(レビュー詳細付き - --reviews オプション用)
|
|
584
654
|
export const QUERY_GET_PULL_REQUEST_WITH_REVIEWS = `query ($owner: String!, $repo: String!, $number: Int!) {
|
|
585
655
|
repository(owner: $owner, name: $repo) {
|
|
@@ -709,6 +779,12 @@ export const QUERY_LIST_OPEN_PULL_REQUESTS = `query ($owner: String!, $repo: Str
|
|
|
709
779
|
}
|
|
710
780
|
}
|
|
711
781
|
}`;
|
|
782
|
+
// 前提(blocked by)を付ける入力の型があるか。対応しない GHES(3.19 より前)では null になる
|
|
783
|
+
export const QUERY_HAS_ADD_BLOCKED_BY_INPUT = `{
|
|
784
|
+
__type(name: "AddBlockedByInput") {
|
|
785
|
+
name
|
|
786
|
+
}
|
|
787
|
+
}`;
|
|
712
788
|
// 前提(blocked by)を付ける。issueId が待つ側、blockingIssueId が前提
|
|
713
789
|
export const MUTATION_ADD_BLOCKED_BY = `mutation ($issueId: ID!, $blockingIssueId: ID!) {
|
|
714
790
|
addBlockedBy(input: { issueId: $issueId, blockingIssueId: $blockingIssueId }) {
|
|
@@ -796,37 +872,6 @@ const PREREQUISITE_ISSUE_FIELDS = `fragment PrerequisiteIssueFields on Issue {
|
|
|
796
872
|
...PullRequestFields
|
|
797
873
|
}
|
|
798
874
|
}
|
|
799
|
-
timelineItems(
|
|
800
|
-
itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT, CROSS_REFERENCED_EVENT]
|
|
801
|
-
first: 20
|
|
802
|
-
) {
|
|
803
|
-
totalCount
|
|
804
|
-
nodes {
|
|
805
|
-
__typename
|
|
806
|
-
... on ConnectedEvent {
|
|
807
|
-
subject {
|
|
808
|
-
... on PullRequest {
|
|
809
|
-
...PullRequestFields
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
... on DisconnectedEvent {
|
|
814
|
-
subject {
|
|
815
|
-
... on PullRequest {
|
|
816
|
-
...PullRequestFields
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
... on CrossReferencedEvent {
|
|
821
|
-
willCloseTarget
|
|
822
|
-
source {
|
|
823
|
-
... on PullRequest {
|
|
824
|
-
...PullRequestFields
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
875
|
}`;
|
|
831
876
|
const SINGLE_SELECT_VALUE_FIELDS = `fragment SingleSelectValueFields on ProjectV2ItemFieldValue {
|
|
832
877
|
... on ProjectV2ItemFieldSingleSelectValue {
|
|
@@ -839,13 +884,22 @@ const SINGLE_SELECT_VALUE_FIELDS = `fragment SingleSelectValueFields on ProjectV
|
|
|
839
884
|
}
|
|
840
885
|
}
|
|
841
886
|
}`;
|
|
842
|
-
// Issue と、その前提(blockedBy)を 1 回で読む。PR は
|
|
843
|
-
export const QUERY_GET_ISSUE_PREREQUISITES = `query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!) {
|
|
887
|
+
// Issue と、その前提(blockedBy)を 1 回で読む。PR は 2 つの読み口(リンクしたブランチと Development 欄)から集める
|
|
888
|
+
export const QUERY_GET_ISSUE_PREREQUISITES = `query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!, $blockedByFirst: Int!) {
|
|
844
889
|
repository(owner: $owner, name: $repo) {
|
|
845
890
|
issue(number: $number) {
|
|
846
891
|
...PrerequisiteIssueFields
|
|
847
892
|
body
|
|
848
|
-
|
|
893
|
+
parent {
|
|
894
|
+
number
|
|
895
|
+
repository {
|
|
896
|
+
owner {
|
|
897
|
+
login
|
|
898
|
+
}
|
|
899
|
+
name
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
blockedBy(first: $blockedByFirst) {
|
|
849
903
|
totalCount
|
|
850
904
|
nodes {
|
|
851
905
|
...PrerequisiteIssueFields
|
|
@@ -880,4 +934,113 @@ export const QUERY_LIST_PULL_REQUESTS_BY_HEAD = `query ($owner: String!, $repo:
|
|
|
880
934
|
}
|
|
881
935
|
|
|
882
936
|
${PULL_REQUEST_FIELDS}`;
|
|
937
|
+
// base のブランチ名で開いている PR を引く(古い順)
|
|
938
|
+
export const QUERY_LIST_PULL_REQUESTS_BY_BASE = `query ($owner: String!, $repo: String!, $baseRefName: String!) {
|
|
939
|
+
repository(owner: $owner, name: $repo) {
|
|
940
|
+
pullRequests(
|
|
941
|
+
baseRefName: $baseRefName
|
|
942
|
+
states: [OPEN]
|
|
943
|
+
first: 20
|
|
944
|
+
orderBy: { field: CREATED_AT, direction: ASC }
|
|
945
|
+
) {
|
|
946
|
+
pageInfo {
|
|
947
|
+
hasNextPage
|
|
948
|
+
}
|
|
949
|
+
nodes {
|
|
950
|
+
...PullRequestFields
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
${PULL_REQUEST_FIELDS}`;
|
|
957
|
+
const BLOCKED_BY_REFERENCE_FIELDS = `fragment BlockedByReferenceFields on Issue {
|
|
958
|
+
id
|
|
959
|
+
number
|
|
960
|
+
state
|
|
961
|
+
repository {
|
|
962
|
+
owner {
|
|
963
|
+
login
|
|
964
|
+
}
|
|
965
|
+
name
|
|
966
|
+
}
|
|
967
|
+
}`;
|
|
968
|
+
// 前提の追加・削除の前の読み取り。判定の読み取りより軽く、本文と前提の参照だけを取る
|
|
969
|
+
export const QUERY_GET_ISSUE_BLOCKED_BY_REFERENCES = `query ($owner: String!, $repo: String!, $number: Int!, $blockedByFirst: Int!) {
|
|
970
|
+
repository(owner: $owner, name: $repo) {
|
|
971
|
+
issue(number: $number) {
|
|
972
|
+
id
|
|
973
|
+
body
|
|
974
|
+
blockedBy(first: $blockedByFirst) {
|
|
975
|
+
totalCount
|
|
976
|
+
nodes {
|
|
977
|
+
...BlockedByReferenceFields
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
985
|
+
// 輪をたどる 1 段分。node ID の並びのそれぞれの前提を、まとめて読む
|
|
986
|
+
export const QUERY_GET_BLOCKED_BY_OF_NODES = `query ($ids: [ID!]!, $blockedByFirst: Int!) {
|
|
987
|
+
nodes(ids: $ids) {
|
|
988
|
+
... on Issue {
|
|
989
|
+
id
|
|
990
|
+
blockedBy(first: $blockedByFirst) {
|
|
991
|
+
totalCount
|
|
992
|
+
nodes {
|
|
993
|
+
...BlockedByReferenceFields
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
1001
|
+
// その Issue を前提にしている Issue(blocking)の参照。PR を作った後に、待つ側の Issue を絞るために読む
|
|
1002
|
+
export const QUERY_GET_ISSUE_BLOCKING_REFERENCES = `query ($owner: String!, $repo: String!, $number: Int!, $blockingFirst: Int!) {
|
|
1003
|
+
repository(owner: $owner, name: $repo) {
|
|
1004
|
+
issue(number: $number) {
|
|
1005
|
+
blocking(first: $blockingFirst) {
|
|
1006
|
+
totalCount
|
|
1007
|
+
nodes {
|
|
1008
|
+
...BlockedByReferenceFields
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
1016
|
+
// Issue 1 件の、指定のプロジェクトの項目と進行の列。ボード全体を読まずに、列を動かす対象を読む
|
|
1017
|
+
export const QUERY_GET_ISSUE_BOARD_ITEM = `query ($owner: String!, $repo: String!, $number: Int!, $workflowFieldName: String!) {
|
|
1018
|
+
repository(owner: $owner, name: $repo) {
|
|
1019
|
+
issue(number: $number) {
|
|
1020
|
+
number
|
|
1021
|
+
title
|
|
1022
|
+
state
|
|
1023
|
+
url
|
|
1024
|
+
repository {
|
|
1025
|
+
owner {
|
|
1026
|
+
login
|
|
1027
|
+
}
|
|
1028
|
+
name
|
|
1029
|
+
}
|
|
1030
|
+
projectItems(first: 20, includeArchived: false) {
|
|
1031
|
+
nodes {
|
|
1032
|
+
id
|
|
1033
|
+
project {
|
|
1034
|
+
id
|
|
1035
|
+
}
|
|
1036
|
+
workflow: fieldValueByName(name: $workflowFieldName) {
|
|
1037
|
+
... on ProjectV2ItemFieldSingleSelectValue {
|
|
1038
|
+
name
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}`;
|
|
883
1046
|
//# sourceMappingURL=queries.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockedByReadout, IssueReadout, PrerequisiteFieldNames, PullRequestReadout } from '../../domain/issue-readout.js';
|
|
1
|
+
import type { BlockedByReadout, BlockedByReference, IssueReadout, PrerequisiteFieldNames, PullRequestReadout } from '../../domain/issue-readout.js';
|
|
2
2
|
import type { JsonValue } from '../../domain/python-format.js';
|
|
3
3
|
/**
|
|
4
4
|
PR のノード 1 つ。`... on PullRequest` の型でない node は空で届くので、undefined を返す。
|
|
@@ -15,4 +15,8 @@ export declare function readIssue(issue: JsonValue, projectId: string, fieldName
|
|
|
15
15
|
- 対象か前提の Issue の connection が、件数の上限で取りこぼされている
|
|
16
16
|
*/
|
|
17
17
|
export declare function readBlockedBy(target: JsonValue, projectId: string, fieldNames: Readonly<PrerequisiteFieldNames>, errorMessages?: readonly string[]): BlockedByReadout;
|
|
18
|
+
/**
|
|
19
|
+
前提 1 件の参照(node ID・番号・リポ・状態)。node は BlockedByReferenceFields の形
|
|
20
|
+
*/
|
|
21
|
+
export declare function readIssueReference(node: JsonValue | undefined): BlockedByReference;
|
|
18
22
|
//# sourceMappingURL=readout.d.ts.map
|
|
@@ -64,37 +64,6 @@ function readProjectFieldValues(issue, projectId, fieldNames) {
|
|
|
64
64
|
: [])
|
|
65
65
|
.filter(value => value !== undefined);
|
|
66
66
|
}
|
|
67
|
-
function pullRequestKey(pullRequest) {
|
|
68
|
-
return `${pullRequest.repository.owner}/${pullRequest.repository.repository}#${String(pullRequest.number)}`;
|
|
69
|
-
}
|
|
70
|
-
function applyTimelineEvent(entries, event, issueNumber) {
|
|
71
|
-
const type = jsonField(event, '__typename');
|
|
72
|
-
if (type === 'CrossReferencedEvent') {
|
|
73
|
-
const pullRequest = readPullRequest(jsonField(event, 'source'));
|
|
74
|
-
if (pullRequest === undefined)
|
|
75
|
-
return entries;
|
|
76
|
-
const isRelated = jsonField(event, 'willCloseTarget') === true || pullRequest.headRefName.endsWith(`/${String(issueNumber)}`);
|
|
77
|
-
return isRelated ? [...entries, { key: pullRequestKey(pullRequest), pullRequest, isConnection: false }] : entries;
|
|
78
|
-
}
|
|
79
|
-
if (type !== 'ConnectedEvent' && type !== 'DisconnectedEvent')
|
|
80
|
-
return entries;
|
|
81
|
-
const pullRequest = readPullRequest(jsonField(event, 'subject'));
|
|
82
|
-
if (pullRequest === undefined)
|
|
83
|
-
return entries;
|
|
84
|
-
const key = pullRequestKey(pullRequest);
|
|
85
|
-
return type === 'ConnectedEvent'
|
|
86
|
-
? [...entries, { key, pullRequest, isConnection: true }]
|
|
87
|
-
: entries.filter(entry => !(entry.isConnection && entry.key === key));
|
|
88
|
-
}
|
|
89
|
-
// ConnectedEvent は、後で同じ PR の DisconnectedEvent が無いものだけ採る。
|
|
90
|
-
// CrossReferencedEvent は、本文やコメントで触れただけの PR を除くため、閉じる参照か head が `/<Issue 番号>` で終わるものだけ採る
|
|
91
|
-
function readTimelinePullRequests(issue, issueNumber) {
|
|
92
|
-
const events = truthyNodes(jsonField(issue, 'timelineItems'));
|
|
93
|
-
let entries = [];
|
|
94
|
-
for (const event of events)
|
|
95
|
-
entries = applyTimelineEvent(entries, event, issueNumber);
|
|
96
|
-
return entries.map(entry => entry.pullRequest);
|
|
97
|
-
}
|
|
98
67
|
export function readIssue(issue, projectId, fieldNames) {
|
|
99
68
|
const issueType = jsonField(jsonField(issue, 'issueType'), 'name');
|
|
100
69
|
const number = requireNumber(jsonField(issue, 'number'), 'issue.number');
|
|
@@ -109,7 +78,6 @@ export function readIssue(issue, projectId, fieldNames) {
|
|
|
109
78
|
projectFieldValues: readProjectFieldValues(issue, projectId, fieldNames),
|
|
110
79
|
linkedBranches: readLinkedBranches(issue),
|
|
111
80
|
closingPullRequests: readPullRequests(truthyNodes(jsonField(issue, 'closedByPullRequestsReferences'))),
|
|
112
|
-
timelinePullRequests: readTimelinePullRequests(issue, number),
|
|
113
81
|
};
|
|
114
82
|
}
|
|
115
83
|
// 件数が totalCount に足りない connection の説明。足りていれば undefined
|
|
@@ -128,7 +96,6 @@ function connectionShortfalls(issue) {
|
|
|
128
96
|
shortfall(linkedBranches, 'linkedBranches', where),
|
|
129
97
|
...truthyNodes(linkedBranches).map(branch => shortfall(jsonField(jsonField(branch, 'ref'), 'associatedPullRequests'), 'associatedPullRequests', where)),
|
|
130
98
|
shortfall(jsonField(issue, 'closedByPullRequestsReferences'), 'closedByPullRequestsReferences', where),
|
|
131
|
-
shortfall(jsonField(issue, 'timelineItems'), 'timelineItems', where),
|
|
132
99
|
].filter(reason => reason !== undefined);
|
|
133
100
|
}
|
|
134
101
|
/**
|
|
@@ -153,4 +120,15 @@ export function readBlockedBy(target, projectId, fieldNames, errorMessages = [])
|
|
|
153
120
|
const [gap] = [target, ...nodes].flatMap(issue => connectionShortfalls(issue));
|
|
154
121
|
return gap === undefined ? { kind: 'ok', issues: nodes.map(node => readIssue(node, projectId, fieldNames)) } : { kind: 'read-failed', reason: gap };
|
|
155
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
前提 1 件の参照(node ID・番号・リポ・状態)。node は BlockedByReferenceFields の形
|
|
125
|
+
*/
|
|
126
|
+
export function readIssueReference(node) {
|
|
127
|
+
return {
|
|
128
|
+
id: requireString(jsonField(node, 'id'), 'blockedBy.nodes.id'),
|
|
129
|
+
repository: readRepository(node, 'blockedBy.nodes'),
|
|
130
|
+
number: requireNumber(jsonField(node, 'number'), 'blockedBy.nodes.number'),
|
|
131
|
+
state: readState(node, ['OPEN', 'CLOSED'], 'blockedBy.nodes'),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
156
134
|
//# sourceMappingURL=readout.js.map
|
|
@@ -9,12 +9,25 @@ export interface CreateReleaseOptions {
|
|
|
9
9
|
readonly draft?: boolean | undefined;
|
|
10
10
|
readonly prerelease?: boolean | undefined;
|
|
11
11
|
}
|
|
12
|
+
export interface GraphqlRateLimit {
|
|
13
|
+
readonly limit: number;
|
|
14
|
+
readonly used: number;
|
|
15
|
+
readonly remaining: number;
|
|
16
|
+
/**
|
|
17
|
+
窓が切り替わる時刻(UNIX 秒)
|
|
18
|
+
*/
|
|
19
|
+
readonly reset: number;
|
|
20
|
+
}
|
|
12
21
|
export declare class ReposApi extends GitHubClientBase {
|
|
13
22
|
/**
|
|
14
23
|
Link ヘッダの next を最後まで辿る。2 ページ目以降は next の絶対 URL を使い、params を再送すると cursor と二重になる
|
|
15
24
|
*/
|
|
16
25
|
protected listAll(path: string, firstParameters: Readonly<Record<string, number | string>>): Promise<readonly JsonValue[]>;
|
|
17
26
|
/**
|
|
27
|
+
GraphQL の点数の上限・使用量・残り・窓の切り替わり(REST の /rate_limit。点数を使わない)。読めない・形が違うときは undefined
|
|
28
|
+
*/
|
|
29
|
+
getGraphqlRateLimit(): Promise<GraphqlRateLimit | undefined>;
|
|
30
|
+
/**
|
|
18
31
|
リポジトリの GraphQL Node ID。見つからなければ GitHubNotFoundError
|
|
19
32
|
*/
|
|
20
33
|
getRepositoryId(owner: string, name: string): Promise<string>;
|
|
@@ -23,6 +36,11 @@ export declare class ReposApi extends GitHubClientBase {
|
|
|
23
36
|
*/
|
|
24
37
|
getBranchSha(owner: string, repository: string, branch: string): Promise<string>;
|
|
25
38
|
/**
|
|
39
|
+
head が base より進んでいる commit の数(REST の compare の ahead_by)。手元の git を使わない。
|
|
40
|
+
per_page=1 で commit の一覧を削っても、ahead_by は変わらない
|
|
41
|
+
*/
|
|
42
|
+
countCommitsAhead(owner: string, repository: string, base: string, head: string): Promise<number>;
|
|
43
|
+
/**
|
|
26
44
|
Issue に紐づいたブランチを作り、その名前を返す(gh issue develop と同等)。
|
|
27
45
|
repositoryId を省くと、Issue と同じリポジトリになる
|
|
28
46
|
*/
|
|
@@ -29,6 +29,26 @@ export class ReposApi extends GitHubClientBase {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
+
GraphQL の点数の上限・使用量・残り・窓の切り替わり(REST の /rate_limit。点数を使わない)。読めない・形が違うときは undefined
|
|
33
|
+
*/
|
|
34
|
+
async getGraphqlRateLimit() {
|
|
35
|
+
let body;
|
|
36
|
+
try {
|
|
37
|
+
body = await this.restJson('GET', '/rate_limit');
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof GitHubAPIError)
|
|
41
|
+
return undefined;
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
const graphql = jsonField(jsonField(body, 'resources'), 'graphql');
|
|
45
|
+
const limit = jsonField(graphql, 'limit');
|
|
46
|
+
const used = jsonField(graphql, 'used');
|
|
47
|
+
const remaining = jsonField(graphql, 'remaining');
|
|
48
|
+
const reset = jsonField(graphql, 'reset');
|
|
49
|
+
return typeof limit === 'number' && typeof used === 'number' && typeof remaining === 'number' && typeof reset === 'number' ? { limit, used, remaining, reset } : undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
32
52
|
リポジトリの GraphQL Node ID。見つからなければ GitHubNotFoundError
|
|
33
53
|
*/
|
|
34
54
|
async getRepositoryId(owner, name) {
|
|
@@ -46,6 +66,17 @@ export class ReposApi extends GitHubClientBase {
|
|
|
46
66
|
return requireString(jsonField(reference, 'sha'), 'object.sha');
|
|
47
67
|
}
|
|
48
68
|
/**
|
|
69
|
+
head が base より進んでいる commit の数(REST の compare の ahead_by)。手元の git を使わない。
|
|
70
|
+
per_page=1 で commit の一覧を削っても、ahead_by は変わらない
|
|
71
|
+
*/
|
|
72
|
+
async countCommitsAhead(owner, repository, base, head) {
|
|
73
|
+
const comparison = await this.restJson('GET', `${repositoryPath(owner, repository)}/compare/${encodePath(base)}...${encodePath(head)}`, { params: { per_page: 1 } });
|
|
74
|
+
const ahead = jsonField(comparison, 'ahead_by');
|
|
75
|
+
if (typeof ahead !== 'number' || !Number.isSafeInteger(ahead))
|
|
76
|
+
throw new GitHubAPIError('could not read ahead_by from the compare response');
|
|
77
|
+
return ahead;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
49
80
|
Issue に紐づいたブランチを作り、その名前を返す(gh issue develop と同等)。
|
|
50
81
|
repositoryId を省くと、Issue と同じリポジトリになる
|
|
51
82
|
*/
|
|
@@ -33,7 +33,7 @@ nx が無い・実行失敗・部分 graph・JSON の解析失敗なら undefine
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function nxProjects(toplevel: string, options?: Readonly<NxGraphOptions>): ReadonlyMap<string, NxProject> | undefined;
|
|
35
35
|
/**
|
|
36
|
-
`baseReference...head` の変更ファイル(リポジトリ root からの相対パス)を返す。
|
|
36
|
+
`baseReference...head` の変更ファイル(リポジトリ root からの相対パス)を返す。baseReference は、ブランチのほか、コミットの SHA(base の記録の位置)も受ける。
|
|
37
37
|
rename 検出だと移動元のプロジェクトが漏れ、`core.quotePath` だと非 ASCII パスが一致しなくなるため、`--no-renames` と NUL 区切りで取る。
|
|
38
38
|
baseReference / head が解決できない・git 失敗・git が無いなら undefined
|
|
39
39
|
*/
|
|
@@ -131,7 +131,7 @@ export function nxProjects(toplevel, options = {}) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
|
-
`baseReference...head` の変更ファイル(リポジトリ root からの相対パス)を返す。
|
|
134
|
+
`baseReference...head` の変更ファイル(リポジトリ root からの相対パス)を返す。baseReference は、ブランチのほか、コミットの SHA(base の記録の位置)も受ける。
|
|
135
135
|
rename 検出だと移動元のプロジェクトが漏れ、`core.quotePath` だと非 ASCII パスが一致しなくなるため、`--no-renames` と NUL 区切りで取る。
|
|
136
136
|
baseReference / head が解決できない・git 失敗・git が無いなら undefined
|
|
137
137
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BaseReading, BaseRecord } from '../domain/state.js';
|
|
1
2
|
export interface StateDirectoryOptions {
|
|
2
3
|
/**
|
|
3
4
|
true なら、無ければ作る
|
|
@@ -10,7 +11,7 @@ export interface StateDirectoryOptions {
|
|
|
10
11
|
export declare function getStateDirectory(options?: Readonly<StateDirectoryOptions>): string;
|
|
11
12
|
/**
|
|
12
13
|
作業ディレクトリ `.pecot/work/<Issue番号>/` を作って返す。
|
|
13
|
-
.pecot-active へ作業対象を記録するタイミング(
|
|
14
|
+
.pecot-active へ作業対象を記録するタイミング(session start / session restore)で呼ぶ。
|
|
14
15
|
作れないとき(プロジェクトルート不明・OS のエラー)は undefined。作業フロー自体は止めない
|
|
15
16
|
*/
|
|
16
17
|
export declare function ensureWorkDirectory(issueReference: string): string | undefined;
|
|
@@ -38,6 +39,14 @@ export declare function writeFlag(flagName: string, content: string): void;
|
|
|
38
39
|
*/
|
|
39
40
|
export declare function readFlag(flagName: string): string | undefined;
|
|
40
41
|
/**
|
|
42
|
+
着手のときに選んだ base を .pecot-base に 1 行で書く
|
|
43
|
+
*/
|
|
44
|
+
export declare function writeBaseRecord(record: Readonly<BaseRecord>): void;
|
|
45
|
+
/**
|
|
46
|
+
.pecot-base を読む。無ければ開発ブランチから着手したものとして返す
|
|
47
|
+
*/
|
|
48
|
+
export declare function readBaseRecord(): BaseReading;
|
|
49
|
+
/**
|
|
41
50
|
作業対象を記録する(.pecot-active と .pecot-session-title を同時に書く)。
|
|
42
51
|
issueReference の末尾が整数でなければ InvalidValueError で、何も書かない
|
|
43
52
|
*/
|
|
@@ -4,7 +4,7 @@ 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 { FLAG_PECOT_ACTIVE, FLAG_PECOT_SESSION_TITLE, planWorkTarget, workDirectoryName } from '../domain/state.js';
|
|
7
|
+
import { FLAG_PECOT_ACTIVE, FLAG_PECOT_BASE, FLAG_PECOT_SESSION_TITLE, formatBaseRecord, interpretBaseRecord, planWorkTarget, workDirectoryName } from '../domain/state.js';
|
|
8
8
|
import { OsError, hasErrorCode, isFileNotFound, isSystemCallError } from './os-error.js';
|
|
9
9
|
import { projectRoot, STATE_DIR, WORK_DIR } from './paths.js';
|
|
10
10
|
import { readTextFile } from './text-file.js';
|
|
@@ -19,7 +19,7 @@ export function getStateDirectory(options = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
作業ディレクトリ `.pecot/work/<Issue番号>/` を作って返す。
|
|
22
|
-
.pecot-active へ作業対象を記録するタイミング(
|
|
22
|
+
.pecot-active へ作業対象を記録するタイミング(session start / session restore)で呼ぶ。
|
|
23
23
|
作れないとき(プロジェクトルート不明・OS のエラー)は undefined。作業フロー自体は止めない
|
|
24
24
|
*/
|
|
25
25
|
export function ensureWorkDirectory(issueReference) {
|
|
@@ -107,6 +107,18 @@ export function readFlag(flagName) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
+
着手のときに選んだ base を .pecot-base に 1 行で書く
|
|
111
|
+
*/
|
|
112
|
+
export function writeBaseRecord(record) {
|
|
113
|
+
writeFlag(FLAG_PECOT_BASE, formatBaseRecord(record));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
.pecot-base を読む。無ければ開発ブランチから着手したものとして返す
|
|
117
|
+
*/
|
|
118
|
+
export function readBaseRecord() {
|
|
119
|
+
return interpretBaseRecord(readFlag(FLAG_PECOT_BASE));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
110
122
|
作業対象を記録する(.pecot-active と .pecot-session-title を同時に書く)。
|
|
111
123
|
issueReference の末尾が整数でなければ InvalidValueError で、何も書かない
|
|
112
124
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HintedText } from '../domain/command-hint.js';
|
|
1
2
|
import { PecotError } from '../domain/errors.js';
|
|
2
3
|
import type { JsonValue } from '../domain/python-format.js';
|
|
3
4
|
import type { Diagnostics } from './diagnostics.js';
|
|
@@ -22,6 +23,8 @@ export interface SymlinkResult {
|
|
|
22
23
|
ワークツリー設定の操作に失敗した
|
|
23
24
|
*/
|
|
24
25
|
export declare class WorktreeConfigError extends PecotError {
|
|
26
|
+
readonly hintedText: HintedText | undefined;
|
|
27
|
+
constructor(message: string | HintedText, options?: Readonly<ErrorOptions>);
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
個別リンク定義。キーは設定ファイルの JSON と同じ
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { spawnSync } from 'node:child_process';
|
|
14
14
|
import { existsSync, lstatSync, mkdirSync, realpathSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
15
15
|
import path from 'node:path';
|
|
16
|
+
import { commandHint, formatHinted, hinted } from '../domain/command-hint.js';
|
|
16
17
|
import { PecotError, InvalidValueError } from '../domain/errors.js';
|
|
17
18
|
import { isJsonObject, jsonField, parseJsonText } from '../domain/json.js';
|
|
18
19
|
import { isJsonArray, pythonStrip, ValidationFailure } from '../domain/python-format.js';
|
|
@@ -68,6 +69,12 @@ const PECOT_GITIGNORE_ENSURE_RELATIVE = 'hooks/lib/core/pecot-gitignore-ensure.s
|
|
|
68
69
|
ワークツリー設定の操作に失敗した
|
|
69
70
|
*/
|
|
70
71
|
export class WorktreeConfigError extends PecotError {
|
|
72
|
+
hintedText;
|
|
73
|
+
// message は CLI の形。MCP では最上位が hintedText から描き直す
|
|
74
|
+
constructor(message, options) {
|
|
75
|
+
super(formatHinted(message, 'cli'), options);
|
|
76
|
+
this.hintedText = typeof message === 'string' ? undefined : message;
|
|
77
|
+
}
|
|
71
78
|
}
|
|
72
79
|
// 検証(pydantic の WorktreeConfig と同じ文を作る)
|
|
73
80
|
function issueOf(type, location, message, input) {
|
|
@@ -245,7 +252,7 @@ function splitLines(text) {
|
|
|
245
252
|
export function loadCopyExcludeSpec(mainWorktree, diagnostics) {
|
|
246
253
|
const file = path.join(mainWorktree, WORKTREE_IGNORE_FILENAME);
|
|
247
254
|
if (!existsSync(file)) {
|
|
248
|
-
throw new WorktreeConfigError(`copy exclude config not found: ${WORKTREE_IGNORE_FILENAME}\n run
|
|
255
|
+
throw new WorktreeConfigError(hinted `copy exclude config not found: ${WORKTREE_IGNORE_FILENAME}\n run ${commandHint(['worktree', 'init'])} to generate the template`);
|
|
249
256
|
}
|
|
250
257
|
const rawLines = splitLines(readTextFile(file));
|
|
251
258
|
const effectiveLines = rawLines.filter(line => pythonStrip(line) !== '' && !pythonStrip(line).startsWith('#'));
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { BaseError } from '../domain/errors.js';
|
|
2
|
+
import type { HintedText } from '../domain/command-hint.js';
|
|
2
3
|
import type { Diagnostics } from './diagnostics.js';
|
|
3
4
|
import type { GitIgnoreSpec } from './gitignore-spec.js';
|
|
4
5
|
import type { SymlinkResult } from './worktree-links.js';
|
|
5
6
|
import type { CopyResult } from './worktree-copy.js';
|
|
6
7
|
import type { SetupResult } from './worktree-setup.js';
|
|
7
8
|
/**
|
|
9
|
+
WorktreeRuntimeError の原因の名前。commands の FailureKind の一部
|
|
10
|
+
*/
|
|
11
|
+
export type WorktreeFailure = 'config-invalid' | 'no-active-project' | 'not-initialized' | 'other' | 'repo-not-in-project' | 'repo-setting-missing';
|
|
12
|
+
/**
|
|
8
13
|
ワークツリー操作に失敗した(Python の RuntimeError に当たる)。メッセージは利用者に見せる文
|
|
9
14
|
*/
|
|
10
15
|
export declare class WorktreeRuntimeError extends BaseError {
|
|
16
|
+
readonly hintedText: HintedText | undefined;
|
|
17
|
+
readonly failure: WorktreeFailure;
|
|
18
|
+
constructor(message: string | HintedText, options?: Readonly<ErrorOptions & {
|
|
19
|
+
readonly failure?: WorktreeFailure;
|
|
20
|
+
}>);
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
pecot worktree 系コマンドが devcontainer 内で実行されていることを確認する。
|
|
@@ -165,10 +175,11 @@ export declare function createWorktree(cwd: string, diagnostics: Diagnostics, op
|
|
|
165
175
|
/**
|
|
166
176
|
ワークツリーを削除する。name は worktree add が付けた名前(wtN)か、checkout しているブランチ名。
|
|
167
177
|
WT が見つからない・削除に失敗した場合は WorktreeRuntimeError。
|
|
168
|
-
ローカルブランチを消せなかったときは、その理由を返す。成功時と shouldKeepBranch は undefined
|
|
178
|
+
ローカルブランチを消せなかったときは、その理由を返す。成功時と shouldKeepBranch は undefined。isDryRun は WT を探すだけで何も消さない
|
|
169
179
|
*/
|
|
170
180
|
export declare function removeWorktree(cwd: string, name: string, diagnostics: Diagnostics, options?: Readonly<{
|
|
171
181
|
readonly isForced?: boolean | undefined;
|
|
172
182
|
readonly shouldKeepBranch?: boolean | undefined;
|
|
183
|
+
readonly isDryRun?: boolean | undefined;
|
|
173
184
|
}>): string | undefined;
|
|
174
185
|
//# sourceMappingURL=worktree.d.ts.map
|