@pecot/workflow-mcp 0.0.0-stage → 5.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 (244) hide show
  1. package/.claude-plugin/plugin.json +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +126 -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 +222 -0
  7. package/cli/dist/commands/cell-table.d.ts +3 -0
  8. package/cli/dist/commands/cell-table.js +495 -0
  9. package/cli/dist/commands/command-binding.d.ts +26 -0
  10. package/cli/dist/commands/command-binding.js +266 -0
  11. package/cli/dist/commands/command-definition.d.ts +136 -0
  12. package/cli/dist/commands/command-definition.js +101 -0
  13. package/cli/dist/commands/command-help.d.ts +8 -0
  14. package/cli/dist/commands/command-help.js +173 -0
  15. package/cli/dist/commands/command-stop.d.ts +19 -0
  16. package/cli/dist/commands/command-stop.js +30 -0
  17. package/cli/dist/commands/dependabot.d.ts +3 -0
  18. package/cli/dist/commands/dependabot.js +165 -0
  19. package/cli/dist/commands/directory-option.d.ts +7 -0
  20. package/cli/dist/commands/directory-option.js +48 -0
  21. package/cli/dist/commands/failure.d.ts +13 -0
  22. package/cli/dist/commands/failure.js +33 -0
  23. package/cli/dist/commands/fuzzy.d.ts +7 -0
  24. package/cli/dist/commands/fuzzy.js +79 -0
  25. package/cli/dist/commands/github-client.d.ts +12 -0
  26. package/cli/dist/commands/github-client.js +23 -0
  27. package/cli/dist/commands/global-options.d.ts +25 -0
  28. package/cli/dist/commands/global-options.js +83 -0
  29. package/cli/dist/commands/help-layout.d.ts +40 -0
  30. package/cli/dist/commands/help-layout.js +117 -0
  31. package/cli/dist/commands/help.d.ts +8 -0
  32. package/cli/dist/commands/help.js +55 -0
  33. package/cli/dist/commands/input-schema.d.ts +14 -0
  34. package/cli/dist/commands/input-schema.js +56 -0
  35. package/cli/dist/commands/issue-board.d.ts +38 -0
  36. package/cli/dist/commands/issue-board.js +62 -0
  37. package/cli/dist/commands/issue-comment.d.ts +3 -0
  38. package/cli/dist/commands/issue-comment.js +196 -0
  39. package/cli/dist/commands/issue-create.d.ts +3 -0
  40. package/cli/dist/commands/issue-create.js +329 -0
  41. package/cli/dist/commands/issue-project.d.ts +3 -0
  42. package/cli/dist/commands/issue-project.js +176 -0
  43. package/cli/dist/commands/issue-quick.d.ts +3 -0
  44. package/cli/dist/commands/issue-quick.js +126 -0
  45. package/cli/dist/commands/issue-read.d.ts +3 -0
  46. package/cli/dist/commands/issue-read.js +80 -0
  47. package/cli/dist/commands/issue-shared.d.ts +159 -0
  48. package/cli/dist/commands/issue-shared.js +419 -0
  49. package/cli/dist/commands/issue.d.ts +4 -0
  50. package/cli/dist/commands/issue.js +15 -0
  51. package/cli/dist/commands/names.d.ts +9 -0
  52. package/cli/dist/commands/names.js +16 -0
  53. package/cli/dist/commands/output.d.ts +78 -0
  54. package/cli/dist/commands/output.js +187 -0
  55. package/cli/dist/commands/pr.d.ts +3 -0
  56. package/cli/dist/commands/pr.js +933 -0
  57. package/cli/dist/commands/project-info.d.ts +48 -0
  58. package/cli/dist/commands/project-info.js +181 -0
  59. package/cli/dist/commands/project-sync.d.ts +91 -0
  60. package/cli/dist/commands/project-sync.js +273 -0
  61. package/cli/dist/commands/project.d.ts +5 -0
  62. package/cli/dist/commands/project.js +677 -0
  63. package/cli/dist/commands/registry.d.ts +6 -0
  64. package/cli/dist/commands/registry.js +27 -0
  65. package/cli/dist/commands/release.d.ts +10 -0
  66. package/cli/dist/commands/release.js +414 -0
  67. package/cli/dist/commands/repository-display.d.ts +3 -0
  68. package/cli/dist/commands/repository-display.js +7 -0
  69. package/cli/dist/commands/repository-match.d.ts +14 -0
  70. package/cli/dist/commands/repository-match.js +33 -0
  71. package/cli/dist/commands/repository.d.ts +5 -0
  72. package/cli/dist/commands/repository.js +265 -0
  73. package/cli/dist/commands/rich-panel.d.ts +22 -0
  74. package/cli/dist/commands/rich-panel.js +295 -0
  75. package/cli/dist/commands/security.d.ts +3 -0
  76. package/cli/dist/commands/security.js +164 -0
  77. package/cli/dist/commands/session.d.ts +3 -0
  78. package/cli/dist/commands/session.js +161 -0
  79. package/cli/dist/commands/tracker-sync.d.ts +58 -0
  80. package/cli/dist/commands/tracker-sync.js +53 -0
  81. package/cli/dist/commands/usage-error.d.ts +47 -0
  82. package/cli/dist/commands/usage-error.js +72 -0
  83. package/cli/dist/commands/value-types.d.ts +46 -0
  84. package/cli/dist/commands/value-types.js +94 -0
  85. package/cli/dist/commands/work-target.d.ts +13 -0
  86. package/cli/dist/commands/work-target.js +41 -0
  87. package/cli/dist/commands/worktree.d.ts +3 -0
  88. package/cli/dist/commands/worktree.js +335 -0
  89. package/cli/dist/domain/api-error-detail.d.ts +10 -0
  90. package/cli/dist/domain/api-error-detail.js +25 -0
  91. package/cli/dist/domain/branch-name.d.ts +5 -0
  92. package/cli/dist/domain/branch-name.js +10 -0
  93. package/cli/dist/domain/changelog.d.ts +43 -0
  94. package/cli/dist/domain/changelog.js +107 -0
  95. package/cli/dist/domain/config.d.ts +215 -0
  96. package/cli/dist/domain/config.js +300 -0
  97. package/cli/dist/domain/dependabot-pull-requests.d.ts +82 -0
  98. package/cli/dist/domain/dependabot-pull-requests.js +338 -0
  99. package/cli/dist/domain/dependabot-source.d.ts +51 -0
  100. package/cli/dist/domain/dependabot-source.js +4 -0
  101. package/cli/dist/domain/dependabot.d.ts +47 -0
  102. package/cli/dist/domain/dependabot.js +88 -0
  103. package/cli/dist/domain/errors.d.ts +19 -0
  104. package/cli/dist/domain/errors.js +31 -0
  105. package/cli/dist/domain/field-options.d.ts +31 -0
  106. package/cli/dist/domain/field-options.js +44 -0
  107. package/cli/dist/domain/format.d.ts +47 -0
  108. package/cli/dist/domain/format.js +168 -0
  109. package/cli/dist/domain/frontmatter.d.ts +122 -0
  110. package/cli/dist/domain/frontmatter.js +264 -0
  111. package/cli/dist/domain/git-runner.d.ts +10 -0
  112. package/cli/dist/domain/git-runner.js +4 -0
  113. package/cli/dist/domain/git-url.d.ts +17 -0
  114. package/cli/dist/domain/git-url.js +30 -0
  115. package/cli/dist/domain/issue-kind.d.ts +16 -0
  116. package/cli/dist/domain/issue-kind.js +16 -0
  117. package/cli/dist/domain/issue-readout.d.ts +107 -0
  118. package/cli/dist/domain/issue-readout.js +4 -0
  119. package/cli/dist/domain/json-null.d.ts +2 -0
  120. package/cli/dist/domain/json-null.js +5 -0
  121. package/cli/dist/domain/json.d.ts +21 -0
  122. package/cli/dist/domain/json.js +47 -0
  123. package/cli/dist/domain/prerequisites.d.ts +32 -0
  124. package/cli/dist/domain/prerequisites.js +192 -0
  125. package/cli/dist/domain/pull-request.d.ts +134 -0
  126. package/cli/dist/domain/pull-request.js +232 -0
  127. package/cli/dist/domain/python-format.d.ts +105 -0
  128. package/cli/dist/domain/python-format.js +304 -0
  129. package/cli/dist/domain/readiness.d.ts +172 -0
  130. package/cli/dist/domain/readiness.js +280 -0
  131. package/cli/dist/domain/reference-parser.d.ts +49 -0
  132. package/cli/dist/domain/reference-parser.js +119 -0
  133. package/cli/dist/domain/release.d.ts +49 -0
  134. package/cli/dist/domain/release.js +72 -0
  135. package/cli/dist/domain/repository-policy.d.ts +32 -0
  136. package/cli/dist/domain/repository-policy.js +65 -0
  137. package/cli/dist/domain/repository-resolver.d.ts +57 -0
  138. package/cli/dist/domain/repository-resolver.js +119 -0
  139. package/cli/dist/domain/sections.d.ts +69 -0
  140. package/cli/dist/domain/sections.js +514 -0
  141. package/cli/dist/domain/security-alerts-source.d.ts +29 -0
  142. package/cli/dist/domain/security-alerts-source.js +4 -0
  143. package/cli/dist/domain/security-alerts.d.ts +52 -0
  144. package/cli/dist/domain/security-alerts.js +107 -0
  145. package/cli/dist/domain/security-tracker.d.ts +115 -0
  146. package/cli/dist/domain/security-tracker.js +353 -0
  147. package/cli/dist/domain/state.d.ts +29 -0
  148. package/cli/dist/domain/state.js +56 -0
  149. package/cli/dist/domain/tracker-body.d.ts +70 -0
  150. package/cli/dist/domain/tracker-body.js +65 -0
  151. package/cli/dist/domain/yaml-document.d.ts +5 -0
  152. package/cli/dist/domain/yaml-document.js +206 -0
  153. package/cli/dist/infra/authored-notes.d.ts +37 -0
  154. package/cli/dist/infra/authored-notes.js +66 -0
  155. package/cli/dist/infra/changelog-file.d.ts +19 -0
  156. package/cli/dist/infra/changelog-file.js +43 -0
  157. package/cli/dist/infra/child-stdin.d.ts +4 -0
  158. package/cli/dist/infra/child-stdin.js +8 -0
  159. package/cli/dist/infra/config-store.d.ts +49 -0
  160. package/cli/dist/infra/config-store.js +121 -0
  161. package/cli/dist/infra/diagnostics.d.ts +9 -0
  162. package/cli/dist/infra/diagnostics.js +2 -0
  163. package/cli/dist/infra/file-kind.d.ts +9 -0
  164. package/cli/dist/infra/file-kind.js +26 -0
  165. package/cli/dist/infra/frontmatter-file.d.ts +14 -0
  166. package/cli/dist/infra/frontmatter-file.js +30 -0
  167. package/cli/dist/infra/git.d.ts +74 -0
  168. package/cli/dist/infra/git.js +133 -0
  169. package/cli/dist/infra/github/auth.d.ts +60 -0
  170. package/cli/dist/infra/github/auth.js +158 -0
  171. package/cli/dist/infra/github/client.d.ts +173 -0
  172. package/cli/dist/infra/github/client.js +576 -0
  173. package/cli/dist/infra/github/dependabot-source.d.ts +13 -0
  174. package/cli/dist/infra/github/dependabot-source.js +33 -0
  175. package/cli/dist/infra/github/errors.d.ts +47 -0
  176. package/cli/dist/infra/github/errors.js +42 -0
  177. package/cli/dist/infra/github/index.d.ts +13 -0
  178. package/cli/dist/infra/github/index.js +19 -0
  179. package/cli/dist/infra/github/issues.d.ts +129 -0
  180. package/cli/dist/infra/github/issues.js +273 -0
  181. package/cli/dist/infra/github/payload.d.ts +44 -0
  182. package/cli/dist/infra/github/payload.js +80 -0
  183. package/cli/dist/infra/github/projects.d.ts +108 -0
  184. package/cli/dist/infra/github/projects.js +303 -0
  185. package/cli/dist/infra/github/pulls.d.ts +80 -0
  186. package/cli/dist/infra/github/pulls.js +161 -0
  187. package/cli/dist/infra/github/queries.d.ts +36 -0
  188. package/cli/dist/infra/github/queries.js +883 -0
  189. package/cli/dist/infra/github/readout.d.ts +18 -0
  190. package/cli/dist/infra/github/readout.js +156 -0
  191. package/cli/dist/infra/github/repos.d.ts +68 -0
  192. package/cli/dist/infra/github/repos.js +137 -0
  193. package/cli/dist/infra/github/rest-path.d.ts +14 -0
  194. package/cli/dist/infra/github/rest-path.js +31 -0
  195. package/cli/dist/infra/github/security-alerts-source.d.ts +15 -0
  196. package/cli/dist/infra/github/security-alerts-source.js +73 -0
  197. package/cli/dist/infra/gitignore-spec.d.ts +36 -0
  198. package/cli/dist/infra/gitignore-spec.js +235 -0
  199. package/cli/dist/infra/nx-scope.d.ts +51 -0
  200. package/cli/dist/infra/nx-scope.js +182 -0
  201. package/cli/dist/infra/os-error.d.ts +24 -0
  202. package/cli/dist/infra/os-error.js +38 -0
  203. package/cli/dist/infra/paths.d.ts +88 -0
  204. package/cli/dist/infra/paths.js +234 -0
  205. package/cli/dist/infra/state-store.d.ts +45 -0
  206. package/cli/dist/infra/state-store.js +118 -0
  207. package/cli/dist/infra/template-store.d.ts +15 -0
  208. package/cli/dist/infra/template-store.js +34 -0
  209. package/cli/dist/infra/text-file.d.ts +12 -0
  210. package/cli/dist/infra/text-file.js +33 -0
  211. package/cli/dist/infra/worktree-copy.d.ts +24 -0
  212. package/cli/dist/infra/worktree-copy.js +95 -0
  213. package/cli/dist/infra/worktree-links.d.ts +139 -0
  214. package/cli/dist/infra/worktree-links.js +433 -0
  215. package/cli/dist/infra/worktree-setup.d.ts +21 -0
  216. package/cli/dist/infra/worktree-setup.js +41 -0
  217. package/cli/dist/infra/worktree.d.ts +174 -0
  218. package/cli/dist/infra/worktree.js +567 -0
  219. package/cli/dist/mcp/result.d.ts +33 -0
  220. package/cli/dist/mcp/result.js +52 -0
  221. package/cli/dist/mcp/serve.d.ts +51 -0
  222. package/cli/dist/mcp/serve.js +183 -0
  223. package/cli/dist/mcp/server.d.ts +21 -0
  224. package/cli/dist/mcp/server.js +128 -0
  225. package/cli/dist/mcp/session-directory.d.ts +26 -0
  226. package/cli/dist/mcp/session-directory.js +84 -0
  227. package/cli/dist/package.json +1 -0
  228. package/cli/dist/version.d.ts +17 -0
  229. package/cli/dist/version.js +42 -0
  230. package/cli/templates/comment/merge-diff.md +34 -0
  231. package/cli/templates/comment/plan.md +181 -0
  232. package/cli/templates/comment/precede-notify.md +33 -0
  233. package/cli/templates/comment/review-findings.md +42 -0
  234. package/cli/templates/comment/review-resolution.md +48 -0
  235. package/cli/templates/issue/bug.md +63 -0
  236. package/cli/templates/issue/epic.md +54 -0
  237. package/cli/templates/issue/task-implement.md +67 -0
  238. package/cli/templates/issue/task.md +48 -0
  239. package/cli/templates/issue/tracker.md +48 -0
  240. package/cli/templates/pr/create.md +123 -0
  241. package/cli/templates/pr/release.md +56 -0
  242. package/hooks/lib/core/pecot-gitignore-ensure.sh +48 -0
  243. package/npm-shrinkwrap.json +83 -0
  244. package/package.json +22 -4
