@pecot/workflow-mcp 6.0.0 → 7.0.1-dev.19
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 +5 -58
- package/cli/dist/commands/board-add.js +11 -1
- package/cli/dist/commands/board-judgment.d.ts +12 -3
- package/cli/dist/commands/board-judgment.js +12 -6
- package/cli/dist/commands/board-move.js +9 -1
- package/cli/dist/commands/board-readiness.d.ts +3 -3
- package/cli/dist/commands/board-show.js +5 -2
- package/cli/dist/commands/board-sync.js +14 -5
- package/cli/dist/commands/board-view.d.ts +94 -5
- package/cli/dist/commands/board-view.js +119 -17
- package/cli/dist/commands/branch.js +11 -17
- package/cli/dist/commands/command-definition.d.ts +19 -2
- package/cli/dist/commands/command-definition.js +9 -0
- package/cli/dist/commands/failure-kind.d.ts +1 -1
- package/cli/dist/commands/failure-kind.js +1 -0
- package/cli/dist/commands/issue-board.d.ts +31 -3
- package/cli/dist/commands/issue-board.js +28 -4
- package/cli/dist/commands/issue-comment.js +19 -2
- package/cli/dist/commands/issue-create.js +96 -17
- package/cli/dist/commands/issue-dependency.js +51 -14
- package/cli/dist/commands/issue-readiness.d.ts +30 -2
- package/cli/dist/commands/issue-readiness.js +35 -0
- package/cli/dist/commands/issue-reopen.js +18 -3
- package/cli/dist/commands/issue-shared.d.ts +11 -5
- package/cli/dist/commands/issue-shared.js +25 -6
- package/cli/dist/commands/issue-show.js +78 -8
- package/cli/dist/commands/names.d.ts +1 -1
- package/cli/dist/commands/names.js +3 -3
- package/cli/dist/commands/output.d.ts +18 -2
- package/cli/dist/commands/output.js +16 -3
- package/cli/dist/commands/pr-merge.d.ts +3 -0
- package/cli/dist/commands/pr-merge.js +225 -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 +231 -0
- package/cli/dist/commands/pr-waiting.d.ts +41 -2
- package/cli/dist/commands/pr-waiting.js +74 -37
- package/cli/dist/commands/pr.d.ts +10 -6
- package/cli/dist/commands/pr.js +214 -111
- package/cli/dist/commands/project-sync.d.ts +10 -2
- package/cli/dist/commands/project-sync.js +7 -6
- package/cli/dist/commands/project.js +174 -17
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +67 -18
- package/cli/dist/commands/renamed-commands.js +0 -1
- package/cli/dist/commands/repository-match.js +7 -2
- package/cli/dist/commands/restack-reading.d.ts +45 -0
- package/cli/dist/commands/restack-reading.js +29 -0
- package/cli/dist/commands/session-finish.js +132 -28
- package/cli/dist/commands/session-start.js +31 -60
- package/cli/dist/commands/session.js +119 -135
- package/cli/dist/commands/tracker-sync-dependabot.js +21 -4
- package/cli/dist/commands/tracker-sync-security.js +22 -4
- package/cli/dist/commands/tracker-sync.d.ts +30 -0
- package/cli/dist/commands/tracker-sync.js +15 -0
- package/cli/dist/commands/tracker.js +2 -0
- package/cli/dist/commands/work-target.d.ts +14 -9
- package/cli/dist/commands/work-target.js +19 -19
- package/cli/dist/commands/worktree.js +71 -5
- 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/issue-readout.d.ts +0 -4
- package/cli/dist/domain/pull-request.d.ts +20 -3
- package/cli/dist/domain/pull-request.js +25 -9
- package/cli/dist/domain/readiness.d.ts +17 -0
- package/cli/dist/domain/readiness.js +39 -2
- package/cli/dist/domain/restack.d.ts +66 -0
- package/cli/dist/domain/restack.js +57 -0
- package/cli/dist/domain/state.d.ts +41 -12
- package/cli/dist/domain/state.js +30 -14
- package/cli/dist/domain/work-start.d.ts +0 -4
- package/cli/dist/domain/work-start.js +0 -7
- package/cli/dist/infra/git.d.ts +69 -0
- package/cli/dist/infra/git.js +117 -0
- package/cli/dist/infra/github/pulls.d.ts +81 -2
- package/cli/dist/infra/github/pulls.js +116 -5
- package/cli/dist/infra/github/queries.d.ts +4 -1
- package/cli/dist/infra/github/queries.js +47 -32
- package/cli/dist/infra/github/readout.js +0 -33
- 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/dist/mcp/result.d.ts +63 -16
- package/cli/dist/mcp/result.js +106 -30
- package/cli/dist/mcp/server.js +37 -4
- package/cli/templates/comment/plan.md +2 -2
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +3 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/cli/dist/mcp/result.d.ts
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import type { CallToolResult } from '@modelcontextprotocol/server';
|
|
1
|
+
import type { CallToolResult, StandardSchemaWithJSON } from '@modelcontextprotocol/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { FailureKind } from '../commands/failure-kind.js';
|
|
4
4
|
import type { CommandIo } from '../commands/registry.js';
|
|
5
5
|
export interface CommandOutcome {
|
|
6
|
+
/**
|
|
7
|
+
成否を決めるためだけに使う。結果には載せない
|
|
8
|
+
*/
|
|
6
9
|
readonly exitCode: number;
|
|
10
|
+
/**
|
|
11
|
+
成功の文を決めるためだけに使う。結果には載せない
|
|
12
|
+
*/
|
|
7
13
|
readonly stdout: string;
|
|
14
|
+
/**
|
|
15
|
+
失敗の detail を決めるためだけに使う。結果には載せない
|
|
16
|
+
*/
|
|
8
17
|
readonly stderr: string;
|
|
9
18
|
/**
|
|
10
19
|
失敗の原因の名前。終了コードが 0 でないのに無ければ other
|
|
11
20
|
*/
|
|
12
21
|
readonly kind?: FailureKind | undefined;
|
|
13
22
|
/**
|
|
14
|
-
失敗の
|
|
23
|
+
失敗の detail の代わりの文。warning を除いた stderr が空のときに使う
|
|
15
24
|
*/
|
|
16
25
|
readonly message?: string | undefined;
|
|
17
26
|
/**
|
|
18
|
-
|
|
27
|
+
成功の文に使う結果の行(片付けの行を除いた最初のもの)。無ければ stdout の最初の空でない行
|
|
19
28
|
*/
|
|
20
29
|
readonly resultLine?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
コマンドの output で検証した後の項目。失敗では途中まで進んだ結果
|
|
32
|
+
*/
|
|
33
|
+
readonly data?: Readonly<Record<string, unknown>> | undefined;
|
|
34
|
+
readonly warnings?: readonly string[] | undefined;
|
|
21
35
|
}
|
|
22
36
|
export interface CollectedIo {
|
|
23
37
|
/**
|
|
@@ -28,26 +42,59 @@ export interface CollectedIo {
|
|
|
28
42
|
readonly stderr: () => string;
|
|
29
43
|
readonly kind: () => FailureKind | undefined;
|
|
30
44
|
readonly resultLine: () => string | undefined;
|
|
45
|
+
readonly data: () => Readonly<Record<string, unknown>>;
|
|
46
|
+
readonly warnings: () => readonly string[];
|
|
31
47
|
}
|
|
32
48
|
/**
|
|
33
|
-
stdout・stderr
|
|
49
|
+
stdout・stderr に書かれた文字列と、失敗の原因の名前、最初の結果の行、項目、warning の文を集める io
|
|
34
50
|
*/
|
|
35
51
|
export declare function collectIo(): CollectedIo;
|
|
36
52
|
/**
|
|
37
|
-
|
|
53
|
+
ツールの項目と並べて structuredContent の最上位に置く、全ツールに共通の 4 項目
|
|
54
|
+
*/
|
|
55
|
+
export declare const COMMON_OUTPUT_PROPERTIES: {
|
|
56
|
+
kind: {
|
|
57
|
+
type: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
detail: {
|
|
61
|
+
type: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
log: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
warnings: {
|
|
69
|
+
type: string;
|
|
70
|
+
items: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
ツールの outputSchema(JSON Schema)。最上位の properties にコマンドの output の項目と共通の 4 項目を並べ、
|
|
78
|
+
anyOf の枝で「成功の必須項目」か「kind と detail」を求める。成功の必須項目が無ければ anyOf を置かない
|
|
79
|
+
*/
|
|
80
|
+
export declare function toolOutputSchema(output: z.ZodObject): Record<string, unknown>;
|
|
81
|
+
/**
|
|
82
|
+
手組みの JSON Schema を、SDK が受ける形にする。検証は SDK の ajv(2020-12)で、値を変えない
|
|
83
|
+
*/
|
|
84
|
+
export declare function standardOutputSchema(schema: Readonly<Record<string, unknown>>): StandardSchemaWithJSON;
|
|
85
|
+
/**
|
|
86
|
+
stderr を、warning の文(前置きと続きの行の字下げを除く)と、それ以外の行に分ける。続きの行は、warning の行の後の空白 2 つで始まる行
|
|
87
|
+
*/
|
|
88
|
+
export declare function splitWarnings(stderr: string): {
|
|
89
|
+
readonly warnings: readonly string[];
|
|
90
|
+
readonly rest: readonly string[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
失敗の全文。warning を除いた stderr の、最初の error の行から後(前置きを除く)。error の行が無ければ warning を除いた stderr の全部、それも空なら message
|
|
38
94
|
*/
|
|
39
|
-
export declare
|
|
40
|
-
ok: z.ZodBoolean;
|
|
41
|
-
exitCode: z.ZodNumber;
|
|
42
|
-
kind: z.ZodOptional<z.ZodString>;
|
|
43
|
-
artifacts: z.ZodArray<z.ZodString>;
|
|
44
|
-
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
45
|
-
message: z.ZodString;
|
|
46
|
-
stdout: z.ZodOptional<z.ZodString>;
|
|
47
|
-
stderr: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, z.core.$strip>;
|
|
95
|
+
export declare function detailOf(stderr: string, message: string): string;
|
|
49
96
|
/**
|
|
50
|
-
structuredContent
|
|
97
|
+
content は、文の text(空なら省く)と、structuredContent と 1 字も違わない JSON の text。ホストがどちらを渡しても同じ中身が届く
|
|
51
98
|
*/
|
|
52
99
|
export declare function toToolResult(outcome: Readonly<CommandOutcome>): CallToolResult;
|
|
53
100
|
/**
|
package/cli/dist/mcp/result.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
// MCP のツールの結果。コマンドの出力と、MCP の io だけが受ける項目・warning を集め、仕様の content・structuredContent・isError の形にする。
|
|
2
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- zod の型は readonly にできない */
|
|
3
|
+
import { fromJsonSchema } from '@modelcontextprotocol/server';
|
|
1
4
|
import { z } from 'zod';
|
|
5
|
+
import { WARNING_PREFIX } from '../commands/output.js';
|
|
2
6
|
import { USAGE_EXIT_CODE } from '../commands/usage-error.js';
|
|
3
7
|
/**
|
|
4
|
-
stdout・stderr
|
|
8
|
+
stdout・stderr に書かれた文字列と、失敗の原因の名前、最初の結果の行、項目、warning の文を集める io
|
|
5
9
|
*/
|
|
6
10
|
export function collectIo() {
|
|
7
11
|
const out = [];
|
|
8
12
|
const error = [];
|
|
9
13
|
let failureKind;
|
|
10
14
|
let firstResult;
|
|
15
|
+
// createOutput を何度も呼ぶコマンドがあるので、項目はここで重ねる
|
|
16
|
+
let fields = {};
|
|
17
|
+
const warnings = [];
|
|
11
18
|
return {
|
|
12
19
|
io: {
|
|
13
20
|
stdout: (text) => {
|
|
@@ -23,62 +30,131 @@ export function collectIo() {
|
|
|
23
30
|
resultLine: (line) => {
|
|
24
31
|
firstResult ??= line;
|
|
25
32
|
},
|
|
33
|
+
data: (added) => {
|
|
34
|
+
fields = { ...fields, ...added };
|
|
35
|
+
},
|
|
36
|
+
warning: (text) => {
|
|
37
|
+
warnings.push(text);
|
|
38
|
+
},
|
|
26
39
|
},
|
|
27
40
|
stdout: () => out.join(''),
|
|
28
41
|
stderr: () => error.join(''),
|
|
29
42
|
kind: () => failureKind,
|
|
30
43
|
resultLine: () => firstResult,
|
|
44
|
+
data: () => fields,
|
|
45
|
+
warnings: () => [...warnings],
|
|
31
46
|
};
|
|
32
47
|
}
|
|
33
48
|
/**
|
|
34
|
-
|
|
49
|
+
ツールの項目と並べて structuredContent の最上位に置く、全ツールに共通の 4 項目
|
|
35
50
|
*/
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
export const COMMON_OUTPUT_PROPERTIES = {
|
|
52
|
+
kind: { type: 'string', description: 'Failure kind (failure only)' },
|
|
53
|
+
detail: { type: 'string', description: 'Full failure text: the error message and the guidance lines that follow it (failure only)' },
|
|
54
|
+
log: { type: 'string', description: 'Raw output of a child process (failure only; omitted when not captured)' },
|
|
55
|
+
warnings: { type: 'array', items: { type: 'string' }, description: 'Warning messages, without the "warning: " prefix (omitted when there is none)' },
|
|
56
|
+
};
|
|
57
|
+
const FAILURE_REQUIRED = ['kind', 'detail'];
|
|
58
|
+
const JsonObjectSchema = z.looseObject({
|
|
59
|
+
properties: z.record(z.string(), z.unknown()).optional(),
|
|
60
|
+
required: z.array(z.string()).optional(),
|
|
45
61
|
});
|
|
62
|
+
/**
|
|
63
|
+
ツールの outputSchema(JSON Schema)。最上位の properties にコマンドの output の項目と共通の 4 項目を並べ、
|
|
64
|
+
anyOf の枝で「成功の必須項目」か「kind と detail」を求める。成功の必須項目が無ければ anyOf を置かない
|
|
65
|
+
*/
|
|
66
|
+
export function toolOutputSchema(output) {
|
|
67
|
+
const generated = Object.entries(z.toJSONSchema(output, { io: 'output' })).filter(([key]) => key !== '$schema');
|
|
68
|
+
const { required = [], properties = {}, ...rest } = JsonObjectSchema.parse(Object.fromEntries(generated));
|
|
69
|
+
return {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: { ...properties, ...COMMON_OUTPUT_PROPERTIES },
|
|
72
|
+
// 定義書に書き出す順(type・properties・additionalProperties)に合わせる
|
|
73
|
+
...rest,
|
|
74
|
+
...required.length > 0 && { anyOf: [{ required }, { required: [...FAILURE_REQUIRED] }] },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
手組みの JSON Schema を、SDK が受ける形にする。検証は SDK の ajv(2020-12)で、値を変えない
|
|
79
|
+
*/
|
|
80
|
+
export function standardOutputSchema(schema) {
|
|
81
|
+
// eslint-disable-next-line no-restricted-syntax -- JsonSchemaType は全キーワードの型で、組み立てた object を当てられない
|
|
82
|
+
return fromJsonSchema(schema);
|
|
83
|
+
}
|
|
46
84
|
const ERROR_PREFIX = 'error: ';
|
|
85
|
+
const CONTINUATION = ' ';
|
|
47
86
|
function linesOf(text) {
|
|
48
87
|
return text.split('\n').filter(line => line.trim() !== '');
|
|
49
88
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
89
|
+
/**
|
|
90
|
+
stderr を、warning の文(前置きと続きの行の字下げを除く)と、それ以外の行に分ける。続きの行は、warning の行の後の空白 2 つで始まる行
|
|
91
|
+
*/
|
|
92
|
+
export function splitWarnings(stderr) {
|
|
93
|
+
const warnings = [];
|
|
94
|
+
const rest = [];
|
|
95
|
+
let current;
|
|
96
|
+
for (const line of stderr.split('\n')) {
|
|
97
|
+
if (line.startsWith(WARNING_PREFIX)) {
|
|
98
|
+
current = [line.slice(WARNING_PREFIX.length)];
|
|
99
|
+
warnings.push('');
|
|
100
|
+
}
|
|
101
|
+
else if (current !== undefined && line.startsWith(CONTINUATION)) {
|
|
102
|
+
current.push(line.slice(CONTINUATION.length));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
current = undefined;
|
|
106
|
+
rest.push(line);
|
|
107
|
+
}
|
|
108
|
+
if (current !== undefined)
|
|
109
|
+
warnings[warnings.length - 1] = current.join('\n');
|
|
110
|
+
}
|
|
111
|
+
return { warnings, rest };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
失敗の全文。warning を除いた stderr の、最初の error の行から後(前置きを除く)。error の行が無ければ warning を除いた stderr の全部、それも空なら message
|
|
115
|
+
*/
|
|
116
|
+
export function detailOf(stderr, message) {
|
|
117
|
+
const { rest } = splitWarnings(stderr);
|
|
118
|
+
const start = rest.findIndex(line => line.startsWith(ERROR_PREFIX));
|
|
119
|
+
const kept = start === -1 ? rest : rest.slice(start).with(0, rest.at(start)?.slice(ERROR_PREFIX.length) ?? '');
|
|
120
|
+
const text = kept.join('\n').replaceAll(/^\n+|\n+$/g, '');
|
|
121
|
+
return text === '' ? message : text;
|
|
122
|
+
}
|
|
123
|
+
// 失敗の detail の代わりの文。渡された message、無ければ最初の error の行の文、それも無ければ stderr の最初の行
|
|
124
|
+
function failureMessageOf(outcome) {
|
|
55
125
|
if (outcome.message !== undefined)
|
|
56
126
|
return outcome.message;
|
|
127
|
+
const lines = linesOf(outcome.stderr);
|
|
57
128
|
const errorLine = lines.find(line => line.startsWith(ERROR_PREFIX));
|
|
58
129
|
return errorLine === undefined ? (lines.at(0)?.trim() ?? '') : errorLine.slice(ERROR_PREFIX.length);
|
|
59
130
|
}
|
|
60
131
|
function toOutput(outcome) {
|
|
61
|
-
const
|
|
132
|
+
const warnings = outcome.warnings ?? [];
|
|
133
|
+
const warned = warnings.length > 0 ? { warnings } : {};
|
|
134
|
+
if (outcome.exitCode === 0) {
|
|
135
|
+
return {
|
|
136
|
+
isOk: true,
|
|
137
|
+
text: outcome.resultLine ?? linesOf(outcome.stdout).at(0)?.trim() ?? '',
|
|
138
|
+
structured: { ...outcome.data, ...warned },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const detail = detailOf(outcome.stderr, failureMessageOf(outcome));
|
|
62
142
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
artifacts: [],
|
|
67
|
-
data: {},
|
|
68
|
-
message: messageOf(outcome),
|
|
69
|
-
...outcome.stdout !== '' && { stdout: outcome.stdout },
|
|
70
|
-
...outcome.stderr !== '' && { stderr: outcome.stderr },
|
|
143
|
+
isOk: false,
|
|
144
|
+
text: detail,
|
|
145
|
+
structured: { kind: outcome.kind ?? 'other', detail, ...outcome.data, ...warned },
|
|
71
146
|
};
|
|
72
147
|
}
|
|
73
148
|
/**
|
|
74
|
-
structuredContent
|
|
149
|
+
content は、文の text(空なら省く)と、structuredContent と 1 字も違わない JSON の text。ホストがどちらを渡しても同じ中身が届く
|
|
75
150
|
*/
|
|
76
151
|
export function toToolResult(outcome) {
|
|
77
|
-
const
|
|
152
|
+
const { isOk, text, structured } = toOutput(outcome);
|
|
153
|
+
const json = { type: 'text', text: JSON.stringify(structured) };
|
|
78
154
|
return {
|
|
79
|
-
content: [{ type: 'text', text
|
|
80
|
-
structuredContent: { ...
|
|
81
|
-
...!
|
|
155
|
+
content: text === '' ? [json] : [{ type: 'text', text }, json],
|
|
156
|
+
structuredContent: { ...structured },
|
|
157
|
+
...!isOk && { isError: true },
|
|
82
158
|
};
|
|
83
159
|
}
|
|
84
160
|
/**
|
package/cli/dist/mcp/server.js
CHANGED
|
@@ -14,7 +14,7 @@ import { findRenamedInput, renamedInputNote } from '../commands/renamed-commands
|
|
|
14
14
|
import { outputWidth } from '../commands/rich-panel.js';
|
|
15
15
|
import { UsageError } from '../commands/usage-error.js';
|
|
16
16
|
import { readVersion } from '../version.js';
|
|
17
|
-
import { collectIo,
|
|
17
|
+
import { collectIo, standardOutputSchema, toAbortedResult, toolOutputSchema, toRejectedResult, toToolResult } from './result.js';
|
|
18
18
|
export const MCP_SERVER_NAME = 'pecot-workflow';
|
|
19
19
|
function rejected(message) {
|
|
20
20
|
return { kind: 'rejected', message: `invalid input: ${message}` };
|
|
@@ -109,10 +109,43 @@ async function invoke(definition, raw, options) {
|
|
|
109
109
|
}
|
|
110
110
|
catch (error_) {
|
|
111
111
|
options.reportUnexpected?.(error_, { stdout: collected.stdout(), stderr: collected.stderr() });
|
|
112
|
-
return
|
|
112
|
+
return finish(definition, collected, { exitCode: 1, message: unexpectedMessage(error_), kind: 'other' }, options);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return finish(definition, collected, { exitCode, message }, options);
|
|
116
|
+
}
|
|
117
|
+
// SDK の検証に任せると、合わない結果は structuredContent の無い文字列だけになるので、ここで検証する
|
|
118
|
+
function finish(definition, collected, ended, options) {
|
|
119
|
+
const stdout = collected.stdout();
|
|
120
|
+
const stderr = collected.stderr();
|
|
121
|
+
const outcome = {
|
|
122
|
+
exitCode: ended.exitCode,
|
|
123
|
+
stdout,
|
|
124
|
+
stderr,
|
|
125
|
+
kind: ended.kind ?? collected.kind(),
|
|
126
|
+
message: ended.message,
|
|
127
|
+
resultLine: collected.resultLine(),
|
|
128
|
+
warnings: collected.warnings(),
|
|
129
|
+
};
|
|
130
|
+
const raw = collected.data();
|
|
131
|
+
if (ended.exitCode === 0) {
|
|
132
|
+
const parsed = definition.output.safeParse(raw);
|
|
133
|
+
if (parsed.success)
|
|
134
|
+
return toToolResult({ ...outcome, data: parsed.data });
|
|
135
|
+
options.reportUnexpected?.(parsed.error, { stdout, stderr });
|
|
136
|
+
// 書き込みが済んだ後の食い違いもありうるので、呼び直さないよう伝える。項目は失敗と同じく省略可の形で検証して残す
|
|
137
|
+
const message = `the command finished, but its data does not match the output schema: ${issuesMessage(parsed.error)}; the operation may already be done, so do not call it again`;
|
|
138
|
+
return toToolResult({ ...outcome, exitCode: 1, stderr: '', kind: 'other', message, data: partialData(definition, raw, stdout, stderr, options) });
|
|
139
|
+
}
|
|
140
|
+
return toToolResult({ ...outcome, data: partialData(definition, raw, stdout, stderr, options) });
|
|
141
|
+
}
|
|
142
|
+
// 失敗の結果は SDK とクライアントが検証しない。省略可の形に合わなければ、kind などを保ち、ツールの項目だけを捨てる
|
|
143
|
+
function partialData(definition, raw, stdout, stderr, options) {
|
|
144
|
+
const parsed = definition.output.partial().safeParse(raw);
|
|
145
|
+
if (parsed.success)
|
|
146
|
+
return parsed.data;
|
|
147
|
+
options.reportUnexpected?.(parsed.error, { stdout, stderr });
|
|
148
|
+
return undefined;
|
|
116
149
|
}
|
|
117
150
|
// コマンドは process.cwd()(起動のときに serve.ts が決めたセッションのディレクトリ)と .pecot/ の状態ファイルを読み書きするので、呼び出しは 1 件ずつ実行する。接続が複数あっても共有する
|
|
118
151
|
const sequence = { tail: Promise.resolve(true) };
|
|
@@ -135,7 +168,7 @@ MCP サーバを作り、commands のそれぞれをツールとして登録す
|
|
|
135
168
|
export function createMcpServer(commands = COMMANDS, options = {}) {
|
|
136
169
|
const server = new McpServer({ name: MCP_SERVER_NAME, version: readVersion() });
|
|
137
170
|
for (const definition of commands) {
|
|
138
|
-
server.registerTool(definition.toolName, { description: definition.description, inputSchema: passthroughSchema(definition), outputSchema:
|
|
171
|
+
server.registerTool(definition.toolName, { description: definition.description, inputSchema: passthroughSchema(definition), outputSchema: standardOutputSchema(toolOutputSchema(definition.output)) }, async (arguments_, serverContext) => await inSequence(serverContext.mcpReq.signal, async () => await invoke(definition, arguments_, options)));
|
|
139
172
|
}
|
|
140
173
|
return server;
|
|
141
174
|
}
|
|
@@ -9,6 +9,7 @@ template: plan
|
|
|
9
9
|
書き方:
|
|
10
10
|
- Files は、外に触る代表ファイルを並べ、`<details>` の中にファイルごとのどう触るかを詳しく書く
|
|
11
11
|
- Files の `<details>` の先頭に作業単位の表(実装者・モデル・担当)を書く。実装者は `w-implementer-1` から順に名付け、main が自分で直すなら `main` と書き、その行のモデルは `—` にする。モデルの基準は w-help スキルの参照「エージェントのモデル」(pecot-w の `skills/w-help/references/agent-models.md`)
|
|
12
|
+
- 作業単位を委譲するかは、w-help スキルの参照「サブエージェントの使い方」(pecot-w の `skills/w-help/references/subagent-usage.md`)の「実装と修正を委譲する条件」で決める。当たらない単位の実装者は `main` にする
|
|
12
13
|
- Claude Code の plan mode の標準 5 項目は、Context・Approach(推奨方針)・Files(主要ファイルと再利用する既存関数)・E2E(検証)に書く
|
|
13
14
|
|
|
14
15
|
CUJ = 利用者(人またはエージェント)が製品の起点から始め、利用者が観測する結果で終わる操作フロー。
|
|
@@ -57,8 +58,7 @@ CUJ ごとに「誰が・起点・観測結果」の 3 要素を必須とし、
|
|
|
57
58
|
|
|
58
59
|
| 実装者 | モデル | 担当 |
|
|
59
60
|
|---|---|---|
|
|
60
|
-
|
|
|
61
|
-
| w-implementer-2 | sonnet | `src/writers/json.py`・`tests/test_export.py`(既存の処理の移し替えと、決まった形のテストの追加) |
|
|
61
|
+
| main | — | 4 ファイルの全部(独立した作業が 3 つに届かず、読むファイルも少ないので、委譲しない) |
|
|
62
62
|
|
|
63
63
|
- `src/export.py`
|
|
64
64
|
- `--format` の引数を足す。値は `json`(既定)と `csv`
|
|
@@ -10,6 +10,7 @@ template: review-findings
|
|
|
10
10
|
- 見出しの `—` の後は、何がどうなったか(どうなるか)を、主語と述語のある 1 文で書く
|
|
11
11
|
- 行に紐づく指摘は、PR の該当行にインラインコメントとして投稿してある。本文をここに再掲しない
|
|
12
12
|
- 指摘 1 件に F-NN を 1 つ振る(F-01 から連番。外部のレビュアーの指摘も同じ連番)
|
|
13
|
+
- 視点の印は w-reviewer の指摘に付け、w-reviewer が返した `[tech]`・`[cuj]`・`[quality]` のどれかを書く。w-e2e-planner が返した CUJ の不合格は `[cuj]` にする。外部のレビュアーの指摘には付けない
|
|
13
14
|
- General には、行に紐づけられない指摘だけを書く(PR 本文・欠けているもの・差分の外の既存行・横断的な設計)
|
|
14
15
|
- Disposition には、インラインにした分も含めて全 F-NN を並べる。URL は、自分が投稿したコメントなら `html_url`、外部のレビュアーなら元のスレッド。インラインでない分は省く
|
|
15
16
|
- 想定する方針は「対応」か「対応不要」で書く。保留は使わない
|
|
@@ -22,7 +23,7 @@ template: review-findings
|
|
|
22
23
|
|
|
23
24
|
### General — PR 本文に CSV の文字コードの説明が無い
|
|
24
25
|
|
|
25
|
-
- **F-02** [tech
|
|
26
|
+
- **F-02** [tech] PR 本文の Summary に、書き出す CSV の文字コード(UTF-8・BOM の有無)が書かれていない
|
|
26
27
|
|
|
27
28
|
### Disposition — 2 件の指摘は、どちらも直す
|
|
28
29
|
|
|
@@ -34,7 +35,7 @@ template: review-findings
|
|
|
34
35
|
|
|
35
36
|
### General — <行に紐づかない指摘を1行で>
|
|
36
37
|
|
|
37
|
-
- **F-02** [
|
|
38
|
+
- **F-02** [<視点の印>] <指摘の要旨(該当箇所)>
|
|
38
39
|
|
|
39
40
|
### Disposition — <F-NN ごとの想定対応方針を1行で>
|
|
40
41
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
title: ""
|
|
3
3
|
type: bug
|
|
4
4
|
repository: ""
|
|
5
|
-
status: ready
|
|
6
5
|
priority: ""
|
|
7
6
|
size: ""
|
|
8
7
|
labels: []
|
|
9
8
|
parent_epic: ""
|
|
10
|
-
|
|
9
|
+
blocked_by: []
|
|
11
10
|
---
|
|
12
11
|
|
|
13
12
|
<!--
|
|
@@ -20,8 +19,18 @@ order: ""
|
|
|
20
19
|
フィールド:
|
|
21
20
|
- repository: 起票先 `owner/repo` 必須
|
|
22
21
|
- parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
|
|
23
|
-
-
|
|
24
|
-
-
|
|
22
|
+
- blocked_by: この Issue の着手を止める前提の一覧。前提が無ければ `[]` のまま
|
|
23
|
+
- `issue` は、前提の Issue を指す `owner/repo/N`
|
|
24
|
+
- マージを待つ前提だけ、`wait: merge` と、待つ理由の 1 文の `reason`(改行しない)を足す
|
|
25
|
+
```yaml
|
|
26
|
+
blocked_by:
|
|
27
|
+
- issue: acme/mytool/12
|
|
28
|
+
- issue: acme/mytool/13
|
|
29
|
+
wait: merge
|
|
30
|
+
reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
|
|
31
|
+
```
|
|
32
|
+
- order・status: 書かない。通し番号(タイトル先頭の `#{epic}-NN`)と置く列(前提があれば `Blocked`、無ければ `Ready`)は CLI が決める
|
|
33
|
+
- 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
|
|
25
34
|
|
|
26
35
|
例:
|
|
27
36
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
title: ""
|
|
3
3
|
type: task
|
|
4
4
|
repository: ""
|
|
5
|
-
status: ready
|
|
6
5
|
priority: ""
|
|
7
6
|
size: ""
|
|
8
7
|
labels: []
|
|
9
8
|
parent_epic: ""
|
|
10
|
-
|
|
9
|
+
blocked_by: []
|
|
11
10
|
---
|
|
12
11
|
|
|
13
12
|
<!--
|
|
@@ -19,8 +18,18 @@ order: ""
|
|
|
19
18
|
フィールド:
|
|
20
19
|
- repository: 起票先 `owner/repo` 必須
|
|
21
20
|
- parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
|
|
22
|
-
-
|
|
23
|
-
-
|
|
21
|
+
- blocked_by: この Issue の着手を止める前提の一覧。前提が無ければ `[]` のまま
|
|
22
|
+
- `issue` は、前提の Issue を指す `owner/repo/N`
|
|
23
|
+
- マージを待つ前提だけ、`wait: merge` と、待つ理由の 1 文の `reason`(改行しない)を足す
|
|
24
|
+
```yaml
|
|
25
|
+
blocked_by:
|
|
26
|
+
- issue: acme/mytool/12
|
|
27
|
+
- issue: acme/mytool/13
|
|
28
|
+
wait: merge
|
|
29
|
+
reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
|
|
30
|
+
```
|
|
31
|
+
- order・status: 書かない。通し番号(タイトル先頭の `#{epic}-NN`)と置く列(前提があれば `Blocked`、無ければ `Ready`)は CLI が決める
|
|
32
|
+
- 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
|
|
24
33
|
|
|
25
34
|
例:
|
|
26
35
|
|
|
@@ -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": "
|
|
3
|
+
"version": "7.0.1-dev.19",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/workflow-mcp",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "7.0.1-dev.19",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/server": "^2.4.0",
|