@pecot/workflow-mcp 8.0.1-dev.40 → 8.0.1-dev.42
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/commands/issue-reopen.js +25 -2
- package/cli/dist/infra/github/projects.d.ts +11 -0
- package/cli/dist/infra/github/projects.js +17 -2
- package/cli/dist/infra/github/queries.d.ts +2 -1
- package/cli/dist/infra/github/queries.js +20 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -13,10 +13,13 @@ import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath,
|
|
|
13
13
|
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
14
14
|
// Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
|
|
15
15
|
const AUTOMATION_WAIT_MILLISECONDS = 3000;
|
|
16
|
+
// 組み込みの Auto-close issue が、初期の設定で Issue を閉じる Status の値
|
|
17
|
+
const DONE_STATUS = 'Done';
|
|
16
18
|
const ISSUE_REOPEN_OUTPUT = z.strictObject({
|
|
17
19
|
issue: z.string().describe('Issue reopened (owner/repo/N)'),
|
|
18
20
|
status: z.string().optional().describe('Workflow status set on the board (omitted when the Issue is not on the board or the status is not configured)'),
|
|
19
21
|
unarchived: z.boolean().describe('Whether the item was unarchived on the board'),
|
|
22
|
+
doneCleared: z.boolean().describe('Whether the built-in Status Done was cleared on the board'),
|
|
20
23
|
commented: z.boolean().describe('Whether the reason was posted as a comment'),
|
|
21
24
|
dryRun: DRY_RUN_FIELD,
|
|
22
25
|
});
|
|
@@ -25,7 +28,7 @@ async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
|
25
28
|
const { owner, repository, number } = issue;
|
|
26
29
|
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
27
30
|
const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
|
|
28
|
-
output.result({ issue: issuePath(issue.owner, issue.repository, issue.number), unarchived: false, commented: false });
|
|
31
|
+
output.result({ issue: issuePath(issue.owner, issue.repository, issue.number), unarchived: false, doneCleared: false, commented: false });
|
|
29
32
|
// アーカイブ済みの項目はボードの列に出ないので戻す。失敗したら Issue を開かずに止める
|
|
30
33
|
if (item?.isArchived === true) {
|
|
31
34
|
try {
|
|
@@ -39,6 +42,8 @@ async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
|
39
42
|
output.done({ verb: 'update', target: `${target} unarchived on the board` });
|
|
40
43
|
output.result({ unarchived: true });
|
|
41
44
|
}
|
|
45
|
+
if (item?.status?.name === DONE_STATUS)
|
|
46
|
+
await clearDoneStatus(output, client, config, { target, itemId: item.id, fieldId: item.status.fieldId });
|
|
42
47
|
await client.reopenIssue(owner, repository, number);
|
|
43
48
|
const itemId = item?.id;
|
|
44
49
|
if (itemId === undefined) {
|
|
@@ -48,6 +53,21 @@ async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
|
48
53
|
await setReopenedStatus(output, client, config, { target, itemId }, status);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
56
|
+
// Status に Done が残ると、Auto-close issue で閉じ直されうる(#536)。消せなければ warning にとどめて続ける
|
|
57
|
+
async function clearDoneStatus(output, client, config, item) {
|
|
58
|
+
const { target, itemId, fieldId } = item;
|
|
59
|
+
try {
|
|
60
|
+
await client.clearProjectItemField(config.project.id, itemId, fieldId);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (!(error instanceof GitHubAPIError))
|
|
64
|
+
throw error;
|
|
65
|
+
output.warning(`could not remove ${target} Status ${DONE_STATUS} on the board: ${error.message}. The board automation may close the Issue again; clear Status on the board`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
output.done({ verb: 'remove', target: `${target} Status ${DONE_STATUS} on the board` });
|
|
69
|
+
output.result({ doneCleared: true });
|
|
70
|
+
}
|
|
51
71
|
// 列を書く。書けなければ warning にとどめ、2 回目の reopen とコメントの投稿へ進む。設定できたときだけ自動化を待つ
|
|
52
72
|
async function setReopenedStatus(output, client, config, item, status) {
|
|
53
73
|
const { target, itemId } = item;
|
|
@@ -100,10 +120,13 @@ async function planReopen(output, client, config, issue, status, comment) {
|
|
|
100
120
|
const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
|
|
101
121
|
const hasComment = comment !== undefined && comment !== '';
|
|
102
122
|
const willSetStatus = item !== undefined && isStatusConfigured(config, status);
|
|
103
|
-
|
|
123
|
+
const willClearDone = item?.status?.name === DONE_STATUS;
|
|
124
|
+
output.result({ issue: issuePath(issue.owner, issue.repository, issue.number), ...willSetStatus && { status }, unarchived: item?.isArchived === true, doneCleared: willClearDone, commented: hasComment });
|
|
104
125
|
output.planned({ verb: 'reopen', target });
|
|
105
126
|
if (item?.isArchived === true)
|
|
106
127
|
output.planned({ verb: 'update', target: `${target} unarchived on the board` });
|
|
128
|
+
if (willClearDone)
|
|
129
|
+
output.planned({ verb: 'remove', target: `${target} Status ${DONE_STATUS} on the board` });
|
|
107
130
|
if (item === undefined)
|
|
108
131
|
output.warning(`${target} is not on the project board`);
|
|
109
132
|
else if (willSetStatus)
|
|
@@ -11,6 +11,13 @@ Issue のボードのアイテム。isArchived はアイテムのアーカイブ
|
|
|
11
11
|
export interface IssueProjectItem {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly isArchived: boolean;
|
|
14
|
+
/**
|
|
15
|
+
組み込みの Status 欄の値。空なら undefined
|
|
16
|
+
*/
|
|
17
|
+
readonly status?: {
|
|
18
|
+
readonly fieldId: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
};
|
|
14
21
|
}
|
|
15
22
|
export interface ListProjectItemsOptions {
|
|
16
23
|
/**
|
|
@@ -68,6 +75,10 @@ export declare class ProjectsApi extends ReposApi {
|
|
|
68
75
|
*/
|
|
69
76
|
updateProjectItemField(projectId: string, itemId: string, fieldId: string, optionId: string): Promise<string>;
|
|
70
77
|
/**
|
|
78
|
+
プロジェクトアイテムのフィールドの値を消す
|
|
79
|
+
*/
|
|
80
|
+
clearProjectItemField(projectId: string, itemId: string, fieldId: string): Promise<void>;
|
|
81
|
+
/**
|
|
71
82
|
アーカイブ済みのアイテムをボードに戻す
|
|
72
83
|
*/
|
|
73
84
|
unarchiveProjectItem(projectId: string, itemId: string): Promise<void>;
|
|
@@ -4,10 +4,16 @@ import { isJsonObject, jsonField } from '../../domain/json.js';
|
|
|
4
4
|
import { JSON_NULL } from '../../domain/json-null.js';
|
|
5
5
|
import { asNotFoundError, GitHubAPIError, GitHubNotFoundError, isSchemaError } from './errors.js';
|
|
6
6
|
import { asArray, asObject, isTruthy, requireString, truthyNodes } from './payload.js';
|
|
7
|
-
import { MUTATION_ADD_TO_PROJECT, MUTATION_CREATE_PROJECT, MUTATION_CREATE_PROJECT_FIELD, MUTATION_DELETE_PROJECT_ITEM, MUTATION_UNARCHIVE_PROJECT_ITEM, MUTATION_LINK_PROJECT_REPOSITORY, MUTATION_UPDATE_PROJECT_FIELD, MUTATION_UPDATE_PROJECT_ITEM_FIELD, QUERY_GET_ISSUE_BOARD_ITEM, QUERY_GET_ISSUE_PROJECT_ITEMS, QUERY_GET_LINKED_REPOSITORIES_ORG, QUERY_GET_LINKED_REPOSITORIES_USER, QUERY_GET_ORG_NODE_ID, QUERY_GET_PROJECT_FIELDS_ORG, QUERY_GET_PROJECT_FIELDS_USER, QUERY_GET_PROJECT_ID_ORG, QUERY_GET_PROJECT_ID_USER, QUERY_GET_USER_NODE_ID, QUERY_LIST_PROJECT_ITEMS, QUERY_LIST_PROJECT_ITEMS_LEGACY, QUERY_LIST_PROJECTS_ORG, QUERY_LIST_PROJECTS_USER, } from './queries.js';
|
|
7
|
+
import { MUTATION_ADD_TO_PROJECT, MUTATION_CLEAR_PROJECT_ITEM_FIELD, MUTATION_CREATE_PROJECT, MUTATION_CREATE_PROJECT_FIELD, MUTATION_DELETE_PROJECT_ITEM, MUTATION_UNARCHIVE_PROJECT_ITEM, MUTATION_LINK_PROJECT_REPOSITORY, MUTATION_UPDATE_PROJECT_FIELD, MUTATION_UPDATE_PROJECT_ITEM_FIELD, QUERY_GET_ISSUE_BOARD_ITEM, QUERY_GET_ISSUE_PROJECT_ITEMS, QUERY_GET_LINKED_REPOSITORIES_ORG, QUERY_GET_LINKED_REPOSITORIES_USER, QUERY_GET_ORG_NODE_ID, QUERY_GET_PROJECT_FIELDS_ORG, QUERY_GET_PROJECT_FIELDS_USER, QUERY_GET_PROJECT_ID_ORG, QUERY_GET_PROJECT_ID_USER, QUERY_GET_USER_NODE_ID, QUERY_LIST_PROJECT_ITEMS, QUERY_LIST_PROJECT_ITEMS_LEGACY, QUERY_LIST_PROJECTS_ORG, QUERY_LIST_PROJECTS_USER, } from './queries.js';
|
|
8
8
|
import { ReposApi } from './repos.js';
|
|
9
9
|
// 着手の判定に足したフィールドの名前が出るスキーマの失敗(`Field 'x' doesn't exist` と `Cannot query field "x"`)
|
|
10
10
|
const READINESS_FIELD_ERROR = /(?:Field '|field ")(?:issueType|subIssues|parent|blockedBy)['"]/u;
|
|
11
|
+
function statusOf(item) {
|
|
12
|
+
const value = jsonField(item, 'status');
|
|
13
|
+
const name = jsonField(value, 'name');
|
|
14
|
+
const fieldId = jsonField(jsonField(value, 'field'), 'id');
|
|
15
|
+
return typeof name === 'string' && typeof fieldId === 'string' ? { fieldId, name } : undefined;
|
|
16
|
+
}
|
|
11
17
|
const MAX_ARCHIVED_CONSECUTIVE = 50;
|
|
12
18
|
const DEFAULT_PROJECT_LIMIT = 20;
|
|
13
19
|
function lowerText(value) {
|
|
@@ -150,6 +156,14 @@ export class ProjectsApi extends ReposApi {
|
|
|
150
156
|
return requireString(jsonField(item, 'id'), 'projectV2Item.id');
|
|
151
157
|
}
|
|
152
158
|
/**
|
|
159
|
+
プロジェクトアイテムのフィールドの値を消す
|
|
160
|
+
*/
|
|
161
|
+
async clearProjectItemField(projectId, itemId, fieldId) {
|
|
162
|
+
const result = await this.executeGraphql(MUTATION_CLEAR_PROJECT_ITEM_FIELD, { projectId, itemId, fieldId });
|
|
163
|
+
if (!isTruthy(jsonField(jsonField(result, 'clearProjectV2ItemFieldValue'), 'projectV2Item')))
|
|
164
|
+
throw new GitHubAPIError('failed to clear the field');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
153
167
|
アーカイブ済みのアイテムをボードに戻す
|
|
154
168
|
*/
|
|
155
169
|
async unarchiveProjectItem(projectId, itemId) {
|
|
@@ -236,7 +250,8 @@ export class ProjectsApi extends ReposApi {
|
|
|
236
250
|
for (const item of projectItems) {
|
|
237
251
|
if (jsonField(jsonField(item, 'project'), 'id') !== projectId)
|
|
238
252
|
continue;
|
|
239
|
-
|
|
253
|
+
const status = statusOf(item);
|
|
254
|
+
return { id: requireString(jsonField(item, 'id'), 'projectItems.nodes.id'), isArchived: jsonField(item, 'isArchived') === true, ...status !== undefined && { status } };
|
|
240
255
|
}
|
|
241
256
|
return undefined;
|
|
242
257
|
}
|
|
@@ -11,10 +11,11 @@ export declare const MUTATION_LINK_PROJECT_REPOSITORY = "mutation ($projectId: I
|
|
|
11
11
|
export declare const MUTATION_ADD_TO_PROJECT = "mutation ($projectId: ID!, $contentId: ID!) {\n addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {\n item {\n id\n }\n }\n}";
|
|
12
12
|
export declare const MUTATION_UPDATE_PROJECT_ITEM_FIELD = "mutation ($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {\n updateProjectV2ItemFieldValue(\n input: {\n projectId: $projectId\n itemId: $itemId\n fieldId: $fieldId\n value: { singleSelectOptionId: $optionId }\n }\n ) {\n projectV2Item {\n id\n }\n }\n}";
|
|
13
13
|
export declare const MUTATION_DELETE_PROJECT_ITEM = "mutation ($projectId: ID!, $itemId: ID!) {\n deleteProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {\n deletedItemId\n }\n}";
|
|
14
|
+
export declare const MUTATION_CLEAR_PROJECT_ITEM_FIELD = "mutation ($projectId: ID!, $itemId: ID!, $fieldId: ID!) {\n clearProjectV2ItemFieldValue(\n input: { projectId: $projectId, itemId: $itemId, fieldId: $fieldId }\n ) {\n projectV2Item {\n id\n }\n }\n}";
|
|
14
15
|
export declare const MUTATION_UNARCHIVE_PROJECT_ITEM = "mutation ($projectId: ID!, $itemId: ID!) {\n unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {\n item {\n id\n }\n }\n}";
|
|
15
16
|
export declare const MUTATION_ADD_SUB_ISSUE = "mutation ($parentId: ID!, $childId: ID!) {\n addSubIssue(input: { issueId: $parentId, subIssueId: $childId }) {\n issue {\n number\n }\n subIssue {\n number\n }\n }\n}";
|
|
16
17
|
export declare const MUTATION_CREATE_LINKED_BRANCH = "mutation CreateLinkedBranch($input: CreateLinkedBranchInput!) {\n createLinkedBranch(input: $input) {\n linkedBranch {\n ref {\n name\n prefix\n }\n }\n }\n}";
|
|
17
|
-
export declare const QUERY_GET_ISSUE_PROJECT_ITEMS = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n projectItems(first: 20) {\n nodes {\n id\n isArchived\n project {\n id\n }\n fieldValues(first: 20) {\n nodes {\n ... on ProjectV2ItemFieldSingleSelectValue {\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}";
|
|
18
|
+
export declare const QUERY_GET_ISSUE_PROJECT_ITEMS = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n projectItems(first: 20) {\n nodes {\n id\n isArchived\n project {\n id\n }\n fieldValues(first: 20) {\n nodes {\n ... on ProjectV2ItemFieldSingleSelectValue {\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n }\n }\n status: fieldValueByName(name: \"Status\") {\n ... on ProjectV2ItemFieldSingleSelectValue {\n name\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}";
|
|
18
19
|
export declare const QUERY_LIST_PROJECTS_USER = "query ($owner: String!, $first: Int!) {\n user(login: $owner) {\n projectsV2(first: $first) {\n nodes {\n number\n title\n url\n id\n }\n }\n }\n}";
|
|
19
20
|
export declare const QUERY_LIST_PROJECTS_ORG = "query ($owner: String!, $first: Int!) {\n organization(login: $owner) {\n projectsV2(first: $first) {\n nodes {\n number\n title\n url\n id\n }\n }\n }\n}";
|
|
20
21
|
export declare const QUERY_GET_PROJECT_FIELDS_USER = "query ($owner: String!, $projectNumber: Int!) {\n user(login: $owner) {\n projectV2(number: $projectNumber) {\n id\n title\n url\n fields(first: 50) {\n nodes {\n ... on ProjectV2SingleSelectField {\n id\n databaseId\n name\n options {\n id\n name\n color\n description\n }\n }\n ... on ProjectV2Field {\n id\n name\n }\n }\n }\n views(first: 1) {\n nodes {\n number\n }\n }\n }\n }\n}";
|
|
@@ -252,6 +252,16 @@ export const MUTATION_DELETE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId:
|
|
|
252
252
|
deletedItemId
|
|
253
253
|
}
|
|
254
254
|
}`;
|
|
255
|
+
// プロジェクトアイテムのフィールドの値を消す
|
|
256
|
+
export const MUTATION_CLEAR_PROJECT_ITEM_FIELD = `mutation ($projectId: ID!, $itemId: ID!, $fieldId: ID!) {
|
|
257
|
+
clearProjectV2ItemFieldValue(
|
|
258
|
+
input: { projectId: $projectId, itemId: $itemId, fieldId: $fieldId }
|
|
259
|
+
) {
|
|
260
|
+
projectV2Item {
|
|
261
|
+
id
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}`;
|
|
255
265
|
// プロジェクトアイテムのアーカイブを解く
|
|
256
266
|
export const MUTATION_UNARCHIVE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId: ID!) {
|
|
257
267
|
unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
@@ -304,6 +314,16 @@ export const QUERY_GET_ISSUE_PROJECT_ITEMS = `query ($owner: String!, $repo: Str
|
|
|
304
314
|
}
|
|
305
315
|
}
|
|
306
316
|
}
|
|
317
|
+
status: fieldValueByName(name: "Status") {
|
|
318
|
+
... on ProjectV2ItemFieldSingleSelectValue {
|
|
319
|
+
name
|
|
320
|
+
field {
|
|
321
|
+
... on ProjectV2SingleSelectField {
|
|
322
|
+
id
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
307
327
|
}
|
|
308
328
|
}
|
|
309
329
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/workflow-mcp",
|
|
3
|
-
"version": "8.0.1-dev.
|
|
3
|
+
"version": "8.0.1-dev.42",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "8.0.1-dev.
|
|
9
|
+
"version": "8.0.1-dev.42",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|