@pecot/workflow-mcp 5.0.0 → 6.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.
Files changed (176) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +80 -22
  3. package/cli/dist/cli.js +6 -1
  4. package/cli/dist/commands/board-add.d.ts +3 -0
  5. package/cli/dist/commands/board-add.js +59 -0
  6. package/cli/dist/commands/board-judgment.d.ts +60 -0
  7. package/cli/dist/commands/board-judgment.js +144 -0
  8. package/cli/dist/commands/board-move.d.ts +3 -0
  9. package/cli/dist/commands/board-move.js +57 -0
  10. package/cli/dist/commands/board-readiness.d.ts +34 -0
  11. package/cli/dist/commands/board-readiness.js +108 -0
  12. package/cli/dist/commands/board-show.d.ts +3 -0
  13. package/cli/dist/commands/board-show.js +72 -0
  14. package/cli/dist/commands/board-sync.d.ts +3 -0
  15. package/cli/dist/commands/board-sync.js +111 -0
  16. package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
  17. package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
  18. package/cli/dist/commands/board.d.ts +3 -0
  19. package/cli/dist/commands/board.js +12 -0
  20. package/cli/dist/commands/branch.d.ts +3 -0
  21. package/cli/dist/commands/branch.js +100 -0
  22. package/cli/dist/commands/command-binding.js +4 -0
  23. package/cli/dist/commands/command-definition.d.ts +20 -6
  24. package/cli/dist/commands/command-definition.js +11 -7
  25. package/cli/dist/commands/command-help.js +2 -2
  26. package/cli/dist/commands/command-hint.d.ts +5 -0
  27. package/cli/dist/commands/command-hint.js +13 -0
  28. package/cli/dist/commands/command-stop.d.ts +5 -3
  29. package/cli/dist/commands/command-stop.js +7 -6
  30. package/cli/dist/commands/failure-kind.d.ts +3 -0
  31. package/cli/dist/commands/failure-kind.js +34 -0
  32. package/cli/dist/commands/failure.d.ts +6 -0
  33. package/cli/dist/commands/failure.js +29 -3
  34. package/cli/dist/commands/github-client.d.ts +6 -2
  35. package/cli/dist/commands/github-client.js +13 -3
  36. package/cli/dist/commands/help.js +8 -13
  37. package/cli/dist/commands/issue-board.d.ts +33 -0
  38. package/cli/dist/commands/issue-board.js +61 -1
  39. package/cli/dist/commands/issue-comment.js +47 -28
  40. package/cli/dist/commands/issue-create.js +548 -91
  41. package/cli/dist/commands/issue-dependency.d.ts +3 -0
  42. package/cli/dist/commands/issue-dependency.js +282 -0
  43. package/cli/dist/commands/issue-readiness.d.ts +94 -0
  44. package/cli/dist/commands/issue-readiness.js +218 -0
  45. package/cli/dist/commands/issue-reopen.d.ts +3 -0
  46. package/cli/dist/commands/issue-reopen.js +115 -0
  47. package/cli/dist/commands/issue-shared.d.ts +32 -19
  48. package/cli/dist/commands/issue-shared.js +82 -75
  49. package/cli/dist/commands/issue-show.d.ts +3 -0
  50. package/cli/dist/commands/issue-show.js +169 -0
  51. package/cli/dist/commands/issue.d.ts +0 -1
  52. package/cli/dist/commands/issue.js +6 -8
  53. package/cli/dist/commands/names.d.ts +33 -0
  54. package/cli/dist/commands/names.js +62 -0
  55. package/cli/dist/commands/output.d.ts +14 -2
  56. package/cli/dist/commands/output.js +14 -7
  57. package/cli/dist/commands/pr-waiting.d.ts +20 -0
  58. package/cli/dist/commands/pr-waiting.js +106 -0
  59. package/cli/dist/commands/pr.d.ts +19 -0
  60. package/cli/dist/commands/pr.js +242 -323
  61. package/cli/dist/commands/project-sync.d.ts +2 -1
  62. package/cli/dist/commands/project-sync.js +18 -9
  63. package/cli/dist/commands/project.d.ts +3 -2
  64. package/cli/dist/commands/project.js +212 -175
  65. package/cli/dist/commands/registry.js +13 -10
  66. package/cli/dist/commands/release.d.ts +2 -2
  67. package/cli/dist/commands/release.js +53 -114
  68. package/cli/dist/commands/renamed-commands.d.ts +26 -0
  69. package/cli/dist/commands/renamed-commands.js +53 -0
  70. package/cli/dist/commands/repository-match.js +3 -2
  71. package/cli/dist/commands/session-finish.d.ts +3 -0
  72. package/cli/dist/commands/session-finish.js +267 -0
  73. package/cli/dist/commands/session-start.d.ts +3 -0
  74. package/cli/dist/commands/{repository.js → session-start.js} +99 -128
  75. package/cli/dist/commands/session.d.ts +3 -0
  76. package/cli/dist/commands/session.js +82 -29
  77. package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
  78. package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
  79. package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
  80. package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
  81. package/cli/dist/commands/tracker-sync.d.ts +7 -0
  82. package/cli/dist/commands/tracker-sync.js +3 -6
  83. package/cli/dist/commands/tracker.d.ts +3 -0
  84. package/cli/dist/commands/tracker.js +18 -0
  85. package/cli/dist/commands/usage-error.d.ts +4 -0
  86. package/cli/dist/commands/usage-error.js +6 -0
  87. package/cli/dist/commands/work-target.d.ts +12 -3
  88. package/cli/dist/commands/work-target.js +46 -5
  89. package/cli/dist/commands/worktree.js +32 -28
  90. package/cli/dist/domain/batch-plan.d.ts +73 -0
  91. package/cli/dist/domain/batch-plan.js +114 -0
  92. package/cli/dist/domain/blocked-by-change.d.ts +99 -0
  93. package/cli/dist/domain/blocked-by-change.js +101 -0
  94. package/cli/dist/domain/board-move.d.ts +90 -0
  95. package/cli/dist/domain/board-move.js +92 -0
  96. package/cli/dist/domain/branch-name.js +1 -1
  97. package/cli/dist/domain/command-hint.d.ts +85 -0
  98. package/cli/dist/domain/command-hint.js +148 -0
  99. package/cli/dist/domain/config.d.ts +4 -0
  100. package/cli/dist/domain/config.js +11 -1
  101. package/cli/dist/domain/dependabot.js +1 -1
  102. package/cli/dist/domain/errors.d.ts +5 -0
  103. package/cli/dist/domain/errors.js +5 -0
  104. package/cli/dist/domain/format.d.ts +51 -4
  105. package/cli/dist/domain/format.js +72 -6
  106. package/cli/dist/domain/frontmatter.d.ts +18 -3
  107. package/cli/dist/domain/frontmatter.js +38 -12
  108. package/cli/dist/domain/issue-order.d.ts +55 -0
  109. package/cli/dist/domain/issue-order.js +65 -0
  110. package/cli/dist/domain/issue-readout.d.ts +36 -0
  111. package/cli/dist/domain/pull-request.d.ts +71 -4
  112. package/cli/dist/domain/pull-request.js +59 -10
  113. package/cli/dist/domain/readiness.d.ts +27 -0
  114. package/cli/dist/domain/readiness.js +114 -3
  115. package/cli/dist/domain/reference-parser.d.ts +3 -1
  116. package/cli/dist/domain/reference-parser.js +6 -2
  117. package/cli/dist/domain/release.d.ts +7 -3
  118. package/cli/dist/domain/release.js +5 -12
  119. package/cli/dist/domain/repository-policy.d.ts +9 -3
  120. package/cli/dist/domain/repository-policy.js +8 -7
  121. package/cli/dist/domain/repository-resolver.js +4 -1
  122. package/cli/dist/domain/security-alerts.js +1 -1
  123. package/cli/dist/domain/state.d.ts +30 -0
  124. package/cli/dist/domain/state.js +39 -0
  125. package/cli/dist/domain/work-start.d.ts +34 -0
  126. package/cli/dist/domain/work-start.js +49 -0
  127. package/cli/dist/infra/authored-notes.d.ts +1 -1
  128. package/cli/dist/infra/authored-notes.js +10 -4
  129. package/cli/dist/infra/config-store.d.ts +4 -0
  130. package/cli/dist/infra/config-store.js +13 -0
  131. package/cli/dist/infra/git.d.ts +12 -0
  132. package/cli/dist/infra/git.js +13 -1
  133. package/cli/dist/infra/github/client.d.ts +5 -0
  134. package/cli/dist/infra/github/client.js +10 -7
  135. package/cli/dist/infra/github/errors.d.ts +18 -0
  136. package/cli/dist/infra/github/errors.js +22 -0
  137. package/cli/dist/infra/github/issues.d.ts +39 -3
  138. package/cli/dist/infra/github/issues.js +178 -23
  139. package/cli/dist/infra/github/projects.d.ts +35 -0
  140. package/cli/dist/infra/github/projects.js +89 -8
  141. package/cli/dist/infra/github/pulls.d.ts +24 -0
  142. package/cli/dist/infra/github/pulls.js +56 -0
  143. package/cli/dist/infra/github/queries.d.ts +12 -4
  144. package/cli/dist/infra/github/queries.js +156 -8
  145. package/cli/dist/infra/github/readout.d.ts +5 -1
  146. package/cli/dist/infra/github/readout.js +11 -0
  147. package/cli/dist/infra/github/repos.d.ts +18 -0
  148. package/cli/dist/infra/github/repos.js +31 -0
  149. package/cli/dist/infra/nx-scope.d.ts +1 -1
  150. package/cli/dist/infra/nx-scope.js +1 -1
  151. package/cli/dist/infra/state-store.d.ts +10 -1
  152. package/cli/dist/infra/state-store.js +14 -2
  153. package/cli/dist/infra/worktree-links.d.ts +3 -0
  154. package/cli/dist/infra/worktree-links.js +8 -1
  155. package/cli/dist/infra/worktree.d.ts +12 -1
  156. package/cli/dist/infra/worktree.js +40 -23
  157. package/cli/dist/mcp/result.d.ts +34 -6
  158. package/cli/dist/mcp/result.js +62 -18
  159. package/cli/dist/mcp/server.d.ts +2 -2
  160. package/cli/dist/mcp/server.js +24 -10
  161. package/cli/templates/comment/plan.md +14 -0
  162. package/cli/templates/issue/bug.md +1 -1
  163. package/cli/templates/issue/task-implement.md +13 -6
  164. package/cli/templates/issue/task.md +1 -1
  165. package/cli/templates/workflow/pecot-board-sync.yml +84 -0
  166. package/npm-shrinkwrap.json +2 -2
  167. package/package.json +1 -1
  168. package/cli/dist/commands/dependabot.d.ts +0 -3
  169. package/cli/dist/commands/issue-project.d.ts +0 -3
  170. package/cli/dist/commands/issue-project.js +0 -176
  171. package/cli/dist/commands/issue-quick.d.ts +0 -3
  172. package/cli/dist/commands/issue-quick.js +0 -126
  173. package/cli/dist/commands/issue-read.d.ts +0 -3
  174. package/cli/dist/commands/issue-read.js +0 -80
  175. package/cli/dist/commands/repository.d.ts +0 -5
  176. package/cli/dist/commands/security.d.ts +0 -3
