@pecot/workflow-mcp 0.0.0-stage → 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 (287) hide show
  1. package/.claude-plugin/plugin.json +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +184 -2
  4. package/bin/pecot-workflow-mcp.mjs +10 -0
  5. package/cli/dist/cli.d.ts +26 -0
  6. package/cli/dist/cli.js +227 -0
  7. package/cli/dist/commands/board-add.d.ts +3 -0
  8. package/cli/dist/commands/board-add.js +59 -0
  9. package/cli/dist/commands/board-judgment.d.ts +60 -0
  10. package/cli/dist/commands/board-judgment.js +144 -0
  11. package/cli/dist/commands/board-move.d.ts +3 -0
  12. package/cli/dist/commands/board-move.js +57 -0
  13. package/cli/dist/commands/board-readiness.d.ts +34 -0
  14. package/cli/dist/commands/board-readiness.js +108 -0
  15. package/cli/dist/commands/board-show.d.ts +3 -0
  16. package/cli/dist/commands/board-show.js +72 -0
  17. package/cli/dist/commands/board-sync.d.ts +3 -0
  18. package/cli/dist/commands/board-sync.js +111 -0
  19. package/cli/dist/commands/board-view.d.ts +62 -0
  20. package/cli/dist/commands/board-view.js +191 -0
  21. package/cli/dist/commands/board.d.ts +3 -0
  22. package/cli/dist/commands/board.js +12 -0
  23. package/cli/dist/commands/branch.d.ts +3 -0
  24. package/cli/dist/commands/branch.js +100 -0
  25. package/cli/dist/commands/cell-table.d.ts +3 -0
  26. package/cli/dist/commands/cell-table.js +495 -0
  27. package/cli/dist/commands/command-binding.d.ts +26 -0
  28. package/cli/dist/commands/command-binding.js +270 -0
  29. package/cli/dist/commands/command-definition.d.ts +150 -0
  30. package/cli/dist/commands/command-definition.js +105 -0
  31. package/cli/dist/commands/command-help.d.ts +8 -0
  32. package/cli/dist/commands/command-help.js +173 -0
  33. package/cli/dist/commands/command-hint.d.ts +5 -0
  34. package/cli/dist/commands/command-hint.js +13 -0
  35. package/cli/dist/commands/command-stop.d.ts +21 -0
  36. package/cli/dist/commands/command-stop.js +31 -0
  37. package/cli/dist/commands/directory-option.d.ts +7 -0
  38. package/cli/dist/commands/directory-option.js +48 -0
  39. package/cli/dist/commands/failure-kind.d.ts +3 -0
  40. package/cli/dist/commands/failure-kind.js +34 -0
  41. package/cli/dist/commands/failure.d.ts +19 -0
  42. package/cli/dist/commands/failure.js +59 -0
  43. package/cli/dist/commands/fuzzy.d.ts +7 -0
  44. package/cli/dist/commands/fuzzy.js +79 -0
  45. package/cli/dist/commands/github-client.d.ts +16 -0
  46. package/cli/dist/commands/github-client.js +33 -0
  47. package/cli/dist/commands/global-options.d.ts +25 -0
  48. package/cli/dist/commands/global-options.js +83 -0
  49. package/cli/dist/commands/help-layout.d.ts +40 -0
  50. package/cli/dist/commands/help-layout.js +117 -0
  51. package/cli/dist/commands/help.d.ts +8 -0
  52. package/cli/dist/commands/help.js +50 -0
  53. package/cli/dist/commands/input-schema.d.ts +14 -0
  54. package/cli/dist/commands/input-schema.js +56 -0
  55. package/cli/dist/commands/issue-board.d.ts +71 -0
  56. package/cli/dist/commands/issue-board.js +122 -0
  57. package/cli/dist/commands/issue-comment.d.ts +3 -0
  58. package/cli/dist/commands/issue-comment.js +215 -0
  59. package/cli/dist/commands/issue-create.d.ts +3 -0
  60. package/cli/dist/commands/issue-create.js +786 -0
  61. package/cli/dist/commands/issue-dependency.d.ts +3 -0
  62. package/cli/dist/commands/issue-dependency.js +282 -0
  63. package/cli/dist/commands/issue-readiness.d.ts +94 -0
  64. package/cli/dist/commands/issue-readiness.js +218 -0
  65. package/cli/dist/commands/issue-reopen.d.ts +3 -0
  66. package/cli/dist/commands/issue-reopen.js +115 -0
  67. package/cli/dist/commands/issue-shared.d.ts +172 -0
  68. package/cli/dist/commands/issue-shared.js +426 -0
  69. package/cli/dist/commands/issue-show.d.ts +3 -0
  70. package/cli/dist/commands/issue-show.js +169 -0
  71. package/cli/dist/commands/issue.d.ts +3 -0
  72. package/cli/dist/commands/issue.js +13 -0
  73. package/cli/dist/commands/names.d.ts +42 -0
  74. package/cli/dist/commands/names.js +78 -0
  75. package/cli/dist/commands/output.d.ts +90 -0
  76. package/cli/dist/commands/output.js +194 -0
  77. package/cli/dist/commands/pr-waiting.d.ts +20 -0
  78. package/cli/dist/commands/pr-waiting.js +106 -0
  79. package/cli/dist/commands/pr.d.ts +22 -0
  80. package/cli/dist/commands/pr.js +852 -0
  81. package/cli/dist/commands/project-sync.d.ts +92 -0
  82. package/cli/dist/commands/project-sync.js +282 -0
  83. package/cli/dist/commands/project.d.ts +6 -0
  84. package/cli/dist/commands/project.js +714 -0
  85. package/cli/dist/commands/registry.d.ts +6 -0
  86. package/cli/dist/commands/registry.js +30 -0
  87. package/cli/dist/commands/release.d.ts +10 -0
  88. package/cli/dist/commands/release.js +353 -0
  89. package/cli/dist/commands/renamed-commands.d.ts +26 -0
  90. package/cli/dist/commands/renamed-commands.js +53 -0
  91. package/cli/dist/commands/repository-display.d.ts +3 -0
  92. package/cli/dist/commands/repository-display.js +7 -0
  93. package/cli/dist/commands/repository-match.d.ts +14 -0
  94. package/cli/dist/commands/repository-match.js +34 -0
  95. package/cli/dist/commands/rich-panel.d.ts +22 -0
  96. package/cli/dist/commands/rich-panel.js +295 -0
  97. package/cli/dist/commands/session-finish.d.ts +3 -0
  98. package/cli/dist/commands/session-finish.js +267 -0
  99. package/cli/dist/commands/session-start.d.ts +3 -0
  100. package/cli/dist/commands/session-start.js +236 -0
  101. package/cli/dist/commands/session.d.ts +6 -0
  102. package/cli/dist/commands/session.js +214 -0
  103. package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
  104. package/cli/dist/commands/tracker-sync-dependabot.js +156 -0
  105. package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
  106. package/cli/dist/commands/tracker-sync-security.js +153 -0
  107. package/cli/dist/commands/tracker-sync.d.ts +65 -0
  108. package/cli/dist/commands/tracker-sync.js +50 -0
  109. package/cli/dist/commands/tracker.d.ts +3 -0
  110. package/cli/dist/commands/tracker.js +18 -0
  111. package/cli/dist/commands/usage-error.d.ts +51 -0
  112. package/cli/dist/commands/usage-error.js +78 -0
  113. package/cli/dist/commands/value-types.d.ts +46 -0
  114. package/cli/dist/commands/value-types.js +94 -0
  115. package/cli/dist/commands/work-target.d.ts +22 -0
  116. package/cli/dist/commands/work-target.js +82 -0
  117. package/cli/dist/commands/worktree.d.ts +3 -0
  118. package/cli/dist/commands/worktree.js +339 -0
  119. package/cli/dist/domain/api-error-detail.d.ts +10 -0
  120. package/cli/dist/domain/api-error-detail.js +25 -0
  121. package/cli/dist/domain/batch-plan.d.ts +73 -0
  122. package/cli/dist/domain/batch-plan.js +114 -0
  123. package/cli/dist/domain/blocked-by-change.d.ts +99 -0
  124. package/cli/dist/domain/blocked-by-change.js +101 -0
  125. package/cli/dist/domain/board-move.d.ts +90 -0
  126. package/cli/dist/domain/board-move.js +92 -0
  127. package/cli/dist/domain/branch-name.d.ts +5 -0
  128. package/cli/dist/domain/branch-name.js +10 -0
  129. package/cli/dist/domain/changelog.d.ts +43 -0
  130. package/cli/dist/domain/changelog.js +107 -0
  131. package/cli/dist/domain/command-hint.d.ts +85 -0
  132. package/cli/dist/domain/command-hint.js +148 -0
  133. package/cli/dist/domain/config.d.ts +219 -0
  134. package/cli/dist/domain/config.js +310 -0
  135. package/cli/dist/domain/dependabot-pull-requests.d.ts +82 -0
  136. package/cli/dist/domain/dependabot-pull-requests.js +338 -0
  137. package/cli/dist/domain/dependabot-source.d.ts +51 -0
  138. package/cli/dist/domain/dependabot-source.js +4 -0
  139. package/cli/dist/domain/dependabot.d.ts +47 -0
  140. package/cli/dist/domain/dependabot.js +88 -0
  141. package/cli/dist/domain/errors.d.ts +24 -0
  142. package/cli/dist/domain/errors.js +36 -0
  143. package/cli/dist/domain/field-options.d.ts +31 -0
  144. package/cli/dist/domain/field-options.js +44 -0
  145. package/cli/dist/domain/format.d.ts +94 -0
  146. package/cli/dist/domain/format.js +234 -0
  147. package/cli/dist/domain/frontmatter.d.ts +137 -0
  148. package/cli/dist/domain/frontmatter.js +290 -0
  149. package/cli/dist/domain/git-runner.d.ts +10 -0
  150. package/cli/dist/domain/git-runner.js +4 -0
  151. package/cli/dist/domain/git-url.d.ts +17 -0
  152. package/cli/dist/domain/git-url.js +30 -0
  153. package/cli/dist/domain/issue-kind.d.ts +16 -0
  154. package/cli/dist/domain/issue-kind.js +16 -0
  155. package/cli/dist/domain/issue-order.d.ts +55 -0
  156. package/cli/dist/domain/issue-order.js +65 -0
  157. package/cli/dist/domain/issue-readout.d.ts +143 -0
  158. package/cli/dist/domain/issue-readout.js +4 -0
  159. package/cli/dist/domain/json-null.d.ts +2 -0
  160. package/cli/dist/domain/json-null.js +5 -0
  161. package/cli/dist/domain/json.d.ts +21 -0
  162. package/cli/dist/domain/json.js +47 -0
  163. package/cli/dist/domain/prerequisites.d.ts +32 -0
  164. package/cli/dist/domain/prerequisites.js +192 -0
  165. package/cli/dist/domain/pull-request.d.ts +201 -0
  166. package/cli/dist/domain/pull-request.js +281 -0
  167. package/cli/dist/domain/python-format.d.ts +105 -0
  168. package/cli/dist/domain/python-format.js +304 -0
  169. package/cli/dist/domain/readiness.d.ts +199 -0
  170. package/cli/dist/domain/readiness.js +391 -0
  171. package/cli/dist/domain/reference-parser.d.ts +51 -0
  172. package/cli/dist/domain/reference-parser.js +123 -0
  173. package/cli/dist/domain/release.d.ts +53 -0
  174. package/cli/dist/domain/release.js +65 -0
  175. package/cli/dist/domain/repository-policy.d.ts +38 -0
  176. package/cli/dist/domain/repository-policy.js +66 -0
  177. package/cli/dist/domain/repository-resolver.d.ts +57 -0
  178. package/cli/dist/domain/repository-resolver.js +122 -0
  179. package/cli/dist/domain/sections.d.ts +69 -0
  180. package/cli/dist/domain/sections.js +514 -0
  181. package/cli/dist/domain/security-alerts-source.d.ts +29 -0
  182. package/cli/dist/domain/security-alerts-source.js +4 -0
  183. package/cli/dist/domain/security-alerts.d.ts +52 -0
  184. package/cli/dist/domain/security-alerts.js +107 -0
  185. package/cli/dist/domain/security-tracker.d.ts +115 -0
  186. package/cli/dist/domain/security-tracker.js +353 -0
  187. package/cli/dist/domain/state.d.ts +59 -0
  188. package/cli/dist/domain/state.js +95 -0
  189. package/cli/dist/domain/tracker-body.d.ts +70 -0
  190. package/cli/dist/domain/tracker-body.js +65 -0
  191. package/cli/dist/domain/work-start.d.ts +34 -0
  192. package/cli/dist/domain/work-start.js +49 -0
  193. package/cli/dist/domain/yaml-document.d.ts +5 -0
  194. package/cli/dist/domain/yaml-document.js +206 -0
  195. package/cli/dist/infra/authored-notes.d.ts +37 -0
  196. package/cli/dist/infra/authored-notes.js +72 -0
  197. package/cli/dist/infra/changelog-file.d.ts +19 -0
  198. package/cli/dist/infra/changelog-file.js +43 -0
  199. package/cli/dist/infra/child-stdin.d.ts +4 -0
  200. package/cli/dist/infra/child-stdin.js +8 -0
  201. package/cli/dist/infra/config-store.d.ts +53 -0
  202. package/cli/dist/infra/config-store.js +134 -0
  203. package/cli/dist/infra/diagnostics.d.ts +9 -0
  204. package/cli/dist/infra/diagnostics.js +2 -0
  205. package/cli/dist/infra/file-kind.d.ts +9 -0
  206. package/cli/dist/infra/file-kind.js +26 -0
  207. package/cli/dist/infra/frontmatter-file.d.ts +14 -0
  208. package/cli/dist/infra/frontmatter-file.js +30 -0
  209. package/cli/dist/infra/git.d.ts +86 -0
  210. package/cli/dist/infra/git.js +145 -0
  211. package/cli/dist/infra/github/auth.d.ts +60 -0
  212. package/cli/dist/infra/github/auth.js +158 -0
  213. package/cli/dist/infra/github/client.d.ts +178 -0
  214. package/cli/dist/infra/github/client.js +579 -0
  215. package/cli/dist/infra/github/dependabot-source.d.ts +13 -0
  216. package/cli/dist/infra/github/dependabot-source.js +33 -0
  217. package/cli/dist/infra/github/errors.d.ts +65 -0
  218. package/cli/dist/infra/github/errors.js +64 -0
  219. package/cli/dist/infra/github/index.d.ts +13 -0
  220. package/cli/dist/infra/github/index.js +19 -0
  221. package/cli/dist/infra/github/issues.d.ts +165 -0
  222. package/cli/dist/infra/github/issues.js +428 -0
  223. package/cli/dist/infra/github/payload.d.ts +44 -0
  224. package/cli/dist/infra/github/payload.js +80 -0
  225. package/cli/dist/infra/github/projects.d.ts +143 -0
  226. package/cli/dist/infra/github/projects.js +384 -0
  227. package/cli/dist/infra/github/pulls.d.ts +104 -0
  228. package/cli/dist/infra/github/pulls.js +217 -0
  229. package/cli/dist/infra/github/queries.d.ts +44 -0
  230. package/cli/dist/infra/github/queries.js +1031 -0
  231. package/cli/dist/infra/github/readout.d.ts +22 -0
  232. package/cli/dist/infra/github/readout.js +167 -0
  233. package/cli/dist/infra/github/repos.d.ts +86 -0
  234. package/cli/dist/infra/github/repos.js +168 -0
  235. package/cli/dist/infra/github/rest-path.d.ts +14 -0
  236. package/cli/dist/infra/github/rest-path.js +31 -0
  237. package/cli/dist/infra/github/security-alerts-source.d.ts +15 -0
  238. package/cli/dist/infra/github/security-alerts-source.js +73 -0
  239. package/cli/dist/infra/gitignore-spec.d.ts +36 -0
  240. package/cli/dist/infra/gitignore-spec.js +235 -0
  241. package/cli/dist/infra/nx-scope.d.ts +51 -0
  242. package/cli/dist/infra/nx-scope.js +182 -0
  243. package/cli/dist/infra/os-error.d.ts +24 -0
  244. package/cli/dist/infra/os-error.js +38 -0
  245. package/cli/dist/infra/paths.d.ts +88 -0
  246. package/cli/dist/infra/paths.js +234 -0
  247. package/cli/dist/infra/state-store.d.ts +54 -0
  248. package/cli/dist/infra/state-store.js +130 -0
  249. package/cli/dist/infra/template-store.d.ts +15 -0
  250. package/cli/dist/infra/template-store.js +34 -0
  251. package/cli/dist/infra/text-file.d.ts +12 -0
  252. package/cli/dist/infra/text-file.js +33 -0
  253. package/cli/dist/infra/worktree-copy.d.ts +24 -0
  254. package/cli/dist/infra/worktree-copy.js +95 -0
  255. package/cli/dist/infra/worktree-links.d.ts +142 -0
  256. package/cli/dist/infra/worktree-links.js +440 -0
  257. package/cli/dist/infra/worktree-setup.d.ts +21 -0
  258. package/cli/dist/infra/worktree-setup.js +41 -0
  259. package/cli/dist/infra/worktree.d.ts +185 -0
  260. package/cli/dist/infra/worktree.js +584 -0
  261. package/cli/dist/mcp/result.d.ts +61 -0
  262. package/cli/dist/mcp/result.js +96 -0
  263. package/cli/dist/mcp/serve.d.ts +51 -0
  264. package/cli/dist/mcp/serve.js +183 -0
  265. package/cli/dist/mcp/server.d.ts +21 -0
  266. package/cli/dist/mcp/server.js +142 -0
  267. package/cli/dist/mcp/session-directory.d.ts +26 -0
  268. package/cli/dist/mcp/session-directory.js +84 -0
  269. package/cli/dist/package.json +1 -0
  270. package/cli/dist/version.d.ts +17 -0
  271. package/cli/dist/version.js +42 -0
  272. package/cli/templates/comment/merge-diff.md +34 -0
  273. package/cli/templates/comment/plan.md +195 -0
  274. package/cli/templates/comment/precede-notify.md +33 -0
  275. package/cli/templates/comment/review-findings.md +42 -0
  276. package/cli/templates/comment/review-resolution.md +48 -0
  277. package/cli/templates/issue/bug.md +63 -0
  278. package/cli/templates/issue/epic.md +54 -0
  279. package/cli/templates/issue/task-implement.md +74 -0
  280. package/cli/templates/issue/task.md +48 -0
  281. package/cli/templates/issue/tracker.md +48 -0
  282. package/cli/templates/pr/create.md +123 -0
  283. package/cli/templates/pr/release.md +56 -0
  284. package/cli/templates/workflow/pecot-board-sync.yml +84 -0
  285. package/hooks/lib/core/pecot-gitignore-ensure.sh +48 -0
  286. package/npm-shrinkwrap.json +83 -0
  287. package/package.json +22 -4
