@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,31 @@
1
+ /**
2
+ 更新の入力に渡す選択肢。既存の選択肢は id を持ち、新しい選択肢は id を持たない
3
+ */
4
+ export type FieldOptionInput = Readonly<{
5
+ id?: string;
6
+ name: string;
7
+ color: string;
8
+ description: string;
9
+ }>;
10
+ export type OptionPlacement = Readonly<{
11
+ after: string;
12
+ } | {
13
+ before: string;
14
+ } | {
15
+ end: true;
16
+ }>;
17
+ /**
18
+ 差し込み先の候補のうち、基準の名前が既存にある最初のものを選ぶ。どれも無ければ末尾
19
+ */
20
+ export declare function choosePlacement(existing: readonly Readonly<{
21
+ name: string;
22
+ }>[], candidates: readonly OptionPlacement[]): OptionPlacement;
23
+ /**
24
+ 既存の選択肢の並びに、新しい選択肢を 1 つ差し込む。同じ名前(大文字と小文字は区別しない)が既にあれば undefined
25
+ */
26
+ export declare function insertOption(existing: readonly FieldOptionInput[], option: Readonly<{
27
+ name: string;
28
+ color: string;
29
+ description: string;
30
+ }>, placement: OptionPlacement): readonly FieldOptionInput[] | undefined;
31
+ //# sourceMappingURL=field-options.d.ts.map
@@ -0,0 +1,44 @@
1
+ // SingleSelect フィールドの選択肢を差し込む純粋な関数。I/O を持たない。
2
+ function indexOfName(options, name) {
3
+ const lowered = name.toLowerCase();
4
+ return options.findIndex(option => option.name.toLowerCase() === lowered);
5
+ }
6
+ // 既存の選択肢は id・name・color・description をそのまま写す(id を落とすと選択肢が作り直され、カードの値が消える)
7
+ function copyOption(option) {
8
+ return option.id === undefined ? { name: option.name, color: option.color, description: option.description } : { id: option.id, name: option.name, color: option.color, description: option.description };
9
+ }
10
+ /**
11
+ 差し込み先の候補のうち、基準の名前が既存にある最初のものを選ぶ。どれも無ければ末尾
12
+ */
13
+ export function choosePlacement(existing, candidates) {
14
+ const anchored = candidates.find((candidate) => {
15
+ if ('after' in candidate)
16
+ return indexOfName(existing, candidate.after) !== -1;
17
+ if ('before' in candidate)
18
+ return indexOfName(existing, candidate.before) !== -1;
19
+ return true;
20
+ });
21
+ return anchored ?? { end: true };
22
+ }
23
+ /**
24
+ 既存の選択肢の並びに、新しい選択肢を 1 つ差し込む。同じ名前(大文字と小文字は区別しない)が既にあれば undefined
25
+ */
26
+ export function insertOption(existing, option, placement) {
27
+ if (indexOfName(existing, option.name) !== -1)
28
+ return undefined;
29
+ const copied = existing.map(item => copyOption(item));
30
+ const created = { name: option.name, color: option.color, description: option.description };
31
+ let position = copied.length;
32
+ if ('after' in placement) {
33
+ const found = indexOfName(existing, placement.after);
34
+ if (found !== -1)
35
+ position = found + 1;
36
+ }
37
+ else if ('before' in placement) {
38
+ const found = indexOfName(existing, placement.before);
39
+ if (found !== -1)
40
+ position = found;
41
+ }
42
+ return [...copied.slice(0, position), created, ...copied.slice(position)];
43
+ }
44
+ //# sourceMappingURL=field-options.js.map
@@ -0,0 +1,94 @@
1
+ import type { JsonObject } from './json.js';
2
+ import type { JsonValue } from './python-format.js';
3
+ /**
4
+ transformItems の出力。formatBoardOutput は、欠けたキーを既定値で補って読む
5
+ */
6
+ export interface BoardItem {
7
+ readonly id?: JsonValue | undefined;
8
+ readonly workflow?: string | null | undefined;
9
+ readonly title?: JsonValue | undefined;
10
+ readonly updatedAt?: JsonValue | undefined;
11
+ readonly content: {
12
+ readonly number?: JsonValue | undefined;
13
+ readonly state?: JsonValue | undefined;
14
+ readonly url?: JsonValue | undefined;
15
+ readonly labels?: readonly string[] | undefined;
16
+ readonly repository?: string | undefined;
17
+ };
18
+ }
19
+ /**
20
+ 一覧の応答から読む、着手の判定の軽い入力。JSON の出力には出さない
21
+ */
22
+ export interface BoardProgress {
23
+ readonly issueType: string | undefined;
24
+ readonly subIssues: number;
25
+ /**
26
+ 親の Issue。無ければ undefined
27
+ */
28
+ readonly parent: {
29
+ readonly repository: string;
30
+ readonly number: number;
31
+ } | undefined;
32
+ /**
33
+ 前提の件数。応答に無ければ undefined
34
+ */
35
+ readonly blockedBy: number | undefined;
36
+ /**
37
+ Status の値(札)
38
+ */
39
+ readonly label: string | undefined;
40
+ }
41
+ /**
42
+ GraphQL の戻り値から Workflow ステータスを抽出する。
43
+ フィールド名は大文字小文字を区別しない。見つからなければ undefined。
44
+ 名前が一致したノードを最初に見つけた時点で、その値(無ければ undefined)を返す
45
+ */
46
+ export declare function extractWorkflowStatus(item: JsonObject, workflowFieldName: string): string | undefined;
47
+ /**
48
+ GraphQL の戻り値をフォーマット用の形式に変換する。
49
+ Draft Issue など content が無いアイテムは除く
50
+ */
51
+ export declare function transformItems(rawItems: readonly JsonObject[], workflowFieldName: string): readonly BoardItem[];
52
+ /**
53
+ 一覧の応答から、Issue ごとの着手の判定の入力を取る。キーは boardItemKey と同じ。Issue 以外と、番号の無いものは含めない
54
+ */
55
+ export declare function readBoardProgress(rawItems: readonly JsonObject[], labelFieldName: string): ReadonlyMap<string, BoardProgress>;
56
+ /**
57
+ 1 アイテムを Markdown 表の行 `| Ref | Title |` にする。extraCells は、Title の後ろに足すセル。
58
+ Ref は GitHub 慣習に倣い `owner/repo#N` で合成する。
59
+ リポジトリ情報または番号が欠落している場合は可能な範囲で埋め、両方欠落しているときは `-` を表示する
60
+ */
61
+ export declare function formatTableRow(item: BoardItem, extraCells?: readonly string[]): string;
62
+ /**
63
+ 判定の文の表(readiness 引数)を引くキー。`owner/repo#N` の小文字で、issueReferenceKey と同じ形になる。
64
+ リポジトリか番号が欠けたアイテムは undefined
65
+ */
66
+ export declare function boardItemKey(item: BoardItem): string | undefined;
67
+ /**
68
+ プロジェクトボードを Markdown 形式で出力する。件数が 0 のステータスは出さない。
69
+ Archived は 6 件以上あるとき、更新が新しい直近 5 件だけを出す。
70
+ readiness(boardItemKey → 判定の文)を渡したときだけ、Ready と Blocked の節に Readiness の列を足す。
71
+ 表に無いアイテムのセルは `-`
72
+ */
73
+ export declare function formatBoardOutput(items: readonly BoardItem[], readiness?: ReadonlyMap<string, string>): string;
74
+ export interface StackableChain {
75
+ /**
76
+ 並びの一番上の Issue の親(表示用の `#N`)。親が無ければ undefined
77
+ */
78
+ readonly epic: string | undefined;
79
+ /**
80
+ 下から並べた Issue(表示用の `#N`)
81
+ */
82
+ readonly chain: readonly string[];
83
+ }
84
+ /**
85
+ `## Stackable chains` の節を作る。1 行が 1 つの並びで、並びが無ければ undefined
86
+ */
87
+ export declare function formatStackableChains(chains: readonly StackableChain[]): string | undefined;
88
+ /**
89
+ アイテムリストを JSON 出力用の辞書にする
90
+ */
91
+ export declare function formatItemsJson(items: readonly BoardItem[]): {
92
+ readonly items: readonly BoardItem[];
93
+ };
94
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,234 @@
1
+ // 出力フォーマット関数。ボード表示や Issue 一覧の整形を担当する。
2
+ //
3
+ // 入力は GitHub の GraphQL 応答(JSON)をそのまま受ける。
4
+ // 入力の読み取りでは、キーが無いことと null を同じ「無い」として扱う。
5
+ // transformItems の出力では、無い値を JSON_NULL にする。Python の CLI の JSON と同じ null が出る。
6
+ import { JSON_NULL } from './json-null.js';
7
+ import { isJsonObject, jsonField } from './json.js';
8
+ import { isJsonArray, pythonRepr } from './python-format.js';
9
+ // ステータスマッピング(表示ラベル → マッチパターン)
10
+ const STATUS_PATTERNS = new Map([
11
+ ['Active', ['Active']],
12
+ ['In Review', ['In Review']],
13
+ ['Blocked', ['Blocked']],
14
+ ['Ready', ['Ready']],
15
+ ['Pending', ['Pending']],
16
+ ['Backlog', ['Backlog']],
17
+ ['Archived', ['Archived']],
18
+ ]);
19
+ // 表示順序
20
+ const STATUS_ORDER = ['Active', 'In Review', 'Blocked', 'Ready', 'Pending', 'Backlog', 'Archived'];
21
+ // Archived は直近これだけ表示する
22
+ const ARCHIVED_DISPLAY_LIMIT = 5;
23
+ // 辞書の値を取る(辞書でなければ undefined)。null は無いものとして扱う
24
+ function member(value, key) {
25
+ return jsonField(value, key) ?? undefined;
26
+ }
27
+ // `nodes` の配列を取る(無ければ空)
28
+ function nodesMember(value) {
29
+ const found = member(value, 'nodes');
30
+ return isJsonArray(found) ? found : [];
31
+ }
32
+ function stringMember(value, key) {
33
+ const found = member(value, key);
34
+ return typeof found === 'string' ? found : '';
35
+ }
36
+ // Python の真偽判定で偽になる値(null・false・0・空文字・空の配列・空の辞書)
37
+ function isEmptyValue(value) {
38
+ if (value === undefined || value === null || value === false || value === 0 || value === '')
39
+ return true;
40
+ if (Array.isArray(value))
41
+ return value.length === 0;
42
+ return isJsonObject(value) && Object.keys(value).length === 0;
43
+ }
44
+ /**
45
+ GraphQL の戻り値から Workflow ステータスを抽出する。
46
+ フィールド名は大文字小文字を区別しない。見つからなければ undefined。
47
+ 名前が一致したノードを最初に見つけた時点で、その値(無ければ undefined)を返す
48
+ */
49
+ export function extractWorkflowStatus(item, workflowFieldName) {
50
+ const nodes = nodesMember(member(item, 'fieldValues'));
51
+ for (const node of nodes) {
52
+ if (isEmptyValue(node))
53
+ continue;
54
+ if (stringMember(member(node, 'field'), 'name').toLowerCase() === workflowFieldName.toLowerCase()) {
55
+ const name = member(node, 'name');
56
+ return typeof name === 'string' ? name : undefined;
57
+ }
58
+ }
59
+ return undefined;
60
+ }
61
+ // ラベルを抽出する(名前があり、空でないものだけ)
62
+ function extractLabels(content) {
63
+ const labels = [];
64
+ const nodes = nodesMember(member(content, 'labels'));
65
+ for (const node of nodes) {
66
+ const name = isEmptyValue(node) ? undefined : member(node, 'name');
67
+ if (typeof name === 'string' && name !== '')
68
+ labels.push(name);
69
+ }
70
+ return labels;
71
+ }
72
+ // リポジトリ情報を `owner/name` にする(どちらかが欠ければ空文字)
73
+ function extractRepository(content) {
74
+ const repository = member(content, 'repository');
75
+ const owner = stringMember(member(repository, 'owner'), 'login');
76
+ const name = stringMember(repository, 'name');
77
+ return owner === '' || name === '' ? '' : `${owner}/${name}`;
78
+ }
79
+ // キーが無いとき空文字になる値を取る
80
+ function memberOrEmpty(value, key) {
81
+ return member(value, key) ?? '';
82
+ }
83
+ // 表に出す文字列(文字列はそのまま、他の値は Python の str と同じ書き方)
84
+ function displayText(value) {
85
+ return typeof value === 'string' ? value : pythonRepr(value);
86
+ }
87
+ /**
88
+ GraphQL の戻り値をフォーマット用の形式に変換する。
89
+ Draft Issue など content が無いアイテムは除く
90
+ */
91
+ export function transformItems(rawItems, workflowFieldName) {
92
+ const transformed = [];
93
+ for (const item of rawItems) {
94
+ const content = member(item, 'content');
95
+ if (isEmptyValue(content))
96
+ continue;
97
+ transformed.push({
98
+ id: memberOrEmpty(item, 'id'),
99
+ workflow: extractWorkflowStatus(item, workflowFieldName) ?? JSON_NULL,
100
+ title: memberOrEmpty(content, 'title'),
101
+ updatedAt: memberOrEmpty(item, 'updatedAt'),
102
+ content: {
103
+ number: member(content, 'number') ?? JSON_NULL,
104
+ state: member(content, 'state') ?? JSON_NULL,
105
+ url: member(content, 'url') ?? JSON_NULL,
106
+ labels: extractLabels(content),
107
+ repository: extractRepository(content),
108
+ },
109
+ });
110
+ }
111
+ return transformed;
112
+ }
113
+ function countMember(value, key) {
114
+ const found = member(member(value, key), 'totalCount');
115
+ return typeof found === 'number' ? found : undefined;
116
+ }
117
+ function parentOf(content) {
118
+ const parent = member(content, 'parent');
119
+ const repository = extractRepository(parent);
120
+ const number = member(parent, 'number');
121
+ return repository === '' || typeof number !== 'number' ? undefined : { repository, number };
122
+ }
123
+ /**
124
+ 一覧の応答から、Issue ごとの着手の判定の入力を取る。キーは boardItemKey と同じ。Issue 以外と、番号の無いものは含めない
125
+ */
126
+ export function readBoardProgress(rawItems, labelFieldName) {
127
+ const progress = new Map();
128
+ for (const item of rawItems) {
129
+ const content = member(item, 'content');
130
+ if (isEmptyValue(content) || member(content, 'blockedBy') === undefined)
131
+ continue;
132
+ const key = boardItemKey({ content: { number: member(content, 'number'), repository: extractRepository(content) } });
133
+ if (key === undefined)
134
+ continue;
135
+ const issueType = member(member(content, 'issueType'), 'name');
136
+ const blockedBy = member(member(content, 'blockedBy'), 'totalCount');
137
+ progress.set(key, {
138
+ issueType: typeof issueType === 'string' ? issueType : undefined,
139
+ subIssues: countMember(content, 'subIssues') ?? 0,
140
+ parent: parentOf(content),
141
+ blockedBy: typeof blockedBy === 'number' ? blockedBy : undefined,
142
+ label: extractWorkflowStatus(item, labelFieldName),
143
+ });
144
+ }
145
+ return progress;
146
+ }
147
+ /**
148
+ 1 アイテムを Markdown 表の行 `| Ref | Title |` にする。extraCells は、Title の後ろに足すセル。
149
+ Ref は GitHub 慣習に倣い `owner/repo#N` で合成する。
150
+ リポジトリ情報または番号が欠落している場合は可能な範囲で埋め、両方欠落しているときは `-` を表示する
151
+ */
152
+ export function formatTableRow(item, extraCells = []) {
153
+ const { number } = item.content;
154
+ const repository = item.content.repository ?? '';
155
+ const numberText = number === undefined || number === null ? '' : displayText(number);
156
+ let reference = '-';
157
+ if (repository !== '' && numberText !== '')
158
+ reference = `${repository}#${numberText}`;
159
+ else if (repository !== '')
160
+ reference = repository;
161
+ else if (numberText !== '')
162
+ reference = `#${numberText}`;
163
+ const { title } = item;
164
+ const titleText = title === undefined || isEmptyValue(title) ? '-' : displayText(title);
165
+ return `| ${[reference, titleText, ...extraCells].join(' | ')} |`;
166
+ }
167
+ function updatedAtOf(item) {
168
+ return typeof item.updatedAt === 'string' ? item.updatedAt : '';
169
+ }
170
+ // updatedAt の新しい順。同じ値は元の順序を保つ
171
+ function newestFirst(first, second) {
172
+ const [a, b] = [updatedAtOf(first), updatedAtOf(second)];
173
+ if (a === b)
174
+ return 0;
175
+ return a < b ? 1 : -1;
176
+ }
177
+ /**
178
+ 判定の文の表(readiness 引数)を引くキー。`owner/repo#N` の小文字で、issueReferenceKey と同じ形になる。
179
+ リポジトリか番号が欠けたアイテムは undefined
180
+ */
181
+ export function boardItemKey(item) {
182
+ const { number } = item.content;
183
+ const repository = item.content.repository ?? '';
184
+ return repository === '' || number === undefined || number === null ? undefined : `${repository}#${displayText(number)}`.toLowerCase();
185
+ }
186
+ // 判定の列を足す節(Ready・Blocked)
187
+ const READINESS_STATUSES = new Set(['Ready', 'Blocked']);
188
+ function readinessCell(item, readiness) {
189
+ const key = boardItemKey(item);
190
+ return (key === undefined ? undefined : readiness.get(key)) ?? '-';
191
+ }
192
+ /**
193
+ プロジェクトボードを Markdown 形式で出力する。件数が 0 のステータスは出さない。
194
+ Archived は 6 件以上あるとき、更新が新しい直近 5 件だけを出す。
195
+ readiness(boardItemKey → 判定の文)を渡したときだけ、Ready と Blocked の節に Readiness の列を足す。
196
+ 表に無いアイテムのセルは `-`
197
+ */
198
+ export function formatBoardOutput(items, readiness) {
199
+ const sections = [];
200
+ for (const status of STATUS_ORDER) {
201
+ const patterns = STATUS_PATTERNS.get(status) ?? [];
202
+ const statusItems = items.filter(item => typeof item.workflow === 'string' && patterns.includes(item.workflow));
203
+ const totalCount = statusItems.length;
204
+ if (totalCount === 0)
205
+ continue;
206
+ const isTruncated = status === 'Archived' && totalCount > ARCHIVED_DISPLAY_LIMIT;
207
+ const displayItems = isTruncated ? statusItems.toSorted(newestFirst).slice(0, ARCHIVED_DISPLAY_LIMIT) : statusItems;
208
+ const heading = isTruncated ? `### ${status} (latest ${String(ARCHIVED_DISPLAY_LIMIT)} of ${String(totalCount)})` : `### ${status} (${String(totalCount)})`;
209
+ if (readiness !== undefined && READINESS_STATUSES.has(status)) {
210
+ const rows = displayItems.map(item => formatTableRow(item, [readinessCell(item, readiness)]));
211
+ sections.push([heading, '| Ref | Title | Readiness |', '|-----|----------|-----------|', ...rows]);
212
+ }
213
+ else {
214
+ sections.push([heading, '| Ref | Title |', '|-----|----------|', ...displayItems.map(item => formatTableRow(item))]);
215
+ }
216
+ }
217
+ return sections.length === 0 ? '_No items_' : sections.map(section => section.join('\n')).join('\n\n');
218
+ }
219
+ /**
220
+ `## Stackable chains` の節を作る。1 行が 1 つの並びで、並びが無ければ undefined
221
+ */
222
+ export function formatStackableChains(chains) {
223
+ if (chains.length === 0)
224
+ return undefined;
225
+ const lines = chains.map(({ epic = '(no epic)', chain }) => `- ${epic}: ${chain.join(' -> ')}`);
226
+ return ['## Stackable chains', '', ...lines].join('\n');
227
+ }
228
+ /**
229
+ アイテムリストを JSON 出力用の辞書にする
230
+ */
231
+ export function formatItemsJson(items) {
232
+ return { items };
233
+ }
234
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,137 @@
1
+ import { z } from 'zod';
2
+ import { PecotError } from './errors.js';
3
+ /**
4
+ コマンドが契約の文を作る誤り。`parallel` は使えなくなった項目、`merge-without-reason` は理由の無い `wait: merge`
5
+ */
6
+ export type FrontmatterErrorKind = 'parallel' | 'merge-without-reason';
7
+ export declare class FrontmatterError extends PecotError {
8
+ readonly kind: FrontmatterErrorKind | undefined;
9
+ constructor(message: string, options?: Readonly<ErrorOptions & {
10
+ kind?: FrontmatterErrorKind;
11
+ }>);
12
+ }
13
+ declare const IssueFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
14
+ title: z.ZodString;
15
+ type: z.ZodEnum<{
16
+ bug: "bug";
17
+ epic: "epic";
18
+ task: "task";
19
+ tracker: "tracker";
20
+ }>;
21
+ template: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
22
+ bug: "bug";
23
+ epic: "epic";
24
+ task: "task";
25
+ "task-implement": "task-implement";
26
+ tracker: "tracker";
27
+ }>>>, z.ZodTransform<"bug" | "epic" | "task" | "task-implement" | "tracker" | undefined, "bug" | "epic" | "task" | "task-implement" | "tracker" | null | undefined>>, unknown>;
28
+ repository: z.ZodString;
29
+ status: z.ZodOptional<z.ZodEnum<{
30
+ active: "active";
31
+ archived: "archived";
32
+ backlog: "backlog";
33
+ blocked: "blocked";
34
+ in_review: "in_review";
35
+ pending: "pending";
36
+ ready: "ready";
37
+ }>>;
38
+ blocked_by: z.ZodPreprocess<z.ZodPrefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
39
+ issue: z.ZodPreprocess<z.ZodString, unknown>;
40
+ wait: z.ZodPrefault<z.ZodEnum<{
41
+ merge: "merge";
42
+ stack: "stack";
43
+ }>>;
44
+ reason: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>, unknown>;
45
+ }, z.core.$strip>>>>>, unknown>;
46
+ priority: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
47
+ high: "high";
48
+ low: "low";
49
+ medium: "medium";
50
+ }>>>, z.ZodTransform<"high" | "low" | "medium" | undefined, "high" | "low" | "medium" | null | undefined>>, unknown>;
51
+ size: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
52
+ l: "l";
53
+ m: "m";
54
+ s: "s";
55
+ xs: "xs";
56
+ }>>>, z.ZodTransform<"l" | "m" | "s" | "xs" | undefined, "l" | "m" | "s" | "xs" | null | undefined>>, unknown>;
57
+ labels: z.ZodPrefault<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
58
+ parent_epic: z.ZodPreprocess<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | number | undefined, unknown>>, unknown>;
59
+ order: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>, unknown>;
60
+ }, z.core.$strip>>;
61
+ declare const CommentFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
62
+ issue_ref: z.ZodString;
63
+ template: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
64
+ "merge-diff": "merge-diff";
65
+ plan: "plan";
66
+ "precede-notify": "precede-notify";
67
+ "review-findings": "review-findings";
68
+ "review-resolution": "review-resolution";
69
+ }>>>, z.ZodTransform<"merge-diff" | "plan" | "precede-notify" | "review-findings" | "review-resolution" | undefined, "merge-diff" | "plan" | "precede-notify" | "review-findings" | "review-resolution" | null | undefined>>;
70
+ comment_url: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
71
+ }, z.core.$strip>>;
72
+ declare const PullRequestFrontmatterSchema: z.ZodReadonly<z.ZodObject<{
73
+ title: z.ZodString;
74
+ repository: z.ZodString;
75
+ base: z.ZodString;
76
+ head: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
77
+ draft: z.ZodPrefault<z.ZodPreprocess<z.ZodBoolean, unknown>>;
78
+ screenshot: z.ZodPreprocess<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>, unknown>;
79
+ }, z.core.$strip>>;
80
+ export type IssueFrontmatter = z.infer<typeof IssueFrontmatterSchema>;
81
+ export type CommentFrontmatter = z.infer<typeof CommentFrontmatterSchema>;
82
+ export type PullRequestFrontmatter = z.infer<typeof PullRequestFrontmatterSchema>;
83
+ export interface ParsedIssue {
84
+ readonly frontmatter: IssueFrontmatter;
85
+ readonly body: string;
86
+ }
87
+ export interface ParsedComment {
88
+ readonly frontmatter: CommentFrontmatter;
89
+ readonly body: string;
90
+ }
91
+ export interface ParsedPullRequest {
92
+ readonly frontmatter: PullRequestFrontmatter;
93
+ readonly body: string;
94
+ }
95
+ /**
96
+ 値から Issue のフロントマターを作る。不正なら FrontmatterError
97
+ */
98
+ export declare function validateIssueFrontmatter(data: unknown): IssueFrontmatter;
99
+ /**
100
+ 値からコメントのフロントマターを作る。不正なら FrontmatterError
101
+ */
102
+ export declare function validateCommentFrontmatter(data: unknown): CommentFrontmatter;
103
+ /**
104
+ 値から PR のフロントマターを作る。不正なら FrontmatterError
105
+ */
106
+ export declare function validatePullRequestFrontmatter(data: unknown): PullRequestFrontmatter;
107
+ /**
108
+ 本文先頭の HTML コメントブロックを 1 つだけ除去する。
109
+ `--prepare` が配る雛形は、冒頭に書き方ガイドの HTML コメントを持つ。
110
+ 利用者が消し忘れたまま投稿しても GitHub 本文に残らないよう、パース時に取り除く(#958 F-02)。
111
+ 本文途中の `<details>` 等の HTML には触れない
112
+ */
113
+ export declare function stripLeadingHtmlComment(body: string): string;
114
+ /**
115
+ フロントマターを落とした本文を返す(不正・不在なら原文をそのまま返す)。
116
+ パース前の素朴な走査(プレースホルダ検証など)で本文だけを対象にするための寛容なヘルパで、検証はしない
117
+ */
118
+ export declare function stripFrontmatter(content: string): string;
119
+ /**
120
+ 文字列から Issue のフロントマターをパースする。不正なら FrontmatterError
121
+ */
122
+ export declare function parseFrontmatter(content: string): ParsedIssue;
123
+ /**
124
+ 文字列からコメントのフロントマターをパースする。不正なら FrontmatterError
125
+ */
126
+ export declare function parseCommentContent(content: string): ParsedComment;
127
+ /**
128
+ 文字列から PR のフロントマターをパースする。不正なら FrontmatterError
129
+ */
130
+ export declare function parsePullRequestContent(content: string): ParsedPullRequest;
131
+ /**
132
+ フロントマターに `key: "value"` の 1 行を足す。同じキーの行があれば置き換えるだけで、足さない。
133
+ フロントマターが無ければ FrontmatterError
134
+ */
135
+ export declare function setFrontmatterValue(content: string, key: string, value: string): string;
136
+ export {};
137
+ //# sourceMappingURL=frontmatter.d.ts.map