@@ -1,4 +1,4 @@
1
- // COMMANDS の 34 個を MCP のツールとして登録するサーバ。CLI と同じ定義の run を呼び、結果の形だけが違う。
1
+ // COMMANDS の全コマンドを MCP のツールとして登録するサーバ。CLI と同じ定義の run を呼び、結果の形だけが違う。
2
2
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- zod と SDK の型は readonly にできない */
3
3
  import { McpServer } from '@modelcontextprotocol/server';
4
4
  import { z } from 'zod';
@@ -10,9 +10,11 @@ import { createOutput } from '../commands/output.js';
10
10
  import { exitCodeOfFailure } from '../commands/failure.js';
11
11
  import { isRecord } from '../commands/input-schema.js';
12
12
  import { COMMANDS } from '../commands/registry.js';
13
+ import { findRenamedInput, renamedInputNote } from '../commands/renamed-commands.js';
13
14
  import { outputWidth } from '../commands/rich-panel.js';
15
+ import { UsageError } from '../commands/usage-error.js';
14
16
  import { readVersion } from '../version.js';
15
- import { collectIo, toRejectedResult, toToolResult } from './result.js';
17
+ import { collectIo, TOOL_OUTPUT_SCHEMA, toAbortedResult, toRejectedResult, toToolResult } from './result.js';
16
18
  export const MCP_SERVER_NAME = 'pecot-workflow';
