@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,290 @@
1
+ // YAML フロントマター付き Markdown のパーサー。文字列を受けて、検証済みのフロントマターと本文を返す。
2
+ // ファイルを読む関数は infra/frontmatter-file.ts が持つ。
3
+ //
4
+ // 検証のエラー文は、Python の CLI が出していた書式(` - 項目: 本文`)に合わせる。
5
+ // 型の変換("2" → 2、"yes" → true、空文字列 → 未指定)も Python の CLI と同じ。
6
+ // 値が無いこと(null・未指定・空文字列)は、読んだ後はどれも undefined になる。
7
+ import { z } from 'zod';
8
+ import { convertToInteger, PRIORITIES, SIZES, WORKFLOW_STATUSES } from './config.js';
9
+ import { PecotError } from './errors.js';
10
+ import { normalizeNewlines, parsePythonInteger, pythonStrip, pythonStringRepr } from './python-format.js';
11
+ import { parseYamlDocument } from './yaml-document.js';
12
+ export class FrontmatterError extends PecotError {
13
+ kind;
14
+ constructor(message, options) {
15
+ super(message, options);
16
+ this.kind = options?.kind;
17
+ }
18
+ }
19
+ // 検証のエラー文
20
+ const REQUIRED_MESSAGE = 'Field required';
21
+ const STRING_MESSAGE = 'Input should be a valid string';
22
+ const LIST_MESSAGE = 'Input should be a valid list';
23
+ const SINGLE_LINE_MESSAGE = 'Value error, reason must be a single line';
24
+ const NOT_EMPTY_MESSAGE = 'String should have at least 1 character';
25
+ function quotedChoices(values) {
26
+ const quoted = values.map(value => pythonStringRepr(String(value)));
27
+ const last = quoted.at(-1);
28
+ return last === undefined || quoted.length <= 1 ? quoted.join('') : `${quoted.slice(0, -1).join(', ')} or ${last}`;
29
+ }
30
+ function choiceMessage(issue) {
31
+ return issue.input === undefined ? REQUIRED_MESSAGE : `Input should be ${quotedChoices(issue.values ?? [])}`;
32
+ }
33
+ function stringMessage(issue) {
34
+ return issue.input === undefined ? REQUIRED_MESSAGE : STRING_MESSAGE;
35
+ }
36
+ function listMessage(issue) {
37
+ return issue.input === undefined ? REQUIRED_MESSAGE : LIST_MESSAGE;
38
+ }
39
+ function integerMessage(input) {
40
+ if (typeof input === 'string')
41
+ return 'Input should be a valid integer, unable to parse string as an integer';
42
+ if (typeof input !== 'number')
43
+ return 'Input should be a valid integer';
44
+ if (!Number.isFinite(input))
45
+ return 'Input should be a finite number';
46
+ return 'Input should be a valid integer, got a number with a fractional part';
47
+ }
48
+ // 2 の 63 乗。これ以上の数は、真偽値の変換で整数として扱われない
49
+ const INTEGER_LIMIT = 2 ** 63;
50
+ function booleanMessage(input) {
51
+ const isParsable = typeof input === 'string' || (typeof input === 'number' && Number.isSafeInteger(input) && Math.abs(input) < INTEGER_LIMIT);
52
+ return isParsable ? 'Input should be a valid boolean, unable to interpret input' : 'Input should be a valid boolean';
53
+ }
54
+ // 型の変換
55
+ function emptyStringToUndefined(value) {
56
+ return value === '' ? undefined : value;
57
+ }
58
+ const TRUE_STRINGS = new Set(['1', 'on', 't', 'true', 'y', 'yes']);
59
+ const FALSE_STRINGS = new Set(['0', 'off', 'f', 'false', 'n', 'no']);
60
+ // bool の lax な変換。文字列は大文字小文字を区別せず(前後の空白は落とさない)、数は 0 と 1 だけを受ける
61
+ function convertToBoolean(value) {
62
+ if (typeof value === 'string') {
63
+ const lowered = value.toLowerCase();
64
+ if (TRUE_STRINGS.has(lowered))
65
+ return true;
66
+ if (FALSE_STRINGS.has(lowered))
67
+ return false;
68
+ return value;
69
+ }
70
+ if (value === 1)
71
+ return true;
72
+ if (value === 0)
73
+ return false;
74
+ return value;
75
+ }
76
+ // 文字列なら前後の空白を落とし、空なら未指定にする(Python の OptionalText)。文字列以外はそのまま
77
+ function normalizeOptionalText(value) {
78
+ return typeof value === 'string' ? emptyStringToUndefined(pythonStrip(value)) : value;
79
+ }
80
+ // parent_epic の入力の正規化。未指定・空文字 → 未指定、数字だけの文字列 → 整数、それ以外の文字列 → 前後の空白を落とした文字列
81
+ function normalizeParentEpic(value) {
82
+ if (value === null || emptyStringToUndefined(value) === undefined)
83
+ return undefined;
84
+ if (typeof value === 'boolean')
85
+ return value ? 1 : 0;
86
+ if (typeof value !== 'string')
87
+ return value;
88
+ const stripped = pythonStrip(value);
89
+ return /^\p{Nd}+$/u.test(stripped) ? parsePythonInteger(stripped) : stripped;
90
+ }
91
+ // スキーマ
92
+ const IntegerSchema = z.number({ error: issue => integerMessage(issue.input) }).refine(Number.isSafeInteger, { error: issue => integerMessage(issue.input) });
93
+ const IssueTypeSchema = z.enum(['task', 'bug', 'epic', 'tracker'], { error: choiceMessage });
94
+ const WorkflowStatusSchema = z.enum(WORKFLOW_STATUSES, { error: choiceMessage });
95
+ function stripString(value) {
96
+ return typeof value === 'string' ? pythonStrip(value) : value;
97
+ }
98
+ const BlockedByEntrySchema = z.object({
99
+ issue: z.preprocess(stripString, z.string({ error: stringMessage }).min(1, { error: NOT_EMPTY_MESSAGE })),
100
+ wait: z.enum(['stack', 'merge'], { error: choiceMessage }).prefault('stack'),
101
+ reason: z.preprocess(normalizeOptionalText, z.string({ error: stringMessage }).refine(value => !/[\r\n]/u.test(value), { error: SINGLE_LINE_MESSAGE }).nullish().transform(value => value ?? undefined)),
102
+ }).readonly();
103
+ const IssueFrontmatterSchema = z.object({
104
+ title: z.string({ error: stringMessage }),
105
+ type: IssueTypeSchema,
106
+ template: z.preprocess(emptyStringToUndefined, z.enum(['task', 'bug', 'epic', 'tracker', 'task-implement'], { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
107
+ repository: z.string({ error: stringMessage }),
108
+ status: WorkflowStatusSchema.optional(),
109
+ blocked_by: z.preprocess(value => value === null ? undefined : value, z.array(BlockedByEntrySchema, { error: listMessage }).readonly().prefault([])),
110
+ priority: z.preprocess(emptyStringToUndefined, z.enum(PRIORITIES, { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
111
+ size: z.preprocess(emptyStringToUndefined, z.enum(SIZES, { error: choiceMessage }).nullish().transform(value => value ?? undefined)),
112
+ labels: z.array(z.string({ error: STRING_MESSAGE }), { error: listMessage }).readonly().prefault([]),
113
+ parent_epic: z.preprocess(normalizeParentEpic, z.unknown().transform((value, context) => {
114
+ // 「整数 | 文字列」のどちらでもない値は、枝ごとの誤り(`parent_epic.int`・`parent_epic.str`)を 2 行で返す
115
+ if (value === undefined || typeof value === 'string' || (typeof value === 'number' && Number.isSafeInteger(value)))
116
+ return value;
117
+ context.issues.push({ code: 'custom', message: integerMessage(value), input: value, path: ['int'] }, { code: 'custom', message: STRING_MESSAGE, input: value, path: ['str'] });
118
+ return z.NEVER;
119
+ })),
120
+ order: z.preprocess(value => convertToInteger(emptyStringToUndefined(value)), IntegerSchema.nullish().transform(value => value ?? undefined)),
121
+ }).readonly();
122
+ const CommentFrontmatterSchema = z.object({
123
+ issue_ref: z.string({ error: stringMessage }),
124
+ template: z.enum(['plan', 'merge-diff', 'review-findings', 'review-resolution', 'precede-notify'], { error: choiceMessage }).nullish().transform(value => value ?? undefined),
125
+ comment_url: z.string({ error: STRING_MESSAGE }).nullish().transform(value => value ?? undefined),
126
+ }).readonly();
127
+ const PullRequestFrontmatterSchema = z.object({
128
+ title: z.string({ error: stringMessage }),
129
+ repository: z.string({ error: stringMessage }),
130
+ base: z.string({ error: stringMessage }),
131
+ head: z.string({ error: STRING_MESSAGE }).nullish().transform(value => value ?? undefined),
132
+ draft: z.preprocess(convertToBoolean, z.boolean({ error: issue => booleanMessage(issue.input) })).prefault(false),
133
+ screenshot: z.preprocess(normalizeOptionalText, z.string({ error: stringMessage }).nullish().transform(value => value ?? undefined)),
134
+ }).readonly();
135
+ function issueLine(issue) {
136
+ return ` - ${issue.path.map(String).join('.')}: ${issue.message}`;
137
+ }
138
+ function validationError(lines) {
139
+ return new FrontmatterError(`validation error:\n${lines.join('\n')}`);
140
+ }
141
+ function fieldErrors(issues) {
142
+ return validationError(issues.map(issue => issueLine(issue)));
143
+ }
144
+ // parent_epic・order・blocked_by・status の相互検証。項目の誤りが無いときだけ行う
145
+ function checkCrossFields(frontmatter) {
146
+ const { parent_epic: parentEpic, order, blocked_by: blockedBy, status, type } = frontmatter;
147
+ if (blockedBy.some(entry => entry.wait === 'merge' && entry.reason === undefined)) {
148
+ throw new FrontmatterError('blocked_by needs reason for wait: merge', { kind: 'merge-without-reason' });
149
+ }
150
+ let message;
151
+ if (parentEpic === undefined && order !== undefined)
152
+ message = 'parent_epic is required when order is set';
153
+ else if (order !== undefined && order <= 0)
154
+ message = `order must be an integer of 1 or more: ${String(order)}`;
155
+ else if (blockedBy.length > 0 && (type === 'epic' || type === 'tracker'))
156
+ message = `blocked_by cannot be set for type ${type}`;
157
+ else if (status === 'ready' && blockedBy.length > 0)
158
+ message = 'status: ready cannot be set together with blocked_by';
159
+ else if (status === 'blocked' && blockedBy.length === 0)
160
+ message = 'status: blocked requires blocked_by';
161
+ if (message !== undefined)
162
+ throw validationError([` - : Value error, ${message}`]);
163
+ }
164
+ function hasParallel(data) {
165
+ const value = typeof data === 'object' && data !== null && 'parallel' in data ? data.parallel : undefined;
166
+ return typeof value === 'string' ? value !== '' : value !== undefined && value !== null;
167
+ }
168
+ /**
169
+ 値から Issue のフロントマターを作る。不正なら FrontmatterError
170
+ */
171
+ export function validateIssueFrontmatter(data) {
172
+ // 使えなくなった項目の案内は、ほかの誤りと重なっても先に出す
173
+ if (hasParallel(data))
174
+ throw new FrontmatterError('parallel is no longer supported', { kind: 'parallel' });
175
+ const result = IssueFrontmatterSchema.safeParse(data);
176
+ if (!result.success)
177
+ throw fieldErrors(result.error.issues);
178
+ checkCrossFields(result.data);
179
+ return result.data;
180
+ }
181
+ /**
182
+ 値からコメントのフロントマターを作る。不正なら FrontmatterError
183
+ */
184
+ export function validateCommentFrontmatter(data) {
185
+ const result = CommentFrontmatterSchema.safeParse(data);
186
+ if (!result.success)
187
+ throw fieldErrors(result.error.issues);
188
+ return result.data;
189
+ }
190
+ /**
191
+ 値から PR のフロントマターを作る。不正なら FrontmatterError
192
+ */
193
+ export function validatePullRequestFrontmatter(data) {
194
+ const result = PullRequestFrontmatterSchema.safeParse(data);
195
+ if (!result.success)
196
+ throw fieldErrors(result.error.issues);
197
+ return result.data;
198
+ }
199
+ // パーサー関数
200
+ // ^---\n で始まり、\n---\n で終わる
201
+ // 先頭の空白の連続と、本文の最短一致が、空白を取り合う。入力はフロントマター付きの Markdown 1 ファイルで、
202
+ // Python の同名の正規表現と同じ範囲を取るため、この形を保つ。
203
+ // eslint-disable-next-line regexp/no-super-linear-backtracking -- 空白の連続が長い入力でだけ遅くなる。取る範囲を Python と揃えるため書き換えない
204
+ const FRONTMATTER_PATTERN = /^---\s*\n(.*?)\n---\s*/dsu;
205
+ // 本文先頭のガイドコメント(`--prepare` 雛形の「読者:/書き方:/フィールド:」ブロック)。
206
+ // 前後の空白・空行ごと 1 ブロックだけ食う。本文途中のコメントは対象外。
207
+ const LEADING_HTML_COMMENT_PATTERN = /^\s*<!--.*?-->\s*/su;
208
+ /**
209
+ 本文先頭の HTML コメントブロックを 1 つだけ除去する。
210
+ `--prepare` が配る雛形は、冒頭に書き方ガイドの HTML コメントを持つ。
211
+ 利用者が消し忘れたまま投稿しても GitHub 本文に残らないよう、パース時に取り除く(#958 F-02)。
212
+ 本文途中の `<details>` 等の HTML には触れない
213
+ */
214
+ export function stripLeadingHtmlComment(body) {
215
+ return body.replace(LEADING_HTML_COMMENT_PATTERN, '');
216
+ }
217
+ /**
218
+ フロントマターを落とした本文を返す(不正・不在なら原文をそのまま返す)。
219
+ パース前の素朴な走査(プレースホルダ検証など)で本文だけを対象にするための寛容なヘルパで、検証はしない
220
+ */
221
+ export function stripFrontmatter(content) {
222
+ const match = FRONTMATTER_PATTERN.exec(content);
223
+ return match === null ? content : content.slice(match[0].length);
224
+ }
225
+ function isMapping(data) {
226
+ return typeof data === 'object' && data !== null && Object.getPrototypeOf(data) === Object.prototype;
227
+ }
228
+ // フロントマターの YAML を読み、本文と分ける。フロントマターの検証はしない
229
+ function splitFrontmatter(content) {
230
+ if (!content.startsWith('---'))
231
+ throw new FrontmatterError('frontmatter not found (does not start with ---)');
232
+ const match = FRONTMATTER_PATTERN.exec(content);
233
+ if (match === null)
234
+ throw new FrontmatterError('frontmatter is not closed (missing closing ---)');
235
+ const rest = pythonStrip(content.slice(match[0].length));
236
+ const body = pythonStrip(stripLeadingHtmlComment(rest));
237
+ let data;
238
+ try {
239
+ // 改行は \r\n・\r も \n と同じ行区切りとして読む(YAML ライブラリは末尾の \r を値に含める)
240
+ data = parseYamlDocument(normalizeNewlines(match[1] ?? ''));
241
+ }
242
+ catch (error) {
243
+ throw new FrontmatterError(`failed to parse YAML: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
244
+ }
245
+ if (!isMapping(data))
246
+ throw new FrontmatterError('frontmatter must be a mapping (key: value)');
247
+ return { data, body };
248
+ }
249
+ /**
250
+ 文字列から Issue のフロントマターをパースする。不正なら FrontmatterError
251
+ */
252
+ export function parseFrontmatter(content) {
253
+ const { data, body } = splitFrontmatter(content);
254
+ return { frontmatter: validateIssueFrontmatter(data), body };
255
+ }
256
+ /**
257
+ 文字列からコメントのフロントマターをパースする。不正なら FrontmatterError
258
+ */
259
+ export function parseCommentContent(content) {
260
+ const { data, body } = splitFrontmatter(content);
261
+ return { frontmatter: validateCommentFrontmatter(data), body };
262
+ }
263
+ /**
264
+ 文字列から PR のフロントマターをパースする。不正なら FrontmatterError
265
+ */
266
+ export function parsePullRequestContent(content) {
267
+ const { data, body } = splitFrontmatter(content);
268
+ return { frontmatter: validatePullRequestFrontmatter(data), body };
269
+ }
270
+ // `key` の直後に空白を挟んで `:` が続く行か(Python の `^key\s*:`)
271
+ function isKeyLine(line, key) {
272
+ return line.startsWith(key) && /^\s*:/u.test(line.slice(key.length));
273
+ }
274
+ /**
275
+ フロントマターに `key: "value"` の 1 行を足す。同じキーの行があれば置き換えるだけで、足さない。
276
+ フロントマターが無ければ FrontmatterError
277
+ */
278
+ export function setFrontmatterValue(content, key, value) {
279
+ const match = FRONTMATTER_PATTERN.exec(content);
280
+ const span = match?.indices?.[1];
281
+ if (match === null || span === undefined)
282
+ throw new FrontmatterError('frontmatter not found');
283
+ const lines = (match[1] ?? '').split('\n');
284
+ const entry = `${key}: "${value}"`;
285
+ const replaced = lines.map(line => isKeyLine(line, key) ? entry : line);
286
+ if (lines.every(line => !isKeyLine(line, key)))
287
+ replaced.push(entry);
288
+ return content.slice(0, span[0]) + replaced.join('\n') + content.slice(span[1]);
289
+ }
290
+ //# sourceMappingURL=frontmatter.js.map
@@ -0,0 +1,10 @@
1
+ export interface GitResult {
2
+ readonly exitCode: number;
3
+ readonly stdout: string;
4
+ readonly stderr: string;
5
+ }
6
+ /**
7
+ git を実行する。非 0 終了でも例外にせず結果を返す。git の起動に失敗したときは例外を投げる。
8
+ */
9
+ export type GitRunner = (arguments_: readonly string[]) => GitResult;
10
+ //# sourceMappingURL=git-runner.d.ts.map
@@ -0,0 +1,4 @@
1
+ // git の実行を domain から切り離す型。実体は infra/git.ts の gitRunnerFor が作る。
2
+ // 作業ディレクトリは実体が持つ。domain は git の引数(先頭に `git` を含めない)だけを渡す。
3
+ export {};
4
+ //# sourceMappingURL=git-runner.js.map
@@ -0,0 +1,17 @@
1
+ import { InvalidValueError } from './errors.js';
2
+ export declare class RemoteUrlFormatError extends InvalidValueError {
3
+ }
4
+ export interface RemoteLocation {
5
+ readonly host: string;
6
+ readonly owner: string;
7
+ readonly repository: string;
8
+ }
9
+ /**
10
+ リモート URL を分ける。前後の空白は除く。
11
+ 対応する形式は次の 3 つ。
12
+ - 形式 1: `https://host/owner/repo[.git]`。
13
+ - 形式 2: `git@host:owner/repo[.git]`。
14
+ - 形式 3: `ssh://[user@]host[:port]/owner/repo[.git][/]`。
15
+ */
16
+ export declare function parseRemoteUrl(url: string): RemoteLocation;
17
+ //# sourceMappingURL=git-url.d.ts.map
@@ -0,0 +1,30 @@
1
+ // Git リモート URL の解析。HTTPS / SSH 形式から (host, owner, repository) を取り出す。
2
+ import { InvalidValueError } from './errors.js';
3
+ import { pythonStrip } from './python-format.js';
4
+ export class RemoteUrlFormatError extends InvalidValueError {
5
+ }
6
+ const HTTPS_URL_PATTERN = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+?)(?:\.git)?$/u;
7
+ const SSH_URL_PATTERN = /^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/u;
8
+ const USERINFO_PATTERN = /^([a-z][a-z0-9+.-]*:\/\/)[^/]*@/iu;
9
+ // eslint-disable-next-line security/detect-unsafe-regex -- 入力はリモート URL 1 本で、バックトラックの幅は URL の長さに収まる
10
+ const SSH_SCHEME_URL_PATTERN = /^ssh:\/\/(?:[^@/]+@)?([^/:@]+)(?::\p{Nd}+)?\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/u;
11
+ /**
12
+ リモート URL を分ける。前後の空白は除く。
13
+ 対応する形式は次の 3 つ。
14
+ - 形式 1: `https://host/owner/repo[.git]`。
15
+ - 形式 2: `git@host:owner/repo[.git]`。
16
+ - 形式 3: `ssh://[user@]host[:port]/owner/repo[.git][/]`。
17
+ */
18
+ export function parseRemoteUrl(url) {
19
+ const trimmed = pythonStrip(url);
20
+ for (const pattern of [HTTPS_URL_PATTERN, SSH_URL_PATTERN, SSH_SCHEME_URL_PATTERN]) {
21
+ const [, host, owner, repository] = pattern.exec(trimmed) ?? [];
22
+ if (host !== undefined && owner !== undefined && repository !== undefined) {
23
+ // https://user:token@host/... の userinfo は host に含めない
24
+ return { host: host.slice(host.lastIndexOf('@') + 1), owner, repository };
25
+ }
26
+ }
27
+ // エラー文に認証情報(userinfo)を出さない
28
+ throw new RemoteUrlFormatError(`unexpected remote URL format: ${trimmed.replace(USERINFO_PATTERN, '$1')}`);
29
+ }
30
+ //# sourceMappingURL=git-url.js.map
@@ -0,0 +1,16 @@
1
+ export declare const EPIC_TYPE_NAME = "Epic";
2
+ /**
3
+ Issue 種別の取得結果。キー名は Python の CLI が返していた辞書と同じ
4
+ */
5
+ export interface IssueKind {
6
+ readonly issue_type?: string | null | undefined;
7
+ readonly sub_issues_total?: number | undefined;
8
+ }
9
+ /**
10
+ Issue Type=Epic、または subIssues.totalCount > 0 を Epic とみなす。
11
+ 1. issue_type が `Epic` なら true(大文字小文字は区別しない)。
12
+ 2. issue_type が空・未設定で sub_issues_total > 0 なら true(Issue Type が無かった頃のフォールバック)。
13
+ 3. それ以外は false。
14
+ */
15
+ export declare function isEpicIssue(issueKind: IssueKind): boolean;
16
+ //# sourceMappingURL=issue-kind.d.ts.map
@@ -0,0 +1,16 @@
1
+ // Issue 種別判定(GitHub の Issue 種別の取得結果に対する純関数)。
2
+ import { pythonStrip } from './python-format.js';
3
+ export const EPIC_TYPE_NAME = 'Epic';
4
+ /**
5
+ Issue Type=Epic、または subIssues.totalCount > 0 を Epic とみなす。
6
+ 1. issue_type が `Epic` なら true(大文字小文字は区別しない)。
7
+ 2. issue_type が空・未設定で sub_issues_total > 0 なら true(Issue Type が無かった頃のフォールバック)。
8
+ 3. それ以外は false。
9
+ */
10
+ export function isEpicIssue(issueKind) {
11
+ const issueType = pythonStrip(issueKind.issue_type ?? '');
12
+ const isEpicType = issueType.toLowerCase() === EPIC_TYPE_NAME.toLowerCase();
13
+ const isFallback = issueType === '' && (issueKind.sub_issues_total ?? 0) > 0;
14
+ return isEpicType || isFallback;
15
+ }
16
+ //# sourceMappingURL=issue-kind.js.map
@@ -0,0 +1,55 @@
1
+ export interface SubIssueTitle {
2
+ readonly number: number;
3
+ readonly state: string;
4
+ readonly title: string;
5
+ }
6
+ export interface UsedOrder {
7
+ readonly number: number;
8
+ readonly state: string;
9
+ readonly title: string;
10
+ /**
11
+ タイトルの番号。枝の文字は数えない
12
+ */
13
+ readonly order: number;
14
+ }
15
+ /**
16
+ サブタスクのうち、タイトルが親 Epic の番号付きのものを、使われた番号にする
17
+ */
18
+ export declare function usedOrdersOf(subIssues: readonly SubIssueTitle[], parentEpic: number): readonly UsedOrder[];
19
+ export interface OrderRequest {
20
+ readonly file: string;
21
+ /**
22
+ 明示の番号。省いたら undefined
23
+ */
24
+ readonly order: number | undefined;
25
+ }
26
+ export type OrderPlan = {
27
+ readonly kind: 'planned';
28
+ readonly orders: readonly number[];
29
+ } | {
30
+ readonly kind: 'duplicate-in-batch';
31
+ readonly order: number;
32
+ readonly files: readonly string[];
33
+ } | {
34
+ readonly kind: 'duplicate-existing';
35
+ readonly order: number;
36
+ readonly existing: UsedOrder;
37
+ readonly nextAvailable: number;
38
+ } | {
39
+ readonly kind: 'unreadable-parent';
40
+ };
41
+ /**
42
+ 一括の中で明示の番号が重なるものを返す。ネットワークを使わずに確かめられる
43
+ */
44
+ export declare function findBatchDuplicate(requests: readonly OrderRequest[]): {
45
+ readonly order: number;
46
+ readonly files: readonly string[];
47
+ } | undefined;
48
+ /**
49
+ 同じ親 Epic のファイルに番号を振る。requests はファイルの順。
50
+ 使われた番号は、親のサブタスクのタイトルから読んだもの(読めなければ undefined)。
51
+ 明示の番号は、既存の番号とも、ほかのファイルの明示の番号とも重ねない。
52
+ 省いたファイルには、既存の番号と明示の番号の最大の次から、ファイルの順に振る。省いたファイルがあって使われた番号を読めなければ、決められない
53
+ */
54
+ export declare function planOrders(used: readonly UsedOrder[] | undefined, requests: readonly OrderRequest[]): OrderPlan;
55
+ //# sourceMappingURL=issue-order.d.ts.map
@@ -0,0 +1,65 @@
1
+ // タイトルの通し番号(specs/024 の R13)。サブタスクのタイトルと明示の番号から、使われた番号・重複・次の番号を決める。I/O を持たない。
2
+ // タイトルの先頭の `#123-01:` と `#123-01a:` から、Epic 番号・番号・枝の文字を取る。`[Task] ` のような接頭辞は許す
3
+ const ORDER_PATTERN = /^#(\d+)-(\d+)([a-z])?:/u;
4
+ const TITLE_PREFIX_PATTERN = /^\[[^\]]*\] ?/u;
5
+ /**
6
+ サブタスクのうち、タイトルが親 Epic の番号付きのものを、使われた番号にする
7
+ */
8
+ export function usedOrdersOf(subIssues, parentEpic) {
9
+ const used = [];
10
+ for (const sub of subIssues) {
11
+ const [, epic, order] = ORDER_PATTERN.exec(sub.title.replace(TITLE_PREFIX_PATTERN, '')) ?? [];
12
+ if (epic === undefined || order === undefined || Number(epic) !== parentEpic)
13
+ continue;
14
+ used.push({ number: sub.number, state: sub.state, title: sub.title, order: Number(order) });
15
+ }
16
+ return used;
17
+ }
18
+ function explicitOrders(requests) {
19
+ const explicit = new Map();
20
+ for (const { file, order } of requests) {
21
+ if (order !== undefined)
22
+ explicit.set(order, [...explicit.get(order) ?? [], file]);
23
+ }
24
+ return explicit;
25
+ }
26
+ /**
27
+ 一括の中で明示の番号が重なるものを返す。ネットワークを使わずに確かめられる
28
+ */
29
+ export function findBatchDuplicate(requests) {
30
+ for (const [order, files] of explicitOrders(requests)) {
31
+ if (files.length > 1)
32
+ return { order, files };
33
+ }
34
+ return undefined;
35
+ }
36
+ /**
37
+ 同じ親 Epic のファイルに番号を振る。requests はファイルの順。
38
+ 使われた番号は、親のサブタスクのタイトルから読んだもの(読めなければ undefined)。
39
+ 明示の番号は、既存の番号とも、ほかのファイルの明示の番号とも重ねない。
40
+ 省いたファイルには、既存の番号と明示の番号の最大の次から、ファイルの順に振る。省いたファイルがあって使われた番号を読めなければ、決められない
41
+ */
42
+ export function planOrders(used, requests) {
43
+ const explicit = explicitOrders(requests);
44
+ // 省いたファイルへの番号と、重複のときの案内は、同じ「既存と明示の最大の次」
45
+ const first = Math.max(0, ...(used ?? []).map(entry => entry.order), ...explicit.keys()) + 1;
46
+ for (const [order, files] of explicit) {
47
+ if (files.length > 1)
48
+ return { kind: 'duplicate-in-batch', order, files };
49
+ const existing = used?.find(entry => entry.order === order);
50
+ if (existing !== undefined)
51
+ return { kind: 'duplicate-existing', order, existing, nextAvailable: first };
52
+ }
53
+ if (used === undefined && requests.some(({ order }) => order === undefined))
54
+ return { kind: 'unreadable-parent' };
55
+ let next = first;
56
+ const orders = requests.map(({ order }) => {
57
+ if (order !== undefined)
58
+ return order;
59
+ const assigned = next;
60
+ next += 1;
61
+ return assigned;
62
+ });
63
+ return { kind: 'planned', orders };
64
+ }
65
+ //# sourceMappingURL=issue-order.js.map
@@ -0,0 +1,143 @@
1
+ import type { RepositoryReference } from './repository-resolver.js';
2
+ /**
3
+ GitHub の PR の状態。GraphQL の PullRequestState の値そのまま
4
+ */
5
+ export type PullRequestStateReadout = 'OPEN' | 'CLOSED' | 'MERGED';
6
+ /**
7
+ Issue の状態。GraphQL の IssueState の値そのまま
8
+ */
9
+ export type IssueStateReadout = 'OPEN' | 'CLOSED';
10
+ export interface PullRequestReadout {
11
+ /**
12
+ PR のあるリポ(base 側)
13
+ */
14
+ readonly repository: RepositoryReference;
15
+ readonly number: number;
16
+ readonly state: PullRequestStateReadout;
17
+ readonly headRefName: string;
18
+ readonly baseRefName: string;
19
+ readonly isDraft: boolean;
20
+ readonly isCrossRepository: boolean;
21
+ }
22
+ /**
23
+ ボードの単一選択のフィールドの値 1 つ。設定のプロジェクトに絞った後の値
24
+ */
25
+ export interface ProjectFieldValueReadout {
26
+ readonly fieldId: string;
27
+ readonly fieldName: string;
28
+ readonly optionId: string;
29
+ readonly optionName: string;
30
+ }
31
+ export interface LinkedBranchReadout {
32
+ readonly name: string;
33
+ /**
34
+ このブランチを head に持つ PR
35
+ */
36
+ readonly pullRequests: readonly PullRequestReadout[];
37
+ }
38
+ export interface IssueReadout {
39
+ /**
40
+ GraphQL の node ID
41
+ */
42
+ readonly id: string;
43
+ readonly repository: RepositoryReference;
44
+ readonly number: number;
45
+ readonly state: IssueStateReadout;
46
+ readonly title: string;
47
+ /**
48
+ Issue Type の名前。無い、または issueType に対応しない GHES では null
49
+ */
50
+ readonly issueType: string | null;
51
+ readonly subIssuesTotal: number;
52
+ /**
53
+ 設定のプロジェクトのアイテムの値。ボードに無ければ空
54
+ */
55
+ readonly projectFieldValues: readonly ProjectFieldValueReadout[];
56
+ readonly linkedBranches: readonly LinkedBranchReadout[];
57
+ /**
58
+ closedByPullRequestsReferences(includeClosedPrs: true) の PR
59
+ */
60
+ readonly closingPullRequests: readonly PullRequestReadout[];
61
+ /**
62
+ timelineItems の PR。ConnectedEvent のうち後で外されていないものと、CrossReferencedEvent のうち閉じる参照か、head が `/<Issue 番号>` で終わるもの
63
+ */
64
+ readonly timelinePullRequests: readonly PullRequestReadout[];
65
+ }
66
+ export interface TargetIssueReadout extends IssueReadout {
67
+ readonly body: string;
68
+ /**
69
+ 親の Issue(sub-issue の親)。親が無い、または応答に無ければ null
70
+ */
71
+ readonly parent: {
72
+ readonly repository: RepositoryReference;
73
+ readonly number: number;
74
+ } | null;
75
+ }
76
+ /**
77
+ blockedBy の読み取り結果。読めない部分があるときは read-failed。
78
+ 読めない部分とは、blockedBy の null の node・エラー・件数不足と、対象と前提の Issue の connection の取りこぼし
79
+ */
80
+ export type BlockedByReadout = {
81
+ readonly kind: 'ok';
82
+ readonly issues: readonly IssueReadout[];
83
+ } | {
84
+ readonly kind: 'read-failed';
85
+ readonly reason: string;
86
+ };
87
+ export interface IssuePrerequisitesReadout {
88
+ readonly issue: TargetIssueReadout;
89
+ readonly blockedBy: BlockedByReadout;
90
+ }
91
+ /**
92
+ ボードのフィールド名。getIssuePrerequisites が値を取る 2 つ
93
+ */
94
+ export interface PrerequisiteFieldNames {
95
+ /**
96
+ 進行の欄のフィールド名
97
+ */
98
+ readonly columnFieldName: string;
99
+ /**
100
+ 札のフィールド名
101
+ */
102
+ readonly labelFieldName: string;
103
+ }
104
+ /**
105
+ head のブランチ名で引いた PR。新しい順
106
+ */
107
+ export interface PullRequestsByHeadReadout {
108
+ readonly pullRequests: readonly PullRequestReadout[];
109
+ /**
110
+ 先頭の件数に収まらず、続きがあるか
111
+ */
112
+ readonly hasNextPage: boolean;
113
+ }
114
+ /**
115
+ 前提 1 件の参照。block / unblock が、付ける前の確認と輪の探索に使う
116
+ */
117
+ export interface BlockedByReference {
118
+ /**
119
+ GraphQL の node ID
120
+ */
121
+ readonly id: string;
122
+ readonly repository: RepositoryReference;
123
+ readonly number: number;
124
+ readonly state: IssueStateReadout;
125
+ }
126
+ /**
127
+ 前提の参照の読み取り結果。total は件数で、issues は読めた分(total に足りないことがある)。
128
+ null の node と部分エラーは read-failed
129
+ */
130
+ export type BlockedByReferences = {
131
+ readonly kind: 'ok';
132
+ readonly total: number;
133
+ readonly issues: readonly BlockedByReference[];
134
+ } | {
135
+ readonly kind: 'read-failed';
136
+ readonly reason: string;
137
+ };
138
+ export interface IssueBlockedByReferences {
139
+ readonly id: string;
140
+ readonly body: string;
141
+ readonly blockedBy: BlockedByReferences;
142
+ }
143
+ //# sourceMappingURL=issue-readout.d.ts.map
@@ -0,0 +1,4 @@
1
+ // 前提の読み取り結果の形。infra(GitHub の応答)と domain(Issue の実態へのまとめ)の境目の型。
2
+ // infra/github/issues.ts の getIssuePrerequisites がこの形で返し、domain/readiness.ts の toIssueFacts が受ける。
3
+ export {};
4
+ //# sourceMappingURL=issue-readout.js.map
@@ -0,0 +1,2 @@
1
+ export declare const JSON_NULL: null;
2
+ //# sourceMappingURL=json-null.d.ts.map