@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,115 @@
1
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
2
+ // issue reopen。cli/commands/issue.py の移植。
3
+ import { setTimeout as delay } from 'node:timers/promises';
4
+ import { z } from 'zod';
5
+ import { GitHubAPIError } from '../infra/github/errors.js';
6
+ import { defineCommand } from './command-definition.js';
7
+ import { isStatusConfigured, setIssueField } from './issue-board.js';
8
+ import { stopWith, requireActiveConfigPlain } from './command-stop.js';
9
+ import { kindOfFailure } from './failure.js';
10
+ import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
11
+ import { createOutput } from './output.js';
12
+ // Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
13
+ const AUTOMATION_WAIT_MILLISECONDS = 3000;
14
+ // アーカイブの解除、1 回目の reopen、ボードの status の更新。設定できたら自動化を待つ
15
+ async function reopenAndSetStatus(output, client, config, issue, status) {
16
+ const { owner, repository, number } = issue;
17
+ const target = `Issue ${issuePath(owner, repository, number)}`;
18
+ const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
19
+ // アーカイブ済みの項目はボードの列に出ないので戻す。失敗したら Issue を開かずに止める
20
+ if (item?.isArchived === true) {
21
+ try {
22
+ await client.unarchiveProjectItem(config.project.id, item.id);
23
+ }
24
+ catch (error) {
25
+ if (!(error instanceof GitHubAPIError))
26
+ throw error;
27
+ stopWith(output, `could not unarchive ${target} on the board: ${error.message}`, kindOfFailure(error));
28
+ }
29
+ output.done({ verb: 'update', target: `${target} unarchived on the board` });
30
+ }
31
+ await client.reopenIssue(owner, repository, number);
32
+ const itemId = item?.id;
33
+ if (itemId === undefined) {
34
+ output.warning(`${target} is not on the project board`);
35
+ }
36
+ else if (await setIssueField(client, config, itemId, 'workflow', status)) {
37
+ output.done({ verb: 'set', target: `${target} status ${status}` });
38
+ await delay(AUTOMATION_WAIT_MILLISECONDS);
39
+ }
40
+ else {
41
+ output.warning(notConfiguredMessage(status));
42
+ }
43
+ }
44
+ // 2 回目の reopen(自動化による close への対策)で open を確かめ、--comment があれば理由を投稿する
45
+ async function confirmReopened(output, client, issue, comment) {
46
+ const { owner, repository, number } = issue;
47
+ const target = `Issue ${issuePath(owner, repository, number)}`;
48
+ const result = await client.reopenIssue(owner, repository, number);
49
+ const state = result['state'];
50
+ if (state !== 'open') {
51
+ stopWith(output, `${target} did not become open (state: ${typeof state === 'string' ? state : 'None'})`, 'other');
52
+ }
53
+ output.done({ verb: 'reopen', target });
54
+ if (comment === undefined || comment === '')
55
+ return;
56
+ await client.addIssueComment(owner, repository, number, comment);
57
+ output.done({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
58
+ }
59
+ // 予行。ボードの項目を読み、書く操作を並べる
60
+ async function planReopen(output, client, config, issue, status, comment) {
61
+ const { owner, repository, number } = issue;
62
+ const target = `Issue ${issuePath(owner, repository, number)}`;
63
+ const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
64
+ output.planned({ verb: 'reopen', target });
65
+ if (item?.isArchived === true)
66
+ output.planned({ verb: 'update', target: `${target} unarchived on the board` });
67
+ if (item === undefined)
68
+ output.warning(`${target} is not on the project board`);
69
+ else if (isStatusConfigured(config, status))
70
+ output.planned({ verb: 'set', target: `${target} status ${status}` });
71
+ else
72
+ output.warning(notConfiguredMessage(status));
73
+ if (comment !== undefined && comment !== '')
74
+ output.planned({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
75
+ }
76
+ async function reopenIssue(output, client, config, issue, status, comment) {
77
+ await reopenAndSetStatus(output, client, config, issue, status);
78
+ await confirmReopened(output, client, issue, comment);
79
+ }
80
+ const ISSUE_REOPEN = defineCommand({
81
+ path: ['issue', 'reopen'],
82
+ description: 'Reopen a closed Issue (also sets the status on the board)',
83
+ input: z.object({
84
+ issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
85
+ status: z.string().default('ready').describe('Status after reopening (backlog/pending/blocked/ready/active/in_review/archived)'),
86
+ comment: z.string().optional().describe('Reason for reopening (posted as a comment)'),
87
+ dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
88
+ }),
89
+ positional: ['issue_ref'],
90
+ shortFlags: { status: '-s', comment: '-c', dry_run: '-n' },
91
+ interactive: false,
92
+ run: async (input, io) => {
93
+ const output = createOutput(input.dry_run, io);
94
+ return await runWithExit(async () => {
95
+ const { status, comment } = input;
96
+ if (!VALID_STATUSES.has(status))
97
+ exitInvalidStatus(output, status);
98
+ const config = requireActiveConfigPlain(output);
99
+ const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
100
+ const target = `Issue ${issuePath(owner, repository, number)}`;
101
+ try {
102
+ const client = await connectToProject(output, config, owner, repository);
103
+ const run = input.dry_run ? planReopen : reopenIssue;
104
+ await run(output, client, config, { owner, repository, number }, status, comment);
105
+ }
106
+ catch (error) {
107
+ if (!(error instanceof GitHubAPIError))
108
+ throw error;
109
+ stopWith(output, `could not reopen ${target}: ${error.message}`, kindOfFailure(error));
110
+ }
111
+ });
112
+ },
113
+ });
114
+ export const ISSUE_REOPEN_COMMANDS = [ISSUE_REOPEN];
115
+ //# sourceMappingURL=issue-reopen.js.map
@@ -0,0 +1,172 @@
1
+ import { z } from 'zod';
2
+ import type { ProjectConfig } from '../domain/config.js';
3
+ import type { IssueFrontmatter } from '../domain/frontmatter.js';
4
+ import type { UsedOrder } from '../domain/issue-order.js';
5
+ import type { IssueReference } from '../domain/reference-parser.js';
6
+ import type { JsonObject } from '../domain/json.js';
7
+ import type { GitHubClient } from '../infra/github/index.js';
8
+ import type { HintedText } from './command-hint.js';
9
+ import type { BoardItem } from './issue-board.js';
10
+ import type { Output } from './output.js';
11
+ export type IssueType = IssueFrontmatter['type'];
12
+ /**
13
+ issue comment のテンプレ検証失敗の終了コード。通信失敗・設定なし・引数不足の 1 と区別し、hooks がこの値で分岐する
14
+ */
15
+ export declare const COMMENT_VALIDATION_EXIT_CODE = 3;
16
+ /**
17
+ Issue 種別の入力。issue create が使う
18
+ */
19
+ export declare const ISSUE_TYPE_SCHEMA: z.ZodDefault<z.ZodEnum<{
20
+ bug: "bug";
21
+ epic: "epic";
22
+ task: "task";
23
+ tracker: "tracker";
24
+ }>>;
25
+ export declare const PARENT_EPIC_DESCRIPTION = "Parent Epic reference: an integer (relative to aggregation_repo) or the primary form 'owner/repo/N'";
26
+ export declare const ISSUE_REF_DESCRIPTION = "Issue reference (`owner/repo/N`, or the short form `N` in the repository of `--repo`, or else of the git remote of the current directory)";
27
+ export declare const VALID_STATUSES: ReadonlySet<string>;
28
+ /**
29
+ 起票時の status は、型対応テンプレートの既定値だけを受ける。pending / archived への配置はボード上の手動操作
30
+ */
31
+ export declare const TYPE_DEFAULT_STATUS: Readonly<Record<IssueType, string>>;
32
+ /**
33
+ Backlog に置く型(freeform の size と quick-mode フラグの扱いが Epic と同じ)
34
+ */
35
+ export declare const BACKLOG_TYPES: ReadonlySet<string>;
36
+ /**
37
+ run の本体を包む。終わったら 0 を返す。BadParameterError は使い方の誤りにして伝える。
38
+ それ以外の例外はそのまま伝える。CommandExit は defineCommand が受けて終了コードにする
39
+ */
40
+ export declare function runWithExit(body: () => Promise<void>): Promise<0>;
41
+ /**
42
+ `owner/repo/N` の表記。エラー文と done の行の対象に使う
43
+ */
44
+ export declare function issuePath(owner: string, repository: string, number: number): string;
45
+ export interface IssueTarget {
46
+ readonly owner: string;
47
+ readonly repository: string;
48
+ readonly number: number;
49
+ }
50
+ /**
51
+ parseIssueReferenceFromContext の失敗を、error の行と終了コード 2 にしたもの
52
+ */
53
+ export declare function parseIssueReferenceOrExit(output: Output, repository: string | undefined, raw: string): IssueTarget;
54
+ /**
55
+ 不正な status と、有効な値を出して終了コード 1
56
+ */
57
+ export declare function exitInvalidStatus(output: Output, status: string): never;
58
+ /**
59
+ 起票時の status が、許す値のどれかと一致するか確かめる。違えば終了コード 1。許す値の既定は、型対応テンプレートの既定値だけ。
60
+ enum 外の値(`--status foo`)と、許さない値(`--type bug --status backlog`)は文を分ける
61
+ */
62
+ export declare function validateStatusForType(output: Output, issueType: IssueType, status: string, allowed?: readonly string[]): void;
63
+ /**
64
+ CLI のオプションで来た parent_epic。空・空白だけなら undefined、数字だけなら整数(安全な整数を超えるなら数字の文字列)、それ以外は文字列
65
+ */
66
+ export declare function normalizeParentEpicCli(raw: string | undefined): number | string | undefined;
67
+ /**
68
+ parent_epic を Issue 参照にする。整数は aggregation_repo の Issue(未設定なら task のリポジトリ)、`owner/repo/N` はそのまま。
69
+ 解決できなければ BadParameterError。番号が安全な整数を超える参照は、丸めずに解決できない参照として扱う
70
+ */
71
+ export declare function resolveParentEpicReference(raw: number | string, config: ProjectConfig, taskOwner: string, taskRepository: string): IssueReference;
72
+ export interface EpicTarget {
73
+ readonly repository: string;
74
+ /**
75
+ --repo が aggregation_repo と違う例外なので、warnEpicRepositoryException を出す
76
+ */
77
+ readonly needsWarning: boolean;
78
+ }
79
+ /**
80
+ Epic を作るリポジトリを、aggregation_repo の方針で決める。
81
+ repository が空で aggregation_repo も未設定なら、決められないので終了コード 2
82
+ */
83
+ export declare function resolveEpicTargetRepository(output: Output, repository: string | undefined, config: ProjectConfig): EpicTarget;
84
+ /**
85
+ Epic の作成先が aggregation_repo と違うときの警告
86
+ */
87
+ export declare function warnEpicRepositoryException(output: Output, resolvedRepository: string, config: ProjectConfig): void;
88
+ export interface IssueTitleOptions {
89
+ readonly parentEpic?: number | undefined;
90
+ readonly order?: number | undefined;
91
+ }
92
+ /**
93
+ タイトルに接頭辞と、Epic 番号・order を付ける。例は `[Task] #353-04: タイトル`
94
+ */
95
+ export declare function buildIssueTitle(issueType: string, title: string, options?: Readonly<IssueTitleOptions>): string;
96
+ /**
97
+ 親 Epic のサブ Issue から、使われた番号を読む。全件を読む。Epic を取れなければ warning を出して undefined
98
+ */
99
+ export declare function readUsedOrders(output: Output, client: GitHubClient, owner: string, repository: string, parentEpic: number): Promise<readonly UsedOrder[] | undefined>;
100
+ /**
101
+ 明示の order が既存の Issue と重なったときの error を出して終了コード 1。一度使った番号は、OPEN でも CLOSED でも再利用できない
102
+ */
103
+ export declare function stopForDuplicateOrder(output: Output, parentEpic: number, order: number, existing: UsedOrder, nextAvailable: number): never;
104
+ /**
105
+ 同じ Epic に、同じ order の Issue が無いことを確かめる。最初の一致を error にして終了コード 1。Epic を取れなければ warning だけで続ける
106
+ */
107
+ export declare function checkDuplicateOrder(output: Output, client: GitHubClient, owner: string, repository: string, parentEpic: number, order: number): Promise<void>;
108
+ /**
109
+ Issue を作り、`created:` の行を出して API の応答を返す。失敗は error の行と終了コード 1。
110
+ source は作成元のファイル名(`from <source>` として行の末尾に付く)
111
+ */
112
+ export declare function createIssueOrExit(output: Output, client: GitHubClient, owner: string, repository: string, title: string, body: string, labels: readonly string[] | undefined, source?: string): Promise<JsonObject>;
113
+ export interface IssueSummary {
114
+ readonly number: number;
115
+ readonly url: string;
116
+ /**
117
+ 作成の応答に node_id が無ければ undefined
118
+ */
119
+ readonly nodeId: string | undefined;
120
+ }
121
+ /**
122
+ Issue の作成の応答から、番号・URL・node id を取る
123
+ */
124
+ export declare function summarizeCreatedIssue(issue: JsonObject): IssueSummary;
125
+ /**
126
+ Issue をボードへ追加する。失敗は warning と Issue の URL を出して undefined
127
+ */
128
+ export declare function addToBoardOrWarn(output: Output, client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, issueNodeId: string | undefined, issueUrl: string): Promise<BoardItem | undefined>;
129
+ export interface IssueField {
130
+ readonly fieldName: string;
131
+ readonly optionName: string;
132
+ /**
133
+ `set:` の行に出す名前
134
+ */
135
+ readonly label: string;
136
+ }
137
+ /**
138
+ カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。失敗したフィールドは、何も出さずに飛ばす。設定できたフィールドの名前を返す
139
+ */
140
+ export declare function setIssueFields(output: Output, client: GitHubClient, config: ProjectConfig, itemId: string, target: string, fields: readonly IssueField[]): Promise<readonly string[]>;
141
+ /**
142
+ 親 Epic のサブ Issue にする。失敗は Issue の URL(issueUrl が undefined なら出し済みとして省く)、error の行の順に出して終了コード 1。issueNodeId は、無ければ取り直す関数
143
+ */
144
+ export declare function linkToParentEpic(output: Output, client: GitHubClient, target: string, parentReference: IssueReference, issueNodeId: string | (() => Promise<string>), issueUrl: string | undefined): Promise<void>;
145
+ /**
146
+ リポジトリがプロジェクトにリンクされていなければ、message を error に出して終了コード 1
147
+ */
148
+ export declare function ensureRepositoryInProject(output: Output, config: ProjectConfig, client: GitHubClient, owner: string, repository: string, message: string): Promise<void>;
149
+ /**
150
+ クライアントを作り、リポジトリがプロジェクトにあることを確かめる。無ければ error と終了コード 1。board add・board move・issue reopen が使う
151
+ */
152
+ export declare function connectToProject(output: Output, config: ProjectConfig, owner: string, repository: string): Promise<GitHubClient>;
153
+ /**
154
+ ボードに無い status の error の文。blocked は後から足せる option なので、足し方の hint を添える
155
+ */
156
+ export declare function notConfiguredMessage(status: string): string | HintedText;
157
+ /**
158
+ 起票用のクライアントを作り、リポジトリのリンクと、親 Epic のリポジトリでの order の重複を確かめる
159
+ */
160
+ export declare function clientForIssueCreate(output: Output, config: ProjectConfig, owner: string, repository: string, display: string, parentReference: IssueReference | undefined, order: number | undefined): Promise<GitHubClient>;
161
+ /**
162
+ 本文をテンプレートと比べ、違反を 1 つの error にして出す。違反があれば true。
163
+ 1 行目はテンプレートのパス。続く行に、違反のある種類だけを並べる
164
+ */
165
+ export declare function hasReportedTemplateViolations(output: Output, body: string, templatePath: string, options?: {
166
+ readonly emDashHint?: boolean;
167
+ }): boolean;
168
+ /**
169
+ Issue 本文を種別のテンプレートと比べる。違反があれば error を出して終了コード 1
170
+ */
171
+ export declare function validateIssueTemplate(output: Output, templateType: NonNullable<IssueFrontmatter['template']>, body: string): void;
172
+ //# sourceMappingURL=issue-shared.d.ts.map