17
19
  function rejected(message) {
18
20
  return { kind: 'rejected', message: `invalid input: ${message}` };
@@ -42,8 +44,13 @@ function prepare(definition, raw) {
42
44
  // arguments が配列や null なら SDK が先に -32602 で断るので、ここに来る非 object は省略(undefined)だけ
43
45
  const input = isRecord(raw) ? raw : {};
44
46
  const unknown = Object.keys(input).filter(key => !Object.hasOwn(definition.input.shape, key));
45
- if (unknown.length > 0)
46
- return rejected(`unknown ${unknown.length === 1 ? 'key' : 'keys'} ${unknown.map(key => `'${key}'`).join(', ')}`);
47
+ if (unknown.length > 0) {
48
+ const notes = unknown.map((key) => {
49
+ const renamed = findRenamedInput(definition.path, key);
50
+ return renamed === undefined ? '' : renamedInputNote(key, renamed);
51
+ });
52
+ return rejected(`unknown ${unknown.length === 1 ? 'key' : 'keys'} ${unknown.map(key => `'${key}'`).join(', ')}${notes.join('')}`);
53
+ }
47
54
  const repository = input['repo'];
48
55
  if (typeof repository === 'string' && !definition.hasOwnRepo) {
49
56
  try {
@@ -68,7 +75,10 @@ function prepare(definition, raw) {
68
75
  function unavailableResult(reason) {
69
76
  const collected = collectIo();
70
77
  createOutput(false, collected.io).error(reason);
71
- return toToolResult({ exitCode: 1, stdout: collected.stdout(), stderr: collected.stderr() });
78
+ return toToolResult({ exitCode: 1, stdout: collected.stdout(), stderr: collected.stderr(), kind: 'session-directory-unresolved' });
79
+ }
80
+ function unexpectedMessage(error) {
81
+ return error instanceof Error ? error.message : String(error);
72
82
  }
73
83
  async function invoke(definition, raw, options) {
74
84
  if (options.unavailableReason !== undefined)
@@ -77,6 +87,7 @@ async function invoke(definition, raw, options) {
77
87
  // interface-env: TERMINAL_WIDTH COLUMNS
78
88
  const width = outputWidth(process.env, undefined);
79
89
  let exitCode;
90
+ let message;
80
91
  try {
81
92
  resolveApiUrlOverride();
82
93
  const preparation = prepare(definition, raw);
@@ -90,15 +101,18 @@ async function invoke(definition, raw, options) {
90
101
  }
91
102
  }
92
103
  catch (error) {
104
+ // 使い方の誤りは枠で出すので、error の行の代わりに例外の文の 1 行目を message にする
105
+ if (error instanceof UsageError)
106
+ message = error.message.split('\n', 1)[0];
93
107
  try {
94
108
  exitCode = exitCodeOfFailure(error, collected.io, width);
95
109
  }
96
110
  catch (error_) {
97
111
  options.reportUnexpected?.(error_, { stdout: collected.stdout(), stderr: collected.stderr() });
98
- throw error_;
112
+ return toToolResult({ exitCode: 1, stdout: collected.stdout(), stderr: collected.stderr(), kind: 'other', message: unexpectedMessage(error_) });
99
113
  }
100
114
  }
101
- return toToolResult({ exitCode, stdout: collected.stdout(), stderr: collected.stderr() });
115
+ return toToolResult({ exitCode, stdout: collected.stdout(), stderr: collected.stderr(), kind: collected.kind(), message, resultLine: collected.resultLine() });
102
116
  }
103
117
  // コマンドは process.cwd()(起動のときに serve.ts が決めたセッションのディレクトリ)と .pecot/ の状態ファイルを読み書きするので、呼び出しは 1 件ずつ実行する。接続が複数あっても共有する
104
118
  const sequence = { tail: Promise.resolve(true) };
@@ -108,8 +122,8 @@ async function inSequence(signal, task) {
108
122
  sequence.tail = turn.promise;
109
123
  await previous;
110
124
  try {
111
- // 待っている間に中断(notifications/cancelled)か接続の切断があれば、本体を呼ばない。応答は届かないので中身は何でもよい
112
- return signal.aborted ? toRejectedResult('cancelled') : await task();
125
+ // 待っている間に中断(notifications/cancelled)か接続の切断があれば、本体を呼ばない。応答は届かない
126
+ return signal.aborted ? toAbortedResult() : await task();
113
127
  }
114
128
  finally {
115
129
  turn.resolve(true);
@@ -121,7 +135,7 @@ MCP サーバを作り、commands のそれぞれをツールとして登録す
121
135
  export function createMcpServer(commands = COMMANDS, options = {}) {
122
136
  const server = new McpServer({ name: MCP_SERVER_NAME, version: readVersion() });
123
137
  for (const definition of commands) {
124
- server.registerTool(definition.toolName, { description: definition.description, inputSchema: passthroughSchema(definition) }, async (arguments_, serverContext) => await inSequence(serverContext.mcpReq.signal, async () => await invoke(definition, arguments_, options)));
138
+ server.registerTool(definition.toolName, { description: definition.description, inputSchema: passthroughSchema(definition), outputSchema: TOOL_OUTPUT_SCHEMA }, async (arguments_, serverContext) => await inSequence(serverContext.mcpReq.signal, async () => await invoke(definition, arguments_, options)));
125
139
  }
126
140
  return server;
127
141
  }
@@ -8,6 +8,7 @@ template: plan
8
8
 
9
9
  書き方:
10
10
  - Files は、外に触る代表ファイルを並べ、`<details>` の中にファイルごとのどう触るかを詳しく書く
11
+ - Files の `<details>` の先頭に作業単位の表(実装者・モデル・担当)を書く。実装者は `w-implementer-1` から順に名付け、main が自分で直すなら `main` と書き、その行のモデルは `—` にする。モデルの基準は w-help スキルの参照「エージェントのモデル」(pecot-w の `skills/w-help/references/agent-models.md`)
11
12
  - Claude Code の plan mode の標準 5 項目は、Context・Approach(推奨方針)・Files(主要ファイルと再利用する既存関数)・E2E(検証)に書く
12
13
 
13
14
  CUJ = 利用者(人またはエージェント)が製品の起点から始め、利用者が観測する結果で終わる操作フロー。
@@ -52,6 +53,13 @@ CUJ ごとに「誰が・起点・観測結果」の 3 要素を必須とし、
52
53
  <details>
53
54
  <summary align="right">詳細はこちら</summary>
54
55
 
56
+ 作業単位
57
+
58
+ | 実装者 | モデル | 担当 |
59
+ |---|---|---|
60
+ | w-implementer-1 | opus | `src/export.py`・`src/writers/csv.py`(形式の選択と CSV の書き手。エスケープと入れ子の値の扱いを決める) |
61
+ | w-implementer-2 | sonnet | `src/writers/json.py`・`tests/test_export.py`(既存の処理の移し替えと、決まった形のテストの追加) |
62
+
55
63
  - `src/export.py`
56
64
  - `--format` の引数を足す。値は `json`(既定)と `csv`
57
65
  - それ以外の値は「csv か json を指定してください」で止める
@@ -143,6 +151,12 @@ CUJ 3
143
151
  <details>
144
152
  <summary align="right">詳細はこちら</summary>
145
153
 
154
+ 作業単位
155
+
156
+ | 実装者 | モデル | 担当 |
157
+ |---|---|---|
158
+ | <w-implementer-1 / main> | <sonnet / opus / —> | <担当ファイルと、そのモデルを選んだ理由> |
159
+
146
160
  <ファイルごとに、どう触るか。再利用する既存の関数があれば、その名前>
147
161
 
148
162
  </details>
@@ -20,7 +20,7 @@ order: ""
20
20
  フィールド:
21
21
  - repository: 起票先 `owner/repo` 必須
22
22
  - parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
23
- - order: 親 Epic 内の通し番号。タイトル先頭が `#{epic}-{order:02d}` で自動生成
23
+ - order: 親 Epic 内の通し番号。タイトル先頭が `#{epic}-NN`(`NN` は `order` を 2 桁に 0 で埋めたもの)で自動生成
24
24
  - 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / order の判定基準)
25
25
 
26
26
  例:
@@ -3,13 +3,11 @@ title: ""
3
3
  type: task
4
4
  template: task-implement
5
5
  repository: ""
6
- status: ready
7
6
  priority: ""
8
7
  size: ""
9
8
  labels: []
10
9
  parent_epic: ""
11
- order: ""
12
- parallel: ""
10
+ blocked_by: []
13
11
  ---
14
12
 
15
13
  <!--
@@ -23,9 +21,18 @@ parallel: ""
23
21
  フィールド:
24
22
  - repository: 実装が行われるリポ `owner/repo` 必須
25
23
  - parent_epic: 親 Epic を `owner/repo/number` で指定(推奨)
26
- - order: フェーズの段(依存グラフの層)。タイトル先頭が `#{epic}-{order:02d}` で自動生成
27
- - parallel: 同じ段に 2 件以上あるときだけ入れる枝の文字(`a`〜`z`)。タイトル先頭が `#{epic}-{order:02d}{parallel}` になる
28
- - 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / order の判定基準)
24
+ - blocked_by: このフェーズの着手を止める前提の一覧。前提が無ければ `[]` のまま
25
+ - `issue` は、同じ一括投稿のファイルのキー(`suffix`)か、Issue 化済みのフェーズを指す `owner/repo/N`
26
+ - マージを待つ前提だけ、`wait: merge` と、前提の表の `理由` の文をそのまま写した `reason`(改行しない)を足す
27
+ ```yaml
28
+ blocked_by:
29
+ - issue: phase3
30
+ - issue: phase4
31
+ wait: merge
32
+ reason: "action は、既定のブランチのプラグインを入れる。main に入るまで、確認ができない"
33
+ ```
34
+ - order・status: 書かない。通し番号と置く列は CLI が決める
35
+ - 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / blocked_by の判定基準)
29
36
 
30
37
  例:
31
38
 
@@ -19,7 +19,7 @@ order: ""
19
19
  フィールド:
20
20
  - repository: 起票先 `owner/repo` 必須
21
21
  - parent_epic: `owner/repo/number` 推奨。番号のみは aggregation_repo 解釈なので別リポの Epic を指すなら full path 必須
22
- - order: 親 Epic 内の通し番号。タイトル先頭が `#{epic}-{order:02d}` で自動生成
22
+ - order: 親 Epic 内の通し番号。タイトル先頭が `#{epic}-NN`(`NN` は `order` を 2 桁に 0 で埋めたもの)で自動生成
23
23
  - 起票ルール: skills/w-help/references/issue-flow-rules.md (投稿先 / parent_epic / order の判定基準)
24
24
 
25
25
  例:
@@ -0,0 +1,84 @@
1
+ # Place this file at .github/workflows/pecot-board-sync.yml in your repository.
2
+ #
3
+ # This workflow runs `pecot board sync` after PRs and issues change.
4
+ # The command fixes the Status column and label of the pecot project board.
5
+ # It reads the whole board on every run, so the trigger only decides when it runs.
6
+ #
7
+ # Set one of the two token setups in Settings > Secrets and variables > Actions.
8
+ # The job is skipped until one of them exists.
9
+ # GitHub App.
10
+ # Use it when the board and this repository have the same organization as owner.
11
+ # The token covers only the installation on that owner (owner: github.repository_owner).
12
+ # Set variable PECOT_BOARD_SYNC_APP_CLIENT_ID.
13
+ # Set secret PECOT_BOARD_SYNC_APP_PRIVATE_KEY.
14
+ # Personal access token.
15
+ # Use it for a personal account board, or when the board owner differs from the repository.
16
+ # Set variable PECOT_BOARD_SYNC_USE_PAT to true.
17
+ # Set secret PECOT_BOARD_SYNC_TOKEN.
18
+ #
19
+ # GitHub Enterprise Server names the token variable after the host.
20
+ # The name is PECOT_GITHUB_<HOST>_TOKEN, with the host upper-cased and dots replaced by underscores.
21
+ # For example, ghe.example.com gives PECOT_GITHUB_GHE_EXAMPLE_COM_TOKEN.
22
+ # Change the name under `env:` in the last step.
23
+ #
24
+ # pull_request_target runs the workflow from the default branch.
25
+ # Secrets are passed to PRs from forks, so this workflow never checks out code from a PR.
26
+ name: pecot board sync
27
+
28
+ on:
29
+ pull_request_target:
30
+ types: [opened, reopened, closed, ready_for_review, converted_to_draft]
31
+ issues:
32
+ types: [closed, reopened]
33
+ workflow_dispatch:
34
+ # Optional periodic run. Choose the interval and uncomment.
35
+ # Actions minutes are billed for private repositories.
36
+ # schedule:
37
+ # - cron: "0 * * * *"
38
+
39
+ permissions:
40
+ contents: read
41
+
42
+ concurrency:
43
+ group: pecot-board-sync
44
+ cancel-in-progress: false
45
+
46
+ jobs:
47
+ sync:
48
+ # A job-level if cannot read secrets, so variables tell whether a token is set up.
49
+ # Runs started by Dependabot are skipped because secrets are not always passed to them.
50
+ # The actor is whoever started the run, so a human merging a Dependabot PR still runs.
51
+ if: ${{ (vars.PECOT_BOARD_SYNC_APP_CLIENT_ID != '' || vars.PECOT_BOARD_SYNC_USE_PAT == 'true') && github.actor != 'dependabot[bot]' }}
52
+ runs-on: ubuntu-latest
53
+ timeout-minutes: 15
54
+ steps:
55
+ # No ref: the default branch is checked out, which holds the project settings.
56
+ - name: Checkout
57
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
58
+ with:
59
+ persist-credentials: false
60
+
61
+ - name: Set up Node.js
62
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
63
+ with:
64
+ node-version: "24.22.1"
65
+
66
+ - name: Generate GitHub App token
67
+ id: app-token
68
+ if: ${{ vars.PECOT_BOARD_SYNC_APP_CLIENT_ID != '' }}
69
+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
70
+ with:
71
+ client-id: ${{ vars.PECOT_BOARD_SYNC_APP_CLIENT_ID }}
72
+ private-key: ${{ secrets.PECOT_BOARD_SYNC_APP_PRIVATE_KEY }}
73
+ owner: ${{ github.repository_owner }}
74
+ permission-organization-projects: write
75
+ permission-issues: read
76
+ permission-pull-requests: read
77
+ permission-contents: read
78
+
79
+ # Pin the major version here. Raise it when the plugin's major version is raised.
80
+ # --prefix=/ keeps npx from stopping in a repository that declares pnpm devEngines.
81
+ - name: Sync the board
82
+ env:
83
+ PECOT_GITHUB_COM_TOKEN: ${{ steps.app-token.outputs.token || secrets.PECOT_BOARD_SYNC_TOKEN }}
84
+ run: npx -y --prefix=/ @pecot/workflow-mcp@6 board sync
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pecot/workflow-mcp",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@pecot/workflow-mcp",
9
- "version": "5.0.0",
9
+ "version": "6.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/server": "^2.4.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pecot/workflow-mcp",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "type": "module",
5
5
  "description": "pecot-workflow MCP server (standalone distribution)",
6
6
  "license": "MIT",
@@ -1,3 +0,0 @@
1
- import type { CommandDefinition } from './command-definition.js';
2
- export declare const DEPENDABOT_COMMANDS: readonly CommandDefinition[];
3
- //# sourceMappingURL=dependabot.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { CommandDefinition } from './command-definition.js';
2
- export declare const ISSUE_PROJECT_COMMANDS: readonly CommandDefinition[];
3
- //# sourceMappingURL=issue-project.d.ts.map
@@ -1,176 +0,0 @@
1
- /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
2
- // add-to-project・update-issue-status・issue reopen。cli/commands/issue.py の移植。
3
- import { setTimeout as delay } from 'node:timers/promises';
4
- import { z } from 'zod';
5
- import { getFieldId, getOptionId } from '../domain/config.js';
6
- import { GitHubAPIError } from '../infra/github/errors.js';
7
- import { defineCommand } from './command-definition.js';
8
- import { addIssueToBoard, setIssueField } from './issue-board.js';
9
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
10
- import { createGitHubClient } from './github-client.js';
11
- import { ensureRepositoryInProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
12
- import { createOutput } from './output.js';
13
- // Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
14
- const AUTOMATION_WAIT_MILLISECONDS = 3000;
15
- // クライアントを作り、リポジトリがプロジェクトにあることを確かめる。無ければ error と終了コード 1
16
- async function connectToProject(output, config, owner, repository) {
17
- const client = createGitHubClient(output, config.host);
18
- await ensureRepositoryInProject(output, config, client, owner, repository, `repository ${owner}/${repository} is not in the project`);
19
- return client;
20
- }
21
- function isStatusConfigured(config, status) {
22
- const fieldId = getFieldId(config, 'workflow');
23
- const optionId = getOptionId(config, 'workflow', status);
24
- return fieldId !== undefined && fieldId !== '' && optionId !== undefined && optionId !== '';
25
- }
26
- // blocked は後から足せる option なので、足し方の hint を添える
27
- function notConfiguredMessage(status) {
28
- const base = `status '${status}' is not configured in the project`;
29
- return status === 'blocked' ? `${base}\nhint: run pecot project init to add the Blocked option to the board` : base;
30
- }
31
- const ADD_TO_PROJECT = defineCommand({
32
- path: ['add-to-project'],
33
- description: 'Add an Issue to the project board with a GraphQL mutation (for an Issue created outside pecot)',
34
- input: z.object({
35
- issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
36
- status: z.string().default('ready').describe('Initial status (backlog/pending/blocked/ready/active/in_review/archived)'),
37
- }),
38
- positional: ['issue_ref'],
39
- shortFlags: { status: '-s' },
40
- interactive: false,
41
- run: async (input, io) => {
42
- const output = createOutput(false, io);
43
- return await runWithExit(async () => {
44
- const { status } = input;
45
- if (status !== '' && !VALID_STATUSES.has(status))
46
- exitInvalidStatus(output, status);
47
- const config = requireActiveConfigPlain(output);
48
- if (status !== '' && !isStatusConfigured(config, status)) {
49
- stopWith(output, notConfiguredMessage(status));
50
- }
51
- const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
52
- const target = `Issue ${issuePath(owner, repository, number)}`;
53
- try {
54
- const client = await connectToProject(output, config, owner, repository);
55
- const { itemId } = await addIssueToBoard(client, config, owner, repository, number, undefined);
56
- output.done({ verb: 'add', target: `${target} to project` });
57
- if (status !== '') {
58
- await setIssueField(client, config, itemId, 'workflow', status);
59
- output.done({ verb: 'set', target: `${target} status ${status}` });
60
- }
61
- }
62
- catch (error) {
63
- if (!(error instanceof GitHubAPIError))
64
- throw error;
65
- stopWith(output, `could not add ${target} to project: ${error.message}`);
66
- }
67
- });
68
- },
69
- });
70
- const UPDATE_ISSUE_STATUS = defineCommand({
71
- path: ['update-issue-status'],
72
- description: 'Update the status of an Issue on the project board by Issue number (pecot commands normally set the status themselves)',
73
- input: z.object({
74
- issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
75
- status: z.string().describe('Status (backlog/pending/blocked/ready/active/in_review/archived)'),
76
- }),
77
- positional: ['issue_ref', 'status'],
78
- interactive: false,
79
- run: async (input, io) => {
80
- const output = createOutput(false, io);
81
- return await runWithExit(async () => {
82
- const { status } = input;
83
- if (!VALID_STATUSES.has(status))
84
- exitInvalidStatus(output, status);
85
- const config = requireActiveConfigPlain(output);
86
- const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
87
- const target = `Issue ${issuePath(owner, repository, number)}`;
88
- try {
89
- const client = await connectToProject(output, config, owner, repository);
90
- const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
91
- if (itemId === undefined) {
92
- stopWith(output, `${target} is not on the project board\nhint: add it to the board first with add-to-project`);
93
- }
94
- if (!await setIssueField(client, config, itemId, 'workflow', status)) {
95
- stopWith(output, notConfiguredMessage(status));
96
- }
97
- output.done({ verb: 'set', target: `${target} status ${status}` });
98
- }
99
- catch (error) {
100
- if (!(error instanceof GitHubAPIError))
101
- throw error;
102
- stopWith(output, `could not set ${target} status ${status}: ${error.message}`);
103
- }
104
- });
105
- },
106
- });
107
- // 1 回目の reopen(status を更新する前提として open にする)と、ボードの status の更新。設定できたら自動化を待つ
108
- async function reopenAndSetStatus(output, client, config, issue, status) {
109
- const { owner, repository, number } = issue;
110
- const target = `Issue ${issuePath(owner, repository, number)}`;
111
- await client.reopenIssue(owner, repository, number);
112
- const itemId = await client.getItemIdByIssue(config.project.id, owner, repository, number);
113
- if (itemId === undefined) {
114
- output.warning(`${target} is not on the project board`);
115
- }
116
- else if (await setIssueField(client, config, itemId, 'workflow', status)) {
117
- output.done({ verb: 'set', target: `${target} status ${status}` });
118
- await delay(AUTOMATION_WAIT_MILLISECONDS);
119
- }
120
- else {
121
- output.warning(notConfiguredMessage(status));
122
- }
123
- }
124
- // 2 回目の reopen(自動化による close への対策)で open を確かめ、--comment があれば理由を投稿する
125
- async function confirmReopened(output, client, issue, comment) {
126
- const { owner, repository, number } = issue;
127
- const target = `Issue ${issuePath(owner, repository, number)}`;
128
- const result = await client.reopenIssue(owner, repository, number);
129
- const state = result['state'];
130
- if (state !== 'open') {
131
- stopWith(output, `${target} did not become open (state: ${typeof state === 'string' ? state : 'None'})`);
132
- }
133
- output.done({ verb: 'reopen', target });
134
- if (comment === undefined || comment === '')
135
- return;
136
- await client.addIssueComment(owner, repository, number, comment);
137
- output.done({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
138
- }
139
- async function reopenIssue(output, client, config, issue, status, comment) {
140
- await reopenAndSetStatus(output, client, config, issue, status);
141
- await confirmReopened(output, client, issue, comment);
142
- }
143
- const ISSUE_REOPEN = defineCommand({
144
- path: ['issue', 'reopen'],
145
- description: 'Reopen a closed Issue (also sets the status on the board)',
146
- input: z.object({
147
- issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
148
- status: z.string().default('ready').describe('Status after reopening (backlog/pending/blocked/ready/active/in_review/archived)'),
149
- comment: z.string().optional().describe('Reason for reopening (posted as a comment)'),
150
- }),
151
- positional: ['issue_ref'],
152
- shortFlags: { status: '-s', comment: '-c' },
153
- interactive: false,
154
- run: async (input, io) => {
155
- const output = createOutput(false, io);
156
- return await runWithExit(async () => {
157
- const { status, comment } = input;
158
- if (!VALID_STATUSES.has(status))
159
- exitInvalidStatus(output, status);
160
- const config = requireActiveConfigPlain(output);
161
- const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
162
- const target = `Issue ${issuePath(owner, repository, number)}`;
163
- try {
164
- const client = await connectToProject(output, config, owner, repository);
165
- await reopenIssue(output, client, config, { owner, repository, number }, status, comment);
166
- }
167
- catch (error) {
168
- if (!(error instanceof GitHubAPIError))
169
- throw error;
170
- stopWith(output, `could not reopen ${target}: ${error.message}`);
171
- }
172
- });
173
- },
174
- });
175
- export const ISSUE_PROJECT_COMMANDS = [ADD_TO_PROJECT, UPDATE_ISSUE_STATUS, ISSUE_REOPEN];
176
- //# sourceMappingURL=issue-project.js.map
@@ -1,3 +0,0 @@
1
- import type { CommandDefinition } from './command-definition.js';
2
- export declare const ISSUE_QUICK_COMMANDS: readonly CommandDefinition[];
3
- //# sourceMappingURL=issue-quick.d.ts.map
@@ -1,126 +0,0 @@
1
- /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
2
- // issue quick。cli/commands/issue.py の issue_quick_command の移植。テンプレートの検証はしない。
3
- import { z } from 'zod';
4
- import { splitOwnerRepository } from '../domain/repository-resolver.js';
5
- import { findRepository } from '../domain/config.js';
6
- import { pythonRightStrip, pythonStrip, truncateCodePoints } from '../domain/python-format.js';
7
- import { FLAG_ISSUE_CREATE_SLASH_PENDING, FLAG_ISSUE_PENDING, FLAG_PECOT_QUICK_MODE } from '../domain/state.js';
8
- import { GitHubAPIError } from '../infra/github/errors.js';
9
- import { formatTimestamp } from '../infra/paths.js';
10
- import { consumeFlag, touchFlag } from '../infra/state-store.js';
11
- import { defineCommand } from './command-definition.js';
12
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
13
- import { addToBoardOrWarn, BACKLOG_TYPES, buildIssueTitle, clientForIssueCreate, createIssueOrExit, ISSUE_TYPE_SCHEMA, issuePath, linkToParentEpic, normalizeParentEpicCli, PARENT_EPIC_DESCRIPTION, resolveParentEpicReference, runWithExit, setIssueFields, summarizeCreatedIssue, } from './issue-shared.js';
14
- import { createOutput } from './output.js';
15
- import { recordWorkTarget } from './work-target.js';
16
- // Python の re の `\s` と同じ集合。JS の `\s` と違い、U+001C〜U+001F を含む。U+FEFF は含まない
17
- // eslint-disable-next-line no-control-regex -- Python の空白に含まれる制御文字
18
- const PYTHON_WHITESPACE_RUN = /[\p{White_Space}\u{1C}\u{1D}\u{1E}\u{1F}]+/gu;
19
- // テンプレートの検証を飛ばす quick でも、起票規約への参照を本文の末尾に残す
20
- const BODY_FOOTER = '<!-- pecot issue quick で起票(テンプレ検証スキップ)。起票ルール: skills/w-help/references/issue-flow-rules.md#起票時の既定-status -->';
21
- const TITLE_LENGTH = 50;
22
- // 空のメッセージと owner/repo の形の誤りを止める
23
- function parseQuickArguments(output, message, repository) {
24
- if (pythonStrip(message) === '') {
25
- stopWith(output, 'the message is empty');
26
- }
27
- const parts = splitOwnerRepository(repository);
28
- if (parts === undefined) {
29
- stopWith(output, `invalid repository format: ${repository}\nexpected: owner/repo`);
30
- }
31
- return [parts.owner, parts.repository];
32
- }
33
- // status は Backlog に置く型なら backlog、それ以外は active。priority は medium、size は s(Backlog に置く型は付けない)
34
- function quickFields(issueType) {
35
- const isBacklog = BACKLOG_TYPES.has(issueType);
36
- const status = isBacklog ? 'backlog' : 'active';
37
- const fields = [
38
- { fieldName: 'workflow', optionName: status, label: `status ${status}` },
39
- { fieldName: 'priority', optionName: 'medium', label: 'priority medium' },
40
- ];
41
- if (!isBacklog)
42
- fields.push({ fieldName: 'size', optionName: 's', label: 'size s' });
43
- return fields;
44
- }
45
- async function createBranch(output, config, client, owner, repository, issueNumber, issueNodeId, title) {
46
- const base = findRepository(config, owner, repository)?.develop_branch;
47
- if (base === undefined || base === '') {
48
- stopWith(output, `develop_branch is not set for repository ${owner}/${repository}\nset it with: pecot project set-repo ${owner}/${repository} --develop-branch develop\n(or --develop-branch develop-aist / --develop-branch main)`);
49
- }
50
- const name = `feat/${formatTimestamp(Date.now())}/${String(issueNumber)}`;
51
- const sha = await client.getBranchSha(owner, repository, base);
52
- const created = await client.createLinkedBranch(issueNodeId, sha, name);
53
- output.done({ verb: 'create', target: `branch ${created} in ${owner}/${repository}` });
54
- recordWorkTarget(output, owner, repository, issueNumber, title, { failWithExit: false });
55
- }
56
- // ブランチの作成。API の失敗は warning にして続ける(--no-branch なら作業対象を記録するだけ)
57
- async function branchOrRecord(output, config, client, target, isNoBranch) {
58
- if (isNoBranch) {
59
- recordWorkTarget(output, target.owner, target.repository, target.number, target.title, { failWithExit: false });
60
- return;
61
- }
62
- try {
63
- await createBranch(output, config, client, target.owner, target.repository, target.number, target.nodeId, target.title);
64
- }
65
- catch (error) {
66
- if (!(error instanceof GitHubAPIError))
67
- throw error;
68
- output.warning(`could not create the branch: ${error.message}\ncreate the branch manually`);
69
- }
70
- }
71
- // 作った Issue の後始末。ボードへの追加に失敗したら、そこで止める
72
- async function finishIssue(output, config, client, owner, repository, issue, options) {
73
- const { number, url, nodeId } = summarizeCreatedIssue(issue);
74
- const target = `Issue ${issuePath(owner, repository, number)}`;
75
- const added = await addToBoardOrWarn(output, client, config, owner, repository, number, nodeId, url);
76
- if (added === undefined)
77
- return;
78
- await setIssueFields(output, client, config, added.itemId, target, quickFields(options.issueType));
79
- if (options.parentReference !== undefined) {
80
- if (options.issueType === 'epic')
81
- output.warning('giving a parent Epic to an Epic is not recommended');
82
- await linkToParentEpic(output, client, target, options.parentReference, added.issueNodeId, url);
83
- }
84
- const title = typeof issue['title'] === 'string' ? issue['title'] : '';
85
- await branchOrRecord(output, config, client, { owner, repository, number, nodeId: added.issueNodeId, title }, options.noBranch);
86
- if (!BACKLOG_TYPES.has(options.issueType))
87
- touchFlag(FLAG_PECOT_QUICK_MODE);
88
- output.data(url);
89
- }
90
- const ISSUE_QUICK = defineCommand({
91
- path: ['issue', 'quick'],
92
- hasOwnRepo: true,
93
- ignoresGlobalRepo: true,
94
- description: 'Create an Issue at once from a free-format message',
95
- input: z.object({
96
- message: z.string().describe('Issue message (free format)'),
97
- repo: z.string().describe('Repository (owner/repo form)'),
98
- parent_epic: z.string().optional().describe(PARENT_EPIC_DESCRIPTION),
99
- order: z.int().optional().describe('Order number of the subtask (used with parent_epic)'),
100
- no_branch: z.boolean().default(false).describe('Skip creating a branch'),
101
- type: ISSUE_TYPE_SCHEMA,
102
- }),
103
- positional: [],
104
- shortFlags: { message: '-m', repo: '-r' },
105
- interactive: false,
106
- run: async (input, io) => {
107
- const output = createOutput(false, io);
108
- return await runWithExit(async () => {
109
- const [owner, repository] = parseQuickArguments(output, input.message, input.repo);
110
- const config = requireActiveConfigPlain(output);
111
- const rawParent = normalizeParentEpicCli(input.parent_epic);
112
- const parentReference = rawParent === undefined ? undefined : resolveParentEpicReference(rawParent, config, owner, repository);
113
- // タイトルは先頭 50 文字の空白を 1 つにまとめたもの
114
- const cleaned = pythonStrip(truncateCodePoints(input.message, TITLE_LENGTH).replaceAll(PYTHON_WHITESPACE_RUN, ' '));
115
- const title = buildIssueTitle(input.type, cleaned, { parentEpic: parentReference?.number, order: input.order });
116
- const client = await clientForIssueCreate(output, config, owner, repository, input.repo, parentReference, input.order);
117
- const body = `${pythonRightStrip(input.message)}\n\n${BODY_FOOTER}`;
118
- const issue = await createIssueOrExit(output, client, owner, repository, title, body, undefined);
119
- consumeFlag(FLAG_ISSUE_PENDING);
120
- consumeFlag(FLAG_ISSUE_CREATE_SLASH_PENDING);
121
- await finishIssue(output, config, client, owner, repository, issue, { issueType: input.type, parentReference, noBranch: input.no_branch });
122
- });
123
- },
124
- });
125
- export const ISSUE_QUICK_COMMANDS = [ISSUE_QUICK];
126
- //# sourceMappingURL=issue-quick.js.map
@@ -1,3 +0,0 @@
1
- import type { CommandDefinition } from './command-definition.js';
2
- export declare const ISSUE_READ_COMMANDS: readonly CommandDefinition[];
3
- //# sourceMappingURL=issue-read.d.ts.map