@vigylx/mcp-servers 0.0.0-stage → 0.2.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.
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * The decisions a Firestore query makes before it touches the network.
4
+ *
5
+ * Separated from the server so they can be tested without credentials: what
6
+ * counts as a legal collection name, how big a page may be, and where "today"
7
+ * starts.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.WHERE_OPERATORS = exports.MAX_AUTH_PAGES = exports.DEFAULT_LIMIT = exports.MAX_LIMIT = void 0;
11
+ exports.clampLimit = clampLimit;
12
+ exports.isAllowedCollection = isAllowedCollection;
13
+ exports.startOfToday = startOfToday;
14
+ exports.isValidTimeZone = isValidTimeZone;
15
+ /** A page bigger than this is rarely read and always expensive. */
16
+ exports.MAX_LIMIT = 100;
17
+ exports.DEFAULT_LIMIT = 10;
18
+ /**
19
+ * Pages of 1,000 Auth users to walk before giving up.
20
+ *
21
+ * `listUsers` is the only way to count, and on a large project it never ends.
22
+ * The count is reported as "at least" when the cap is hit, rather than pretending
23
+ * to be exact or hanging the command.
24
+ */
25
+ exports.MAX_AUTH_PAGES = 20;
26
+ function clampLimit(requested) {
27
+ if (requested === undefined || !Number.isFinite(requested))
28
+ return exports.DEFAULT_LIMIT;
29
+ return Math.min(exports.MAX_LIMIT, Math.max(1, Math.floor(requested)));
30
+ }
31
+ /**
32
+ * Is this a collection the server will read?
33
+ *
34
+ * Firestore accepts a slash-separated path, so `users/u1/sessions` is a valid
35
+ * collection reference — and so is anything else with an odd number of
36
+ * segments. Allowing a free-form path would let a prompt walk the whole
37
+ * database a level at a time, so only plain names and explicit subcollection
38
+ * paths of known shape are accepted, and nothing with traversal in it.
39
+ */
40
+ function isAllowedCollection(name) {
41
+ if (name === '' || name.length > 200)
42
+ return false;
43
+ if (name.startsWith('/') || name.endsWith('/'))
44
+ return false;
45
+ if (name.includes('//'))
46
+ return false;
47
+ const segments = name.split('/');
48
+ if (segments.length % 2 === 0)
49
+ return false; // even = a document, not a collection
50
+ if (segments.length > 5)
51
+ return false;
52
+ return segments.every((segment) => /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(segment) && segment !== '..');
53
+ }
54
+ exports.WHERE_OPERATORS = ['==', '!=', '<', '<=', '>', '>='];
55
+ /**
56
+ * The start of today, in a named IANA zone.
57
+ *
58
+ * "How many users signed up today?" is asked by a person in a place. The server
59
+ * runs wherever it runs, and on a UTC box the answer is wrong for most of the
60
+ * day in Asia — by 05:30 for the operator of this project.
61
+ */
62
+ function startOfToday(timeZone, now = new Date()) {
63
+ const parts = new Intl.DateTimeFormat('en-CA', {
64
+ timeZone,
65
+ year: 'numeric',
66
+ month: '2-digit',
67
+ day: '2-digit',
68
+ hour: '2-digit',
69
+ minute: '2-digit',
70
+ second: '2-digit',
71
+ hour12: false,
72
+ }).formatToParts(now);
73
+ const get = (type) => Number(parts.find((part) => part.type === type)?.value ?? 0);
74
+ // Midnight local, expressed as the instant it happened.
75
+ const elapsedMs = (get('hour') % 24) * 3_600_000 + get('minute') * 60_000 + get('second') * 1_000;
76
+ return new Date(now.getTime() - elapsedMs - now.getMilliseconds());
77
+ }
78
+ /** Reject a time zone the platform does not know, rather than silently using UTC. */
79
+ function isValidTimeZone(timeZone) {
80
+ try {
81
+ new Intl.DateTimeFormat('en-US', { timeZone });
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GitHub MCP server.
4
+ *
5
+ * Five tools: three that read (open PRs, CI status, recent commits) and two
6
+ * that act (trigger a workflow, open an issue).
7
+ *
8
+ * The two that act are marked `readOnlyHint: false` in their MCP annotations,
9
+ * which is the hook the daemon's approval gate keys off — a model asking to
10
+ * deploy should reach Approve/Deny buttons, not GitHub. Until that wiring lands
11
+ * (days 13–14) they are gated by `GITHUB_ALLOW_WRITES`, because an MCP server
12
+ * that can dispatch a production workflow is one prompt injection away from
13
+ * doing it, and a Firestore document or an issue title is written by somebody
14
+ * else.
15
+ */
16
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
17
+ /**
18
+ * The slice of Octokit used here.
19
+ *
20
+ * Declared rather than imported so the tests can pass a fake and the package
21
+ * typechecks without the optional dependency installed.
22
+ */
23
+ export interface GitHubApi {
24
+ pulls: {
25
+ list(params: Record<string, unknown>): Promise<{
26
+ data: PullRequest[];
27
+ }>;
28
+ };
29
+ checks: {
30
+ listForRef(params: Record<string, unknown>): Promise<{
31
+ data: {
32
+ check_runs: CheckRun[];
33
+ };
34
+ }>;
35
+ };
36
+ repos: {
37
+ listCommits(params: Record<string, unknown>): Promise<{
38
+ data: Commit[];
39
+ }>;
40
+ };
41
+ actions: {
42
+ createWorkflowDispatch(params: Record<string, unknown>): Promise<unknown>;
43
+ };
44
+ issues: {
45
+ create(params: Record<string, unknown>): Promise<{
46
+ data: {
47
+ number: number;
48
+ html_url: string;
49
+ };
50
+ }>;
51
+ };
52
+ }
53
+ interface PullRequest {
54
+ number: number;
55
+ title: string;
56
+ state: string;
57
+ draft?: boolean;
58
+ user?: {
59
+ login?: string;
60
+ } | null;
61
+ created_at: string;
62
+ updated_at: string;
63
+ html_url: string;
64
+ head?: {
65
+ ref?: string;
66
+ sha?: string;
67
+ };
68
+ base?: {
69
+ ref?: string;
70
+ };
71
+ }
72
+ interface CheckRun {
73
+ name: string;
74
+ status?: string | null;
75
+ conclusion?: string | null;
76
+ started_at?: string | null;
77
+ completed_at?: string | null;
78
+ html_url?: string | null;
79
+ }
80
+ interface Commit {
81
+ sha: string;
82
+ commit: {
83
+ message: string;
84
+ author?: {
85
+ name?: string;
86
+ date?: string;
87
+ } | null;
88
+ };
89
+ html_url: string;
90
+ }
91
+ /** Writes are off unless the operator turns them on. */
92
+ export declare function writesAllowed(env?: Record<string, string | undefined>): boolean;
93
+ export declare function registerGitHubTools(server: McpServer, api: GitHubApi, env?: Record<string, string | undefined>): void;
94
+ /**
95
+ * Say what went wrong without relaying GitHub's own error.
96
+ *
97
+ * A raw Octokit error includes the request URL and headers, which carry the
98
+ * token's scopes and sometimes the token itself in a retry context.
99
+ */
100
+ export declare function describeGitHubError(error: unknown, subject: string): string;
101
+ /**
102
+ * Build an Octokit client.
103
+ *
104
+ * `@octokit/rest` v22 is ESM-only with no CommonJS build. `require()` happens to
105
+ * work on Node 22.12+ through require(esm), but this package supports Node 20,
106
+ * where it throws ERR_REQUIRE_ESM — so it is reached by dynamic import, built
107
+ * with `new Function` because TypeScript rewrites `import()` to `require()`
108
+ * under `module: commonjs`.
109
+ *
110
+ * The token is optional: public repositories answer without one, at a lower
111
+ * rate limit.
112
+ */
113
+ export declare function createOctokit(env?: Record<string, string | undefined>): Promise<GitHubApi>;
114
+ export {};
115
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,347 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.writesAllowed = writesAllowed;
5
+ exports.registerGitHubTools = registerGitHubTools;
6
+ exports.describeGitHubError = describeGitHubError;
7
+ exports.createOctokit = createOctokit;
8
+ /**
9
+ * GitHub MCP server.
10
+ *
11
+ * Five tools: three that read (open PRs, CI status, recent commits) and two
12
+ * that act (trigger a workflow, open an issue).
13
+ *
14
+ * The two that act are marked `readOnlyHint: false` in their MCP annotations,
15
+ * which is the hook the daemon's approval gate keys off — a model asking to
16
+ * deploy should reach Approve/Deny buttons, not GitHub. Until that wiring lands
17
+ * (days 13–14) they are gated by `GITHUB_ALLOW_WRITES`, because an MCP server
18
+ * that can dispatch a production workflow is one prompt injection away from
19
+ * doing it, and a Firestore document or an issue title is written by somebody
20
+ * else.
21
+ */
22
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
23
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
24
+ const zod_1 = require("zod");
25
+ const untrusted_1 = require("../shared/untrusted");
26
+ const repo_1 = require("./repo");
27
+ const SERVER_NAME = 'vigyl-github';
28
+ const VERSION = '0.2.0';
29
+ /** Writes are off unless the operator turns them on. */
30
+ function writesAllowed(env = process.env) {
31
+ const value = env.GITHUB_ALLOW_WRITES?.trim().toLowerCase();
32
+ return value === '1' || value === 'true' || value === 'yes';
33
+ }
34
+ const WRITES_DISABLED = 'Writing to GitHub is disabled. Set GITHUB_ALLOW_WRITES=true to enable it — ' +
35
+ 'and note that until the approval gate is wired to these tools, nothing will ' +
36
+ 'ask before it runs.';
37
+ function registerGitHubTools(server, api, env = process.env) {
38
+ const registerTool = server.registerTool.bind(server);
39
+ const target = (args) => (0, repo_1.resolveTarget)(args, env);
40
+ const repoShape = {
41
+ owner: zod_1.z.string().optional().describe('Repository owner. Defaults to GITHUB_REPO.'),
42
+ repo: zod_1.z.string().optional().describe('Repository name. Defaults to GITHUB_REPO.'),
43
+ };
44
+ registerTool('list_prs', {
45
+ title: 'List pull requests',
46
+ description: `Pull requests for a repository, most recently updated first. Up to ${repo_1.MAX_PER_PAGE}.`,
47
+ inputSchema: {
48
+ ...repoShape,
49
+ state: zod_1.z.enum(['open', 'closed', 'all']).optional().describe('Default open.'),
50
+ limit: zod_1.z.number().int().optional().describe(`Default ${repo_1.DEFAULT_PER_PAGE}, max ${repo_1.MAX_PER_PAGE}.`),
51
+ },
52
+ annotations: { readOnlyHint: true },
53
+ }, async (raw) => {
54
+ const args = raw;
55
+ let where;
56
+ try {
57
+ where = target(args);
58
+ }
59
+ catch (error) {
60
+ return (0, untrusted_1.errorResult)(error.message);
61
+ }
62
+ try {
63
+ const { data } = await api.pulls.list({
64
+ ...where,
65
+ state: args.state ?? 'open',
66
+ sort: 'updated',
67
+ direction: 'desc',
68
+ per_page: (0, repo_1.clampPerPage)(args.limit),
69
+ });
70
+ return (0, untrusted_1.dataResult)(`github ${where.owner}/${where.repo} pull requests`, {
71
+ repository: `${where.owner}/${where.repo}`,
72
+ state: args.state ?? 'open',
73
+ count: data.length,
74
+ pullRequests: data.map((pr) => ({
75
+ number: pr.number,
76
+ title: pr.title,
77
+ author: pr.user?.login ?? 'unknown',
78
+ state: pr.state,
79
+ draft: pr.draft === true,
80
+ branch: pr.head?.ref,
81
+ into: pr.base?.ref,
82
+ updatedAt: pr.updated_at,
83
+ url: pr.html_url,
84
+ })),
85
+ });
86
+ }
87
+ catch (error) {
88
+ return (0, untrusted_1.errorResult)(describeGitHubError(error, `${where.owner}/${where.repo}`));
89
+ }
90
+ });
91
+ registerTool('ci_status', {
92
+ title: 'CI status',
93
+ description: 'Whether checks passed for a branch, tag or commit. Says "no checks" ' +
94
+ 'when none ran, which is not the same as passing.',
95
+ inputSchema: {
96
+ ...repoShape,
97
+ ref: zod_1.z.string().optional().describe('Branch, tag or SHA. Default main.'),
98
+ },
99
+ annotations: { readOnlyHint: true },
100
+ }, async (raw) => {
101
+ const args = raw;
102
+ let where;
103
+ try {
104
+ where = target(args);
105
+ }
106
+ catch (error) {
107
+ return (0, untrusted_1.errorResult)(error.message);
108
+ }
109
+ const ref = args.ref?.trim() || 'main';
110
+ if (!(0, repo_1.isValidRef)(ref))
111
+ return (0, untrusted_1.errorResult)(`"${ref}" is not a valid git ref.`);
112
+ try {
113
+ const { data } = await api.checks.listForRef({ ...where, ref, per_page: repo_1.MAX_PER_PAGE });
114
+ const summary = (0, repo_1.summariseChecks)(data.check_runs);
115
+ return (0, untrusted_1.dataResult)(`github ${where.owner}/${where.repo} checks for ${ref}`, {
116
+ repository: `${where.owner}/${where.repo}`,
117
+ ref,
118
+ verdict: summary.verdict,
119
+ counts: {
120
+ total: summary.total,
121
+ passed: summary.passed,
122
+ failed: summary.failed,
123
+ running: summary.running,
124
+ skipped: summary.skipped,
125
+ },
126
+ checks: data.check_runs.map((run) => ({
127
+ name: run.name,
128
+ status: run.status,
129
+ conclusion: run.conclusion,
130
+ completedAt: run.completed_at,
131
+ url: run.html_url,
132
+ })),
133
+ });
134
+ }
135
+ catch (error) {
136
+ return (0, untrusted_1.errorResult)(describeGitHubError(error, `${where.owner}/${where.repo}@${ref}`));
137
+ }
138
+ });
139
+ registerTool('recent_commits', {
140
+ title: 'Recent commits',
141
+ description: 'The latest commits on a branch, newest first.',
142
+ inputSchema: {
143
+ ...repoShape,
144
+ branch: zod_1.z.string().optional().describe('Default main.'),
145
+ limit: zod_1.z.number().int().optional().describe(`Default ${repo_1.DEFAULT_COMMITS}, max ${repo_1.MAX_PER_PAGE}.`),
146
+ },
147
+ annotations: { readOnlyHint: true },
148
+ }, async (raw) => {
149
+ const args = raw;
150
+ let where;
151
+ try {
152
+ where = target(args);
153
+ }
154
+ catch (error) {
155
+ return (0, untrusted_1.errorResult)(error.message);
156
+ }
157
+ const branch = args.branch?.trim() || 'main';
158
+ if (!(0, repo_1.isValidRef)(branch))
159
+ return (0, untrusted_1.errorResult)(`"${branch}" is not a valid branch name.`);
160
+ try {
161
+ const { data } = await api.repos.listCommits({
162
+ ...where,
163
+ sha: branch,
164
+ per_page: (0, repo_1.clampPerPage)(args.limit, repo_1.DEFAULT_COMMITS),
165
+ });
166
+ return (0, untrusted_1.dataResult)(`github ${where.owner}/${where.repo} commits on ${branch}`, {
167
+ repository: `${where.owner}/${where.repo}`,
168
+ branch,
169
+ count: data.length,
170
+ commits: data.map((commit) => ({
171
+ sha: commit.sha.slice(0, 7),
172
+ // First line only: a commit body can be hundreds of lines, and
173
+ // this goes into a prompt.
174
+ message: commit.commit.message.split(String.fromCharCode(10))[0],
175
+ author: commit.commit.author?.name ?? 'unknown',
176
+ date: commit.commit.author?.date,
177
+ url: commit.html_url,
178
+ })),
179
+ });
180
+ }
181
+ catch (error) {
182
+ return (0, untrusted_1.errorResult)(describeGitHubError(error, `${where.owner}/${where.repo}@${branch}`));
183
+ }
184
+ });
185
+ registerTool('trigger_workflow', {
186
+ title: 'Trigger a GitHub Actions workflow',
187
+ description: 'Dispatch a workflow. This runs real CI and can deploy. Requires ' +
188
+ 'GITHUB_ALLOW_WRITES and a token with workflow scope.',
189
+ inputSchema: {
190
+ ...repoShape,
191
+ workflowId: zod_1.z.string().describe('Workflow file name, e.g. deploy.yml, or its numeric id.'),
192
+ ref: zod_1.z.string().optional().describe('Branch or tag to run on. Default main.'),
193
+ inputs: zod_1.z.record(zod_1.z.string()).optional().describe('Workflow inputs.'),
194
+ },
195
+ // The daemon's approval gate keys off this: not read-only, and it causes
196
+ // something to happen that cannot be taken back.
197
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
198
+ }, async (raw) => {
199
+ const args = raw;
200
+ if (!writesAllowed(env))
201
+ return (0, untrusted_1.errorResult)(WRITES_DISABLED);
202
+ let where;
203
+ try {
204
+ where = target(args);
205
+ }
206
+ catch (error) {
207
+ return (0, untrusted_1.errorResult)(error.message);
208
+ }
209
+ const workflowId = args.workflowId?.trim() ?? '';
210
+ if (!(0, repo_1.isValidWorkflowId)(workflowId)) {
211
+ return (0, untrusted_1.errorResult)(`"${workflowId}" is not a workflow file name or id.`);
212
+ }
213
+ const ref = args.ref?.trim() || 'main';
214
+ if (!(0, repo_1.isValidRef)(ref))
215
+ return (0, untrusted_1.errorResult)(`"${ref}" is not a valid git ref.`);
216
+ try {
217
+ await api.actions.createWorkflowDispatch({
218
+ ...where,
219
+ workflow_id: workflowId,
220
+ ref,
221
+ inputs: args.inputs ?? {},
222
+ });
223
+ return (0, untrusted_1.dataResult)(`github ${where.owner}/${where.repo} workflow dispatched`, {
224
+ repository: `${where.owner}/${where.repo}`,
225
+ workflow: workflowId,
226
+ ref,
227
+ dispatched: true,
228
+ // Dispatch returns 204 with no body, so there is no run id to report.
229
+ note: 'GitHub accepted the dispatch. Use ci_status to see the result.',
230
+ });
231
+ }
232
+ catch (error) {
233
+ return (0, untrusted_1.errorResult)(describeGitHubError(error, `${where.owner}/${where.repo} ${workflowId}`));
234
+ }
235
+ });
236
+ registerTool('create_issue', {
237
+ title: 'Open an issue',
238
+ description: 'Create a GitHub issue. Requires GITHUB_ALLOW_WRITES.',
239
+ inputSchema: {
240
+ ...repoShape,
241
+ title: zod_1.z.string().describe('Issue title.'),
242
+ body: zod_1.z.string().optional().describe('Issue body, markdown.'),
243
+ labels: zod_1.z.array(zod_1.z.string()).optional().describe('Labels to apply.'),
244
+ },
245
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
246
+ }, async (raw) => {
247
+ const args = raw;
248
+ if (!writesAllowed(env))
249
+ return (0, untrusted_1.errorResult)(WRITES_DISABLED);
250
+ let where;
251
+ try {
252
+ where = target(args);
253
+ }
254
+ catch (error) {
255
+ return (0, untrusted_1.errorResult)(error.message);
256
+ }
257
+ const title = args.title?.trim() ?? '';
258
+ if (title === '')
259
+ return (0, untrusted_1.errorResult)('An issue needs a title.');
260
+ if (title.length > 256)
261
+ return (0, untrusted_1.errorResult)('That issue title is too long (max 256 characters).');
262
+ try {
263
+ const { data } = await api.issues.create({
264
+ ...where,
265
+ title,
266
+ body: args.body,
267
+ labels: args.labels,
268
+ });
269
+ return (0, untrusted_1.dataResult)(`github ${where.owner}/${where.repo} issue created`, {
270
+ repository: `${where.owner}/${where.repo}`,
271
+ number: data.number,
272
+ url: data.html_url,
273
+ });
274
+ }
275
+ catch (error) {
276
+ return (0, untrusted_1.errorResult)(describeGitHubError(error, `${where.owner}/${where.repo}`));
277
+ }
278
+ });
279
+ }
280
+ /**
281
+ * Say what went wrong without relaying GitHub's own error.
282
+ *
283
+ * A raw Octokit error includes the request URL and headers, which carry the
284
+ * token's scopes and sometimes the token itself in a retry context.
285
+ */
286
+ function describeGitHubError(error, subject) {
287
+ const status = error.status;
288
+ const message = String(error?.message ?? error);
289
+ switch (status) {
290
+ case 401:
291
+ return 'GitHub rejected the token. Check GITHUB_TOKEN is set and has not expired.';
292
+ case 403:
293
+ if (/rate limit/i.test(message)) {
294
+ return 'GitHub rate limit reached. Wait a few minutes, or set GITHUB_TOKEN to raise the limit.';
295
+ }
296
+ return `The token is not allowed to do that on ${subject}. Check its scopes.`;
297
+ case 404:
298
+ return `Not found: ${subject}. Either it does not exist or the token cannot see it.`;
299
+ case 422:
300
+ return `GitHub refused that as invalid for ${subject}. A workflow must have a workflow_dispatch trigger to be dispatched.`;
301
+ default:
302
+ break;
303
+ }
304
+ if (/ENOTFOUND|ECONNREFUSED|ETIMEDOUT|network/i.test(message)) {
305
+ return 'Could not reach GitHub. Check the network and try again.';
306
+ }
307
+ return `The GitHub request for ${subject} failed.`;
308
+ }
309
+ /**
310
+ * Build an Octokit client.
311
+ *
312
+ * `@octokit/rest` v22 is ESM-only with no CommonJS build. `require()` happens to
313
+ * work on Node 22.12+ through require(esm), but this package supports Node 20,
314
+ * where it throws ERR_REQUIRE_ESM — so it is reached by dynamic import, built
315
+ * with `new Function` because TypeScript rewrites `import()` to `require()`
316
+ * under `module: commonjs`.
317
+ *
318
+ * The token is optional: public repositories answer without one, at a lower
319
+ * rate limit.
320
+ */
321
+ async function createOctokit(env = process.env) {
322
+ const importEsm = new Function('specifier', 'return import(specifier)');
323
+ const { Octokit } = await importEsm('@octokit/rest');
324
+ const token = env.GITHUB_TOKEN?.trim();
325
+ return new Octokit({
326
+ auth: token || undefined,
327
+ userAgent: `vigyl-mcp-github/${VERSION}`,
328
+ request: { timeout: 15_000 },
329
+ });
330
+ }
331
+ async function main() {
332
+ const api = await createOctokit();
333
+ const server = new mcp_js_1.McpServer({ name: SERVER_NAME, version: VERSION });
334
+ registerGitHubTools(server, api);
335
+ await server.connect(new stdio_js_1.StdioServerTransport());
336
+ const scope = process.env.GITHUB_REPO?.trim();
337
+ const auth = process.env.GITHUB_TOKEN ? 'with a token' : 'unauthenticated (public repos only)';
338
+ const writes = writesAllowed() ? 'writes ENABLED' : 'read-only';
339
+ process.stderr.write(`${SERVER_NAME} ready ${auth}, ${writes}${scope ? `, default repo ${scope}` : ''}\n`);
340
+ }
341
+ if (require.main === module) {
342
+ main().catch((error) => {
343
+ process.stderr.write(`${SERVER_NAME} failed to start: ${error.message}\n`);
344
+ process.exit(1);
345
+ });
346
+ }
347
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Repository identity and the shapes GitHub answers in.
3
+ *
4
+ * Kept apart from the server so it can be tested without a token.
5
+ */
6
+ /** A page bigger than this is never read in a chat reply. */
7
+ export declare const MAX_PER_PAGE = 50;
8
+ export declare const DEFAULT_PER_PAGE = 20;
9
+ export declare const DEFAULT_COMMITS = 10;
10
+ export interface RepoTarget {
11
+ owner: string;
12
+ repo: string;
13
+ }
14
+ export declare function isValidOwner(owner: string): boolean;
15
+ export declare function isValidRepo(repo: string): boolean;
16
+ /**
17
+ * Work out which repository a call means.
18
+ *
19
+ * `GITHUB_REPO=owner/name` sets a default, so the operator's own project does
20
+ * not have to be named in every message — and so a model that guesses a
21
+ * plausible-looking repository reaches ours rather than a stranger's.
22
+ */
23
+ export declare function resolveTarget(args: {
24
+ owner?: string;
25
+ repo?: string;
26
+ }, env?: Record<string, string | undefined>): RepoTarget;
27
+ export declare function clampPerPage(requested: number | undefined, fallback?: number): number;
28
+ /**
29
+ * A git ref that is safe to put in a URL path.
30
+ *
31
+ * Branch names allow a lot, but not these: refusing them here keeps a crafted
32
+ * ref from reaching a different endpoint than the one intended.
33
+ */
34
+ export declare function isValidRef(ref: string): boolean;
35
+ /** A workflow is a file name or a numeric id. Anything else is a mistake. */
36
+ export declare function isValidWorkflowId(id: string): boolean;
37
+ export interface CheckSummary {
38
+ total: number;
39
+ passed: number;
40
+ failed: number;
41
+ running: number;
42
+ skipped: number;
43
+ verdict: 'passed' | 'failed' | 'running' | 'no checks';
44
+ }
45
+ /**
46
+ * Reduce check runs to an answer.
47
+ *
48
+ * "Did CI pass?" wants one word. The guide's version called everything passed
49
+ * when `check_runs` was empty, so a branch with no CI configured reported "all
50
+ * checks passed" — which is the opposite of useful when someone is deciding
51
+ * whether to deploy.
52
+ */
53
+ export declare function summariseChecks(runs: ReadonlyArray<{
54
+ status?: string | null;
55
+ conclusion?: string | null;
56
+ }>): CheckSummary;
57
+ //# sourceMappingURL=repo.d.ts.map