@@ -0,0 +1,191 @@
1
+ // board show の表示と、Archived の整理、Dependabot alert の収集。
2
+ import { effectiveReleaseType, workflowFieldName } from '../domain/config.js';
3
+ import { DependabotAlertError, fetchDependabotAlertStatus } from '../domain/dependabot.js';
4
+ import { formatItemsJson, readBoardProgress, transformItems } from '../domain/format.js';
5
+ import { JSON_NULL } from '../domain/json-null.js';
6
+ import { compareStrings } from '../domain/python-format.js';
7
+ import { createDependabotSource } from '../infra/github/dependabot-source.js';
8
+ import { GitHubAPIError } from '../infra/github/errors.js';
9
+ import { STATUS_FIELD_NAME } from './project-sync.js';
10
+ /**
11
+ Archived のうち、ボードに残す件数
12
+ */
13
+ const ARCHIVED_KEEP = 20;
14
+ /**
15
+ Dependabot alert を並列に取る数の上限(Python の _ALERT_FETCH_MAX_WORKERS と同じ)
16
+ */
17
+ const ALERT_FETCH_MAX_WORKERS = 8;
18
+ const DISPLAY_STATUSES = new Set(['Backlog', 'Pending', 'Blocked', 'Ready', 'Active', 'In Review']);
19
+ function updatedAtOf(item) {
20
+ return typeof item.updatedAt === 'string' ? item.updatedAt : '';
21
+ }
22
+ /**
23
+ Archived のアイテムを updatedAt の新しい順に並べ、最新の 20 件を残して、残りをボードから消す。
24
+ 消せなかった件数を warning の行に出し、その数を返す
25
+ */
26
+ export async function pruneArchivedItems(out, client, config, allItems, isDryRun) {
27
+ const archived = allItems.filter(item => item.workflow === 'Archived').toSorted((first, second) => compareStrings(updatedAtOf(second), updatedAtOf(first)));
28
+ if (archived.length <= ARCHIVED_KEEP)
29
+ return 0;
30
+ const targets = archived.slice(ARCHIVED_KEEP);
31
+ if (isDryRun) {
32
+ out.planned({ verb: 'delete', target: `${String(targets.length)} archived items` });
33
+ return 0;
34
+ }
35
+ let deleted = 0;
36
+ for (const item of targets) {
37
+ // ID が文字列でないアイテムは、API を呼ばず、失敗として数える
38
+ if (typeof item.id !== 'string')
39
+ continue;
40
+ try {
41
+ await client.deleteProjectItem(config.project.id, item.id);
42
+ deleted += 1;
43
+ }
44
+ catch (error) {
45
+ // 削除の失敗は数えて続ける
46
+ if (!(error instanceof GitHubAPIError))
47
+ throw error;
48
+ }
49
+ }
50
+ if (deleted > 0)
51
+ out.done({ verb: 'delete', target: `${String(deleted)} archived items`, aside: true });
52
+ const failed = targets.length - deleted;
53
+ if (failed > 0)
54
+ out.warning(`failed to delete ${String(failed)} archived items`);
55
+ return failed;
56
+ }
57
+ /**
58
+ 登録リポジトリごとの Dependabot alert の状態(登録の順)。
59
+ 1 つの取得の失敗でボードの表示を止めないよう、DependabotAlertError はここで理由の文字列にする
60
+ */
61
+ export async function collectAlertStatuses(client, config) {
62
+ const source = createDependabotSource(client);
63
+ return await mapWithLimit(config.repositories, ALERT_FETCH_MAX_WORKERS, async (entry) => {
64
+ try {
65
+ return await fetchDependabotAlertStatus(source, config.host, entry.owner, entry.name);
66
+ }
67
+ catch (error) {
68
+ if (error instanceof DependabotAlertError)
69
+ return error.message;
70
+ throw error;
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ items を最大 limit 件ずつ並列に処理し、結果を items の順で返す。1 件でも投げたら、その例外で止まる
76
+ */
77
+ export async function mapWithLimit(items, limit, task) {
78
+ const results = [];
79
+ // 全ての worker が同じ iterator から次の項目を取る
80
+ const pending = items.entries();
81
+ const worker = async () => {
82
+ // eslint-disable-next-line security/detect-object-injection -- index は entries() の添字
83
+ for (const [index, item] of pending)
84
+ results[index] = await task(item);
85
+ };
86
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
87
+ return results;
88
+ }
89
+ /**
90
+ index 番目の取得結果。件数が登録のリポジトリとずれていたら投げる
91
+ */
92
+ function statusAt(statuses, index) {
93
+ const status = statuses.at(index);
94
+ if (status === undefined)
95
+ throw new RangeError(`no Dependabot alert status for repository #${String(index)}`);
96
+ return status;
97
+ }
98
+ function alertsJson(status) {
99
+ return typeof status === 'string' ? { error: status } : { enabled: status.enabled, open_count: status.openCount, max_severity: status.maxSeverity ?? JSON_NULL, alerts_url: status.alertsUrl };
100
+ }
101
+ function alertsLine(status) {
102
+ if (typeof status === 'string')
103
+ return ` dependabot_alerts: fetch failed (${status})`;
104
+ if (!status.enabled)
105
+ return ' dependabot_alerts: disabled';
106
+ return ` dependabot_alerts: open ${String(status.openCount)}`;
107
+ }
108
+ /**
109
+ info --json の出力
110
+ */
111
+ export function boardShowJson(view, items, readiness) {
112
+ const { config, projectName, statuses } = view;
113
+ const output = {
114
+ project: {
115
+ name: projectName,
116
+ host: config.host,
117
+ owner: config.owner,
118
+ number: config.project.number,
119
+ aggregation_repo: config.aggregation_repo ?? JSON_NULL,
120
+ },
121
+ repositories: config.repositories.map((entry, index) => ({
122
+ full_name: `${entry.owner}/${entry.name}`,
123
+ owner: entry.owner,
124
+ name: entry.name,
125
+ develop_branch: entry.develop_branch ?? JSON_NULL,
126
+ release_branch: entry.release_branch ?? JSON_NULL,
127
+ dependabot_alerts: alertsJson(statusAt(statuses, index)),
128
+ })),
129
+ board: readiness === undefined ? formatItemsJson(items) : { items: items.map(item => ({ ...item, readiness: readiness(item) })) },
130
+ };
131
+ return JSON.stringify(output, undefined, 2);
132
+ }
133
+ function repositoryLines(view) {
134
+ const { config, statuses } = view;
135
+ if (config.repositories.length === 0)
136
+ return ['## Registered repositories', '- none'];
137
+ const lines = ['## Registered repositories'];
138
+ for (const [index, entry] of config.repositories.entries()) {
139
+ const develop = entry.develop_branch === undefined || entry.develop_branch === '' ? [] : [`develop: ${entry.develop_branch}`];
140
+ const release = entry.release_branch === undefined || entry.release_branch === '' ? [] : [`release: ${entry.release_branch}`];
141
+ const branches = [...develop, ...release];
142
+ const fullName = `${entry.owner}/${entry.name}`;
143
+ lines.push(branches.length > 0 ? `- ${fullName} (${branches.join(', ')})` : `- ${fullName}`, ` release_type: ${effectiveReleaseType(entry)}`, alertsLine(statusAt(statuses, index)));
144
+ if (entry.packages !== undefined && entry.packages.length > 0) {
145
+ for (const item of entry.packages)
146
+ lines.push(` package: ${item.name} → ${item.changelog}`);
147
+ }
148
+ else if (entry.changelog_file !== undefined && entry.changelog_file !== '') {
149
+ lines.push(` changelog: ${entry.changelog_file}`);
150
+ }
151
+ }
152
+ return lines;
153
+ }
154
+ /**
155
+ info の Markdown の出力
156
+ */
157
+ export function boardShowMarkdown(view, effectiveRepository, boardOutput, chainsSection) {
158
+ const { config, projectName } = view;
159
+ const aggregation = config.aggregation_repo === undefined || config.aggregation_repo === '' ? 'none' : `\`${config.aggregation_repo}\``;
160
+ return [
161
+ '# Project info',
162
+ '',
163
+ '## Overview',
164
+ `- Project: ${projectName}`,
165
+ `- Host: ${config.host}`,
166
+ `- Owner: ${config.owner}`,
167
+ `- Roadmap repo: ${aggregation}`,
168
+ '',
169
+ ...repositoryLines(view),
170
+ '',
171
+ effectiveRepository === undefined || effectiveRepository === '' ? '## Board status' : `## Board status (filter: ${effectiveRepository})`,
172
+ '',
173
+ boardOutput,
174
+ ...(chainsSection === undefined ? [] : ['', chainsSection]),
175
+ ].join('\n');
176
+ }
177
+ /**
178
+ ボードのアイテムを全部読み、表示するものに絞る
179
+ */
180
+ export async function readBoard(client, config, effectiveRepository) {
181
+ const fieldName = workflowFieldName(config);
182
+ const state = { isLegacy: false };
183
+ const rawItems = await client.listProjectItems(config.project.id, { workflowFieldName: fieldName, onLegacy: () => {
184
+ state.isLegacy = true;
185
+ } });
186
+ const allItems = transformItems(rawItems, fieldName);
187
+ const open = allItems.filter(item => item.content.state === 'OPEN' && typeof item.workflow === 'string' && DISPLAY_STATUSES.has(item.workflow));
188
+ const items = effectiveRepository === undefined || effectiveRepository === '' ? open : open.filter(item => item.content.repository === effectiveRepository);
189
+ return { allItems, items, progress: readBoardProgress(rawItems, STATUS_FIELD_NAME), isLegacy: state.isLegacy };
190
+ }
191
+ //# sourceMappingURL=board-view.js.map
@@ -0,0 +1,3 @@
1
+ import type { CommandDefinition } from './command-definition.js';
2
+ export declare const BOARD_COMMANDS: readonly CommandDefinition[];
3
+ //# sourceMappingURL=board.d.ts.map
@@ -0,0 +1,12 @@
1
+ // board のグループのコマンド。並びは help の一覧に出る順
2
+ import { BOARD_ADD_COMMANDS } from './board-add.js';
3
+ import { BOARD_MOVE_COMMANDS } from './board-move.js';
4
+ import { BOARD_SHOW_COMMANDS } from './board-show.js';
5
+ import { BOARD_SYNC_COMMANDS } from './board-sync.js';
6
+ export const BOARD_COMMANDS = [
7
+ ...BOARD_SHOW_COMMANDS,
8
+ ...BOARD_ADD_COMMANDS,
9
+ ...BOARD_MOVE_COMMANDS,
10
+ ...BOARD_SYNC_COMMANDS,
11
+ ];
12
+ //# sourceMappingURL=board.js.map
@@ -0,0 +1,3 @@
1
+ import type { CommandDefinition } from './command-definition.js';
2
+ export declare const BRANCH_COMMANDS: readonly CommandDefinition[];
3
+ //# sourceMappingURL=branch.d.ts.map
@@ -0,0 +1,100 @@
1
+ // branch delete。Python の cli/commands/repo.py の delete_branch の移植。
2
+ import { z } from 'zod';
3
+ import { describeApiError } from '../domain/api-error-detail.js';
4
+ import { findRepository } from '../domain/config.js';
5
+ import { compareStrings } from '../domain/python-format.js';
6
+ import { ReferenceParseError, parseRepositoryReference } from '../domain/reference-parser.js';
7
+ import { GitHubAPIError, isMissingReferenceError } from '../infra/github/errors.js';
8
+ import { defineCommand } from './command-definition.js';
9
+ import { requireActiveConfig, stopWith } from './command-stop.js';
10
+ import { kindOfFailure } from './failure.js';
11
+ import { createGitHubClient } from './github-client.js';
12
+ import { createOutput } from './output.js';
13
+ import { requireRepositoryMatch } from './repository-match.js';
14
+ import { USAGE_EXIT_CODE } from './usage-error.js';
15
+ const branchDeleteCommand = defineCommand({
16
+ path: ['branch', 'delete'],
17
+ hasOwnRepo: true,
18
+ ignoresGlobalRepo: true,
19
+ description: 'Delete a remote branch (a protected branch is never deleted)',
20
+ input: z.strictObject({
21
+ repo: z.string().describe('Repository reference (owner/repo)'),
22
+ branch: z.string().describe('Name of the branch to delete'),
23
+ dry_run: z.boolean().default(false).describe('Show what would be deleted without deleting anything'),
24
+ }),
25
+ positional: ['repo', 'branch'],
26
+ shortFlags: { dry_run: '-n' },
27
+ interactive: false,
28
+ run: async (input, io) => {
29
+ // 位置引数の repo は対象のリポで、cwd と比べる明示値ではない
30
+ requireRepositoryMatch('reject', undefined, io, process.cwd());
31
+ const out = createOutput(input.dry_run, io);
32
+ // 1. repo をパース
33
+ let target;
34
+ try {
35
+ target = parseRepositoryReference(input.repo);
36
+ }
37
+ catch (error) {
38
+ if (!(error instanceof ReferenceParseError))
39
+ throw error;
40
+ return stopWith(out, error.message, 'invalid-input', USAGE_EXIT_CODE);
41
+ }
42
+ const { owner, repository } = target;
43
+ // 2. 設定取得
44
+ const config = requireActiveConfig(out);
45
+ // 3. 保護ブランチ収集(設定の develop_branch・release_branch と、API の既定ブランチ)
46
+ const protectedBranches = new Set();
47
+ const repositoryConfig = findRepository(config, owner, repository);
48
+ for (const branch of [repositoryConfig?.develop_branch, repositoryConfig?.release_branch]) {
49
+ if (branch !== undefined && branch !== '')
50
+ protectedBranches.add(branch);
51
+ }
52
+ let client;
53
+ try {
54
+ client = createGitHubClient(out, config.host);
55
+ protectedBranches.add(await client.getRepositoryDefaultBranch(owner, repository));
56
+ }
57
+ catch (error) {
58
+ if (!(error instanceof GitHubAPIError))
59
+ throw error;
60
+ return stopWith(out, `could not read the default branch of ${owner}/${repository}: ${error.message}`, kindOfFailure(error));
61
+ }
62
+ // 4. 保護ブランチチェック
63
+ if (protectedBranches.has(input.branch)) {
64
+ return stopWith(out, `${input.branch} is a protected branch\nprotected: ${[...protectedBranches].toSorted(compareStrings).join(', ')}`, 'guard-blocked');
65
+ }
66
+ // 5. dry-run
67
+ const operation = { verb: 'delete', target: `remote branch ${input.branch} in ${owner}/${repository}` };
68
+ if (input.dry_run) {
69
+ out.planned(operation);
70
+ return 0;
71
+ }
72
+ // 6. 削除実行
73
+ try {
74
+ await client.deleteBranch(owner, repository, input.branch);
75
+ }
76
+ catch (error) {
77
+ if (!(error instanceof GitHubAPIError))
78
+ throw error;
79
+ return stopWith(out, `could not delete remote branch ${input.branch} in ${owner}/${repository}: ${error.message}`, kindOfFailure(error));
80
+ }
81
+ out.done(operation);
82
+ // wip ブランチも連動削除
83
+ const wipBranch = `wip/${input.branch}`;
84
+ try {
85
+ await client.deleteBranch(owner, repository, wipBranch);
86
+ }
87
+ catch (error) {
88
+ if (!(error instanceof GitHubAPIError))
89
+ throw error;
90
+ // wip ブランチの削除の失敗だけは、API の応答の本文の詳細も見せる(Python の describe_api_error と同じ)。存在しない場合は何も出さない
91
+ if (!isMissingReferenceError(error))
92
+ out.warning(`could not delete remote branch ${wipBranch} in ${owner}/${repository}: ${describeApiError(error)}`);
93
+ return 0;
94
+ }
95
+ out.done({ verb: 'delete', target: `remote branch ${wipBranch} in ${owner}/${repository}` });
96
+ return 0;
97
+ },
98
+ });
99
+ export const BRANCH_COMMANDS = [branchDeleteCommand];
100
+ //# sourceMappingURL=branch.js.map
@@ -0,0 +1,3 @@
1
+ export declare const CELL_WIDTHS: readonly (readonly [number, number, number])[];
2
+ export declare const NARROW_TO_WIDE: readonly number[];
3
+ //# sourceMappingURL=cell-table.d.ts.map