@pecot/workflow-mcp 0.0.0-stage → 5.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 +8 -0
- package/LICENSE +21 -0
- package/README.md +126 -2
- package/bin/pecot-workflow-mcp.mjs +10 -0
- package/cli/dist/cli.d.ts +26 -0
- package/cli/dist/cli.js +222 -0
- package/cli/dist/commands/cell-table.d.ts +3 -0
- package/cli/dist/commands/cell-table.js +495 -0
- package/cli/dist/commands/command-binding.d.ts +26 -0
- package/cli/dist/commands/command-binding.js +266 -0
- package/cli/dist/commands/command-definition.d.ts +136 -0
- package/cli/dist/commands/command-definition.js +101 -0
- package/cli/dist/commands/command-help.d.ts +8 -0
- package/cli/dist/commands/command-help.js +173 -0
- package/cli/dist/commands/command-stop.d.ts +19 -0
- package/cli/dist/commands/command-stop.js +30 -0
- package/cli/dist/commands/dependabot.d.ts +3 -0
- package/cli/dist/commands/dependabot.js +165 -0
- package/cli/dist/commands/directory-option.d.ts +7 -0
- package/cli/dist/commands/directory-option.js +48 -0
- package/cli/dist/commands/failure.d.ts +13 -0
- package/cli/dist/commands/failure.js +33 -0
- package/cli/dist/commands/fuzzy.d.ts +7 -0
- package/cli/dist/commands/fuzzy.js +79 -0
- package/cli/dist/commands/github-client.d.ts +12 -0
- package/cli/dist/commands/github-client.js +23 -0
- package/cli/dist/commands/global-options.d.ts +25 -0
- package/cli/dist/commands/global-options.js +83 -0
- package/cli/dist/commands/help-layout.d.ts +40 -0
- package/cli/dist/commands/help-layout.js +117 -0
- package/cli/dist/commands/help.d.ts +8 -0
- package/cli/dist/commands/help.js +55 -0
- package/cli/dist/commands/input-schema.d.ts +14 -0
- package/cli/dist/commands/input-schema.js +56 -0
- package/cli/dist/commands/issue-board.d.ts +38 -0
- package/cli/dist/commands/issue-board.js +62 -0
- package/cli/dist/commands/issue-comment.d.ts +3 -0
- package/cli/dist/commands/issue-comment.js +196 -0
- package/cli/dist/commands/issue-create.d.ts +3 -0
- package/cli/dist/commands/issue-create.js +329 -0
- package/cli/dist/commands/issue-project.d.ts +3 -0
- package/cli/dist/commands/issue-project.js +176 -0
- package/cli/dist/commands/issue-quick.d.ts +3 -0
- package/cli/dist/commands/issue-quick.js +126 -0
- package/cli/dist/commands/issue-read.d.ts +3 -0
- package/cli/dist/commands/issue-read.js +80 -0
- package/cli/dist/commands/issue-shared.d.ts +159 -0
- package/cli/dist/commands/issue-shared.js +419 -0
- package/cli/dist/commands/issue.d.ts +4 -0
- package/cli/dist/commands/issue.js +15 -0
- package/cli/dist/commands/names.d.ts +9 -0
- package/cli/dist/commands/names.js +16 -0
- package/cli/dist/commands/output.d.ts +78 -0
- package/cli/dist/commands/output.js +187 -0
- package/cli/dist/commands/pr.d.ts +3 -0
- package/cli/dist/commands/pr.js +933 -0
- package/cli/dist/commands/project-info.d.ts +48 -0
- package/cli/dist/commands/project-info.js +181 -0
- package/cli/dist/commands/project-sync.d.ts +91 -0
- package/cli/dist/commands/project-sync.js +273 -0
- package/cli/dist/commands/project.d.ts +5 -0
- package/cli/dist/commands/project.js +677 -0
- package/cli/dist/commands/registry.d.ts +6 -0
- package/cli/dist/commands/registry.js +27 -0
- package/cli/dist/commands/release.d.ts +10 -0
- package/cli/dist/commands/release.js +414 -0
- package/cli/dist/commands/repository-display.d.ts +3 -0
- package/cli/dist/commands/repository-display.js +7 -0
- package/cli/dist/commands/repository-match.d.ts +14 -0
- package/cli/dist/commands/repository-match.js +33 -0
- package/cli/dist/commands/repository.d.ts +5 -0
- package/cli/dist/commands/repository.js +265 -0
- package/cli/dist/commands/rich-panel.d.ts +22 -0
- package/cli/dist/commands/rich-panel.js +295 -0
- package/cli/dist/commands/security.d.ts +3 -0
- package/cli/dist/commands/security.js +164 -0
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +161 -0
- package/cli/dist/commands/tracker-sync.d.ts +58 -0
- package/cli/dist/commands/tracker-sync.js +53 -0
- package/cli/dist/commands/usage-error.d.ts +47 -0
- package/cli/dist/commands/usage-error.js +72 -0
- package/cli/dist/commands/value-types.d.ts +46 -0
- package/cli/dist/commands/value-types.js +94 -0
- package/cli/dist/commands/work-target.d.ts +13 -0
- package/cli/dist/commands/work-target.js +41 -0
- package/cli/dist/commands/worktree.d.ts +3 -0
- package/cli/dist/commands/worktree.js +335 -0
- package/cli/dist/domain/api-error-detail.d.ts +10 -0
- package/cli/dist/domain/api-error-detail.js +25 -0
- package/cli/dist/domain/branch-name.d.ts +5 -0
- package/cli/dist/domain/branch-name.js +10 -0
- package/cli/dist/domain/changelog.d.ts +43 -0
- package/cli/dist/domain/changelog.js +107 -0
- package/cli/dist/domain/config.d.ts +215 -0
- package/cli/dist/domain/config.js +300 -0
- package/cli/dist/domain/dependabot-pull-requests.d.ts +82 -0
- package/cli/dist/domain/dependabot-pull-requests.js +338 -0
- package/cli/dist/domain/dependabot-source.d.ts +51 -0
- package/cli/dist/domain/dependabot-source.js +4 -0
- package/cli/dist/domain/dependabot.d.ts +47 -0
- package/cli/dist/domain/dependabot.js +88 -0
- package/cli/dist/domain/errors.d.ts +19 -0
- package/cli/dist/domain/errors.js +31 -0
- package/cli/dist/domain/field-options.d.ts +31 -0
- package/cli/dist/domain/field-options.js +44 -0
- package/cli/dist/domain/format.d.ts +47 -0
- package/cli/dist/domain/format.js +168 -0
- package/cli/dist/domain/frontmatter.d.ts +122 -0
- package/cli/dist/domain/frontmatter.js +264 -0
- package/cli/dist/domain/git-runner.d.ts +10 -0
- package/cli/dist/domain/git-runner.js +4 -0
- package/cli/dist/domain/git-url.d.ts +17 -0
- package/cli/dist/domain/git-url.js +30 -0
- package/cli/dist/domain/issue-kind.d.ts +16 -0
- package/cli/dist/domain/issue-kind.js +16 -0
- package/cli/dist/domain/issue-readout.d.ts +107 -0
- package/cli/dist/domain/issue-readout.js +4 -0
- package/cli/dist/domain/json-null.d.ts +2 -0
- package/cli/dist/domain/json-null.js +5 -0
- package/cli/dist/domain/json.d.ts +21 -0
- package/cli/dist/domain/json.js +47 -0
- package/cli/dist/domain/prerequisites.d.ts +32 -0
- package/cli/dist/domain/prerequisites.js +192 -0
- package/cli/dist/domain/pull-request.d.ts +134 -0
- package/cli/dist/domain/pull-request.js +232 -0
- package/cli/dist/domain/python-format.d.ts +105 -0
- package/cli/dist/domain/python-format.js +304 -0
- package/cli/dist/domain/readiness.d.ts +172 -0
- package/cli/dist/domain/readiness.js +280 -0
- package/cli/dist/domain/reference-parser.d.ts +49 -0
- package/cli/dist/domain/reference-parser.js +119 -0
- package/cli/dist/domain/release.d.ts +49 -0
- package/cli/dist/domain/release.js +72 -0
- package/cli/dist/domain/repository-policy.d.ts +32 -0
- package/cli/dist/domain/repository-policy.js +65 -0
- package/cli/dist/domain/repository-resolver.d.ts +57 -0
- package/cli/dist/domain/repository-resolver.js +119 -0
- package/cli/dist/domain/sections.d.ts +69 -0
- package/cli/dist/domain/sections.js +514 -0
- package/cli/dist/domain/security-alerts-source.d.ts +29 -0
- package/cli/dist/domain/security-alerts-source.js +4 -0
- package/cli/dist/domain/security-alerts.d.ts +52 -0
- package/cli/dist/domain/security-alerts.js +107 -0
- package/cli/dist/domain/security-tracker.d.ts +115 -0
- package/cli/dist/domain/security-tracker.js +353 -0
- package/cli/dist/domain/state.d.ts +29 -0
- package/cli/dist/domain/state.js +56 -0
- package/cli/dist/domain/tracker-body.d.ts +70 -0
- package/cli/dist/domain/tracker-body.js +65 -0
- package/cli/dist/domain/yaml-document.d.ts +5 -0
- package/cli/dist/domain/yaml-document.js +206 -0
- package/cli/dist/infra/authored-notes.d.ts +37 -0
- package/cli/dist/infra/authored-notes.js +66 -0
- package/cli/dist/infra/changelog-file.d.ts +19 -0
- package/cli/dist/infra/changelog-file.js +43 -0
- package/cli/dist/infra/child-stdin.d.ts +4 -0
- package/cli/dist/infra/child-stdin.js +8 -0
- package/cli/dist/infra/config-store.d.ts +49 -0
- package/cli/dist/infra/config-store.js +121 -0
- package/cli/dist/infra/diagnostics.d.ts +9 -0
- package/cli/dist/infra/diagnostics.js +2 -0
- package/cli/dist/infra/file-kind.d.ts +9 -0
- package/cli/dist/infra/file-kind.js +26 -0
- package/cli/dist/infra/frontmatter-file.d.ts +14 -0
- package/cli/dist/infra/frontmatter-file.js +30 -0
- package/cli/dist/infra/git.d.ts +74 -0
- package/cli/dist/infra/git.js +133 -0
- package/cli/dist/infra/github/auth.d.ts +60 -0
- package/cli/dist/infra/github/auth.js +158 -0
- package/cli/dist/infra/github/client.d.ts +173 -0
- package/cli/dist/infra/github/client.js +576 -0
- package/cli/dist/infra/github/dependabot-source.d.ts +13 -0
- package/cli/dist/infra/github/dependabot-source.js +33 -0
- package/cli/dist/infra/github/errors.d.ts +47 -0
- package/cli/dist/infra/github/errors.js +42 -0
- package/cli/dist/infra/github/index.d.ts +13 -0
- package/cli/dist/infra/github/index.js +19 -0
- package/cli/dist/infra/github/issues.d.ts +129 -0
- package/cli/dist/infra/github/issues.js +273 -0
- package/cli/dist/infra/github/payload.d.ts +44 -0
- package/cli/dist/infra/github/payload.js +80 -0
- package/cli/dist/infra/github/projects.d.ts +108 -0
- package/cli/dist/infra/github/projects.js +303 -0
- package/cli/dist/infra/github/pulls.d.ts +80 -0
- package/cli/dist/infra/github/pulls.js +161 -0
- package/cli/dist/infra/github/queries.d.ts +36 -0
- package/cli/dist/infra/github/queries.js +883 -0
- package/cli/dist/infra/github/readout.d.ts +18 -0
- package/cli/dist/infra/github/readout.js +156 -0
- package/cli/dist/infra/github/repos.d.ts +68 -0
- package/cli/dist/infra/github/repos.js +137 -0
- package/cli/dist/infra/github/rest-path.d.ts +14 -0
- package/cli/dist/infra/github/rest-path.js +31 -0
- package/cli/dist/infra/github/security-alerts-source.d.ts +15 -0
- package/cli/dist/infra/github/security-alerts-source.js +73 -0
- package/cli/dist/infra/gitignore-spec.d.ts +36 -0
- package/cli/dist/infra/gitignore-spec.js +235 -0
- package/cli/dist/infra/nx-scope.d.ts +51 -0
- package/cli/dist/infra/nx-scope.js +182 -0
- package/cli/dist/infra/os-error.d.ts +24 -0
- package/cli/dist/infra/os-error.js +38 -0
- package/cli/dist/infra/paths.d.ts +88 -0
- package/cli/dist/infra/paths.js +234 -0
- package/cli/dist/infra/state-store.d.ts +45 -0
- package/cli/dist/infra/state-store.js +118 -0
- package/cli/dist/infra/template-store.d.ts +15 -0
- package/cli/dist/infra/template-store.js +34 -0
- package/cli/dist/infra/text-file.d.ts +12 -0
- package/cli/dist/infra/text-file.js +33 -0
- package/cli/dist/infra/worktree-copy.d.ts +24 -0
- package/cli/dist/infra/worktree-copy.js +95 -0
- package/cli/dist/infra/worktree-links.d.ts +139 -0
- package/cli/dist/infra/worktree-links.js +433 -0
- package/cli/dist/infra/worktree-setup.d.ts +21 -0
- package/cli/dist/infra/worktree-setup.js +41 -0
- package/cli/dist/infra/worktree.d.ts +174 -0
- package/cli/dist/infra/worktree.js +567 -0
- package/cli/dist/mcp/result.d.ts +33 -0
- package/cli/dist/mcp/result.js +52 -0
- package/cli/dist/mcp/serve.d.ts +51 -0
- package/cli/dist/mcp/serve.js +183 -0
- package/cli/dist/mcp/server.d.ts +21 -0
- package/cli/dist/mcp/server.js +128 -0
- package/cli/dist/mcp/session-directory.d.ts +26 -0
- package/cli/dist/mcp/session-directory.js +84 -0
- package/cli/dist/package.json +1 -0
- package/cli/dist/version.d.ts +17 -0
- package/cli/dist/version.js +42 -0
- package/cli/templates/comment/merge-diff.md +34 -0
- package/cli/templates/comment/plan.md +181 -0
- package/cli/templates/comment/precede-notify.md +33 -0
- package/cli/templates/comment/review-findings.md +42 -0
- package/cli/templates/comment/review-resolution.md +48 -0
- package/cli/templates/issue/bug.md +63 -0
- package/cli/templates/issue/epic.md +54 -0
- package/cli/templates/issue/task-implement.md +67 -0
- package/cli/templates/issue/task.md +48 -0
- package/cli/templates/issue/tracker.md +48 -0
- package/cli/templates/pr/create.md +123 -0
- package/cli/templates/pr/release.md +56 -0
- package/hooks/lib/core/pecot-gitignore-ensure.sh +48 -0
- package/npm-shrinkwrap.json +83 -0
- package/package.json +22 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kohei Hayakawa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pecot/workflow-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
pecot-workflow プラグインの MCP サーバを、npm のパッケージとして単体で配布したものです。プラグインを導入していない環境でも、
|
|
4
|
+
MCP クライアントに 1 エントリ登録するだけで、Issue・PR・ボード・リリース・worktree のツールが使えます。
|
|
5
|
+
|
|
6
|
+
## 前提
|
|
7
|
+
|
|
8
|
+
- Node.js 24 系は 24.22.1 以上、26 系は 26.12.1 以上。下限に満たない Node でも npm は警告だけで起動しますが、脆弱性の修正を含まない版では使わないでください
|
|
9
|
+
- `git` と `gh` が PATH にあり、`gh auth status` が通ること。ツールは両方をそのまま起動する
|
|
10
|
+
- Windows ネイティブ環境は対象外です(Linux / macOS / WSL2 で使用してください)
|
|
11
|
+
|
|
12
|
+
## 登録
|
|
13
|
+
|
|
14
|
+
使用する MCP クライアントの設定に次の 1 エントリを追加します。
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"pecot-workflow": {
|
|
20
|
+
"command": "npx",
|
|
21
|
+
"args": ["-y", "--prefix=/", "@pecot/workflow-mcp"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`--prefix=/` は、pnpm の `devEngines` を宣言したリポジトリの中で起動しても止まらないようにするための指定です。
|
|
28
|
+
`--prefix` を付けないと、そのリポジトリを cwd にした npx が `EBADDEVENGINES` で止まります。
|
|
29
|
+
npm には devEngines の判定だけを外す公式の手段が無く、要望(npm/rfcs#830)は not_planned で閉じています。
|
|
30
|
+
|
|
31
|
+
パッケージは `--package=` ではなく、位置引数で渡してください。
|
|
32
|
+
`--package=` で渡すと、npm が `npm_config_package` をサーバの子プロセスに残します。
|
|
33
|
+
すると、`worktree_add` の `setup_command` などが打つ npx が、これを読んで別のパッケージを実行します。
|
|
34
|
+
|
|
35
|
+
`--prefix=/` には次の副作用があります。
|
|
36
|
+
|
|
37
|
+
- 利用者のリポジトリの `.npmrc` を読まず、globalconfig も `/etc/npmrc` になる。registry・proxy・cafile は `~/.npmrc` に置く
|
|
38
|
+
- `npm_config_prefix=/` などの環境変数がサーバに引き継がれる。`worktree_add` の `setup_command` で `npm i -g` を打つと `/lib/node_modules` を向く
|
|
39
|
+
|
|
40
|
+
この副作用を避けたいときは、先に `npm i -g @pecot/workflow-mcp` で入れて、コマンドを直接登録します。
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"pecot-workflow": {
|
|
46
|
+
"command": "pecot-workflow-mcp"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Windows の MCP クライアントから使う場合は WSL2 経由で起動します。
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"pecot-workflow": {
|
|
58
|
+
"command": "wsl",
|
|
59
|
+
"args": ["npx", "-y", "--prefix=/", "@pecot/workflow-mcp"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
WSL 内の npx が非ログインシェルの PATH に無い場合は、`args` を次に差し替えます。
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
["-e", "bash", "-lc", "npx -y --prefix=/ @pecot/workflow-mcp"]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
版を固定するときは、`@pecot/workflow-mcp@1.2.3` のように版を付けます。
|
|
72
|
+
依存は `npm-shrinkwrap.json` で固定されているため、同じ版なら同じ依存が入ります。
|
|
73
|
+
|
|
74
|
+
ツールが対象にするリポジトリは、サーバを起動したディレクトリを含むリポジトリです。
|
|
75
|
+
Claude Code では、Claude Code がサーバを起動するディレクトリ(通常はプロジェクトの root)になります。
|
|
76
|
+
|
|
77
|
+
プラグインの hooks は働きません。`issue_create`・`issue_quick`・`pr_create` の確認は、MCP クライアント自身の確認だけになります。
|
|
78
|
+
これらのツールは自動で許可しないでください。また、`--help` を打つと、プラグインで出る補足の節は出ません。
|
|
79
|
+
|
|
80
|
+
## ツール
|
|
81
|
+
|
|
82
|
+
| ツール | 内容 |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `add_to_project` | プロジェクトボードに Issue を足す(pecot の外で作った Issue 用) |
|
|
85
|
+
| `update_issue_status` | Issue 番号でボードのステータスを更新する |
|
|
86
|
+
| `create_branch` | Issue に紐づくブランチを作る |
|
|
87
|
+
| `delete_branch` | リモートブランチを削除する(保護ブランチは消さない) |
|
|
88
|
+
| `project_list` | 使えるプロジェクトを一覧する |
|
|
89
|
+
| `project_search` | GitHub API でプロジェクトを検索する |
|
|
90
|
+
| `project_init` | 既存のプロジェクトに pecot-workflow のフィールドを足す |
|
|
91
|
+
| `project_create` | プロジェクトを新規に作る |
|
|
92
|
+
| `project_info` | プロジェクトの情報をまとめて表示する |
|
|
93
|
+
| `project_activate` | 初期化済みのプロジェクトを有効にする |
|
|
94
|
+
| `project_set_repo` | プロジェクトの設定にリポジトリを足す・更新する |
|
|
95
|
+
| `project_set_aggregation_repo` | Epic の集約先リポジトリを設定する |
|
|
96
|
+
| `project_unset_aggregation_repo` | Epic の集約先リポジトリを解除する |
|
|
97
|
+
| `project_show_aggregation_repo` | Epic の集約先リポジトリを表示する |
|
|
98
|
+
| `issue_create` | frontmatter 付きの Markdown から Issue を作る |
|
|
99
|
+
| `issue_quick` | 自由形式のメッセージから Issue をすぐ作る |
|
|
100
|
+
| `issue_read` | Issue の詳細を必要な項目だけ取得する |
|
|
101
|
+
| `issue_comment` | Issue にコメントを投稿する |
|
|
102
|
+
| `issue_reopen` | 閉じた Issue を開き直す(ボードのステータスも戻す) |
|
|
103
|
+
| `pr_cleanup` | マージ後の後処理をする(Issue のクローズ、ブランチ削除、ローカルの整理) |
|
|
104
|
+
| `pr_create` | PR を作る |
|
|
105
|
+
| `pr_preflight` | PR を作る前に確かめる情報をまとめて表示する |
|
|
106
|
+
| `pr_read` | PR の詳細を必要な項目だけ取得する |
|
|
107
|
+
| `session_status` | セッションのフラグ、ブランチ、推定した Issue を表示する |
|
|
108
|
+
| `session_restore` | 失われたセッションのフラグをブランチから復元する |
|
|
109
|
+
| `release_preflight` | リリース前の確認をする |
|
|
110
|
+
| `release_create` | GitHub のリリースとタグを作る(ノートは CHANGELOG から取る) |
|
|
111
|
+
| `release_merge` | リリースの PR を通常のマージで取り込む |
|
|
112
|
+
| `security_sync` | 開いている Tracker のセキュリティアラートの一覧を書き直す |
|
|
113
|
+
| `dependabot_sync` | 開いている Tracker の Dependabot PR の一覧を書き直す |
|
|
114
|
+
| `worktree_add` | worktree を作る |
|
|
115
|
+
| `worktree_remove` | worktree を削除する |
|
|
116
|
+
| `worktree_init` | メイン worktree に worktree の設定ファイルを作る |
|
|
117
|
+
| `worktree_link` | 既存の worktree にシンボリックリンクを適用・更新する |
|
|
118
|
+
|
|
119
|
+
## 失敗したとき
|
|
120
|
+
|
|
121
|
+
- 初回の起動は依存の取得に時間がかかる。Claude Code で起動が 30 秒を超えて失敗したら、環境変数 `MCP_TIMEOUT` を延ばす
|
|
122
|
+
- ツールが失敗すると、結果の末尾に `exit code: <n>` の行が付く。標準出力が空のときは、結果は標準エラーだけになる
|
|
123
|
+
- `EBADDEVENGINES` で止まるときは、登録の `args` に `--prefix=/` が付いているか確認する
|
|
124
|
+
|
|
125
|
+
## 版
|
|
126
|
+
|
|
127
|
+
npm の版は pecot-workflow プラグインの版と一致します。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
6
|
+
for (const name of ['CLAUDE_PLUGIN_ROOT', 'PLUGIN_ROOT', 'COPILOT_PLUGIN_ROOT']) delete process.env[name]
|
|
7
|
+
if (process.argv.length === 2) process.argv.push('mcp')
|
|
8
|
+
// 絶対パスの動的 import は Windows で ERR_UNSUPPORTED_ESM_URL_SCHEME になるため file URL を通す。
|
|
9
|
+
const { main } = await import(pathToFileURL(path.join(root, 'cli/dist/cli.js')).href)
|
|
10
|
+
main()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CommandDefinition, CommandIo } from './commands/registry.js';
|
|
2
|
+
export interface CliContext {
|
|
3
|
+
readonly commands: readonly CommandDefinition[];
|
|
4
|
+
readonly io: CommandIo;
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
/**
|
|
7
|
+
rich の幅を決める環境変数(TERMINAL_WIDTH・COLUMNS)
|
|
8
|
+
*/
|
|
9
|
+
readonly environment: Readonly<Record<string, string | undefined>>;
|
|
10
|
+
/**
|
|
11
|
+
端末の幅。端末につながっていなければ undefined
|
|
12
|
+
*/
|
|
13
|
+
readonly terminalColumns: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
argv(node とスクリプトを除く)を実行して終了コードを返す。
|
|
17
|
+
使い方の誤りは枠付きで stderr に出して 2。確認の中止は Aborted. で 1。独自の例外は error の行で 1。それ以外の例外は伝える
|
|
18
|
+
*/
|
|
19
|
+
export declare function runCli(argv: readonly string[], context: Readonly<CliContext>): Promise<number>;
|
|
20
|
+
/**
|
|
21
|
+
出力先のパイプが閉じられたとき(`pecot ... | head`)に、エラーを出さず静かに終わる。
|
|
22
|
+
Python の __main__.py は SIGPIPE を既定の動作に戻し、BrokenPipeError も握って終了コード 0 で終わる。Node は EPIPE を error イベントで受ける
|
|
23
|
+
*/
|
|
24
|
+
export declare function exitQuietlyOnBrokenPipe(stream: Readonly<Pick<NodeJS.WritableStream, 'on'>>, finish: () => void): void;
|
|
25
|
+
export declare function main(): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=cli.d.ts.map
|
package/cli/dist/cli.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- zod のスキーマは深い readonly にできない */
|
|
2
|
+
// pecot-workflow の Node CLI のエントリポイント。
|
|
3
|
+
// グローバルオプションは Python の CLI(typer)と同じ順で処理する。
|
|
4
|
+
// 1. 解析の誤り(未知のオプション・値の欠け)。
|
|
5
|
+
// 2. eager な --version・--help。他の引数が不正でも実行する。
|
|
6
|
+
// 3. --repo の形式。不正なら使い方の誤りの枠を出して終了コード 2。
|
|
7
|
+
// 3.5. `mcp`。コマンドではないので、名前の解決の前に MCP サーバを stdio で起動する(help の一覧と打ち間違いの候補に出さない)。
|
|
8
|
+
// 4. コマンド名の解決。
|
|
9
|
+
// 5. PECOT_GITHUB_API_URL の検証。不正なら文言を出して終了コード 1。
|
|
10
|
+
// 6. --show-repo。解決して 2 行を出し、終了コード 0。
|
|
11
|
+
// 7. コマンドの --help。`--` より前に --help があれば、ほかの引数を検証せずに help を出して終了コード 0。
|
|
12
|
+
// 8. コマンドの実行。コマンドが無ければ終了コード 0。
|
|
13
|
+
//
|
|
14
|
+
// 例外は、使い方の誤りなら枠付きで終了コード 2、独自の例外なら failure.ts の文で終了コード 1 にする。
|
|
15
|
+
import { realpathSync } from 'node:fs';
|
|
16
|
+
import { pathToFileURL } from 'node:url';
|
|
17
|
+
import { InvalidValueError } from './domain/errors.js';
|
|
18
|
+
import { AmbiguousRepositoryError, parseOwnerRepository, resolveRepository } from './domain/repository-resolver.js';
|
|
19
|
+
import { readAuthoredNotes } from './infra/authored-notes.js';
|
|
20
|
+
import { gitRunnerFor } from './infra/git.js';
|
|
21
|
+
import { resolveApiUrlOverride } from './infra/github/client.js';
|
|
22
|
+
import { hasErrorCode } from './infra/os-error.js';
|
|
23
|
+
import { extraArgumentsMessage, isHelpRequested, runDefinition } from './commands/command-binding.js';
|
|
24
|
+
import { commandHelpText } from './commands/command-help.js';
|
|
25
|
+
import { interfaceIdOf } from './commands/command-definition.js';
|
|
26
|
+
import { invalidRepositoryMessage, parseGlobalOptions, ROOT_USAGE } from './commands/global-options.js';
|
|
27
|
+
import { exitCodeOfFailure } from './commands/failure.js';
|
|
28
|
+
import { closeMatches } from './commands/fuzzy.js';
|
|
29
|
+
import { helpText } from './commands/help.js';
|
|
30
|
+
import { COMMANDS, findCommand } from './commands/registry.js';
|
|
31
|
+
import { createOutput, createProcessIo } from './commands/output.js';
|
|
32
|
+
import { formatResolvedRepository } from './commands/repository-display.js';
|
|
33
|
+
import { outputWidth } from './commands/rich-panel.js';
|
|
34
|
+
import { COMMAND_SYNOPSIS, MISSING_COMMAND_MESSAGE, noSuchCommandMessage, noSuchOptionMessage, USAGE_EXIT_CODE, UsageError, } from './commands/usage-error.js';
|
|
35
|
+
import { readVersion } from './version.js';
|
|
36
|
+
function isUnderGroup(path, group) {
|
|
37
|
+
return group.every((segment, index) => path.at(index) === segment);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
コマンド名を、グループをたどって解決する。見つからなければ UsageError
|
|
41
|
+
*/
|
|
42
|
+
function resolveCommand(group, rest, commands) {
|
|
43
|
+
const context = { commandPath: group, synopsis: COMMAND_SYNOPSIS };
|
|
44
|
+
const [name, ...tail] = rest;
|
|
45
|
+
if (name === undefined)
|
|
46
|
+
throw new UsageError(MISSING_COMMAND_MESSAGE, context);
|
|
47
|
+
if (group.length > 0 && name.startsWith('-')) {
|
|
48
|
+
if (name === '--help')
|
|
49
|
+
return { kind: 'help', path: group };
|
|
50
|
+
throw new UsageError(noSuchOptionMessage(name, name.startsWith('--') ? closeMatches(name, ['--help']) : []), context);
|
|
51
|
+
}
|
|
52
|
+
const path = [...group, name];
|
|
53
|
+
const names = commands
|
|
54
|
+
.filter(command => command.path.length > group.length && isUnderGroup(command.path, group))
|
|
55
|
+
.map(command => command.path.slice(group.length, group.length + 1).join(''));
|
|
56
|
+
if (!names.includes(name)) {
|
|
57
|
+
const possibilities = closeMatches(name, [...new Set(names)]);
|
|
58
|
+
throw new UsageError(noSuchCommandMessage(name, possibilities), context);
|
|
59
|
+
}
|
|
60
|
+
const definition = findCommand(path, commands);
|
|
61
|
+
return definition === undefined ? resolveCommand(path, tail, commands) : { kind: 'command', definition, argv: tail };
|
|
62
|
+
}
|
|
63
|
+
function validateRepository(repository) {
|
|
64
|
+
if (repository === undefined)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
parseOwnerRepository(repository);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (!(error instanceof InvalidValueError))
|
|
71
|
+
throw error;
|
|
72
|
+
throw new UsageError(invalidRepositoryMessage(error.message), ROOT_USAGE);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function showRepository(repository, context) {
|
|
76
|
+
try {
|
|
77
|
+
// Python の resolve_repo も GIT_* を外さずに git を呼ぶ(git の hook の下では GIT_DIR が cwd より優先される)。同じ動作にそろえる
|
|
78
|
+
const resolved = resolveRepository(repository, gitRunnerFor(context.cwd));
|
|
79
|
+
context.io.stdout(formatResolvedRepository(resolved));
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof InvalidValueError)
|
|
84
|
+
context.io.stderr(`error: --repo: ${error.message}\n`);
|
|
85
|
+
else if (error instanceof AmbiguousRepositoryError)
|
|
86
|
+
context.io.stderr(`error: ${error.message}\n`);
|
|
87
|
+
else
|
|
88
|
+
throw error;
|
|
89
|
+
return USAGE_EXIT_CODE;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
コマンドの help を stdout に出して 0 を返す。details・constraints・examples・default_notes は定義書の手書きの側から読む。
|
|
94
|
+
読めなければ Constraints・Details・Examples と初期値の補足を出さず、stderr に場所と理由の warning を 1 行出す(help を誤りで止めない)
|
|
95
|
+
*/
|
|
96
|
+
function showCommandHelp(definition, context, width) {
|
|
97
|
+
const result = readAuthoredNotes(interfaceIdOf(definition.path));
|
|
98
|
+
if (result.kind === 'unreadable')
|
|
99
|
+
createOutput(false, context.io).warning(`could not read the details of '${definition.path.join(' ')}' from ${result.file}: ${result.reason}; they are left out of this help`);
|
|
100
|
+
context.io.stdout(commandHelpText(definition, result.kind === 'read' ? result.notes : undefined, width));
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const MCP_COMMAND = 'mcp';
|
|
104
|
+
// mcp の待ち受け中は、stdout の EPIPE を serve.ts が終了コード 1 で報告する。main の静かな終了にしない
|
|
105
|
+
const serving = { isActive: false };
|
|
106
|
+
/**
|
|
107
|
+
`pecot mcp` を stdio の MCP サーバとして起動する。待ち受けは stdin が閉じるまで続くので、起動の結果の終了コードを返す
|
|
108
|
+
*/
|
|
109
|
+
async function startMcp(extras) {
|
|
110
|
+
if (extras.length > 0)
|
|
111
|
+
throw new UsageError(extraArgumentsMessage(extras), { commandPath: [MCP_COMMAND], synopsis: '[OPTIONS]' });
|
|
112
|
+
const { executeMcpServe } = await import('./mcp/serve.js');
|
|
113
|
+
serving.isActive = true;
|
|
114
|
+
return executeMcpServe();
|
|
115
|
+
}
|
|
116
|
+
async function execute(argv, context, width) {
|
|
117
|
+
const options = parseGlobalOptions(argv);
|
|
118
|
+
if (argv.length === 0) {
|
|
119
|
+
context.io.stdout(helpText([], context.commands, width));
|
|
120
|
+
return USAGE_EXIT_CODE;
|
|
121
|
+
}
|
|
122
|
+
if (options.eager === 'version') {
|
|
123
|
+
context.io.stdout(`pecot version ${readVersion()}\n`);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
if (options.eager === 'help') {
|
|
127
|
+
context.io.stdout(helpText([], context.commands, width));
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
validateRepository(options.repo);
|
|
131
|
+
if (options.rest[0] === MCP_COMMAND)
|
|
132
|
+
return await startMcp(options.rest.slice(1));
|
|
133
|
+
const resolution = options.rest.length === 0 ? undefined : resolveCommand([], options.rest, context.commands);
|
|
134
|
+
try {
|
|
135
|
+
resolveApiUrlOverride();
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (!(error instanceof InvalidValueError))
|
|
139
|
+
throw error;
|
|
140
|
+
context.io.stderr(`error: ${error.message}\n`);
|
|
141
|
+
return 1;
|
|
142
|
+
}
|
|
143
|
+
if (options.showRepo)
|
|
144
|
+
return showRepository(options.repo, context);
|
|
145
|
+
if (resolution === undefined)
|
|
146
|
+
return 0;
|
|
147
|
+
if (resolution.kind === 'help') {
|
|
148
|
+
context.io.stdout(helpText(resolution.path, context.commands, width));
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
return isHelpRequested(resolution.argv)
|
|
152
|
+
? showCommandHelp(resolution.definition, context, width)
|
|
153
|
+
: await runDefinition(resolution.definition, resolution.argv, context.io, options.repo);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
argv(node とスクリプトを除く)を実行して終了コードを返す。
|
|
157
|
+
使い方の誤りは枠付きで stderr に出して 2。確認の中止は Aborted. で 1。独自の例外は error の行で 1。それ以外の例外は伝える
|
|
158
|
+
*/
|
|
159
|
+
export async function runCli(argv, context) {
|
|
160
|
+
const width = outputWidth(context.environment, context.terminalColumns);
|
|
161
|
+
try {
|
|
162
|
+
return await execute(argv, context, width);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return exitCodeOfFailure(error, context.io, width);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
出力先のパイプが閉じられたとき(`pecot ... | head`)に、エラーを出さず静かに終わる。
|
|
170
|
+
Python の __main__.py は SIGPIPE を既定の動作に戻し、BrokenPipeError も握って終了コード 0 で終わる。Node は EPIPE を error イベントで受ける
|
|
171
|
+
*/
|
|
172
|
+
export function exitQuietlyOnBrokenPipe(stream, finish) {
|
|
173
|
+
stream.on('error', (error) => {
|
|
174
|
+
if (hasErrorCode(error) && error.code === 'EPIPE')
|
|
175
|
+
finish();
|
|
176
|
+
else
|
|
177
|
+
throw error;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
端末の幅。rich は標準入力・標準出力・標準エラーの順に、端末につながったものの幅を使う。Node では出力側の 2 つを見る
|
|
182
|
+
*/
|
|
183
|
+
function terminalColumns() {
|
|
184
|
+
if (process.stderr.isTTY)
|
|
185
|
+
return process.stderr.columns;
|
|
186
|
+
return process.stdout.isTTY ? process.stdout.columns : undefined;
|
|
187
|
+
}
|
|
188
|
+
export async function main() {
|
|
189
|
+
const io = createProcessIo();
|
|
190
|
+
const pipe = { isClosed: false };
|
|
191
|
+
const finish = () => {
|
|
192
|
+
if (serving.isActive)
|
|
193
|
+
return;
|
|
194
|
+
pipe.isClosed = true;
|
|
195
|
+
process.exitCode = 0;
|
|
196
|
+
process.stdout.destroy();
|
|
197
|
+
};
|
|
198
|
+
exitQuietlyOnBrokenPipe(process.stdout, finish);
|
|
199
|
+
exitQuietlyOnBrokenPipe(process.stderr, finish);
|
|
200
|
+
const code = await runCli(process.argv.slice(2), {
|
|
201
|
+
commands: COMMANDS,
|
|
202
|
+
io,
|
|
203
|
+
cwd: process.cwd(),
|
|
204
|
+
// interface-env: TERMINAL_WIDTH COLUMNS
|
|
205
|
+
environment: process.env,
|
|
206
|
+
terminalColumns: terminalColumns(),
|
|
207
|
+
});
|
|
208
|
+
if (!pipe.isClosed)
|
|
209
|
+
process.exitCode = code;
|
|
210
|
+
}
|
|
211
|
+
/* v8 ignore start -- 直接起動時にだけ通る */
|
|
212
|
+
if (process.argv[1] !== undefined) {
|
|
213
|
+
// import.meta.url は symlink を解決した実体パスを指すため、argv[1] 側も realpath に揃える。
|
|
214
|
+
// 揃えないと symlink 経由起動で一致せず、何もせず exit 0 で終わる。
|
|
215
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- 起動された自分自身のパス
|
|
216
|
+
const selfUrl = pathToFileURL(realpathSync(process.argv[1])).href;
|
|
217
|
+
if (import.meta.url === selfUrl) {
|
|
218
|
+
await main();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/* v8 ignore stop */
|
|
222
|
+
//# sourceMappingURL=cli.js.map
|