@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,576 @@
1
+ // GitHub API クライアントの基底(認証・REST と GraphQL の実行・エラー変換)。cli/core/github/client.py の移植。
2
+ // issues・pulls・projects・repos の操作はこの基底に足す。
3
+ //
4
+ // Python は httpx と gql で送っていた。ここでは fetch で送り、次の点を揃える。
5
+ // - redirect: 'manual' で呼ぶ。301 などは成功にせず、Python と同じ失敗にする。
6
+ // - URL は文字列の連結で作る。new URL は GHE の base(/api/v3)を落とす。
7
+ // - 失敗の文は httpx と gql の文言を写す。
8
+ import { spawnSync } from 'node:child_process';
9
+ import path from 'node:path';
10
+ import { isJsonObject, parseJsonText } from '../../domain/json.js';
11
+ import { BaseError, InvalidValueError } from '../../domain/errors.js';
12
+ import { formatHttpStatusError, isJsonArray, pythonRepr, pythonStrip, pythonTypeName, splitCodePoints, } from '../../domain/python-format.js';
13
+ import { configDirectory } from '../config-store.js';
14
+ import { projectRoot } from '../paths.js';
15
+ import { ensureEnvironmentFile, environmentValue, getEnvironmentVariableName, loadEnvironmentFile, pythonString, ROOT_ENV_VAR_MAP, scopesFor, tokenUrlFor, } from './auth.js';
16
+ import { GitHubAPIError, GitHubAuthError, GitHubNotFoundError, GitHubRateLimitError, } from './errors.js';
17
+ import { asObject, isTruthy } from './payload.js';
18
+ const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost']);
19
+ const MAX_PORT = 65_535;
20
+ // Python の TOKEN_FALLBACK_WARNING と同じ文。前置きと字下げを含まない
21
+ const TOKEN_FALLBACK_WARNING = 'the token in the environment variable is invalid (401 Unauthorized); fell back to gh auth token\n'
22
+ + 'update or remove the token in .env';
23
+ function isControlOrSpace(character) {
24
+ return (character.codePointAt(0) ?? 0) <= 0x20;
25
+ }
26
+ function trimTrailingSlashes(text) {
27
+ let end = text.length;
28
+ while (end > 0 && text.charAt(end - 1) === '/')
29
+ end -= 1;
30
+ return text.slice(0, end);
31
+ }
32
+ /**
33
+ urlsplit(raw) の結果が、ループバックの http URL(query・fragment・userinfo なし)かを判定する。
34
+ host は new URL で正規化せず、元の文字列の authority で比べる。
35
+ そのため `127.1`・`0x7f.0.0.1` は拒否し、`HTTP://LOCALHOST:5` は受ける(urlsplit が scheme と host を小文字にする)。
36
+ 空の query と fragment(クエリ記号やハッシュだけの末尾)は受ける
37
+ */
38
+ function isLoopbackHttpUrl(raw) {
39
+ let start = 0;
40
+ while (start < raw.length && isControlOrSpace(raw.charAt(start)))
41
+ start += 1;
42
+ const url = raw.slice(start).replaceAll(/[\t\n\r]/gu, '');
43
+ const scheme = /^([A-Za-z][\d+.A-Za-z-]*):/u.exec(url);
44
+ if (scheme?.[1]?.toLowerCase() !== 'http')
45
+ return false;
46
+ const rest = url.slice(scheme[0].length);
47
+ if (!rest.startsWith('//'))
48
+ return false;
49
+ const afterSlashes = rest.slice(2);
50
+ const delimiter = afterSlashes.search(/[#/?]/u);
51
+ const netloc = delimiter === -1 ? afterSlashes : afterSlashes.slice(0, delimiter);
52
+ const tail = delimiter === -1 ? '' : afterSlashes.slice(delimiter);
53
+ const fragmentStart = tail.indexOf('#');
54
+ const fragment = fragmentStart === -1 ? '' : tail.slice(fragmentStart + 1);
55
+ const beforeFragment = fragmentStart === -1 ? tail : tail.slice(0, fragmentStart);
56
+ const queryStart = beforeFragment.indexOf('?');
57
+ const query = queryStart === -1 ? '' : beforeFragment.slice(queryStart + 1);
58
+ // userinfo があるもの、IPv6 の角括弧があるものは、ループバックの 2 つのいずれでもない
59
+ if (query !== '' || fragment !== '' || /[@[\]]/u.test(netloc))
60
+ return false;
61
+ const portStart = netloc.indexOf(':');
62
+ const hostname = (portStart === -1 ? netloc : netloc.slice(0, portStart)).toLowerCase();
63
+ if (!LOOPBACK_HOSTS.has(hostname))
64
+ return false;
65
+ if (portStart === -1)
66
+ return true;
67
+ const port = netloc.slice(portStart + 1);
68
+ return port === '' || (/^\d+$/u.test(port) && Number(port) <= MAX_PORT);
69
+ }
70
+ /**
71
+ PECOT_GITHUB_API_URL を検証して返す。未設定・空文字なら undefined。
72
+ 前後比較のテストが GitHub の代わりに偽サーバへ向けるための差し替え口。
73
+ ループバックの http URL だけを受け付け、それ以外は InvalidValueError。末尾の `/` は落とす
74
+ */
75
+ export function resolveApiUrlOverride() {
76
+ const raw = process.env['PECOT_GITHUB_API_URL'] ?? '';
77
+ if (raw === '')
78
+ return undefined;
79
+ if (!isLoopbackHttpUrl(raw)) {
80
+ throw new InvalidValueError(`PECOT_GITHUB_API_URL accepts only an http://127.0.0.1 or http://localhost URL: ${raw}`);
81
+ }
82
+ return trimTrailingSlashes(raw);
83
+ }
84
+ /**
85
+ 送信の失敗(接続できない・時間切れ)。Python の httpx の例外に当たり、PecotError ではない
86
+ */
87
+ export class TransportFailure extends BaseError {
88
+ }
89
+ function errorCode(error) {
90
+ return error instanceof Error && 'code' in error && typeof error.code === 'string' ? error.code : undefined;
91
+ }
92
+ const SOCKET_FAILURES = new Map([
93
+ ['ECONNREFUSED', '[Errno 111] Connection refused'],
94
+ ['ECONNRESET', '[Errno 104] Connection reset by peer'],
95
+ ['ENOTFOUND', '[Errno -2] Name or service not known'],
96
+ ['EAI_AGAIN', '[Errno -3] Temporary failure in name resolution'],
97
+ ]);
98
+ /**
99
+ fetch の失敗の文。接続の失敗は errno の文、時間切れは httpx の ReadTimeout の文(timed out)にする。
100
+ それ以外は例外の文そのもの
101
+ */
102
+ function describeTransportFailure(error) {
103
+ if (error instanceof Error && (error.name === 'TimeoutError' || error.name === 'AbortError'))
104
+ return 'timed out';
105
+ const cause = error instanceof Error ? error.cause : undefined;
106
+ const code = errorCode(cause) ?? errorCode(error);
107
+ const known = code === undefined ? undefined : SOCKET_FAILURES.get(code);
108
+ if (known !== undefined)
109
+ return known;
110
+ if (cause instanceof Error)
111
+ return cause.message;
112
+ return error instanceof Error ? error.message : String(error);
113
+ }
114
+ // urllib.parse.quote_plus と同じ。英数字と `_.-~` 以外は UTF-8 の %XX にし、空白は `+`
115
+ function quotePlus(text) {
116
+ let result = '';
117
+ const bytes = new TextEncoder().encode(text);
118
+ for (const byte of bytes) {
119
+ const character = String.fromCodePoint(byte);
120
+ if (/[\w.~-]/u.test(character))
121
+ result += character;
122
+ else if (byte === 0x20)
123
+ result += '+';
124
+ else
125
+ result += `%${byte.toString(16).toUpperCase().padStart(2, '0')}`;
126
+ }
127
+ return result;
128
+ }
129
+ function queryValueText(value) {
130
+ if (value === undefined)
131
+ return '';
132
+ if (typeof value === 'boolean')
133
+ return value ? 'true' : 'false';
134
+ return String(value);
135
+ }
136
+ const ABSOLUTE_URL = /^[A-Za-z][\d+.A-Za-z-]*:\/\//u;
137
+ function buildUrl(base, target, parameters) {
138
+ const url = ABSOLUTE_URL.test(target) ? target : `${base}/${target.replace(/^\/+/u, '')}`;
139
+ if (parameters === undefined)
140
+ return url;
141
+ const query = Object.entries(parameters).map(([key, value]) => `${quotePlus(key)}=${quotePlus(queryValueText(value))}`).join('&');
142
+ // params を指定すると、URL に書かれたクエリは置き換わる。空の params は URL のクエリを消す(httpx と同じ)
143
+ const queryStart = url.indexOf('?');
144
+ const withoutQuery = queryStart === -1 ? url : url.slice(0, queryStart);
145
+ return query === '' ? withoutQuery : `${withoutQuery}?${query}`;
146
+ }
147
+ const LINK_STRIP = new Set([' ', '\'', '"']);
148
+ function stripCharacters(text, characters) {
149
+ let start = 0;
150
+ let end = text.length;
151
+ while (start < end && characters.has(text.charAt(start)))
152
+ start += 1;
153
+ while (end > start && characters.has(text.charAt(end - 1)))
154
+ end -= 1;
155
+ return text.slice(start, end);
156
+ }
157
+ // `key=value;key=value` を読む。要素が `=` で 2 つに割れなければ、そこで打ち切る
158
+ function parseLinkParameters(text) {
159
+ const parameters = new Map();
160
+ for (const parameter of text.split(';')) {
161
+ const pieces = parameter.split('=');
162
+ if (pieces.length !== 2)
163
+ return parameters;
164
+ parameters.set(stripCharacters(pieces[0] ?? '', LINK_STRIP), stripCharacters(pieces[1] ?? '', LINK_STRIP));
165
+ }
166
+ return parameters;
167
+ }
168
+ /**
169
+ Link ヘッダを httpx の Response.links と同じ規則で読む。キーは rel、無ければ url
170
+ */
171
+ function parseLinks(header = '') {
172
+ const links = new Map();
173
+ const value = stripCharacters(header, LINK_STRIP);
174
+ if (value === '')
175
+ return links;
176
+ const urlStrip = new Set([...LINK_STRIP, '<', '>']);
177
+ for (const part of value.split(/, *</u)) {
178
+ const semicolon = part.indexOf(';');
179
+ const url = stripCharacters(semicolon === -1 ? part : part.slice(0, semicolon), urlStrip);
180
+ const relation = parseLinkParameters(semicolon === -1 ? '' : part.slice(semicolon + 1)).get('rel');
181
+ links.set(relation === undefined || relation === '' ? url : relation, { url, rel: relation });
182
+ }
183
+ return links;
184
+ }
185
+ /**
186
+ REST の応答。Python の httpx.Response のうち、呼び出し側が使う部分
187
+ */
188
+ export class RestResponse {
189
+ headers;
190
+ statusCode;
191
+ statusText;
192
+ url;
193
+ text;
194
+ constructor(init) {
195
+ this.statusCode = init.statusCode;
196
+ this.statusText = init.statusText;
197
+ this.url = init.url;
198
+ this.text = init.text;
199
+ this.headers = init.headers;
200
+ }
201
+ /**
202
+ 状態コードが 2xx
203
+ */
204
+ get isSuccess() {
205
+ return this.statusCode >= 200 && this.statusCode < 300;
206
+ }
207
+ /**
208
+ ヘッダの値。名前は大文字小文字を区別しない
209
+ */
210
+ header(name) {
211
+ return this.headers.get(name.toLowerCase());
212
+ }
213
+ /**
214
+ Link ヘッダ。キーは rel(無ければ url)
215
+ */
216
+ get links() {
217
+ return parseLinks(this.header('link'));
218
+ }
219
+ /**
220
+ 本文を JSON として読む。不正なら InvalidValueError
221
+ */
222
+ json() {
223
+ return parseJsonText(this.text);
224
+ }
225
+ }
226
+ /**
227
+ gql の例外に当たる。分類には文ではなく、応答の状態コードと errors の type を使う
228
+ */
229
+ class GraphqlFailure extends BaseError {
230
+ statusCode;
231
+ errorType;
232
+ constructor(message, detail = {}) {
233
+ super(message, detail.cause === undefined ? undefined : { cause: detail.cause });
234
+ this.statusCode = detail.statusCode;
235
+ this.errorType = detail.errorType;
236
+ }
237
+ }
238
+ // errors[0] が辞書で type が文字列なら、その type
239
+ function firstErrorType(errors) {
240
+ const first = isJsonArray(errors) ? errors.at(0) : errors;
241
+ const type = isJsonObject(first) ? first['type'] : undefined;
242
+ return typeof type === 'string' ? type : undefined;
243
+ }
244
+ // gql の str_first_element。list は先頭、str は先頭の 1 文字、dict などは全体
245
+ function firstErrorText(errors) {
246
+ if (isJsonArray(errors)) {
247
+ const first = errors.at(0);
248
+ return first === undefined ? '' : pythonString(first);
249
+ }
250
+ return pythonString(typeof errors === 'string' ? splitCodePoints(errors).slice(0, 1).join('') : errors);
251
+ }
252
+ // data があり、errors のすべてが道筋を持って isTolerated を満たすとき、その errors。それ以外は undefined
253
+ function toleratedErrors(errors, data, isTolerated) {
254
+ if (isTolerated === undefined || !isJsonObject(data) || !isJsonArray(errors) || errors.length === 0)
255
+ return undefined;
256
+ const objects = errors.filter(error => isJsonObject(error));
257
+ const areAllTolerated = objects.length === errors.length && objects.every((error) => {
258
+ const path = error['path'];
259
+ return isJsonArray(path) && isTolerated(path);
260
+ });
261
+ return areAllTolerated ? objects : undefined;
262
+ }
263
+ // 認証エラーの判定。文に 401 が入っていても(Issue 番号の 401 など)、認証エラーにはしない
264
+ function isUnauthorized(failure) {
265
+ return failure.statusCode === 401 || failure.errorType === 'UNAUTHORIZED';
266
+ }
267
+ /**
268
+ レート制限の判定は、REST と GraphQL でこの 1 つを使う。
269
+ 状態が 429、GitHub の種類が RATE_LIMITED、または文に rate limit を含むとき
270
+ */
271
+ function isRateLimited(signal) {
272
+ return signal.statusCode === 429 || signal.errorType === 'RATE_LIMITED' || signal.text.toLowerCase().includes('rate limit');
273
+ }
274
+ function toGraphqlFailure(error) {
275
+ if (error instanceof GraphqlFailure)
276
+ return error;
277
+ return new GraphqlFailure(error instanceof Error ? error.message : pythonRepr(String(error)), { cause: error });
278
+ }
279
+ const DEFAULT_TIMEOUT_MILLISECONDS = 30_000;
280
+ // gh auth token は手元の資格情報を読むだけで、ネットワークを使わない。
281
+ // OS のキーチェーンの解錠待ちを見込んで 10 秒にする。それ以上かかるなら、無応答として認証エラーに倒す
282
+ const DEFAULT_GH_TIMEOUT_MILLISECONDS = 10_000;
283
+ /**
284
+ GitHub API クライアント(REST と GraphQL)。github.com と GHES に対応する。
285
+
286
+ トークンの優先順位は、token の指定、config/.env、ルート .env、gh auth token の順。
287
+ issues・pulls・projects・repos の操作は、次のメソッドを使って作る。
288
+ restJson・restObject・restRequest・handleHttpError・executeGraphql。
289
+ */
290
+ export class GitHubClientBase {
291
+ diagnostics;
292
+ usedFallback = false;
293
+ host;
294
+ token;
295
+ timeoutMilliseconds;
296
+ ghTimeoutMilliseconds;
297
+ apiUrl;
298
+ graphqlUrl;
299
+ /**
300
+ プロジェクトにリンクされたリポジトリの一覧のキャッシュ(`owner/projectNumber` がキー)
301
+ */
302
+ linkedRepositoriesCache = new Map();
303
+ constructor(options) {
304
+ this.diagnostics = options.diagnostics;
305
+ this.host = options.host ?? 'github.com';
306
+ this.ghTimeoutMilliseconds = options.ghTimeoutMilliseconds ?? DEFAULT_GH_TIMEOUT_MILLISECONDS;
307
+ this.token = options.token === undefined || options.token === '' ? this.resolveToken(this.host) : options.token;
308
+ this.timeoutMilliseconds = options.timeoutMilliseconds ?? DEFAULT_TIMEOUT_MILLISECONDS;
309
+ const override = resolveApiUrlOverride();
310
+ if (override !== undefined) {
311
+ this.apiUrl = override;
312
+ this.graphqlUrl = `${override}/graphql`;
313
+ }
314
+ else if (this.host === 'github.com') {
315
+ this.apiUrl = 'https://api.github.com';
316
+ this.graphqlUrl = 'https://api.github.com/graphql';
317
+ }
318
+ else {
319
+ this.apiUrl = `https://${this.host}/api/v3`;
320
+ this.graphqlUrl = `https://${this.host}/api/graphql`;
321
+ }
322
+ }
323
+ // config/.env → ルート .env → gh auth token の順
324
+ resolveToken(host) {
325
+ return this.tokenFromEnvironment(host) ?? this.tokenFromGh(host);
326
+ }
327
+ tokenFromEnvironment(host) {
328
+ loadEnvironmentFile(path.join(configDirectory(), '.env'));
329
+ const token = environmentValue(getEnvironmentVariableName(host));
330
+ if (token !== undefined && token !== '')
331
+ return token;
332
+ loadEnvironmentFile(path.join(projectRoot(), '.env'));
333
+ const rootName = ROOT_ENV_VAR_MAP.get(host);
334
+ if (rootName === undefined)
335
+ return undefined;
336
+ const rootToken = environmentValue(rootName);
337
+ return rootToken === undefined || rootToken === '' ? undefined : rootToken;
338
+ }
339
+ tokenFromGh(host) {
340
+ const arguments_ = host === 'github.com' ? ['auth', 'token'] : ['auth', 'token', '-h', host];
341
+ const result = spawnSync('gh', arguments_, { encoding: 'utf8', timeout: this.ghTimeoutMilliseconds });
342
+ // gh が無い・時間切れ(error)、終了コードが 0 でない、または出力が空
343
+ const token = result.error === undefined && result.status === 0 ? pythonStrip(result.stdout) : '';
344
+ if (token.length === 0)
345
+ throw new GitHubAuthError(this.authErrorMessage(host));
346
+ return token;
347
+ }
348
+ /**
349
+ 認証エラーの文を作る。.env が無ければ生成し、あるときはホストの変数が無ければ追記する
350
+ */
351
+ authErrorMessage(host) {
352
+ const file = ensureEnvironmentFile(host);
353
+ const scopes = scopesFor(host);
354
+ const scopesLine = scopes.length > 0 ? ` required scopes: ${scopes.join(', ')}` : '';
355
+ return `authentication error: could not get a GitHub API token
356
+
357
+ ${file} was generated. Set the token as follows:
358
+
359
+ 1. get a token: ${tokenUrlFor(host)}
360
+ ${scopesLine}
361
+
362
+ 2. edit ${file} and set the token in ${getEnvironmentVariableName(host)}
363
+
364
+ or authenticate with the GitHub CLI:
365
+ gh auth login -h ${host}`;
366
+ }
367
+ // github.com は Bearer、GHE Server は token(gh CLI 互換)
368
+ requestHeaders() {
369
+ return {
370
+ 'Authorization': `${this.host === 'github.com' ? 'Bearer' : 'token'} ${this.token}`,
371
+ 'Accept': 'application/vnd.github+json',
372
+ 'X-GitHub-Api-Version': '2022-11-28',
373
+ };
374
+ }
375
+ /**
376
+ env のトークンが失効したとき、gh auth token に 1 回だけ切り替える。切り替えたら true
377
+ */
378
+ retryWithFallbackToken() {
379
+ if (this.usedFallback)
380
+ return false;
381
+ this.usedFallback = true;
382
+ let newToken;
383
+ try {
384
+ newToken = this.tokenFromGh(this.host);
385
+ }
386
+ catch (error) {
387
+ if (error instanceof GitHubAuthError)
388
+ return false;
389
+ throw error;
390
+ }
391
+ if (newToken === this.token)
392
+ return false;
393
+ this.diagnostics.warning(TOKEN_FALLBACK_WARNING);
394
+ this.token = newToken;
395
+ return true;
396
+ }
397
+ async send(method, url, headers, body) {
398
+ try {
399
+ const response = await fetch(url, {
400
+ method,
401
+ headers,
402
+ ...(body !== undefined && { body }),
403
+ redirect: 'manual',
404
+ signal: AbortSignal.timeout(this.timeoutMilliseconds),
405
+ });
406
+ const text = await response.text();
407
+ return new RestResponse({
408
+ statusCode: response.status,
409
+ statusText: response.statusText,
410
+ url: response.url === '' ? url : response.url,
411
+ text,
412
+ headers: new Map(response.headers),
413
+ });
414
+ }
415
+ catch (error) {
416
+ throw new TransportFailure(describeTransportFailure(error), { cause: error });
417
+ }
418
+ }
419
+ async sendRest(method, url, json) {
420
+ const headers = json === undefined ? this.requestHeaders() : { ...this.requestHeaders(), 'Content-Type': 'application/json' };
421
+ return this.send(method, url, headers, json === undefined ? undefined : JSON.stringify(json));
422
+ }
423
+ // gql の HTTPXTransport.execute と同じ 4 つの失敗の文を作る。成功したら data と、許した errors
424
+ async sendGraphql(query, variables, isTolerated) {
425
+ let response;
426
+ try {
427
+ response = await this.send('POST', this.graphqlUrl, { ...this.requestHeaders(), 'Content-Type': 'application/json' }, JSON.stringify({ query, variables }));
428
+ }
429
+ catch (error) {
430
+ throw new GraphqlFailure(error instanceof Error ? error.message : String(error), { cause: error });
431
+ }
432
+ const { statusCode } = response;
433
+ // JSON でない応答。2xx 以外は httpx の状態の文、2xx は gql の文
434
+ const raiseResponseError = (reason) => {
435
+ if (!response.isSuccess) {
436
+ throw new GraphqlFailure(formatHttpStatusError({
437
+ statusCode: response.statusCode,
438
+ statusText: response.statusText,
439
+ url: response.url,
440
+ location: response.header('location'),
441
+ }), { statusCode });
442
+ }
443
+ throw new GraphqlFailure(`Server did not return a GraphQL result: ${reason}: ${response.text}`, { statusCode });
444
+ };
445
+ let result;
446
+ try {
447
+ result = response.json();
448
+ }
449
+ catch {
450
+ return raiseResponseError('Not a JSON answer');
451
+ }
452
+ // "errors" not in result and "data" not in result。オブジェクトはキーの有無、配列と文字列は「含まない」とみなす
453
+ if (result === null || typeof result === 'number' || typeof result === 'boolean') {
454
+ throw new GraphqlFailure(`argument of type '${pythonTypeName(result)}' is not a container or iterable`, { statusCode });
455
+ }
456
+ const object = isJsonObject(result) ? result : {};
457
+ if (!Object.hasOwn(object, 'errors') && !Object.hasOwn(object, 'data')) {
458
+ return raiseResponseError('No "data" or "errors" keys in answer');
459
+ }
460
+ // errors は status を問わず先頭の要素の文になる。許す errors(isTolerated)だけで data もあるときは、data と一緒に返す
461
+ const errors = object['errors'];
462
+ const data = object['data'];
463
+ const tolerated = toleratedErrors(errors, data, isTolerated);
464
+ if (tolerated === undefined && errors !== undefined && isTruthy(errors))
465
+ throw new GraphqlFailure(firstErrorText(errors), { statusCode, errorType: firstErrorType(errors) });
466
+ if (data === undefined || data === null)
467
+ throw new GraphqlFailure('Transport returned an ExecutionResult without data or errors', { statusCode });
468
+ return { data: isJsonObject(data) ? data : {}, errors: tolerated ?? [] };
469
+ }
470
+ classifyGraphqlFailure(failure) {
471
+ const { message } = failure;
472
+ const detail = { cause: failure };
473
+ if (isUnauthorized(failure))
474
+ return new GitHubAuthError(`GraphQL authentication error: ${message}`, detail);
475
+ if (isRateLimited({ statusCode: failure.statusCode, errorType: failure.errorType, text: message })) {
476
+ return new GitHubRateLimitError(`GraphQL rate limit error: ${message}`, detail);
477
+ }
478
+ return new GitHubAPIError(`GraphQL query error: ${message}`, detail);
479
+ }
480
+ async runGraphql(query, variables, isTolerated) {
481
+ try {
482
+ return await this.sendGraphql(query, variables, isTolerated);
483
+ }
484
+ catch (error) {
485
+ const failure = toGraphqlFailure(error);
486
+ if (!isUnauthorized(failure))
487
+ throw this.classifyGraphqlFailure(failure);
488
+ if (!this.retryWithFallbackToken())
489
+ throw new GitHubAuthError(`GraphQL authentication error: ${failure.message}`, { cause: failure });
490
+ try {
491
+ return await this.sendGraphql(query, variables, isTolerated);
492
+ }
493
+ catch (retryError) {
494
+ throw this.classifyGraphqlFailure(toGraphqlFailure(retryError));
495
+ }
496
+ }
497
+ }
498
+ // 絶対 URL(Link ヘッダの next など)は、API と同じ origin だけを辿る。
499
+ // 別のホストへ Authorization を付けて送らないため
500
+ assertSameOrigin(target) {
501
+ if (!ABSOLUTE_URL.test(target))
502
+ return;
503
+ if (URL.canParse(target) && new URL(target).origin === new URL(this.apiUrl).origin)
504
+ return;
505
+ throw new GitHubAPIError(`refusing to follow a URL on a different host than the API: ${target}`);
506
+ }
507
+ /**
508
+ REST の要求(401 のときは gh auth token に切り替えて 1 回だけ再試行する)。
509
+ target は `/user` のようなパス(base の後ろにつなぐ)か、`https://` で始まる絶対 URL(Link ヘッダの next など)。
510
+ 失敗の状態コードは例外にせず、そのまま返す。呼び出し側が isSuccess を見て handleHttpError に渡す
511
+ */
512
+ async restRequest(method, target, options = {}) {
513
+ this.assertSameOrigin(target);
514
+ const url = buildUrl(this.apiUrl, target, options.params);
515
+ const response = await this.sendRest(method, url, options.json);
516
+ return response.statusCode === 401 && this.retryWithFallbackToken() ? this.sendRest(method, url, options.json) : response;
517
+ }
518
+ /**
519
+ REST の要求を送り、成功した応答の JSON を返す。失敗の応答は handleHttpError の例外にする。
520
+ 本文が無い応答(204 など)には使わない
521
+ */
522
+ async restJson(method, target, options = {}) {
523
+ const response = await this.restRequest(method, target, options);
524
+ if (!response.isSuccess)
525
+ this.handleHttpError(response);
526
+ return response.json();
527
+ }
528
+ /**
529
+ restJson の結果をオブジェクトとして返す(オブジェクトでなければ空のオブジェクト。Python の as_dict と同じ)
530
+ */
531
+ async restObject(method, target, options = {}) {
532
+ return asObject(await this.restJson(method, target, options));
533
+ }
534
+ /**
535
+ HTTP エラーの応答を、状態コード別の例外にして投げる
536
+ */
537
+ handleHttpError(response) {
538
+ const detail = { statusCode: response.statusCode, responseBody: response.text };
539
+ if (response.statusCode === 401) {
540
+ throw new GitHubAuthError('authentication failed: check the token', detail);
541
+ }
542
+ if (response.statusCode === 404) {
543
+ throw new GitHubNotFoundError(`resource not found: ${response.url}`, detail);
544
+ }
545
+ if (response.statusCode === 429 || (response.statusCode === 403 && isRateLimited({ statusCode: 403, text: response.text }))) {
546
+ throw new GitHubRateLimitError('API rate limit reached', detail);
547
+ }
548
+ if (response.statusCode === 403) {
549
+ throw new GitHubAPIError('access denied', detail);
550
+ }
551
+ throw new GitHubAPIError(`GitHub API error: ${String(response.statusCode)}`, detail);
552
+ }
553
+ /**
554
+ GraphQL を実行する。失敗は応答の状態コードと errors の type で分類する。
555
+ 状態が 401(または type が UNAUTHORIZED)は GitHubAuthError。gh auth token に 1 回切り替えて再試行する。
556
+ レート制限は GitHubRateLimitError、それ以外は GitHubAPIError
557
+ */
558
+ async executeGraphql(query, variables = {}) {
559
+ const { data } = await this.runGraphql(query, variables);
560
+ return data;
561
+ }
562
+ /**
563
+ executeGraphql の、部分エラーを許す版。data があり、errors のすべてが isTolerated を満たすとき、例外にせず data と errors を返す。
564
+ それ以外の errors は executeGraphql と同じ例外になる
565
+ */
566
+ async executeGraphqlTolerating(query, variables, isTolerated) {
567
+ return this.runGraphql(query, variables, isTolerated);
568
+ }
569
+ /**
570
+ 認証ユーザーの情報(login・id・name・email など)
571
+ */
572
+ async getAuthenticatedUser() {
573
+ return this.restJson('GET', '/user');
574
+ }
575
+ }
576
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,13 @@
1
+ import type { DependabotAlert, DependabotSource } from '../../domain/dependabot-source.js';
2
+ /**
3
+ 取得に使うクライアントの操作。ReposApi(GitHubClient)が満たす
4
+ */
5
+ export interface DependabotClient {
6
+ readonly isDependabotAlertsEnabled: (owner: string, repository: string) => Promise<boolean>;
7
+ readonly listOpenDependabotAlerts: (owner: string, repository: string) => Promise<readonly DependabotAlert[]>;
8
+ }
9
+ /**
10
+ GitHub のクライアントから DependabotSource を作る
11
+ */
12
+ export declare function createDependabotSource(client: DependabotClient): DependabotSource;
13
+ //# sourceMappingURL=dependabot-source.d.ts.map
@@ -0,0 +1,33 @@
1
+ // Dependabot alert の取得元を、GitHub の REST で満たす実体。型は domain/dependabot-source.ts の DependabotSource。
2
+ // 例外を結果の種類(kind)に直す。レート制限は rateLimited、その他の 403 は forbidden、他の API エラーは failure。
3
+ // 通信の失敗は network にする。
4
+ import { TransportFailure } from './client.js';
5
+ import { GitHubAPIError, GitHubRateLimitError } from './errors.js';
6
+ const FORBIDDEN = 403;
7
+ function failureOf(error) {
8
+ return { message: error.message, statusCode: error.statusCode, responseBody: error.responseBody };
9
+ }
10
+ async function capture(action) {
11
+ try {
12
+ return { kind: 'ok', value: await action() };
13
+ }
14
+ catch (error) {
15
+ if (error instanceof GitHubRateLimitError)
16
+ return { kind: 'rateLimited', failure: failureOf(error) };
17
+ if (error instanceof GitHubAPIError)
18
+ return { kind: error.statusCode === FORBIDDEN ? 'forbidden' : 'failure', failure: failureOf(error) };
19
+ if (error instanceof TransportFailure)
20
+ return { kind: 'network', message: error.message };
21
+ throw error;
22
+ }
23
+ }
24
+ /**
25
+ GitHub のクライアントから DependabotSource を作る
26
+ */
27
+ export function createDependabotSource(client) {
28
+ return {
29
+ listOpenAlerts: async (owner, repository) => capture(async () => client.listOpenDependabotAlerts(owner, repository)),
30
+ isAlertsEnabled: async (owner, repository) => capture(async () => client.isDependabotAlertsEnabled(owner, repository)),
31
+ };
32
+ }
33
+ //# sourceMappingURL=dependabot-source.js.map
@@ -0,0 +1,47 @@
1
+ import { PecotError } from '../../domain/errors.js';
2
+ export interface GitHubErrorDetail {
3
+ /**
4
+ HTTP の状態コード(該当する場合)
5
+ */
6
+ readonly statusCode?: number | undefined;
7
+ /**
8
+ 応答の本文(該当する場合)
9
+ */
10
+ readonly responseBody?: string | undefined;
11
+ /**
12
+ 元の例外
13
+ */
14
+ readonly cause?: unknown;
15
+ }
16
+ /**
17
+ GitHub API 操作エラーの基底
18
+ */
19
+ export declare class GitHubAPIError extends PecotError {
20
+ readonly statusCode: number | undefined;
21
+ readonly responseBody: string | undefined;
22
+ constructor(message: string, detail?: Readonly<GitHubErrorDetail>);
23
+ }
24
+ /**
25
+ 認証エラー(401 Unauthorized)。トークンが無効または期限切れのときに起きる
26
+ */
27
+ export declare class GitHubAuthError extends GitHubAPIError {
28
+ }
29
+ /**
30
+ リソースが見つからない(404 Not Found)。指定したリポジトリ・Issue・プロジェクトが無いときに起きる
31
+ */
32
+ export declare class GitHubNotFoundError extends GitHubAPIError {
33
+ }
34
+ /**
35
+ レート制限エラー(403 Forbidden で rate limit を超えたとき)
36
+ */
37
+ export declare class GitHubRateLimitError extends GitHubAPIError {
38
+ }
39
+ /**
40
+ このエラーが、ブランチ(ref)がもう無いことを表すか。`Reference does not exist` を含む 404・422 だけを「無い」と見なす
41
+ */
42
+ export declare function isMissingReferenceError(error: Readonly<GitHubAPIError>): boolean;
43
+ /**
44
+ 別の要求が同時に閉じたことを示す 422 か(PR の Closes による自動 close など)
45
+ */
46
+ export declare function isClosedByAnotherRequest(error: Readonly<GitHubAPIError>): boolean;
47
+ //# sourceMappingURL=errors.d.ts.map