@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,83 @@
1
+ // ルートのグローバルオプションの解析。Python の CLI(click)が root で行っていた解析を写す。
2
+ //
3
+ // 解析はコマンド名の手前で止まる。コマンド名より後ろの引数は、そのコマンドの解析に渡す。
4
+ // ここでは値の検証はしない。--repo の形式と PECOT_GITHUB_API_URL は、呼び出す側が決まった順で検証する。
5
+ import { closeMatches } from './fuzzy.js';
6
+ import { COMMAND_SYNOPSIS, invalidValueMessage, noSuchOptionMessage, optionRequiresArgumentMessage, optionTakesNoValueMessage, UsageError, } from './usage-error.js';
7
+ /**
8
+ --repo の値が不正なときの文。detail は owner/repo の解析が投げた例外の文
9
+ */
10
+ export function invalidRepositoryMessage(detail) {
11
+ return invalidValueMessage('--repo', `must be in 'owner/repo' form: ${detail}`);
12
+ }
13
+ export const ROOT_USAGE = { commandPath: [], synopsis: COMMAND_SYNOPSIS };
14
+ /**
15
+ 未知のオプションの候補に使う名前。--install-completion と --show-completion は Python の CLI にあり、Node の CLI は実装しない
16
+ */
17
+ const LONG_OPTION_NAMES = ['--version', '--repo', '--show-repo', '--install-completion', '--show-completion', '--help'];
18
+ const LONG_FLAGS = new Map([
19
+ ['--version', 'version'],
20
+ ['--help', 'help'],
21
+ ['--show-repo', 'show-repo'],
22
+ ]);
23
+ /**
24
+ root の引数を解析する。誤りは UsageError にする。
25
+ --repo の値が欠けた誤りと値を取らないオプションに値を付けた誤りは、click と同じく Usage 行を付けない
26
+ */
27
+ export function parseGlobalOptions(argv) {
28
+ let eager;
29
+ let repository;
30
+ let isShowRepository = false;
31
+ let rest = [];
32
+ // next は、いま見ている引数の次の位置
33
+ let next = 0;
34
+ while (next < argv.length) {
35
+ const argument = argv.at(next) ?? '';
36
+ const current = next;
37
+ next += 1;
38
+ if (argument === '--') {
39
+ rest = argv.slice(next);
40
+ // click は、-- の後ろの先頭がオプションの形でコマンド名でもないとき、その引数をオプションとして解析し直す
41
+ if (rest.at(0)?.startsWith('-') === true) {
42
+ const again = parseGlobalOptions(rest);
43
+ return { eager: eager ?? again.eager, repo: again.repo ?? repository, showRepo: isShowRepository || again.showRepo, rest: again.rest };
44
+ }
45
+ break;
46
+ }
47
+ if (argument === '-' || !argument.startsWith('-')) {
48
+ rest = argv.slice(current);
49
+ break;
50
+ }
51
+ if (!argument.startsWith('--')) {
52
+ for (const letter of argument.slice(1)) {
53
+ if (letter !== 'v')
54
+ throw new UsageError(noSuchOptionMessage(`-${letter}`), ROOT_USAGE);
55
+ eager ??= 'version';
56
+ }
57
+ continue;
58
+ }
59
+ const separator = argument.indexOf('=');
60
+ const name = separator === -1 ? argument : argument.slice(0, separator);
61
+ const value = separator === -1 ? undefined : argument.slice(separator + 1);
62
+ if (name === '--repo') {
63
+ const taken = value ?? argv.at(next);
64
+ if (taken === undefined)
65
+ throw new UsageError(optionRequiresArgumentMessage(name));
66
+ repository = taken;
67
+ if (value === undefined)
68
+ next += 1;
69
+ continue;
70
+ }
71
+ const flag = LONG_FLAGS.get(name);
72
+ if (flag === undefined)
73
+ throw new UsageError(noSuchOptionMessage(name, closeMatches(name, LONG_OPTION_NAMES)), ROOT_USAGE);
74
+ if (value !== undefined)
75
+ throw new UsageError(optionTakesNoValueMessage(name));
76
+ if (flag === 'show-repo')
77
+ isShowRepository = true;
78
+ else
79
+ eager ??= flag;
80
+ }
81
+ return { eager, repo: repository, showRepo: isShowRepository, rest };
82
+ }
83
+ //# sourceMappingURL=global-options.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ 端末の幅から help を組む幅を返す。誤りの枠(rich-panel.ts の MIN_WIDTH)の下限は別
3
+ */
4
+ export declare function helpWidth(columns: number): number;
5
+ /**
6
+ 2 列の節の 1 行。name は打つ形、description は説明(空でもよい)
7
+ */
8
+ export interface DefinitionRow {
9
+ readonly name: string;
10
+ readonly description: string;
11
+ }
12
+ /**
13
+ 全部の help の Options に並ぶ --help の行
14
+ */
15
+ export declare const HELP_OPTION: DefinitionRow;
16
+ /**
17
+ 名前と説明の組を 2 列で並べる。名前の列は「字下げ 2 + 最長の名前 + 間 2」で取る。
18
+ 説明の幅が 32 桁を切るときは、節の全行で名前だけの行の次に、字下げ 6 の説明を置く。行ごとには切り替えない(列がそろわなくなる)
19
+ */
20
+ export declare function definitionSection(title: string, rows: readonly DefinitionRow[], width: number): string;
21
+ /**
22
+ `Usage: ` の後ろを折り返す。続きの行は 7 桁下げる
23
+ */
24
+ export declare function usageLines(text: string, width: number): string;
25
+ /**
26
+ 見出しの無い段落。幅で折り返す
27
+ */
28
+ export declare function paragraph(text: string, width: number): string;
29
+ /**
30
+ `- ` の箇条書きの節。続きの行は 4 桁下げる
31
+ */
32
+ export declare function bulletSection(title: string, items: readonly string[], width: number): string;
33
+ /**
34
+ 例の節。打つ形の行は、コピーして打てるように折り返さない。1 行の説明は字下げ 6 で折り返す
35
+ */
36
+ export declare function examplesSection(examples: readonly Readonly<{
37
+ run: string;
38
+ note: string;
39
+ }>[], width: number): string;
40
+ //# sourceMappingURL=help-layout.d.ts.map
@@ -0,0 +1,117 @@
1
+ // help の共通の書式。枠を使わず、「見出し + 字下げした 2 列」で並べる。
2
+ // どの関数も、行を改行でつないだ文字列を返す(末尾の改行は付けない)。
3
+ import { cellLength, padCells, wrapText as wrapCells } from './rich-panel.js';
4
+ /**
5
+ help の幅の下限。これより狭い端末でも、Usage と名前の列が崩れないように 40 桁で組む
6
+ */
7
+ const MIN_HELP_WIDTH = 40;
8
+ /**
9
+ 端末の幅から help を組む幅を返す。誤りの枠(rich-panel.ts の MIN_WIDTH)の下限は別
10
+ */
11
+ export function helpWidth(columns) {
12
+ return Math.max(MIN_HELP_WIDTH, columns);
13
+ }
14
+ /**
15
+ 全部の help の Options に並ぶ --help の行
16
+ */
17
+ export const HELP_OPTION = { name: '--help', description: 'Show this message and exit.' };
18
+ const INDENT = 2;
19
+ const COLUMN_GAP = 2;
20
+ const BULLET_CONTINUATION = 4;
21
+ const USAGE_CONTINUATION = 7;
22
+ const WRAPPED_DESCRIPTION_INDENT = 6;
23
+ /**
24
+ 説明の幅がこの桁を切るなら、節の全行で説明を次の行に下げる
25
+ */
26
+ const MIN_DESCRIPTION_WIDTH = 32;
27
+ /**
28
+ 幅より長い語を、`/` の後ろで折れる塊に分ける。塊は幅まで詰め、1 つの塊が幅を超えるものだけ、後段の wrapText が幅で折る
29
+ */
30
+ function chunksOfLongWord(word, width) {
31
+ const chunks = [];
32
+ for (const segment of word.split(/(?<=\/)/u)) {
33
+ const last = chunks.at(-1);
34
+ if (last !== undefined && cellLength(last) + cellLength(segment) <= width)
35
+ chunks[chunks.length - 1] = `${last}${segment}`;
36
+ else
37
+ chunks.push(segment);
38
+ }
39
+ return chunks;
40
+ }
41
+ /**
42
+ 行の中の、幅より長い語を `/` の後ろで折る。幅より長い語は必ず新しい行から始まる(wrapText と同じ)ので、その前に改行を入れ、塊ごとに行を分ける。後ろの語は最後の塊の行に続く。
43
+ `/` を持たない語は、そのまま後段の wrapText が幅で折る
44
+ */
45
+ function breakLongWords(line, width) {
46
+ const parts = line.split(/(\s+)/u);
47
+ return parts.map((part, index) => {
48
+ if (part.trim() === '' || cellLength(part) <= width || !part.includes('/'))
49
+ return part;
50
+ const hasTextBefore = parts.slice(0, index).join('').trim() !== '';
51
+ return `${hasTextBefore ? '\n' : ''}${chunksOfLongWord(part, width).join('\n')}`;
52
+ }).join('');
53
+ }
54
+ /**
55
+ 幅で折り返す。幅より長い語は `/` の後ろを折れる位置として扱い、それでも入らない塊だけを幅で折る。
56
+ wrapText は折り返した行に空白を残すことがあるので、行末の空白を落とす
57
+ */
58
+ function wrapText(text, width) {
59
+ return wrapCells(text.split('\n').map(line => breakLongWords(line, width)).join('\n'), width).map(line => line.trimEnd());
60
+ }
61
+ function indentOf(count) {
62
+ return ' '.repeat(count);
63
+ }
64
+ /**
65
+ 名前と説明の組を 2 列で並べる。名前の列は「字下げ 2 + 最長の名前 + 間 2」で取る。
66
+ 説明の幅が 32 桁を切るときは、節の全行で名前だけの行の次に、字下げ 6 の説明を置く。行ごとには切り替えない(列がそろわなくなる)
67
+ */
68
+ export function definitionSection(title, rows, width) {
69
+ const nameWidth = Math.max(0, ...rows.map(row => cellLength(row.name)));
70
+ const descriptionWidth = width - INDENT - nameWidth - COLUMN_GAP;
71
+ const isStacked = descriptionWidth < MIN_DESCRIPTION_WIDTH;
72
+ const lines = rows.flatMap(row => isStacked ? stackedLines(row, width) : columnLines(row, nameWidth, descriptionWidth));
73
+ return [`${title}:`, ...lines].join('\n');
74
+ }
75
+ function columnLines(row, nameWidth, descriptionWidth) {
76
+ const prefix = indentOf(INDENT);
77
+ const continuation = indentOf(INDENT + nameWidth + COLUMN_GAP);
78
+ return wrapText(row.description, descriptionWidth).map((line, index) => {
79
+ const head = index === 0 ? `${prefix}${padCells(row.name, nameWidth + COLUMN_GAP)}` : continuation;
80
+ return `${head}${line}`.trimEnd();
81
+ });
82
+ }
83
+ function stackedLines(row, width) {
84
+ const nameLines = wrapText(row.name, width - INDENT).map(line => `${indentOf(INDENT)}${line}`);
85
+ const descriptionLines = row.description === '' ? [] : wrapText(row.description, width - WRAPPED_DESCRIPTION_INDENT).map(line => `${indentOf(WRAPPED_DESCRIPTION_INDENT)}${line}`);
86
+ return [...nameLines, ...descriptionLines];
87
+ }
88
+ /**
89
+ `Usage: ` の後ろを折り返す。続きの行は 7 桁下げる
90
+ */
91
+ export function usageLines(text, width) {
92
+ return wrapText(text, width - USAGE_CONTINUATION).map((line, index) => index === 0 ? `Usage: ${line}` : `${indentOf(USAGE_CONTINUATION)}${line}`).join('\n');
93
+ }
94
+ /**
95
+ 見出しの無い段落。幅で折り返す
96
+ */
97
+ export function paragraph(text, width) {
98
+ return wrapText(text, width).join('\n');
99
+ }
100
+ /**
101
+ `- ` の箇条書きの節。続きの行は 4 桁下げる
102
+ */
103
+ export function bulletSection(title, items, width) {
104
+ const lines = items.flatMap(item => wrapText(item, width - BULLET_CONTINUATION).map((line, index) => (index === 0 ? `${indentOf(INDENT)}- ${line}` : `${indentOf(BULLET_CONTINUATION)}${line}`).trimEnd()));
105
+ return [`${title}:`, ...lines].join('\n');
106
+ }
107
+ /**
108
+ 例の節。打つ形の行は、コピーして打てるように折り返さない。1 行の説明は字下げ 6 で折り返す
109
+ */
110
+ export function examplesSection(examples, width) {
111
+ const lines = examples.flatMap(example => [
112
+ `${indentOf(INDENT)}${example.run}`.trimEnd(),
113
+ ...example.note === '' ? [] : wrapText(example.note, width - WRAPPED_DESCRIPTION_INDENT).map(line => `${indentOf(WRAPPED_DESCRIPTION_INDENT)}${line}`),
114
+ ]);
115
+ return ['Examples:', ...lines].join('\n');
116
+ }
117
+ //# sourceMappingURL=help-layout.js.map
@@ -0,0 +1,8 @@
1
+ import type { CommandDefinition } from './registry.js';
2
+ export declare const PROGRAM_DESCRIPTION = "pecot-workflow CLI - work tracking on GitHub Projects";
3
+ /**
4
+ path のグループ(空ならルート)の説明。Usage、説明、Options、Commands の順で、ルートだけ末尾に 1 行の案内が付く。
5
+ 末尾は改行で終わる。幅は 40 を下限にする。--help と引数なしの呼び出しは、どちらもこの文字列をそのまま出す
6
+ */
7
+ export declare function helpText(path: readonly string[], commands: readonly CommandDefinition[], columns?: number): string;
8
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1,50 @@
1
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- zod の型は readonly にできない */
2
+ // ルートとグループの説明。枠を使わず、コマンドごとの --help と同じ「見出し + 字下げした 2 列」の書式で出す(help-layout.ts)。
3
+ // 節は Usage、説明、Options、Commands の順。中身の無い節は出さない。
4
+ import { definitionSection, HELP_OPTION, helpWidth, paragraph, usageLines } from './help-layout.js';
5
+ import { COMMAND_GROUPS } from './names.js';
6
+ export const PROGRAM_DESCRIPTION = 'pecot-workflow CLI - work tracking on GitHub Projects';
7
+ function groupHelp(name) {
8
+ return COMMAND_GROUPS.find(group => group.name === name)?.help ?? '';
9
+ }
10
+ const ROOT_OPTIONS = [
11
+ { name: '-v, --version', description: 'Show the version' },
12
+ { name: '--repo <owner/repo>', description: 'Target repository, given explicitly as \'owner/repo\'' },
13
+ { name: '--show-repo', description: 'Show the resolved repository and where it came from, then exit' },
14
+ HELP_OPTION,
15
+ ];
16
+ const ROOT_FOOTER = 'Run \'pecot COMMAND --help\' for the arguments and options of a command.';
17
+ /**
18
+ path の直下のコマンドとグループを、コマンドを先にして登録順で並べる。
19
+ コマンドはどれも 2 語なので、ルートにはグループだけ、グループの下にはコマンドだけが並ぶ
20
+ */
21
+ function entriesOf(path, commands) {
22
+ const level = path.length;
23
+ const direct = commands.filter(command => command.path.length === level + 1 && path.every((segment, index) => command.path.at(index) === segment));
24
+ const groups = commands
25
+ .filter(command => command.path.length > level + 1 && path.every((segment, index) => command.path.at(index) === segment))
26
+ .map(command => command.path.slice(level, level + 1).join(''));
27
+ return [
28
+ ...direct.map(command => ({ name: command.path.slice(level, level + 1).join(''), description: command.description })),
29
+ ...[...new Set(groups)].map(name => ({ name, description: groupHelp(name) })),
30
+ ];
31
+ }
32
+ /**
33
+ path のグループ(空ならルート)の説明。Usage、説明、Options、Commands の順で、ルートだけ末尾に 1 行の案内が付く。
34
+ 末尾は改行で終わる。幅は 40 を下限にする。--help と引数なしの呼び出しは、どちらもこの文字列をそのまま出す
35
+ */
36
+ export function helpText(path, commands, columns = 80) {
37
+ const width = helpWidth(columns);
38
+ const isRoot = path.length === 0;
39
+ const description = isRoot ? PROGRAM_DESCRIPTION : groupHelp(path.slice(0, 1).join(''));
40
+ const entries = entriesOf(path, commands);
41
+ const sections = [
42
+ usageLines(['pecot', ...path, '[OPTIONS] COMMAND [ARGS]...'].join(' '), width),
43
+ ...description === '' ? [] : [paragraph(description, width)],
44
+ definitionSection('Options', isRoot ? ROOT_OPTIONS : [HELP_OPTION], width),
45
+ ...entries.length === 0 ? [] : [definitionSection('Commands', entries, width)],
46
+ ...isRoot ? [paragraph(ROOT_FOOTER, width)] : [],
47
+ ];
48
+ return `${sections.join('\n\n')}\n`;
49
+ }
50
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1,14 @@
1
+ export type JsonObject = Readonly<Record<string, unknown>>;
2
+ export interface InputSchema {
3
+ readonly type: 'object';
4
+ readonly properties: Readonly<Record<string, JsonObject>>;
5
+ readonly required: readonly string[];
6
+ readonly additionalProperties: false;
7
+ }
8
+ export declare function isRecord(value: unknown): value is JsonObject;
9
+ /**
10
+ グローバルの repo を除いて、input を正規化する。repo は defineCommand が足したもので、コマンド自身の引数ではない。
11
+ 自分の `--repo` を持つコマンド(hasOwnRepo)の repo は、コマンド自身の引数なので残す
12
+ */
13
+ export declare function normalizeInput(schema: JsonObject, command: string, isRepositoryKept: boolean): InputSchema;
14
+ //# sourceMappingURL=input-schema.d.ts.map
@@ -0,0 +1,56 @@
1
+ // コマンドの入力(zod)から JSON Schema を作り、定義書(generated.json)と同じ形にそろえる。
2
+ // 定義書の書き出し(scripts/export-interface.ts)と、コマンドごとの --help が同じ関数を通す。
3
+ import { byName } from './names.js';
4
+ /**
5
+ 引数の中のキーの順。ここに無いキーは後ろに、名前の順で付ける
6
+ */
7
+ const SCHEMA_KEY_ORDER = ['type', 'items', 'enum', 'minimum', 'maximum', 'default', 'description'];
8
+ /**
9
+ z.int() が付ける安全な整数の端
10
+ */
11
+ const SAFE_INTEGER_EDGES = new Set([Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER]);
12
+ /**
13
+ contracts の表に載せる type
14
+ */
15
+ const TYPES = new Set(['string', 'integer', 'boolean', 'array']);
16
+ export function isRecord(value) {
17
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
18
+ }
19
+ function keyRank(key) {
20
+ const index = SCHEMA_KEY_ORDER.indexOf(key);
21
+ return index === -1 ? SCHEMA_KEY_ORDER.length : index;
22
+ }
23
+ /**
24
+ 引数 1 つの JSON Schema を、キーの順をそろえ、z.int() の端を外した形にする。
25
+ 表に無いキーと type は、where を付けて例外で止める
26
+ */
27
+ function normalizeProperty(schema, where) {
28
+ const entries = Object.entries(schema)
29
+ .filter(([key, value]) => !(typeof value === 'number' && (key === 'minimum' || key === 'maximum') && SAFE_INTEGER_EDGES.has(value)))
30
+ .map(([key, value]) => {
31
+ if (!SCHEMA_KEY_ORDER.includes(key))
32
+ throw new TypeError(`${where}: unsupported JSON Schema key ${key}`);
33
+ if (key === 'type' && !(typeof value === 'string' && TYPES.has(value)))
34
+ throw new TypeError(`${where}: unsupported type ${JSON.stringify(value)}`);
35
+ return [key, key === 'items' && isRecord(value) ? normalizeProperty(value, where) : value];
36
+ })
37
+ .toSorted(([left], [right]) => keyRank(left) - keyRank(right));
38
+ return Object.fromEntries(entries);
39
+ }
40
+ /**
41
+ グローバルの repo を除いて、input を正規化する。repo は defineCommand が足したもので、コマンド自身の引数ではない。
42
+ 自分の `--repo` を持つコマンド(hasOwnRepo)の repo は、コマンド自身の引数なので残す
43
+ */
44
+ export function normalizeInput(schema, command, isRepositoryKept) {
45
+ const { properties, required } = schema;
46
+ const isKept = (name) => isRepositoryKept || name !== 'repo';
47
+ const own = (isRecord(properties) ? Object.entries(properties) : []).filter(([name]) => isKept(name));
48
+ const names = (Array.isArray(required) ? required.filter((name) => typeof name === 'string') : []).filter(name => isKept(name));
49
+ return {
50
+ type: 'object',
51
+ properties: Object.fromEntries(own.toSorted(([left], [right]) => byName(left, right)).map(([name, property]) => [name, normalizeProperty(isRecord(property) ? property : {}, `${command}: ${name}`)])),
52
+ required: names.toSorted(byName),
53
+ additionalProperties: false,
54
+ };
55
+ }
56
+ //# sourceMappingURL=input-schema.js.map
@@ -0,0 +1,71 @@
1
+ import type { BoardMove, MissingValue, MovableColumn } from '../domain/board-move.js';
2
+ import type { ProjectConfig } from '../domain/config.js';
3
+ import type { IssueReference } from '../domain/reference-parser.js';
4
+ import type { RepositoryReference } from '../domain/repository-resolver.js';
5
+ import type { JsonObject } from '../domain/json.js';
6
+ import type { GitHubClient } from '../infra/github/index.js';
7
+ import type { Output } from './output.js';
8
+ export interface BoardItem {
9
+ readonly itemId: string;
10
+ readonly issueNodeId: string;
11
+ }
12
+ /**
13
+ Issue を作って API の応答を返す。作成に失敗したら GitHubAPIError
14
+ */
15
+ export declare function createIssue(client: GitHubClient, owner: string, repository: string, title: string, body: string, labels: readonly string[] | undefined): Promise<JsonObject>;
16
+ /**
17
+ Issue をボードへ追加し、項目 ID と Issue の node id を返す。
18
+ 追加済みの Issue には既存の項目 ID が返る(何度呼んでも同じ結果になる)。node id の取得かボードへの追加に失敗したら GitHubAPIError
19
+ */
20
+ export declare function addIssueToBoard(client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, issueNodeId: string | undefined): Promise<BoardItem>;
21
+ /**
22
+ 設定の workflow に、その status のオプションがあるか
23
+ */
24
+ export declare function isStatusConfigured(config: ProjectConfig, status: string): boolean;
25
+ /**
26
+ カスタムフィールドを 1 つ設定する。設定したら true。
27
+ 設定に無いフィールド・オプションは何もせず false。更新に失敗したら GitHubAPIError
28
+ */
29
+ export declare function setIssueField(client: GitHubClient, config: ProjectConfig, itemId: string, fieldName: string, optionName: string): Promise<boolean>;
30
+ /**
31
+ ボード項目にそのフィールドの値が入っているか。
32
+ 設定にないフィールドは入っているとみなす(設定できないので、空として扱わない)。取得に失敗したら GitHubAPIError
33
+ */
34
+ export declare function itemHasFieldValue(client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, itemId: string, fieldName: string): Promise<boolean>;
35
+ export interface PutOnBoardOptions {
36
+ /**
37
+ 真なら、ボード項目のそのフィールドが空のときだけ入れる。人が動かした Status や Priority を戻さない
38
+ */
39
+ readonly onlyIfEmpty: boolean;
40
+ }
41
+ /**
42
+ ボードへの追加と、Status(Backlog)・Priority の設定(何度やっても同じ結果になる)。
43
+ 途中で失敗して空のままの項目は、次の onlyIfEmpty の実行で直る。失敗したら GitHubAPIError
44
+ */
45
+ export declare function putOnBoard(client: GitHubClient, config: ProjectConfig, owner: string, repository: string, issueNumber: number, priority: string | undefined, options: Readonly<PutOnBoardOptions>): Promise<void>;
46
+ export interface AppliedMove {
47
+ /**
48
+ 実際に動いた先の列。動かなかったら undefined
49
+ */
50
+ readonly column: MovableColumn | undefined;
51
+ readonly missing: readonly MissingValue[];
52
+ /**
53
+ 書き込みに失敗した。列だけ書けて札で失敗したときも真
54
+ */
55
+ readonly hasFailed: boolean;
56
+ }
57
+ interface MoveTarget {
58
+ readonly ref: IssueReference;
59
+ readonly home: RepositoryReference | undefined;
60
+ }
61
+ /**
62
+ decideBoardMove の結果をボードに書く。書き込みの失敗は warning にして続ける(元の列のまま)。
63
+ text は列を動かす理由の判定の文。board sync と issue block / unblock が使う
64
+ */
65
+ export declare function applyBoardMove(out: Readonly<Output>, client: GitHubClient, config: ProjectConfig, itemId: string, target: MoveTarget, move: Readonly<BoardMove>, text: string): Promise<AppliedMove>;
66
+ /**
67
+ applyBoardMove と同じ文を、書かずに予定の行として出す(--dry-run)
68
+ */
69
+ export declare function planBoardMove(out: Readonly<Output>, target: MoveTarget, move: Readonly<BoardMove>, text: string): void;
70
+ export {};
71
+ //# sourceMappingURL=issue-board.d.ts.map
@@ -0,0 +1,122 @@
1
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
2
+ // Issue の作成・ボードへの追加・フィールドの設定と、判定に応じた列と札の書き込み(applyBoardMove)。cli/core/issue_board.py の移植に applyBoardMove を足した。
3
+ // 失敗は GitHubAPIError で呼び出し側に返す。表示と終了コードは呼び出し側が決める。
4
+ import { COLUMN_CONFIG_KEYS, LABEL_CONFIG_KEYS } from '../domain/board-move.js';
5
+ import { getFieldId, getOptionId } from '../domain/config.js';
6
+ import { displayReference } from '../domain/readiness.js';
7
+ import { GitHubAPIError } from '../infra/github/errors.js';
8
+ // 作ったボード項目の Status(Tracker はここから始める)
9
+ const BOARD_STATUS = 'backlog';
10
+ /**
11
+ Issue を作って API の応答を返す。作成に失敗したら GitHubAPIError
12
+ */
13
+ export async function createIssue(client, owner, repository, title, body, labels) {
14
+ return await client.createIssue(owner, repository, title, body, labels);
15
+ }
16
+ /**
17
+ Issue をボードへ追加し、項目 ID と Issue の node id を返す。
18
+ 追加済みの Issue には既存の項目 ID が返る(何度呼んでも同じ結果になる)。node id の取得かボードへの追加に失敗したら GitHubAPIError
19
+ */
20
+ export async function addIssueToBoard(client, config, owner, repository, issueNumber, issueNodeId) {
21
+ const nodeId = issueNodeId === undefined || issueNodeId === '' ? await client.getIssueNodeId(owner, repository, issueNumber) : issueNodeId;
22
+ const itemId = await client.addToProject(config.project.id, nodeId);
23
+ return { itemId, issueNodeId: nodeId };
24
+ }
25
+ /**
26
+ 設定の workflow に、その status のオプションがあるか
27
+ */
28
+ export function isStatusConfigured(config, status) {
29
+ const fieldId = getFieldId(config, 'workflow');
30
+ const optionId = getOptionId(config, 'workflow', status);
31
+ return fieldId !== undefined && fieldId !== '' && optionId !== undefined && optionId !== '';
32
+ }
33
+ /**
34
+ カスタムフィールドを 1 つ設定する。設定したら true。
35
+ 設定に無いフィールド・オプションは何もせず false。更新に失敗したら GitHubAPIError
36
+ */
37
+ // eslint-disable-next-line unicorn/consistent-boolean-name -- Python の set_issue_field と名前をそろえる
38
+ export async function setIssueField(client, config, itemId, fieldName, optionName) {
39
+ const fieldId = getFieldId(config, fieldName);
40
+ const optionId = getOptionId(config, fieldName, optionName);
41
+ if (fieldId === undefined || fieldId === '' || optionId === undefined || optionId === '')
42
+ return false;
43
+ await client.updateProjectItemField(config.project.id, itemId, fieldId, optionId);
44
+ return true;
45
+ }
46
+ /**
47
+ ボード項目にそのフィールドの値が入っているか。
48
+ 設定にないフィールドは入っているとみなす(設定できないので、空として扱わない)。取得に失敗したら GitHubAPIError
49
+ */
50
+ // eslint-disable-next-line unicorn/consistent-boolean-name -- Python の item_has_field_value と名前をそろえる
51
+ export async function itemHasFieldValue(client, config, owner, repository, issueNumber, itemId, fieldName) {
52
+ const fieldId = getFieldId(config, fieldName);
53
+ if (fieldId === undefined || fieldId === '')
54
+ return true;
55
+ const filledFieldIds = await client.getItemSetFieldIds(config.project.id, owner, repository, issueNumber, itemId);
56
+ return filledFieldIds.has(fieldId);
57
+ }
58
+ /**
59
+ ボードへの追加と、Status(Backlog)・Priority の設定(何度やっても同じ結果になる)。
60
+ 途中で失敗して空のままの項目は、次の onlyIfEmpty の実行で直る。失敗したら GitHubAPIError
61
+ */
62
+ export async function putOnBoard(client, config, owner, repository, issueNumber, priority, options) {
63
+ const { itemId } = await addIssueToBoard(client, config, owner, repository, issueNumber, undefined);
64
+ const fields = [['workflow', BOARD_STATUS]];
65
+ if (priority !== undefined)
66
+ fields.push(['priority', priority]);
67
+ for (const [fieldName, option] of fields) {
68
+ if (options.onlyIfEmpty && await itemHasFieldValue(client, config, owner, repository, issueNumber, itemId, fieldName))
69
+ continue;
70
+ await setIssueField(client, config, itemId, fieldName, option);
71
+ }
72
+ }
73
+ function moveOperation(name, column, text) {
74
+ return { verb: 'move', target: `${name} ${column.from} -> ${column.to} (${text})` };
75
+ }
76
+ function labelOperation(name, label) {
77
+ return { verb: 'set', target: `Status of ${name} to ${label}` };
78
+ }
79
+ function warnConflict(out, name, target, conflict) {
80
+ const blockers = conflict.issues.map(issue => displayReference(issue, target.home));
81
+ out.warning(`${name} is in ${conflict.column} but blocked${blockers.length > 0 ? ` by ${blockers.join(', ')}` : ''}`);
82
+ }
83
+ /**
84
+ decideBoardMove の結果をボードに書く。書き込みの失敗は warning にして続ける(元の列のまま)。
85
+ text は列を動かす理由の判定の文。board sync と issue block / unblock が使う
86
+ */
87
+ export async function applyBoardMove(out, client, config, itemId, target, move, text) {
88
+ const name = displayReference(target.ref, target.home);
89
+ if (move.conflict !== undefined)
90
+ warnConflict(out, name, target, move.conflict);
91
+ let moved;
92
+ let hasFailed = false;
93
+ try {
94
+ if (move.column !== undefined && await setIssueField(client, config, itemId, 'workflow', COLUMN_CONFIG_KEYS[move.column.to])) {
95
+ moved = move.column.to;
96
+ out.done(moveOperation(name, move.column, text));
97
+ }
98
+ if (move.label !== undefined && await setIssueField(client, config, itemId, 'status', LABEL_CONFIG_KEYS[move.label])) {
99
+ out.done(labelOperation(name, move.label));
100
+ }
101
+ }
102
+ catch (error) {
103
+ if (!(error instanceof GitHubAPIError))
104
+ throw error;
105
+ out.warning(`could not move ${name}: ${error.message}`);
106
+ hasFailed = true;
107
+ }
108
+ return { column: moved, missing: move.missing, hasFailed };
109
+ }
110
+ /**
111
+ applyBoardMove と同じ文を、書かずに予定の行として出す(--dry-run)
112
+ */
113
+ export function planBoardMove(out, target, move, text) {
114
+ const name = displayReference(target.ref, target.home);
115
+ if (move.conflict !== undefined)
116
+ warnConflict(out, name, target, move.conflict);
117
+ if (move.column !== undefined)
118
+ out.planned(moveOperation(name, move.column, text));
119
+ if (move.label !== undefined)
120
+ out.planned(labelOperation(name, move.label));
121
+ }
122
+ //# sourceMappingURL=issue-board.js.map
@@ -0,0 +1,3 @@
1
+ import type { CommandDefinition } from './command-definition.js';
2
+ export declare const ISSUE_COMMENT_COMMANDS: readonly CommandDefinition[];
3
+ //# sourceMappingURL=issue-comment.d.ts.map