@@ -0,0 +1,280 @@
1
+ // Issue の着手の可否の判定と、フェーズの進め方(specs/024 の data-model.md の 2〜4)。I/O を持たない純関数だけを置く。
2
+ import { isEpicIssue } from './issue-kind.js';
3
+ import { issueReferenceKey } from './reference-parser.js';
4
+ import { isSameRepository } from './repository-resolver.js';
5
+ export const PENDING_COLUMN = 'Pending';
6
+ export const NEEDS_ATTENTION_LABEL = 'Needs Attention';
7
+ export const TRACKER_TITLE_PREFIX = '[Tracker]';
8
+ function openPullRequests(issue) {
9
+ return issue.pullRequests.filter(pullRequest => pullRequest.state === 'open');
10
+ }
11
+ export function isDone(issue) {
12
+ return issue.state === 'closed' && issue.pullRequests.some(pullRequest => pullRequest.state === 'merged');
13
+ }
14
+ /**
15
+ open で、open の PR がちょうど 1 本あり、fork からでない。ドラフトも含む
16
+ */
17
+ export function isInReview(issue) {
18
+ const open = openPullRequests(issue);
19
+ return issue.state === 'open' && open.length === 1 && open[0]?.isCrossRepository === false;
20
+ }
21
+ export function hasStarted(issue) {
22
+ return issue.branches.length > 0 || issue.pullRequests.length > 0;
23
+ }
24
+ function isPending(issue) {
25
+ return issue.column === PENDING_COLUMN;
26
+ }
27
+ // 列が Pending の前提は、人が後回しにしたものなので、PR があっても積む先にしない
28
+ function isStackable(issue) {
29
+ return isInReview(issue) && !isPending(issue);
30
+ }
31
+ function isStackBase(pullRequest) {
32
+ return pullRequest.state === 'open' && !pullRequest.isCrossRepository;
33
+ }
34
+ function notInReviewState(issue) {
35
+ if (isPending(issue))
36
+ return 'pending';
37
+ const open = openPullRequests(issue);
38
+ if (open.length > 1)
39
+ return 'multiple-prs';
40
+ if (open.length === 1)
41
+ return 'fork-pr';
42
+ return hasStarted(issue) ? 'started-without-pr' : 'not-started';
43
+ }
44
+ // 開発ブランチに届かない(途切れる・輪になる)列は undefined
45
+ function headsToDevelopment(start, byHead, developmentBranch) {
46
+ const reached = new Set([start.headRefName]);
47
+ let current = start;
48
+ while (current.baseRefName !== developmentBranch) {
49
+ const next = byHead.get(current.baseRefName);
50
+ if (next === undefined || reached.has(next.headRefName))
51
+ return undefined;
52
+ reached.add(next.headRefName);
53
+ current = next;
54
+ }
55
+ return reached;
56
+ }
57
+ // 済んでいない前提はすべて PR 中なので、open の PR がちょうど 1 本ある
58
+ function findStackTarget(unfinished, input) {
59
+ const entries = unfinished.flatMap(({ issue }) => {
60
+ const [pullRequest] = openPullRequests(issue);
61
+ return pullRequest === undefined ? [] : { issue: issue.ref, pullRequest };
62
+ });
63
+ const byHead = new Map([...input.pullRequestsByHead].filter(([, pullRequest]) => isStackBase(pullRequest)));
64
+ for (const { pullRequest } of entries)
65
+ byHead.set(pullRequest.headRefName, pullRequest);
66
+ for (const start of entries) {
67
+ const reached = headsToDevelopment(start.pullRequest, byHead, input.developmentBranch);
68
+ if (reached !== undefined && entries.every(other => reached.has(other.pullRequest.headRefName))) {
69
+ return { branch: start.pullRequest.headRefName, issue: start.issue };
70
+ }
71
+ }
72
+ return undefined;
73
+ }
74
+ function result(kind, fields) {
75
+ return { kind, stackOn: fields.stackOn, reason: fields.reason, needsReview: fields.needsReview, attention: fields.attention };
76
+ }
77
+ /**
78
+ data-model.md の 3 の表を上から当てはめる。Epic と Tracker には判定を出さず undefined を返す
79
+ */
80
+ export function judgeReadiness(input) {
81
+ const { target, prerequisites, cycle } = input;
82
+ if (target.kind !== 'task')
83
+ return undefined;
84
+ if (prerequisites === 'read-failed') {
85
+ return result('blocked', { reason: { code: 'unreadable' }, needsReview: false, attention: [] });
86
+ }
87
+ const unfinished = prerequisites.filter(({ issue }) => !isDone(issue));
88
+ const closedUnmerged = unfinished.filter(({ issue }) => issue.state === 'closed');
89
+ const isNeedsReview = closedUnmerged.length > 0;
90
+ const attention = unfinished.filter(({ issue }) => issue.label === NEEDS_ATTENTION_LABEL).map(({ issue }) => issue.ref);
91
+ const blocked = (reason) => result('blocked', { reason, needsReview: isNeedsReview, attention });
92
+ if (cycle !== undefined)
93
+ return blocked({ code: 'cycle', cycle });
94
+ if (isNeedsReview)
95
+ return blocked({ code: 'closed-unmerged', issues: closedUnmerged.map(({ issue }) => issue.ref) });
96
+ const waitsMerge = unfinished.filter(({ wait }) => wait === 'merge');
97
+ if (waitsMerge.length > 0) {
98
+ return blocked({ code: 'waits-merge', issues: waitsMerge.map(({ issue, reason }) => ({ issue: issue.ref, reason })) });
99
+ }
100
+ if (unfinished.length === 0)
101
+ return result('startable', { needsReview: isNeedsReview, attention });
102
+ const otherRepository = unfinished.filter(({ issue }) => !isSameRepository(issue.ref.repository, target.ref.repository));
103
+ if (otherRepository.length > 0)
104
+ return blocked({ code: 'other-repository', issues: otherRepository.map(({ issue }) => issue.ref) });
105
+ const notInReview = unfinished.filter(({ issue }) => !isStackable(issue));
106
+ if (notInReview.length > 0) {
107
+ return blocked({ code: 'not-in-review', issues: notInReview.map(({ issue }) => ({ issue: issue.ref, state: notInReviewState(issue) })) });
108
+ }
109
+ const stackOn = findStackTarget(unfinished, input);
110
+ return stackOn === undefined
111
+ ? blocked({ code: 'diverged', issues: unfinished.map(({ issue }) => issue.ref) })
112
+ : result('stackable', { stackOn, needsReview: isNeedsReview, attention });
113
+ }
114
+ // localeCompare は環境で順が変わるので、コード単位の順にする
115
+ function compareKeys(left, right) {
116
+ if (left < right)
117
+ return -1;
118
+ return left > right ? 1 : 0;
119
+ }
120
+ /**
121
+ キーから前提のキーへの辺の表から、輪を 1 つ返す。始点を末尾にも置き、始点は輪のキーの最小にする。
122
+ キーと辺をソートして探すので、入力の順に依らない。自分自身への辺は長さ 1 の輪になる
123
+ */
124
+ export function findCycle(edges) {
125
+ const states = new Map();
126
+ const path = [];
127
+ const visit = (key) => {
128
+ states.set(key, 'visiting');
129
+ path.push(key);
130
+ const neighbors = (edges.get(key) ?? []).toSorted(compareKeys);
131
+ for (const next of neighbors) {
132
+ const state = states.get(next);
133
+ if (state === 'visiting') {
134
+ const loop = path.slice(path.indexOf(next));
135
+ const smallest = loop.indexOf(loop.toSorted(compareKeys).at(0) ?? next);
136
+ return [...loop.slice(smallest), ...loop.slice(0, smallest), loop.at(smallest) ?? next];
137
+ }
138
+ const found = state === undefined ? visit(next) : undefined;
139
+ if (found !== undefined)
140
+ return found;
141
+ }
142
+ path.pop();
143
+ states.set(key, 'done');
144
+ return undefined;
145
+ };
146
+ const roots = [...edges].map(([key]) => key).toSorted(compareKeys);
147
+ for (const key of roots) {
148
+ const found = states.has(key) ? undefined : visit(key);
149
+ if (found !== undefined)
150
+ return found;
151
+ }
152
+ return undefined;
153
+ }
154
+ function reachableThrough(start, stackEdges) {
155
+ const reached = new Set();
156
+ const pending = [start];
157
+ for (let key = pending.pop(); key !== undefined; key = pending.pop()) {
158
+ const nextKeys = stackEdges.get(key) ?? [];
159
+ for (const next of nextKeys) {
160
+ if (reached.has(next))
161
+ continue;
162
+ reached.add(next);
163
+ pending.push(next);
164
+ }
165
+ }
166
+ return reached;
167
+ }
168
+ /**
169
+ フェーズごとの進め方を、Issue の状態を見ずに前提の形と種類だけで決める。輪があれば進め方を出さず輪を返す
170
+ */
171
+ export function planProgression(phases) {
172
+ const cycle = findCycle(new Map(phases.map(phase => [phase.key, phase.prerequisites.map(({ key }) => key)])));
173
+ if (cycle !== undefined)
174
+ return { kind: 'cycle', cycle };
175
+ const stackEdges = new Map(phases.map(phase => [phase.key, phase.prerequisites.filter(({ wait }) => wait === 'stack').map(({ key }) => key)]));
176
+ const progressions = new Map();
177
+ for (const phase of phases) {
178
+ const keys = phase.prerequisites.map(({ key }) => key);
179
+ if (keys.length === 0) {
180
+ progressions.set(phase.key, { kind: 'alone' });
181
+ }
182
+ else if (phase.prerequisites.some(({ wait }) => wait === 'merge')) {
183
+ progressions.set(phase.key, { kind: 'wait-merge' });
184
+ }
185
+ else {
186
+ const top = keys.find((key) => {
187
+ const reached = reachableThrough(key, stackEdges);
188
+ return keys.every(other => other === key || reached.has(other));
189
+ });
190
+ progressions.set(phase.key, top === undefined ? { kind: 'join' } : { kind: 'stack', on: top });
191
+ }
192
+ }
193
+ return { kind: 'planned', progressions };
194
+ }
195
+ /**
196
+ stack の積む先をたどった木の、根から葉までの道を、下から並べて返す。stack の無い根は道を作らないので、1 段だけの道は出ない
197
+ */
198
+ export function stackChains(progressions) {
199
+ const children = new Map();
200
+ for (const [key, progression] of progressions) {
201
+ if (progression.kind === 'stack')
202
+ children.set(progression.on, [...children.get(progression.on) ?? [], key]);
203
+ }
204
+ const roots = [...children].map(([key]) => key).filter(key => progressions.get(key)?.kind !== 'stack');
205
+ const walk = (key, path) => {
206
+ const next = (children.get(key) ?? []).filter(child => !path.includes(child));
207
+ return next.length === 0 ? [path] : next.flatMap(child => walk(child, [...path, child]));
208
+ };
209
+ return roots.flatMap(root => walk(root, [root]));
210
+ }
211
+ const LOWER_STATE = { OPEN: 'open', MERGED: 'merged', CLOSED: 'closed' };
212
+ function toPullRequest(readout) {
213
+ return {
214
+ repository: readout.repository,
215
+ number: readout.number,
216
+ state: LOWER_STATE[readout.state],
217
+ headRefName: readout.headRefName,
218
+ baseRefName: readout.baseRefName,
219
+ isDraft: readout.isDraft,
220
+ isCrossRepository: readout.isCrossRepository,
221
+ };
222
+ }
223
+ // 3 つの読み口で同じ PR を 1 本に数える。fork からの PR は、リンクしたブランチの読み口だけ捨てる
224
+ function collectPullRequests(readout) {
225
+ const sources = [
226
+ ...readout.linkedBranches.flatMap(branch => branch.pullRequests).filter(pullRequest => !pullRequest.isCrossRepository),
227
+ ...readout.closingPullRequests,
228
+ ...readout.timelinePullRequests,
229
+ ];
230
+ const seen = new Set();
231
+ return sources
232
+ .filter((source) => {
233
+ const key = issueReferenceKey({ repository: source.repository, number: source.number });
234
+ if (seen.has(key))
235
+ return false;
236
+ seen.add(key);
237
+ return true;
238
+ })
239
+ .map(source => toPullRequest(source));
240
+ }
241
+ function workKind(readout) {
242
+ if (isEpicIssue({ issue_type: readout.issueType, sub_issues_total: readout.subIssuesTotal }))
243
+ return 'epic';
244
+ return readout.title.startsWith(TRACKER_TITLE_PREFIX) ? 'tracker' : 'task';
245
+ }
246
+ function toFacts(readout, options) {
247
+ const valueOf = (fieldName) => readout.projectFieldValues.find(value => value.fieldName === fieldName)?.optionName;
248
+ return {
249
+ ref: { repository: readout.repository, number: readout.number },
250
+ state: LOWER_STATE[readout.state],
251
+ column: valueOf(options.columnFieldName),
252
+ label: valueOf(options.labelFieldName),
253
+ kind: workKind(readout),
254
+ branches: readout.linkedBranches.map(branch => branch.name),
255
+ pullRequests: collectPullRequests(readout),
256
+ };
257
+ }
258
+ /**
259
+ infra の読み取り結果を、判定の入力(Issue の実態)にまとめる。
260
+ 本文の節が malformed なら前提をすべて merge にし、節にあって blocked by に無い組は mismatches に返す
261
+ */
262
+ export function toIssueFacts(readout, section, options) {
263
+ const target = toFacts(readout.issue, options);
264
+ if (readout.blockedBy.kind === 'read-failed')
265
+ return { target, prerequisites: 'read-failed', mismatches: [] };
266
+ const lines = section.kind === 'ok' ? section.lines : [];
267
+ const reasons = new Map(lines.map(line => [issueReferenceKey(line.ref), line.reason]));
268
+ const prerequisites = readout.blockedBy.issues.map((blocker) => {
269
+ const issue = toFacts(blocker, options);
270
+ const reason = reasons.get(issueReferenceKey(issue.ref));
271
+ const wait = reason !== undefined || section.kind === 'malformed' ? 'merge' : 'stack';
272
+ return { issue, wait, reason };
273
+ });
274
+ const present = new Set(prerequisites.map(({ issue }) => issueReferenceKey(issue.ref)));
275
+ const mismatches = lines
276
+ .filter(line => !present.has(issueReferenceKey(line.ref)))
277
+ .map(line => ({ ref: line.ref, reason: line.reason }));
278
+ return { target, prerequisites, mismatches };
279
+ }
280
+ //# sourceMappingURL=readiness.js.map
@@ -0,0 +1,49 @@
1
+ import { PecotError } from './errors.js';
2
+ import type { RepositoryReference } from './repository-resolver.js';
3
+ /**
4
+ 参照のパースエラー。CLI 層で引数の誤りに変換する。元の入力を持つ
5
+ */
6
+ export declare class ReferenceParseError extends PecotError {
7
+ readonly reference: string;
8
+ constructor(message: string, reference: string, options?: Readonly<ErrorOptions>);
9
+ }
10
+ export interface IssueReference {
11
+ readonly repository: RepositoryReference;
12
+ readonly number: number;
13
+ }
14
+ /**
15
+ 番号が正の整数であることを検証して作る。Issue と PR は番号空間を共有する
16
+ */
17
+ export declare function createIssueReference(repository: RepositoryReference, number: number): IssueReference;
18
+ export declare function issueReferenceToString(reference: IssueReference): string;
19
+ /**
20
+ リポ名の大文字小文字を区別しない、Issue / PR の同一判定用のキー
21
+ */
22
+ export declare function issueReferenceKey(reference: IssueReference): string;
23
+ export declare function issueReferenceToCliReference(reference: IssueReference): string;
24
+ /**
25
+ Issue 参照を IssueReference にする。
26
+ `owner/repo/N` は主軸形式。`N` は短縮形で、baseRepository が要る。
27
+ 形式が不正・短縮形で基準リポが無いときは ReferenceParseError。
28
+ repositoryFlag は --repo で短縮形を解決するコマンドか。true のときだけ error で --repo を案内する
29
+ */
30
+ export declare function parseIssueReference(raw: string, baseRepository?: RepositoryReference, { repositoryFlag }?: {
31
+ readonly repositoryFlag?: boolean;
32
+ }): IssueReference;
33
+ /**
34
+ PR 参照を IssueReference にする。Issue と番号空間を共有するので parseIssueReference に委ねる
35
+ */
36
+ export declare function parsePullRequestReference(raw: string, baseRepository?: RepositoryReference, options?: {
37
+ readonly repositoryFlag?: boolean;
38
+ }): IssueReference;
39
+ /**
40
+ `owner/repo` 形式の文字列を RepositoryReference にする。不正なら ReferenceParseError
41
+ */
42
+ export declare function parseRepositoryReference(raw: string): RepositoryReference;
43
+ /**
44
+ PR 本文の Refs で参照された Issue 番号を集める。
45
+ 受理形式は `Refs #N`・`Refs owner/repo#N`・`Refs owner/repo/N`(`Ref` も可、コロンは任意、大文字小文字は区別しない)。
46
+ owner/repo 付きの参照は、repository と一致(大文字小文字を区別しない)するものだけ採る
47
+ */
48
+ export declare function extractReferencesIssueNumbers(body: string | undefined, repository: RepositoryReference): ReadonlySet<number>;
49
+ //# sourceMappingURL=reference-parser.d.ts.map
@@ -0,0 +1,119 @@
1
+ // Issue / PR 参照のパーサー。
2
+ //
3
+ // `owner/repo/N` 形式を IssueReference にする。短縮形 `N` は基準リポ(baseRepository)で補う。
4
+ // 参照の形式が不正なときの文は、Python の CLI が出していた文に揃える。
5
+ import { PecotError, InvalidValueError } from './errors.js';
6
+ import { parsePythonInteger, ValidationFailure } from './python-format.js';
7
+ import { createRepositoryReference, parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
8
+ /**
9
+ 参照のパースエラー。CLI 層で引数の誤りに変換する。元の入力を持つ
10
+ */
11
+ export class ReferenceParseError extends PecotError {
12
+ reference;
13
+ constructor(message, reference, options) {
14
+ super(message, options);
15
+ this.reference = reference;
16
+ }
17
+ }
18
+ /**
19
+ 番号が正の整数であることを検証して作る。Issue と PR は番号空間を共有する
20
+ */
21
+ export function createIssueReference(repository, number) {
22
+ if (number <= 0) {
23
+ throw new ValidationFailure('IssueRef', [{ type: 'greater_than', location: ['number'], message: 'Input should be greater than 0', input: number }]);
24
+ }
25
+ return Object.freeze({ repository, number });
26
+ }
27
+ export function issueReferenceToString(reference) {
28
+ return `${repositoryFullName(reference.repository)}#${String(reference.number)}`;
29
+ }
30
+ /**
31
+ リポ名の大文字小文字を区別しない、Issue / PR の同一判定用のキー
32
+ */
33
+ export function issueReferenceKey(reference) {
34
+ return issueReferenceToString(reference).toLowerCase();
35
+ }
36
+ export function issueReferenceToCliReference(reference) {
37
+ return `${repositoryFullName(reference.repository)}/${String(reference.number)}`;
38
+ }
39
+ // Python の `$` は末尾の改行の手前にも一致する。`\d` は Unicode の 10 進数字に一致する
40
+ const FULL_REFERENCE_PATTERN = /^([^/]+)\/([^/]+)\/(\p{Nd}+)\n?$/u;
41
+ function integerOf(digits) {
42
+ const value = parsePythonInteger(digits);
43
+ if (value === undefined)
44
+ throw new InvalidValueError(`invalid literal for int() with base 10: ${digits}`);
45
+ return value;
46
+ }
47
+ function invalidFormat(raw) {
48
+ return new ReferenceParseError(`invalid reference: ${raw}\naccepted forms:\n - full: 'owner/repo/N'\n - short: 'N' (with a base repository)`, raw);
49
+ }
50
+ /**
51
+ Issue 参照を IssueReference にする。
52
+ `owner/repo/N` は主軸形式。`N` は短縮形で、baseRepository が要る。
53
+ 形式が不正・短縮形で基準リポが無いときは ReferenceParseError。
54
+ repositoryFlag は --repo で短縮形を解決するコマンドか。true のときだけ error で --repo を案内する
55
+ */
56
+ export function parseIssueReference(raw, baseRepository, { repositoryFlag = false } = {}) {
57
+ if (/^\d+$/u.test(raw)) {
58
+ if (baseRepository === undefined) {
59
+ throw new ReferenceParseError(repositoryFlag
60
+ ? 'the short form \'N\' needs a base_repo: pass --repo <owner/repo> or use the full form \'owner/repo/N\''
61
+ : 'the short form \'N\' is not accepted here: use the full form \'owner/repo/N\'', raw);
62
+ }
63
+ return createIssueReference(baseRepository, integerOf(raw));
64
+ }
65
+ const [, owner, repository, digits] = FULL_REFERENCE_PATTERN.exec(raw) ?? [];
66
+ if (owner === undefined || repository === undefined || digits === undefined)
67
+ throw invalidFormat(raw);
68
+ try {
69
+ return createIssueReference(createRepositoryReference(owner, repository), integerOf(digits));
70
+ }
71
+ catch (error) {
72
+ if (error instanceof InvalidValueError)
73
+ throw new ReferenceParseError(error.message, raw, { cause: error });
74
+ throw error;
75
+ }
76
+ }
77
+ /**
78
+ PR 参照を IssueReference にする。Issue と番号空間を共有するので parseIssueReference に委ねる
79
+ */
80
+ export function parsePullRequestReference(raw, baseRepository, options = {}) {
81
+ return parseIssueReference(raw, baseRepository, options);
82
+ }
83
+ /**
84
+ `owner/repo` 形式の文字列を RepositoryReference にする。不正なら ReferenceParseError
85
+ */
86
+ export function parseRepositoryReference(raw) {
87
+ try {
88
+ return parseOwnerRepository(raw);
89
+ }
90
+ catch (error) {
91
+ if (error instanceof InvalidValueError)
92
+ throw new ReferenceParseError(error.message, raw, { cause: error });
93
+ throw error;
94
+ }
95
+ }
96
+ const REFS_PATTERN = /(?:^|\s)Refs?:?\s+(?:#(?<number>\p{Nd}+)|(?<owner>[\w.-]+)\/(?<repository>[\w.-]+)[#/](?<qualifiedNumber>\p{Nd}+))/gimu;
97
+ /**
98
+ PR 本文の Refs で参照された Issue 番号を集める。
99
+ 受理形式は `Refs #N`・`Refs owner/repo#N`・`Refs owner/repo/N`(`Ref` も可、コロンは任意、大文字小文字は区別しない)。
100
+ owner/repo 付きの参照は、repository と一致(大文字小文字を区別しない)するものだけ採る
101
+ */
102
+ export function extractReferencesIssueNumbers(body, repository) {
103
+ const numbers = new Set();
104
+ if (body === undefined || body === '')
105
+ return numbers;
106
+ const ownerKey = repository.owner.toLowerCase();
107
+ const repositoryKey = repository.repository.toLowerCase();
108
+ for (const match of body.matchAll(REFS_PATTERN)) {
109
+ const { number, owner, repository: matchedRepository, qualifiedNumber } = match.groups ?? {};
110
+ if (number !== undefined) {
111
+ numbers.add(integerOf(number));
112
+ }
113
+ else if (qualifiedNumber !== undefined && owner?.toLowerCase() === ownerKey && matchedRepository?.toLowerCase() === repositoryKey) {
114
+ numbers.add(integerOf(qualifiedNumber));
115
+ }
116
+ }
117
+ return numbers;
118
+ }
119
+ //# sourceMappingURL=reference-parser.js.map
@@ -0,0 +1,49 @@
1
+ import { PecotError } from './errors.js';
2
+ import type { GitRunner } from './git-runner.js';
3
+ export declare class ReleaseError extends PecotError {
4
+ }
5
+ export interface PreflightResult {
6
+ readonly version: string;
7
+ readonly releaseNotes: string;
8
+ readonly developBranch: string;
9
+ readonly releaseBranch: string;
10
+ /**
11
+ release→develop の差分コミット数
12
+ */
13
+ readonly diffCount: number;
14
+ /**
15
+ 作成予定のタグ名(`v0.6.1` または `pecot-workflow-v0.6.1`)
16
+ */
17
+ readonly tagName: string;
18
+ }
19
+ export interface PreflightOptions {
20
+ /**
21
+ エラー文に出す CHANGELOG.md のパス
22
+ */
23
+ readonly changelogPath: string;
24
+ /**
25
+ CHANGELOG.md の内容。ファイルが無ければ undefined
26
+ */
27
+ readonly changelogContent: string | undefined;
28
+ readonly developBranch: string;
29
+ readonly releaseBranch: string;
30
+ /**
31
+ リリースバージョン。省略すると CHANGELOG から検出する
32
+ */
33
+ readonly version: string | undefined;
34
+ /**
35
+ タグの prefix(monorepo 用)。空でなければ `<prefix>-v<ver>`、省略か空なら `v<ver>`
36
+ */
37
+ readonly tagPrefix: string | undefined;
38
+ /**
39
+ ls-remote・fetch・差分確認に使う remote 名。省略すると origin
40
+ */
41
+ readonly remote?: string | undefined;
42
+ }
43
+ /**
44
+ リリース前チェックを実行する。
45
+ 1. CHANGELOG.md の存在、2. バージョンの検出または検証、3. タグが無いこと(ローカル・リモート)、
46
+ 4. release→develop の差分、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
47
+ */
48
+ export declare function runPreflight(options: PreflightOptions, git: GitRunner): PreflightResult;
49
+ //# sourceMappingURL=release.d.ts.map
@@ -0,0 +1,72 @@
1
+ // リリース前チェック(preflight)。git は GitRunner を受けて呼ぶ。CHANGELOG は内容(文字列)を受ける。
2
+ import { changelogFileName, changelogNotFoundMessage, extractVersionReleaseNotes, getLatestVersion, validateSemver, VersionNotFoundError } from './changelog.js';
3
+ import { PecotError, InvalidValueError } from './errors.js';
4
+ import { parsePythonInteger, pythonStringRepr, pythonStrip } from './python-format.js';
5
+ export class ReleaseError extends PecotError {
6
+ }
7
+ /**
8
+ git を実行して標準出力を返す。非 0 終了は ReleaseError
9
+ */
10
+ function runGit(git, arguments_) {
11
+ const result = git(arguments_);
12
+ if (result.exitCode !== 0) {
13
+ throw new ReleaseError(`git command failed: git ${arguments_.join(' ')}\n${pythonStrip(result.stderr)}`);
14
+ }
15
+ return pythonStrip(result.stdout);
16
+ }
17
+ function determineVersion(options, changelogContent) {
18
+ if (options.version === undefined) {
19
+ try {
20
+ return getLatestVersion(changelogContent, changelogFileName(options.changelogPath));
21
+ }
22
+ catch (error) {
23
+ if (error instanceof VersionNotFoundError)
24
+ throw new ReleaseError(error.message, { cause: error });
25
+ throw error;
26
+ }
27
+ }
28
+ validateSemver(options.version);
29
+ return options.version;
30
+ }
31
+ function countDifference(output) {
32
+ const count = parsePythonInteger(output);
33
+ if (count === undefined)
34
+ throw new InvalidValueError(`invalid literal for int() with base 10: ${pythonStringRepr(output)}`);
35
+ return count;
36
+ }
37
+ /**
38
+ リリース前チェックを実行する。
39
+ 1. CHANGELOG.md の存在、2. バージョンの検出または検証、3. タグが無いこと(ローカル・リモート)、
40
+ 4. release→develop の差分、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
41
+ */
42
+ export function runPreflight(options, git) {
43
+ const { changelogContent, developBranch, releaseBranch } = options;
44
+ if (changelogContent === undefined)
45
+ throw new ReleaseError(changelogNotFoundMessage(options.changelogPath));
46
+ const remote = options.remote ?? 'origin';
47
+ const version = determineVersion(options, changelogContent);
48
+ const tagName = options.tagPrefix === undefined || options.tagPrefix === '' ? `v${version}` : `${options.tagPrefix}-v${version}`;
49
+ const localTags = runGit(git, ['tag', '-l', tagName]);
50
+ if (localTags.split('\n').includes(tagName))
51
+ throw new ReleaseError(`tag already exists locally: ${tagName}`);
52
+ const remoteTags = runGit(git, ['ls-remote', '--tags', remote, `refs/tags/${tagName}`]);
53
+ if (remoteTags !== '')
54
+ throw new ReleaseError(`tag already exists on the remote: ${tagName}`);
55
+ runGit(git, ['fetch', remote, releaseBranch, developBranch]);
56
+ const diffCount = countDifference(runGit(git, ['rev-list', '--count', `${remote}/${releaseBranch}..${remote}/${developBranch}`]));
57
+ if (diffCount === 0) {
58
+ throw new ReleaseError(`no difference between ${remote}/${releaseBranch} and ${remote}/${developBranch}: `
59
+ + 'there is nothing to release');
60
+ }
61
+ let releaseNotes;
62
+ try {
63
+ releaseNotes = extractVersionReleaseNotes(changelogContent, version, changelogFileName(options.changelogPath));
64
+ }
65
+ catch (error) {
66
+ if (error instanceof VersionNotFoundError)
67
+ throw new ReleaseError(error.message, { cause: error });
68
+ throw error;
69
+ }
70
+ return { version, releaseNotes, developBranch, releaseBranch, diffCount, tagName };
71
+ }
72
+ //# sourceMappingURL=release.js.map
@@ -0,0 +1,32 @@
1
+ import type { RepositoryReference, ResolvedRepository } from './repository-resolver.js';
2
+ export type PolicyMode = 'reject' | 'warn';
3
+ export interface PolicyInput {
4
+ /**
5
+ グローバル `--repo` の値。無ければ undefined
6
+ */
7
+ readonly explicit: string | undefined;
8
+ /**
9
+ カレント Git remote からの解決結果。解決できなければ undefined
10
+ */
11
+ readonly resolved: ResolvedRepository | undefined;
12
+ readonly mode: PolicyMode;
13
+ }
14
+ /**
15
+ 結果の種類は kind で判別する。stderr は改行を含まない行の並びで、呼ぶ側が 1 行ずつ出す。
16
+ - proceed は、続行する。adopted は明示値から採用したリポジトリ(--repo が無ければ undefined)。
17
+ - exit は、stderr を出して指定の終了コードで終わる。
18
+ */
19
+ export type PolicyOutcome = {
20
+ readonly kind: 'proceed';
21
+ readonly adopted: RepositoryReference | undefined;
22
+ readonly stderr: readonly string[];
23
+ } | {
24
+ readonly kind: 'exit';
25
+ readonly exitCode: 1;
26
+ readonly stderr: readonly string[];
27
+ };
28
+ /**
29
+ `--repo` とカレント Git remote の不一致時の方針を判定する
30
+ */
31
+ export declare function applyRepositoryPolicy(input: PolicyInput): PolicyOutcome;
32
+ //# sourceMappingURL=repository-policy.d.ts.map
@@ -0,0 +1,65 @@
1
+ // `--repo` 不一致方針(FR-009a / FR-009b)の判定。
2
+ //
3
+ // ローカル Git を破壊する操作系(worktree・create-branch・delete-branch など)は reject にする。
4
+ // GitHub API 側への操作が中心のもの(release など)は warn にする。
5
+ // 判定だけを純粋な関数にする。stderr への出力と終了は、呼ぶ側(commands 層)が行う。
6
+ //
7
+ // 決定木:
8
+ // 1. --repo を指定しない場合
9
+ // - カレント Git remote を解決できたら続行する(採用値なし)。
10
+ // - 解決できなければ「リポジトリが曖昧です」で終了コード 1。
11
+ // 2. --repo を指定した場合
12
+ // - 形式が不正なら終了コード 1。
13
+ // - カレント Git remote が無い場合(Git 外・remote 無し)は、比較できないので明示値を採用して続行する。
14
+ // - 一致なら明示値を採用して続行する。
15
+ // - 不一致で reject は終了コード 1、warn は警告を出して明示値を採用して続行する。
16
+ //
17
+ // 文言は contracts/cli-commands.md の固定文言と一致させる(stderr を e2e で確かめるため)。
18
+ import { InvalidValueError } from './errors.js';
19
+ import { pythonStringRepr } from './python-format.js';
20
+ import { parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
21
+ function exitWith(...stderr) {
22
+ return { kind: 'exit', exitCode: 1, stderr };
23
+ }
24
+ function parseExplicit(explicit) {
25
+ try {
26
+ return parseOwnerRepository(explicit);
27
+ }
28
+ catch (error) {
29
+ if (error instanceof InvalidValueError)
30
+ return undefined;
31
+ throw error;
32
+ }
33
+ }
34
+ /**
35
+ `--repo` とカレント Git remote の不一致時の方針を判定する
36
+ */
37
+ export function applyRepositoryPolicy(input) {
38
+ const { explicit, resolved, mode } = input;
39
+ if (explicit === undefined) {
40
+ return resolved === undefined
41
+ ? exitWith('error: the repository is ambiguous', ' give --repo <owner/repo>')
42
+ : { kind: 'proceed', adopted: undefined, stderr: [] };
43
+ }
44
+ const explicitReference = parseExplicit(explicit);
45
+ if (explicitReference === undefined)
46
+ return exitWith(`error: --repo has an invalid form: ${pythonStringRepr(explicit)}`);
47
+ // Git 外 / remote 不在は比較対象が無いので、明示値を採用する
48
+ if (resolved?.source !== 'current-git')
49
+ return { kind: 'proceed', adopted: explicitReference, stderr: [] };
50
+ const current = resolved.repository;
51
+ if (current.owner === explicitReference.owner && current.repository === explicitReference.repository) {
52
+ return { kind: 'proceed', adopted: explicitReference, stderr: [] };
53
+ }
54
+ const explicitName = repositoryFullName(explicitReference);
55
+ const currentName = repositoryFullName(current);
56
+ if (mode === 'reject') {
57
+ return exitWith(`error: --repo ${explicitName} differs from the current Git remote (${currentName})`, ' this command works only on the repository of the current Git remote');
58
+ }
59
+ return {
60
+ kind: 'proceed',
61
+ adopted: explicitReference,
62
+ stderr: [`warning: using --repo ${explicitName} (current Git remote: ${currentName})`],
63
+ };
64
+ }
65
+ //# sourceMappingURL=repository-policy.js.map