@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,82 @@
1
+ import { PecotError } from './errors.js';
2
+ import type { JsonObject } from './json.js';
3
+ export declare const PR_LABEL = "dependabot-pr";
4
+ export declare const LIST_BEGIN = "<!-- pecot-dependabot-pr: list-begin -->";
5
+ export declare const LIST_END = "<!-- pecot-dependabot-pr: list-end -->";
6
+ export declare const PRIORITY = "medium";
7
+ export declare const TRACKER_PATTERN: RegExp;
8
+ /**
9
+ Tracker の本文を読み書きできない場合のエラー
10
+ */
11
+ export declare class DependabotPrError extends PecotError {
12
+ }
13
+ /**
14
+ commit の message から、依存ごとの [dependency-name, update-type] を読む。
15
+ update-type は major・minor・patch のどれか。YAML に無ければ message の版から計算し、版も無ければ undefined。
16
+ YAML の欠け・読めない YAML・依存の無い YAML では undefined
17
+ */
18
+ export declare function parseUpdateMetadata(message: string): readonly (readonly [string, string | undefined])[] | undefined;
19
+ /**
20
+ 検証の結果を表の語にする。結果が無ければ none
21
+ */
22
+ export declare function checksLabel(state: string | undefined): string;
23
+ /**
24
+ 最後の commit の検証(statusCheckRollup)の state。結果が無ければ undefined
25
+ */
26
+ export declare function rollupState(pr: JsonObject): string | undefined;
27
+ /**
28
+ PR が人の判断を待っている理由の並び。空なら載せない。
29
+ pr は listOpenDependabotPullRequests が返す PR のノード、now は判定の時刻
30
+ */
31
+ export declare function waitingReasons(pr: JsonObject, now: Readonly<Date>): readonly string[];
32
+ /**
33
+ Tracker の表の 1 行(人の判断を待つ PR)。reasons は実行のログにだけ出し、表には出さない。
34
+ checks は最後の commit の検証の結果(passed・failed・pending・none)
35
+ */
36
+ export interface PrEntry {
37
+ readonly number: number;
38
+ readonly title: string;
39
+ readonly url: string;
40
+ readonly reasons: readonly string[];
41
+ readonly checks: string;
42
+ }
43
+ /**
44
+ PR と Tracker の一覧の突き合わせの結果
45
+ */
46
+ export interface PrPlan {
47
+ /**
48
+ 新しい Tracker を立てるか(open の Tracker が無く、載せる行があるとき)
49
+ */
50
+ readonly create: boolean;
51
+ /**
52
+ Tracker を閉じるか(open の Tracker があり、載せる行が無いとき)
53
+ */
54
+ readonly close: boolean;
55
+ /**
56
+ 書き直した後の行(番号順)
57
+ */
58
+ readonly entries: readonly PrEntry[];
59
+ readonly added: readonly PrEntry[];
60
+ readonly removed: readonly number[];
61
+ }
62
+ /**
63
+ Tracker の本文から、一覧に載っている PR 番号を読む(番号順)。
64
+ list-begin / list-end の印が 1 組でなければ DependabotPrError
65
+ */
66
+ export declare function parseTrackerPullRequestNumbers(body?: string): readonly number[];
67
+ /**
68
+ Tracker の本文を作る。existingBody があれば list-begin から list-end の間だけを書き直し、外の文は残す。
69
+ 無ければ Tracker の印と一覧だけの本文を作る。existingBody の印が 1 組でなければ DependabotPrError
70
+ */
71
+ export declare function renderTrackerBody(entries: readonly PrEntry[], existingBody?: string): string;
72
+ /**
73
+ Tracker の題。today は立てた日(UTC)の YYYY-MM-DD
74
+ */
75
+ export declare function buildTrackerTitle(today: string): string;
76
+ /**
77
+ 待つ PR と Tracker の今の行から、書き直した行を出す。
78
+ oldNumbers が undefined のときは open の Tracker が無い。載せる行があるときだけ立てる。
79
+ open の Tracker があり、載せる行が無いときは閉じる
80
+ */
81
+ export declare function planTracker(entries: readonly PrEntry[], oldNumbers: readonly number[] | undefined): PrPlan;
82
+ //# sourceMappingURL=dependabot-pull-requests.d.ts.map
@@ -0,0 +1,338 @@
1
+ // 人の判断を待つ dependabot の PR を Tracker に載せるための純粋な処理(cli/core/dependabot_prs.py の移植)。
2
+ // 自動マージの対象かは dependabot/fetch-metadata v3.1.0 と同じ情報源・規則で決める。
3
+ // 正規表現は m フラグと `.`・`\s`・`\d`・`$` に頼らず、Python と同じ範囲を明示する。
4
+ import { PecotError } from './errors.js';
5
+ import { isJsonObject, jsonField } from './json.js';
6
+ import { isJsonArray, normalizeNewlines, parsePythonInteger, pythonStrip } from './python-format.js';
7
+ import { compilePattern, listRegion, markerPatterns, NON_SPACE, SPACE } from './tracker-body.js';
8
+ import { parseYamlDocument } from './yaml-document.js';
9
+ export const PR_LABEL = 'dependabot-pr';
10
+ const TRACKER_MARKER = '<!-- pecot-dependabot-pr: tracker -->';
11
+ export const LIST_BEGIN = '<!-- pecot-dependabot-pr: list-begin -->';
12
+ export const LIST_END = '<!-- pecot-dependabot-pr: list-end -->';
13
+ export const PRIORITY = 'medium';
14
+ // security の Tracker の種類ごとの見出しと同じ形にする
15
+ const SECTION_HEADING = '## dependabot PR';
16
+ const REASON_UNKNOWN = 'unknown update type';
17
+ const REASON_MAJOR = 'major';
18
+ const REASON_FAILED = 'checks failed';
19
+ const REASON_STUCK = 'checks not finishing';
20
+ const REASON_CONFLICT = 'conflict';
21
+ const REASON_DEQUEUED = 'dequeued';
22
+ const REASON_NO_AUTO_MERGE = 'no auto-merge';
23
+ const MICROSECONDS_PER_MINUTE = 60000000n;
24
+ // dependabot-auto-merge.yml が auto-merge を入れるまでの猶予と、検証の待ち時間の上限
25
+ const GRACE = 30n * MICROSECONDS_PER_MINUTE;
26
+ const CHECKS_TIMEOUT = 24n * 60n * MICROSECONDS_PER_MINUTE;
27
+ const LINE_START = '(?<![^\\n])';
28
+ const LINE_END = '(?![^\\n])';
29
+ const BACKTICK = '`';
30
+ const DIGIT = '\\p{Nd}';
31
+ const ROW_MARKER_PATTERN = compilePattern(`<!--${SPACE}*pecot-dependabot-pr:${SPACE}*pr/(${DIGIT}+)${SPACE}*-->`, 'u');
32
+ const MARKERS = markerPatterns('pecot-dependabot-pr');
33
+ export const TRACKER_PATTERN = MARKERS.tracker;
34
+ const TABLE_LINE_PATTERN = compilePattern(String.raw `^${SPACE}*\|`, 'u');
35
+ const LINE_BREAK_RUN = compilePattern(String.raw `${SPACE}*[\r\n]+${SPACE}*`, 'gu');
36
+ // fetch-metadata v3.1.0 の parse・parseMetadataLinks と同じ。commit の message から YAML と版の記述を抜く
37
+ const YAML_PATTERN = compilePattern(String.raw `${LINE_START}-{3}\n([\s\S]*?)\n${LINE_START}\.{3}\n`, 'u');
38
+ const BUMP_PATTERN = compilePattern(String.raw `${LINE_START}Bumps [^\n]* from (v?${DIGIT}[^ ]*) to (v?${DIGIT}[^ ]*)\.${LINE_END}`, 'u');
39
+ const UPDATES_PATTERN = compilePattern(`${LINE_START}Updates ${BACKTICK}(${NON_SPACE}+)${BACKTICK} (?:from (${NON_SPACE}+) )?to (${NON_SPACE}+)${LINE_END}`, 'gu');
40
+ // eslint-disable-next-line security/detect-unsafe-regex -- 入力は GitHub が返す固定の形の時刻で、量指定子は入れ子にならない
41
+ const TIME_PATTERN = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(?:\.(?<fraction>\d+))?(?:Z|(?<sign>[+-])(?<offsetHour>\d{2}):(?<offsetMinute>\d{2}))$/u;
42
+ const UPDATE_TYPES = new Set(['patch', 'minor', 'major']);
43
+ // GraphQL の commit.author.user.login。PR の author は `[bot]` が付かない
44
+ const BOT_LOGIN = 'dependabot[bot]';
45
+ const MAX_HOUR = 23;
46
+ const MAX_MINUTE_OR_SECOND = 59;
47
+ const MONTH_OFFSET = 1;
48
+ const MICROSECOND_DIGITS = 6;
49
+ /**
50
+ Tracker の本文を読み書きできない場合のエラー
51
+ */
52
+ export class DependabotPrError extends PecotError {
53
+ }
54
+ function ownField(value, key) {
55
+ return typeof value === 'object' && value !== null ? new Map(Object.entries(value)).get(key) : undefined;
56
+ }
57
+ // Python の dict だけを通す。Set・Buffer・Date などは辞書として読まない
58
+ function isPlainObject(value) {
59
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
60
+ return false;
61
+ const prototype = Object.getPrototypeOf(value);
62
+ return prototype === Object.prototype || prototype === null;
63
+ }
64
+ function objectOrEmpty(value) {
65
+ return isJsonObject(value) ? value : {};
66
+ }
67
+ function arrayOrEmpty(value) {
68
+ return isJsonArray(value) ? value : [];
69
+ }
70
+ // キーをたどった先の値。途中がオブジェクトでなければ undefined
71
+ function dig(value, ...keys) {
72
+ let current = value;
73
+ for (const key of keys)
74
+ current = jsonField(current, key);
75
+ return current;
76
+ }
77
+ function firstNode(value) {
78
+ const [first] = arrayOrEmpty(jsonField(value, 'nodes'));
79
+ return objectOrEmpty(first);
80
+ }
81
+ // Python の bool() と同じ
82
+ function isTruthyValue(value) {
83
+ if (value === undefined || value === null || value === false || value === 0 || value === '')
84
+ return false;
85
+ if (Array.isArray(value))
86
+ return value.length > 0;
87
+ if (typeof value === 'object')
88
+ return Object.keys(value).length > 0;
89
+ return true;
90
+ }
91
+ /**
92
+ fetch-metadata の calculateUpdateType と同じ。前後のどちらかが空・両方が同じなら undefined。
93
+ `v` は最初の 1 文字を除く。先頭が違えば major、要素が 2 つ未満か 2 番目が違えば minor、それ以外は patch
94
+ */
95
+ function versionType(oldVersion, newVersion) {
96
+ if (oldVersion === '' || newVersion === '' || oldVersion === newVersion)
97
+ return undefined;
98
+ const a = removeFirstV(oldVersion).split('.');
99
+ const b = removeFirstV(newVersion).split('.');
100
+ if (a[0] !== b[0])
101
+ return 'major';
102
+ if (a.length < 2 || b.length < 2 || a[1] !== b[1])
103
+ return 'minor';
104
+ return 'patch';
105
+ }
106
+ function removeFirstV(text) {
107
+ const index = text.indexOf('v');
108
+ return index === -1 ? text : text.slice(0, index) + text.slice(index + 1);
109
+ }
110
+ function readYamlMapping(source) {
111
+ let data;
112
+ try {
113
+ data = parseYamlDocument(source);
114
+ }
115
+ catch {
116
+ return undefined;
117
+ }
118
+ return isPlainObject(data) ? data : undefined;
119
+ }
120
+ /**
121
+ commit の message から、依存ごとの [dependency-name, update-type] を読む。
122
+ update-type は major・minor・patch のどれか。YAML に無ければ message の版から計算し、版も無ければ undefined。
123
+ YAML の欠け・読めない YAML・依存の無い YAML では undefined
124
+ */
125
+ export function parseUpdateMetadata(message) {
126
+ const text = message.replaceAll('\r\n', '\n');
127
+ const matched = YAML_PATTERN.exec(text);
128
+ if (matched === null)
129
+ return undefined;
130
+ const data = readYamlMapping(matched[1] ?? '');
131
+ if (data === undefined)
132
+ return undefined;
133
+ const dependencies = ownField(data, 'updated-dependencies');
134
+ const items = Array.isArray(dependencies) ? dependencies : [];
135
+ const bump = BUMP_PATTERN.exec(text);
136
+ const links = new Map();
137
+ for (const link of text.matchAll(UPDATES_PATTERN)) {
138
+ const name = link[1] ?? '';
139
+ links.set(name, [...links.get(name) ?? [], [link[2] ?? '', link[3] ?? '']]);
140
+ }
141
+ const seen = new Map();
142
+ const result = [];
143
+ for (const [index, item] of items.entries()) {
144
+ const name = ownField(item, 'dependency-name');
145
+ if (typeof name !== 'string')
146
+ continue;
147
+ const nth = seen.get(name) ?? 0;
148
+ seen.set(name, nth + 1);
149
+ const [linkOld, linkNew] = links.get(name)?.at(nth) ?? ['', ''];
150
+ // Bumps 行は先頭の依存にだけ当てる
151
+ const [bumpOld, bumpNew] = index === 0 ? [bump?.[1] ?? '', bump?.[2] ?? ''] : ['', ''];
152
+ const version = ownField(item, 'dependency-version');
153
+ const yamlNew = typeof version === 'string' ? version : '';
154
+ const oldVersion = linkOld === '' ? bumpOld : linkOld;
155
+ const newVersion = (yamlNew === '' ? linkNew : yamlNew) || bumpNew;
156
+ result.push([name, rawUpdateType(ownField(item, 'update-type')) ?? versionType(oldVersion, newVersion)]);
157
+ }
158
+ return result.length > 0 ? result : undefined;
159
+ }
160
+ // `version-update:semver-minor` の最後の semver- より後ろ。major・minor・patch のどれでもなければ undefined
161
+ function rawUpdateType(raw) {
162
+ if (typeof raw !== 'string')
163
+ return undefined;
164
+ const marker = raw.lastIndexOf('semver-');
165
+ const type = marker === -1 ? raw : raw.slice(marker + 'semver-'.length);
166
+ return UPDATE_TYPES.has(type) ? type : undefined;
167
+ }
168
+ // `YYYY-MM-DDTHH:MM:SS(.f+)?(Z|±HH:MM)` の形だけを読む。マイクロ秒の数。読めなければ undefined
169
+ function parseTime(value) {
170
+ const parts = typeof value === 'string' ? TIME_PATTERN.exec(value)?.groups : undefined;
171
+ if (parts === undefined)
172
+ return undefined;
173
+ const { year = '', month = '', day = '', hour = '', minute = '', second = '', fraction = '', sign = '+', offsetHour = '0', offsetMinute = '0' } = parts;
174
+ const date = new Date(0);
175
+ date.setUTCFullYear(Number(year), Number(month) - MONTH_OFFSET, Number(day));
176
+ date.setUTCHours(Number(hour), Number(minute), Number(second), 0);
177
+ const isSameDay = Number(year) >= 1 && date.getUTCFullYear() === Number(year) && date.getUTCMonth() === Number(month) - MONTH_OFFSET && date.getUTCDate() === Number(day);
178
+ const isTimeInRange = Number(hour) <= MAX_HOUR && Number(minute) <= MAX_MINUTE_OR_SECOND && Number(second) <= MAX_MINUTE_OR_SECOND;
179
+ if (!isSameDay || !isTimeInRange || Number(offsetHour) > MAX_HOUR || Number(offsetMinute) > MAX_MINUTE_OR_SECOND)
180
+ return undefined;
181
+ const micros = BigInt(fraction.slice(0, MICROSECOND_DIGITS).padEnd(MICROSECOND_DIGITS, '0'));
182
+ const offsetMinutes = BigInt(Number(offsetHour) * 60 + Number(offsetMinute)) * (sign === '-' ? -1n : 1n);
183
+ return BigInt(date.getTime()) * 1000n + micros - offsetMinutes * MICROSECONDS_PER_MINUTE;
184
+ }
185
+ /**
186
+ 検証の結果を表の語にする。結果が無ければ none
187
+ */
188
+ export function checksLabel(state) {
189
+ if (state === 'SUCCESS')
190
+ return 'passed';
191
+ if (state === 'FAILURE' || state === 'ERROR')
192
+ return 'failed';
193
+ return state === undefined ? 'none' : 'pending';
194
+ }
195
+ /**
196
+ 最後の commit の検証(statusCheckRollup)の state。結果が無ければ undefined
197
+ */
198
+ export function rollupState(pr) {
199
+ const state = dig(firstNode(jsonField(pr, 'headCommits')), 'commit', 'statusCheckRollup', 'state');
200
+ return typeof state === 'string' ? state : undefined;
201
+ }
202
+ function commitOf(pr) {
203
+ const first = firstNode(jsonField(pr, 'firstCommits'));
204
+ return objectOrEmpty(jsonField(first, 'commit'));
205
+ }
206
+ // update-type から決まる理由と、自動マージの対象か
207
+ function metadataReasons(pr) {
208
+ const commit = commitOf(pr);
209
+ // fetch-metadata は署名が有効でない commit の metadata を返さない(auto-merge も入らない)
210
+ const isSigned = dig(commit, 'signature', 'isValid') === true;
211
+ const message = jsonField(commit, 'message');
212
+ const isBot = dig(commit, 'author', 'user', 'login') === BOT_LOGIN;
213
+ const metadata = isBot && isSigned && typeof message === 'string' ? parseUpdateMetadata(message) : undefined;
214
+ if (metadata === undefined)
215
+ return { reasons: [REASON_UNKNOWN], isTarget: false };
216
+ const types = metadata.map(([, type]) => type).filter(type => type !== undefined);
217
+ if (types.length === 0)
218
+ return { reasons: [REASON_UNKNOWN], isTarget: false };
219
+ if (types.includes('major'))
220
+ return { reasons: [REASON_MAJOR], isTarget: false };
221
+ return { reasons: [], isTarget: true };
222
+ }
223
+ function eventTimes(pr, alias) {
224
+ const createdAt = arrayOrEmpty(dig(pr, alias, 'nodes')).map(node => jsonField(node, 'createdAt'));
225
+ const times = createdAt.map(value => parseTime(value));
226
+ return times.filter(time => time !== undefined);
227
+ }
228
+ // 読めた時刻のうち最も新しいもの
229
+ function latest(times) {
230
+ let best;
231
+ for (const time of times) {
232
+ if (time !== undefined && (best === undefined || time > best))
233
+ best = time;
234
+ }
235
+ return best;
236
+ }
237
+ /**
238
+ PR が人の判断を待っている理由の並び。空なら載せない。
239
+ pr は listOpenDependabotPullRequests が返す PR のノード、now は判定の時刻
240
+ */
241
+ export function waitingReasons(pr, now) {
242
+ const { reasons: base, isTarget } = metadataReasons(pr);
243
+ if (!isTarget)
244
+ return base;
245
+ const reasons = [...base];
246
+ const nowMicros = BigInt(now.getTime()) * 1000n;
247
+ const lastPush = latest([parseTime(jsonField(pr, 'createdAt')), ...eventTimes(pr, 'lastForcePush')]);
248
+ if (lastPush === undefined)
249
+ return reasons;
250
+ const state = rollupState(pr);
251
+ const autoMergeRequest = jsonField(pr, 'autoMergeRequest');
252
+ const hasAutoMerge = autoMergeRequest !== undefined && autoMergeRequest !== null;
253
+ const isInQueue = isTruthyValue(jsonField(pr, 'isInMergeQueue'));
254
+ if (state === 'FAILURE' || state === 'ERROR')
255
+ reasons.push(REASON_FAILED);
256
+ else if (hasAutoMerge && state !== 'SUCCESS' && nowMicros - lastPush > CHECKS_TIMEOUT)
257
+ reasons.push(REASON_STUCK);
258
+ if (jsonField(pr, 'mergeable') === 'CONFLICTING') {
259
+ const baseTime = parseTime(dig(pr, 'baseRef', 'target', 'committedDate'));
260
+ const since = latest([lastPush, baseTime]) ?? lastPush;
261
+ if (nowMicros - since > GRACE)
262
+ reasons.push(REASON_CONFLICT);
263
+ }
264
+ if (!hasAutoMerge && !isInQueue) {
265
+ if (eventTimes(pr, 'lastDequeue').some(time => time > lastPush))
266
+ reasons.push(REASON_DEQUEUED);
267
+ else if (nowMicros - lastPush > GRACE)
268
+ reasons.push(REASON_NO_AUTO_MERGE);
269
+ }
270
+ return reasons;
271
+ }
272
+ // PR の題のセル。`@scope/pkg` をメンションとして読ませないため、コードスパンで囲む。囲いは題のバッククォートの連なりより長くする
273
+ function titleCell(title) {
274
+ const oneLine = pythonStrip(title.replaceAll(LINE_BREAK_RUN, ' ')).replaceAll('|', String.raw `\|`);
275
+ const longest = Math.max(0, ...(oneLine.match(/`+/gu) ?? []).map(run => run.length));
276
+ const fence = '`'.repeat(longest + 1);
277
+ const pad = oneLine.startsWith('`') || oneLine.endsWith('`') ? ' ' : '';
278
+ return `${fence}${pad}${oneLine}${pad}${fence}`;
279
+ }
280
+ function row(entry) {
281
+ return `| <!-- pecot-dependabot-pr: pr/${String(entry.number)} --> ${titleCell(entry.title)} | [#${String(entry.number)}](${entry.url}) | ${entry.checks} |`;
282
+ }
283
+ /**
284
+ Tracker の本文から、一覧に載っている PR 番号を読む(番号順)。
285
+ list-begin / list-end の印が 1 組でなければ DependabotPrError
286
+ */
287
+ export function parseTrackerPullRequestNumbers(body = '') {
288
+ const text = normalizeNewlines(body);
289
+ const { begin, end } = listRegion(text, MARKERS.begin, MARKERS.end, DependabotPrError);
290
+ const numbers = new Set();
291
+ for (const line of text.slice(begin, end).split('\n')) {
292
+ if (!TABLE_LINE_PATTERN.test(line))
293
+ continue;
294
+ const parsed = parsePythonInteger(ROW_MARKER_PATTERN.exec(line)?.[1] ?? '');
295
+ if (parsed !== undefined)
296
+ numbers.add(parsed);
297
+ }
298
+ return [...numbers].toSorted((a, b) => a - b);
299
+ }
300
+ /**
301
+ Tracker の本文を作る。existingBody があれば list-begin から list-end の間だけを書き直し、外の文は残す。
302
+ 無ければ Tracker の印と一覧だけの本文を作る。existingBody の印が 1 組でなければ DependabotPrError
303
+ */
304
+ export function renderTrackerBody(entries, existingBody) {
305
+ const table = entries.length > 0
306
+ ? ['| title | PR | checks |', '|---|---|---|', ...entries.map(entry => row(entry))].join('\n')
307
+ : 'none';
308
+ const section = `${SECTION_HEADING}\n\n${table}`;
309
+ if (existingBody === undefined)
310
+ return `${TRACKER_MARKER}\n\n${LIST_BEGIN}\n${section}\n${LIST_END}\n`;
311
+ const text = normalizeNewlines(existingBody);
312
+ const { begin, end } = listRegion(text, MARKERS.begin, MARKERS.end, DependabotPrError);
313
+ return `${text.slice(0, begin)}\n${section}\n${text.slice(end)}`;
314
+ }
315
+ /**
316
+ Tracker の題。today は立てた日(UTC)の YYYY-MM-DD
317
+ */
318
+ export function buildTrackerTitle(today) {
319
+ return `[Tracker] dependabot PR — ${today}`;
320
+ }
321
+ /**
322
+ 待つ PR と Tracker の今の行から、書き直した行を出す。
323
+ oldNumbers が undefined のときは open の Tracker が無い。載せる行があるときだけ立てる。
324
+ open の Tracker があり、載せる行が無いときは閉じる
325
+ */
326
+ export function planTracker(entries, oldNumbers) {
327
+ const rows = entries.toSorted((a, b) => a.number - b.number);
328
+ const old = new Set(oldNumbers);
329
+ const current = new Set(rows.map(entry => entry.number));
330
+ return {
331
+ create: oldNumbers === undefined && rows.length > 0,
332
+ close: oldNumbers !== undefined && rows.length === 0,
333
+ entries: rows,
334
+ added: rows.filter(entry => !old.has(entry.number)),
335
+ removed: [...old].filter(number => !current.has(number)).toSorted((a, b) => a - b),
336
+ };
337
+ }
338
+ //# sourceMappingURL=dependabot-pull-requests.js.map
@@ -0,0 +1,51 @@
1
+ import type { JsonValue } from './python-format.js';
2
+ /**
3
+ 失敗した応答の情報。message は API エラーの文(応答の状態を含む)
4
+ */
5
+ export interface DependabotFailure {
6
+ readonly message: string;
7
+ readonly statusCode: number | undefined;
8
+ /**
9
+ 応答本文。JSON なら message を添えるために使う
10
+ */
11
+ readonly responseBody: string | undefined;
12
+ }
13
+ /**
14
+ 結果の種類は kind で判別する。
15
+ - ok は、取得できた。
16
+ - forbidden は、403 のうちレート制限ではないもの。
17
+ - rateLimited は、レート制限による 403。
18
+ - failure は、上記以外の API エラー。
19
+ - network は、通信の失敗(応答を得られなかった)。
20
+ */
21
+ export type DependabotResult<T> = {
22
+ readonly kind: 'ok';
23
+ readonly value: T;
24
+ } | {
25
+ readonly kind: 'forbidden';
26
+ readonly failure: DependabotFailure;
27
+ } | {
28
+ readonly kind: 'rateLimited';
29
+ readonly failure: DependabotFailure;
30
+ } | {
31
+ readonly kind: 'failure';
32
+ readonly failure: DependabotFailure;
33
+ } | {
34
+ readonly kind: 'network';
35
+ readonly message: string;
36
+ };
37
+ /**
38
+ alert の 1 件。使うのは security_vulnerability.severity だけ
39
+ */
40
+ export type DependabotAlert = JsonValue;
41
+ export interface DependabotSource {
42
+ /**
43
+ open な alert を全件取得する。alerts が無効なとき等は forbidden
44
+ */
45
+ readonly listOpenAlerts: (owner: string, repository: string) => Promise<DependabotResult<readonly DependabotAlert[]>>;
46
+ /**
47
+ alerts が有効かを取得する。有効なら true、無効(404)なら false。それ以外の応答は ok にしない
48
+ */
49
+ readonly isAlertsEnabled: (owner: string, repository: string) => Promise<DependabotResult<boolean>>;
50
+ }
51
+ //# sourceMappingURL=dependabot-source.d.ts.map
@@ -0,0 +1,4 @@
1
+ // Dependabot alert の取得元の型。domain/dependabot.ts が使い、GitHub を使う実体は infra/github/dependabot-source.ts に置く。
2
+ // 結果は判別共用体(kind)で返す。例外にしないので、domain のテストはメモリ上の実装で書ける。
3
+ export {};
4
+ //# sourceMappingURL=dependabot-source.js.map
@@ -0,0 +1,47 @@
1
+ import type { DependabotSource } from './dependabot-source.js';
2
+ import { PecotError } from './errors.js';
3
+ /**
4
+ alert の状態を判定できない。alerts が無効なのか権限不足なのかを区別できないときも含む
5
+ */
6
+ export declare class DependabotAlertError extends PecotError {
7
+ }
8
+ /**
9
+ open の alert 1 件の要点
10
+ */
11
+ export interface OpenAlert {
12
+ readonly number: number;
13
+ /**
14
+ 依存パッケージ名。応答に無ければ undefined
15
+ */
16
+ readonly package: string | undefined;
17
+ readonly severity: string | undefined;
18
+ }
19
+ export interface DependabotAlertStatus {
20
+ /**
21
+ alerts が有効か
22
+ */
23
+ readonly enabled: boolean;
24
+ /**
25
+ open の alert 件数(無効なら 0)
26
+ */
27
+ readonly openCount: number;
28
+ /**
29
+ open の alert の最高 severity(0 件・無効なら undefined)
30
+ */
31
+ readonly maxSeverity: string | undefined;
32
+ /**
33
+ alert 一覧の Web URL
34
+ */
35
+ readonly alertsUrl: string;
36
+ /**
37
+ open の alert の要点(番号が整数のものだけ)
38
+ */
39
+ readonly openAlerts: readonly OpenAlert[];
40
+ }
41
+ /**
42
+ リポジトリの Dependabot alert の状態を取得する。
43
+ 一覧取得が成功なら有効確定で集計する。403(レート制限を除く)のときだけ有効 / 無効の判定で分類する(権限不足を「無効」と取り違えないため)。
44
+ 状態を判定できなければ DependabotAlertError
45
+ */
46
+ export declare function fetchDependabotAlertStatus(source: DependabotSource, host: string, owner: string, repository: string): Promise<DependabotAlertStatus>;
47
+ //# sourceMappingURL=dependabot.d.ts.map
@@ -0,0 +1,88 @@
1
+ // Dependabot alert の状態判定。`release preflight` と `project info` が同じ判定を共有する。
2
+ // 有効 / 無効・open 件数・最高 severity・一覧 URL をまとめて返す。取得は DependabotSource に任せる。
3
+ import { describeApiError } from './api-error-detail.js';
4
+ import { PecotError } from './errors.js';
5
+ import { isJsonObject, jsonField } from './json.js';
6
+ /**
7
+ alert の状態を判定できない。alerts が無効なのか権限不足なのかを区別できないときも含む
8
+ */
9
+ export class DependabotAlertError extends PecotError {
10
+ }
11
+ // severity の強さ順(大きいほど重い)。未知の値は順位 -1 として扱い、落とさない
12
+ const SEVERITY_ORDER = new Map([['low', 0], ['medium', 1], ['high', 2], ['critical', 3]]);
13
+ function severityRank(severity) {
14
+ return SEVERITY_ORDER.get(severity) ?? -1;
15
+ }
16
+ /**
17
+ 各 alert の security_vulnerability.severity の最大値。同順位は先に現れた値(Python の max と同じ)
18
+ */
19
+ function maxSeverity(alerts) {
20
+ let best;
21
+ for (const alert of alerts) {
22
+ if (!isJsonObject(alert))
23
+ continue;
24
+ const vulnerability = alert['security_vulnerability'];
25
+ if (!isJsonObject(vulnerability))
26
+ continue;
27
+ const severity = vulnerability['severity'];
28
+ if (typeof severity === 'string' && (best === undefined || severityRank(severity) > severityRank(best)))
29
+ best = severity;
30
+ }
31
+ return best;
32
+ }
33
+ function stringOrUndefined(value) {
34
+ return typeof value === 'string' ? value : undefined;
35
+ }
36
+ function openAlertOf(alert) {
37
+ const number = jsonField(alert, 'number');
38
+ if (typeof number !== 'number' || !Number.isSafeInteger(number))
39
+ return undefined;
40
+ const dependency = jsonField(alert, 'dependency');
41
+ return {
42
+ number,
43
+ package: stringOrUndefined(jsonField(jsonField(dependency, 'package'), 'name')),
44
+ severity: stringOrUndefined(jsonField(jsonField(alert, 'security_vulnerability'), 'severity')),
45
+ };
46
+ }
47
+ /**
48
+ 成功以外の結果をエラーにする。ok のときは値を返す
49
+ */
50
+ function unwrap(result, owner, repository) {
51
+ switch (result.kind) {
52
+ case 'ok': {
53
+ return result.value;
54
+ }
55
+ case 'network': {
56
+ throw new DependabotAlertError(`${owner}/${repository}: request failed: ${result.message}`);
57
+ }
58
+ case 'forbidden':
59
+ case 'rateLimited':
60
+ case 'failure': {
61
+ throw new DependabotAlertError(`${owner}/${repository}: ${describeApiError(result.failure)}`);
62
+ }
63
+ }
64
+ }
65
+ /**
66
+ 一覧が 403 のとき、vulnerability-alerts で「無効」かどうかを分類する。
67
+ 404 のみを無効とみなす。204 は有効なのに一覧が取れない状態で、エラーにする
68
+ */
69
+ async function classifyForbidden(source, owner, repository, alertsUrl) {
70
+ if (unwrap(await source.isAlertsEnabled(owner, repository), owner, repository)) {
71
+ throw new DependabotAlertError(`${owner}/${repository}: Dependabot alerts are enabled but the list cannot be fetched (permission may be missing)`);
72
+ }
73
+ return { enabled: false, openCount: 0, maxSeverity: undefined, alertsUrl, openAlerts: [] };
74
+ }
75
+ /**
76
+ リポジトリの Dependabot alert の状態を取得する。
77
+ 一覧取得が成功なら有効確定で集計する。403(レート制限を除く)のときだけ有効 / 無効の判定で分類する(権限不足を「無効」と取り違えないため)。
78
+ 状態を判定できなければ DependabotAlertError
79
+ */
80
+ export async function fetchDependabotAlertStatus(source, host, owner, repository) {
81
+ const alertsUrl = `https://${host}/${owner}/${repository}/security/dependabot`;
82
+ const listed = await source.listOpenAlerts(owner, repository);
83
+ if (listed.kind === 'forbidden')
84
+ return classifyForbidden(source, owner, repository, alertsUrl);
85
+ const alerts = unwrap(listed, owner, repository);
86
+ return { enabled: true, openCount: alerts.length, maxSeverity: maxSeverity(alerts), alertsUrl, openAlerts: alerts.map(alert => openAlertOf(alert)).filter(alert => alert !== undefined) };
87
+ }
88
+ //# sourceMappingURL=dependabot.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ name をクラス名にし、cause を受け取る共通の基底
3
+ */
4
+ export declare class BaseError extends Error {
5
+ constructor(message: string, options?: Readonly<ErrorOptions>);
6
+ }
7
+ export declare class PecotError extends BaseError {
8
+ }
9
+ /**
10
+ プロジェクトルートが見つからない
11
+ */
12
+ export declare class ProjectRootNotFoundError extends PecotError {
13
+ }
14
+ /**
15
+ 値の形式が不正(Python の ValueError に当たる)。PecotError ではない
16
+ */
17
+ export declare class InvalidValueError extends BaseError {
18
+ }
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,31 @@
1
+ // CLI の例外の基底。
2
+ //
3
+ // 階層は 2 系統ある。どちらも BaseError を共通の基底にする。
4
+ // - PecotError 系は、利用者に見せる独自の例外。
5
+ // Python の core/errors.py の PecotError と同じ階層で、各モジュールの独自例外が継承する。
6
+ // - Python の組み込み例外に当たる系は、PecotError を継承せず BaseError を直接継承する。
7
+ // InvalidValueError は ValueError、OsError は OSError、GitCommandError は CalledProcessError に当たる。
8
+ // TransportFailure、GraphqlFailure、UsageError などもこの系統。
9
+ // 最上位で拾う側(commands/failure.ts)が、この 2 系統を区別して扱う。
10
+ /**
11
+ name をクラス名にし、cause を受け取る共通の基底
12
+ */
13
+ export class BaseError extends Error {
14
+ constructor(message, options) {
15
+ super(message, options);
16
+ this.name = new.target.name;
17
+ }
18
+ }
19
+ export class PecotError extends BaseError {
20
+ }
21
+ /**
22
+ プロジェクトルートが見つからない
23
+ */
24
+ export class ProjectRootNotFoundError extends PecotError {
25
+ }
26
+ /**
27
+ 値の形式が不正(Python の ValueError に当たる)。PecotError ではない
28
+ */
29
+ export class InvalidValueError extends BaseError {
30
+ }
31
+ //# sourceMappingURL=errors.js.map