@myrialabs/clopen 0.4.37 → 0.4.38

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 (101) hide show
  1. package/README.md +2 -2
  2. package/backend/auth/permissions.ts +14 -0
  3. package/backend/bootstrap.ts +16 -0
  4. package/backend/database/crypto/envelope.test.ts +93 -0
  5. package/backend/database/crypto/envelope.ts +127 -0
  6. package/backend/database/crypto/index.ts +22 -0
  7. package/backend/database/crypto/master-key.ts +129 -0
  8. package/backend/database/crypto/secret-columns.ts +147 -0
  9. package/backend/database/migrations/071_create_notes_tables.ts +90 -0
  10. package/backend/database/migrations/072_encrypt_stored_secrets.ts +107 -0
  11. package/backend/database/migrations/073_create_integration_tables.ts +119 -0
  12. package/backend/database/migrations/074_create_work_tables.ts +94 -0
  13. package/backend/database/migrations/index.ts +28 -0
  14. package/backend/database/queries/db-client-connection-queries.ts +23 -12
  15. package/backend/database/queries/engine-queries.ts +23 -10
  16. package/backend/database/queries/index.ts +6 -1
  17. package/backend/database/queries/integration-queries.ts +297 -0
  18. package/backend/database/queries/mcp-server-queries.ts +38 -11
  19. package/backend/database/queries/note-queries.test.ts +190 -0
  20. package/backend/database/queries/note-queries.ts +269 -0
  21. package/backend/database/queries/profile-queries.ts +1 -1
  22. package/backend/database/queries/ssh-connection-queries.ts +19 -8
  23. package/backend/database/queries/work-queries.ts +210 -0
  24. package/backend/engine/docs/artifacts.md +22 -9
  25. package/backend/files/os-clipboard.test.ts +209 -0
  26. package/backend/files/os-clipboard.ts +567 -0
  27. package/backend/http/integration-hooks.ts +42 -0
  28. package/backend/http/notes-images.test.ts +228 -0
  29. package/backend/http/notes-images.ts +196 -0
  30. package/backend/index.ts +9 -0
  31. package/backend/integrations/accounts.ts +229 -0
  32. package/backend/integrations/health.ts +146 -0
  33. package/backend/integrations/index.ts +36 -0
  34. package/backend/integrations/projections/index.ts +120 -0
  35. package/backend/integrations/projections/mcp-projector.test.ts +204 -0
  36. package/backend/integrations/projections/mcp-projector.ts +159 -0
  37. package/backend/integrations/projections/types.ts +51 -0
  38. package/backend/integrations/registry/define.ts +38 -0
  39. package/backend/integrations/registry/index.ts +56 -0
  40. package/backend/integrations/registry/providers/context7.ts +44 -0
  41. package/backend/integrations/registry/providers/firecrawl.ts +41 -0
  42. package/backend/integrations/registry/providers/github.ts +78 -0
  43. package/backend/integrations/registry/types.ts +96 -0
  44. package/backend/integrations/webhooks/gateway.ts +160 -0
  45. package/backend/integrations/webhooks/verify.ts +65 -0
  46. package/backend/mcp/README.md +25 -3
  47. package/backend/mcp/external/config.ts +35 -1
  48. package/backend/mcp/index.ts +1 -1
  49. package/backend/mcp/internal/config.ts +1 -1
  50. package/backend/notes/access.test.ts +82 -0
  51. package/backend/notes/access.ts +27 -0
  52. package/backend/notes/storage.test.ts +77 -0
  53. package/backend/notes/storage.ts +114 -0
  54. package/backend/permissions/service.ts +2 -2
  55. package/backend/profiles/service.ts +1 -1
  56. package/backend/projects/project-cleanup.ts +6 -0
  57. package/backend/work/bindings.ts +124 -0
  58. package/backend/work/index.ts +42 -0
  59. package/backend/work/prompts.ts +150 -0
  60. package/backend/work/providers/github/actions-logs.ts +180 -0
  61. package/backend/work/providers/github/adapter.test.ts +88 -0
  62. package/backend/work/providers/github/adapter.ts +1255 -0
  63. package/backend/work/providers/github/client.ts +280 -0
  64. package/backend/work/providers/github/list-range.test.ts +158 -0
  65. package/backend/work/providers/github/token-kind.test.ts +42 -0
  66. package/backend/work/pull-requests.ts +242 -0
  67. package/backend/work/registry.ts +27 -0
  68. package/backend/work/service.ts +436 -0
  69. package/backend/work/start-work.test.ts +71 -0
  70. package/backend/work/start-work.ts +232 -0
  71. package/backend/work/types.ts +180 -0
  72. package/backend/ws/files/clipboard.ts +78 -0
  73. package/backend/ws/files/index.ts +5 -0
  74. package/backend/ws/git/diff-budget.ts +70 -11
  75. package/backend/ws/index.ts +11 -1
  76. package/backend/ws/integrations/crud.ts +219 -0
  77. package/backend/ws/integrations/index.ts +22 -0
  78. package/backend/ws/mcp/crud.ts +25 -1
  79. package/backend/ws/notes/index.ts +278 -0
  80. package/backend/ws/profiles/crud.ts +1 -1
  81. package/backend/ws/work/actions.ts +206 -0
  82. package/backend/ws/work/context.ts +51 -0
  83. package/backend/ws/work/crud.ts +347 -0
  84. package/backend/ws/work/index.ts +17 -0
  85. package/backend/ws/work/pull-requests.ts +177 -0
  86. package/backend/ws/work/schemas.ts +226 -0
  87. package/dist/assets/{index-sJmS_CCm.js → index-CyH7fSbR.js} +1 -1
  88. package/dist/assets/{index-Bik9TCBi.js → index-DSHIANSy.js} +1 -1
  89. package/dist/assets/main-D2IOjftb.css +1 -0
  90. package/dist/assets/main-DM-tHKbW.js +1152 -0
  91. package/dist/index.html +2 -2
  92. package/package.json +1 -1
  93. package/shared/constants/engine-tools.ts +1 -1
  94. package/shared/constants/tool-icons.ts +33 -0
  95. package/shared/types/database/schema.ts +41 -0
  96. package/shared/types/integrations.ts +140 -0
  97. package/shared/types/stores/settings.ts +8 -0
  98. package/shared/types/work.ts +426 -0
  99. package/shared/utils/logger.ts +3 -0
  100. package/dist/assets/main-DLqolBI2.css +0 -1
  101. package/dist/assets/main-Df1I3hnw.js +0 -1096
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The prompts this surface sends into a chat session.
3
+ *
4
+ * They live on the SERVER, next to the data that fills them, for the same
5
+ * reason the git panel's conflict prompt does not: this text is assembled from
6
+ * a provider response the client never receives in full, and duplicating the
7
+ * assembly on both sides would mean two versions of the instructions to keep in
8
+ * step.
9
+ *
10
+ * A budget applies to everything variable. An issue with 200 comments is not
11
+ * rare, and pasting all of them turns "start work" into a request that costs
12
+ * more than the work.
13
+ */
14
+
15
+ import type { CheckLogBundle, WorkItemDetail } from '$shared/types/work';
16
+
17
+ /** Body text kept from the item itself. Enough for a detailed bug report. */
18
+ const MAX_BODY_CHARS = 8_000;
19
+ /** Comments are where a thread goes off-topic, so they get a tighter budget. */
20
+ const MAX_COMMENTS = 12;
21
+ const MAX_COMMENT_CHARS = 1_200;
22
+
23
+ function clip(text: string, limit: number): string {
24
+ const trimmed = (text ?? '').trim();
25
+ if (trimmed.length <= limit) return trimmed;
26
+ return `${trimmed.slice(0, limit)}\n… truncated, ${trimmed.length - limit} more characters — read the item online for the rest`;
27
+ }
28
+
29
+ /**
30
+ * Comments, newest last, oldest dropped first.
31
+ *
32
+ * Dropping from the FRONT is the right direction here and the wrong one for CI
33
+ * logs: a long issue thread converges on the current understanding, so the last
34
+ * comments are the ones that matter.
35
+ */
36
+ function renderComments(item: WorkItemDetail): string {
37
+ if (item.comments.length === 0) return '';
38
+
39
+ const kept = item.comments.slice(-MAX_COMMENTS);
40
+ const dropped = item.comments.length - kept.length;
41
+ const rendered = kept
42
+ .map((comment) => `**${comment.author}** (${comment.createdAt}):\n${clip(comment.body, MAX_COMMENT_CHARS)}`)
43
+ .join('\n\n---\n\n');
44
+
45
+ const header = dropped > 0
46
+ ? `Comments (${kept.length} most recent of ${item.comments.length}):`
47
+ : `Comments (${item.comments.length}):`;
48
+
49
+ return `${header}\n\n${rendered}`;
50
+ }
51
+
52
+ /** The first message of a session started from a work item. */
53
+ export function buildStartWorkPrompt(
54
+ item: WorkItemDetail,
55
+ context: { branch: string; branchMode: 'create' | 'checkout'; locator: string }
56
+ ): string {
57
+ const sections: string[] = [
58
+ `Work on ${item.kind === 'pull-request' ? 'pull request' : 'issue'} #${item.identifier} from ${context.locator}.`,
59
+ `**${item.title}**\n${item.url}`
60
+ ];
61
+
62
+ const facts: string[] = [`State: ${item.state}`];
63
+ if (item.labels.length > 0) facts.push(`Labels: ${item.labels.join(', ')}`);
64
+ if (item.assignees.length > 0) facts.push(`Assigned to: ${item.assignees.join(', ')}`);
65
+ if (item.author) facts.push(`Opened by: ${item.author}`);
66
+ sections.push(facts.join(' · '));
67
+
68
+ sections.push(item.body.trim()
69
+ ? `Description:\n\n${clip(item.body, MAX_BODY_CHARS)}`
70
+ : 'The item has no description.');
71
+
72
+ const comments = renderComments(item);
73
+ if (comments) sections.push(comments);
74
+
75
+ // The environment matters, and it differs by kind: an agent told it is on a
76
+ // new branch will not go looking for existing work, and an agent NOT told it
77
+ // is on a review branch will offer to create one.
78
+ sections.push(
79
+ context.branchMode === 'create'
80
+ ? [
81
+ 'You are in a fresh worktree of this project, already on a new branch:',
82
+ `\`${context.branch}\``,
83
+ '',
84
+ 'Start by reading the relevant code to confirm the description matches what is actually there, then say what you plan to change before changing it. Do not commit or push anything unless asked.'
85
+ ].join('\n')
86
+ : [
87
+ 'You are in a fresh worktree of this project, with the pull request branch checked out:',
88
+ `\`${context.branch}\``,
89
+ '',
90
+ 'The change is already here — read it before anything else. Summarise what it does, then say what you think is wrong with it or what it is missing. Do not commit or push anything unless asked.'
91
+ ].join('\n')
92
+ );
93
+
94
+ return sections.join('\n\n');
95
+ }
96
+
97
+ /** The message sent when a failing CI run is pushed into the chat. */
98
+ export function buildCheckLogPrompt(
99
+ bundle: CheckLogBundle,
100
+ context: { locator: string; branch: string; runUrl: string }
101
+ ): string {
102
+ return [
103
+ `A CI run failed on \`${context.branch}\` in ${context.locator}.`,
104
+ `**${bundle.runName}**\n${context.runUrl}`,
105
+ bundle.truncated
106
+ ? 'Logs from the failed jobs (tails only — earlier output was dropped to fit):'
107
+ : 'Logs from the failed jobs:',
108
+ bundle.text,
109
+ 'Work out what failed and why from these logs, check the claim against the code in this worktree, and propose the smallest fix that addresses the cause. If the logs are not enough to tell, say what else you need rather than guessing.'
110
+ ].join('\n\n');
111
+ }
112
+
113
+ /** The instruction that drafts a pull-request description. */
114
+ export function buildPrDescriptionPrompt(input: {
115
+ branch: string;
116
+ base: string;
117
+ commits: { hash: string; subject: string }[];
118
+ linkedItem: { identifier: string; title: string | null } | null;
119
+ diff: string;
120
+ diffTruncated: boolean;
121
+ }): string {
122
+ const sections: string[] = [
123
+ `Write a pull request description for merging \`${input.branch}\` into \`${input.base}\`.`
124
+ ];
125
+
126
+ if (input.linkedItem) {
127
+ sections.push(
128
+ `This branch was started from issue #${input.linkedItem.identifier}${input.linkedItem.title ? ` ("${input.linkedItem.title}")` : ''}. Reference it in the description.`
129
+ );
130
+ }
131
+
132
+ if (input.commits.length > 0) {
133
+ sections.push(`Commits on this branch:\n${input.commits.map((c) => `- ${c.subject}`).join('\n')}`);
134
+ }
135
+
136
+ sections.push(
137
+ [
138
+ 'Rules:',
139
+ '- title: one line, imperative, no trailing period. If the commits follow a convention, follow it.',
140
+ '- body: markdown. Lead with what changed and why, in prose. Add a short bullet list only when the change touches several unrelated areas.',
141
+ '- Describe only what is in the diff. Do not invent testing that was not done, and do not promise follow-up work.',
142
+ input.diffTruncated
143
+ ? '- The diff below is a sample. Describe the change as a whole using the file list, not only the visible hunks.'
144
+ : ''
145
+ ].filter(Boolean).join('\n')
146
+ );
147
+
148
+ sections.push(input.diff);
149
+ return sections.join('\n\n');
150
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Pulling a failing Actions run's logs into something a prompt can carry.
3
+ *
4
+ * Two decisions worth stating.
5
+ *
6
+ * FAILED JOBS ONLY, VIA THE PER-JOB ENDPOINT. The run-level endpoint hands back
7
+ * a zip of every job's log, including the twelve that passed. Listing the jobs
8
+ * and fetching only the failed ones is one extra request and avoids unzipping
9
+ * megabytes to throw almost all of it away.
10
+ *
11
+ * THE TAIL, NOT THE HEAD. A CI log's first 500 lines are dependency
12
+ * installation; the failure is at the end. Truncating from the front is the one
13
+ * way to produce a log excerpt that contains no information about the failure,
14
+ * so this keeps the tail and says how much it dropped.
15
+ */
16
+
17
+ import type { CheckLogBundle } from '$shared/types/work';
18
+ import { apiBaseOf, githubRequest, GitHubError, type GitHubCredentials } from './client';
19
+ import { debug } from '$shared/utils/logger';
20
+
21
+ /** Total log text handed to the model, across every failed job in the run. */
22
+ const TOTAL_LOG_BUDGET = 24 * 1024;
23
+ /** Per job, so one catastrophic job cannot crowd out the other three. */
24
+ const PER_JOB_BUDGET = 12 * 1024;
25
+ const LOG_TIMEOUT_MS = 30_000;
26
+
27
+ interface GitHubJob {
28
+ id: number;
29
+ name: string;
30
+ conclusion: string | null;
31
+ status: string;
32
+ html_url: string | null;
33
+ steps?: { name: string; conclusion: string | null; number: number }[];
34
+ }
35
+
36
+ /**
37
+ * Fetch one job's log as text.
38
+ *
39
+ * `redirect: 'manual'` is not a detail. GitHub answers with a 302 to a signed
40
+ * storage URL, and that URL carries its own credentials in the query string.
41
+ * Following automatically would replay our `Authorization: Bearer` header at a
42
+ * third-party host — leaking the token to a service that has no business seeing
43
+ * it, and which will reject the request for having two credentials anyway.
44
+ */
45
+ async function fetchJobLog(credentials: GitHubCredentials, jobId: number): Promise<string> {
46
+ const url = `${apiBaseOf(credentials)}/actions/jobs/${jobId}/logs`;
47
+
48
+ const response = await fetch(url, {
49
+ headers: {
50
+ Accept: 'application/vnd.github+json',
51
+ Authorization: `Bearer ${credentials.token}`,
52
+ 'X-GitHub-Api-Version': '2022-11-28',
53
+ 'User-Agent': 'clopen'
54
+ },
55
+ redirect: 'manual',
56
+ signal: AbortSignal.timeout(LOG_TIMEOUT_MS)
57
+ });
58
+
59
+ if (response.status >= 300 && response.status < 400) {
60
+ const location = response.headers.get('location');
61
+ if (!location) throw new GitHubError('GitHub returned a redirect with no location', response.status, 'error');
62
+ const followed = await fetch(location, { signal: AbortSignal.timeout(LOG_TIMEOUT_MS) });
63
+ if (!followed.ok) {
64
+ throw new GitHubError(`Could not download the job log (HTTP ${followed.status})`, followed.status, 'error');
65
+ }
66
+ return followed.text();
67
+ }
68
+
69
+ if (!response.ok) {
70
+ // Logs expire, and a repo can disable log retention entirely. Both are
71
+ // normal states, not failures of this feature.
72
+ throw new GitHubError(
73
+ response.status === 410
74
+ ? 'These logs have expired and are no longer stored by GitHub'
75
+ : `Could not read the job log (HTTP ${response.status})`,
76
+ response.status,
77
+ response.status === 401 ? 'auth' : 'error'
78
+ );
79
+ }
80
+
81
+ return response.text();
82
+ }
83
+
84
+ /** Keep the last `limit` bytes, cut on a line boundary, and say what was dropped. */
85
+ function keepTail(text: string, limit: number): { text: string; truncated: boolean } {
86
+ if (text.length <= limit) return { text, truncated: false };
87
+ const tail = text.slice(text.length - limit);
88
+ const firstNewline = tail.indexOf('\n');
89
+ const body = firstNewline >= 0 ? tail.slice(firstNewline + 1) : tail;
90
+ const droppedLines = text.slice(0, text.length - body.length).split('\n').length;
91
+ return {
92
+ text: `… ${droppedLines} earlier line${droppedLines === 1 ? '' : 's'} omitted …\n${body}`,
93
+ truncated: true
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Actions prefixes every line with an ISO timestamp and wraps output in
99
+ * `##[group]` markers. Both are pure noise in a prompt and together they are
100
+ * roughly a quarter of the bytes, which is a quarter of the budget spent on
101
+ * nothing.
102
+ */
103
+ function stripActionsNoise(text: string): string {
104
+ return text
105
+ .split('\n')
106
+ .map((line) => line.replace(/^\d{4}-\d{2}-\d{2}T[\d:.]+Z\s?/, ''))
107
+ .filter((line) => !/^##\[(group|endgroup)\]/.test(line))
108
+ .join('\n')
109
+ .trimEnd();
110
+ }
111
+
112
+ /**
113
+ * Logs for the failed jobs of one run, budgeted and annotated.
114
+ *
115
+ * Returns a bundle even when every job's log has expired: the run name and the
116
+ * list of failed steps still tell the agent what broke, and an empty answer
117
+ * would look like the feature not working.
118
+ */
119
+ export async function buildRunLogBundle(
120
+ credentials: GitHubCredentials,
121
+ locator: string,
122
+ runId: string,
123
+ runName: string
124
+ ): Promise<CheckLogBundle> {
125
+ const jobs = await githubRequest<{ jobs: GitHubJob[] }>(
126
+ credentials,
127
+ `/repos/${locator}/actions/runs/${runId}/jobs?per_page=100`,
128
+ { noCache: true }
129
+ );
130
+
131
+ const failed = (jobs.data?.jobs ?? []).filter(
132
+ (job) => job.conclusion === 'failure' || job.conclusion === 'timed_out'
133
+ );
134
+
135
+ if (failed.length === 0) {
136
+ return {
137
+ runId,
138
+ runName,
139
+ text: 'The run reported a failure but no individual job failed — this is usually a cancelled or infrastructure-level failure.',
140
+ truncated: false
141
+ };
142
+ }
143
+
144
+ const sections: string[] = [];
145
+ let used = 0;
146
+ let truncated = false;
147
+
148
+ for (const job of failed) {
149
+ const failedSteps = (job.steps ?? [])
150
+ .filter((step) => step.conclusion === 'failure')
151
+ .map((step) => step.name);
152
+
153
+ const header = failedSteps.length > 0
154
+ ? `### Job "${job.name}" — failed at: ${failedSteps.join(', ')}`
155
+ : `### Job "${job.name}" — failed`;
156
+
157
+ if (used >= TOTAL_LOG_BUDGET) {
158
+ sections.push(`${header}\n(log omitted — the earlier jobs used the available context)`);
159
+ truncated = true;
160
+ continue;
161
+ }
162
+
163
+ let body: string;
164
+ try {
165
+ const raw = stripActionsNoise(await fetchJobLog(credentials, job.id));
166
+ const limit = Math.min(PER_JOB_BUDGET, TOTAL_LOG_BUDGET - used);
167
+ const clipped = keepTail(raw, limit);
168
+ if (clipped.truncated) truncated = true;
169
+ body = clipped.text;
170
+ used += clipped.text.length;
171
+ } catch (error) {
172
+ debug.warn('work', `Could not read log for job ${job.id}:`, error);
173
+ body = `(log unavailable: ${error instanceof Error ? error.message : String(error)})`;
174
+ }
175
+
176
+ sections.push(`${header}\n\n\`\`\`\n${body}\n\`\`\``);
177
+ }
178
+
179
+ return { runId, runName, text: sections.join('\n\n'), truncated };
180
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Turning a git remote into a repository locator.
3
+ *
4
+ * This is what makes the binding automatic, and it is the one place where being
5
+ * wrong is silently destructive rather than loudly broken: bind to the wrong
6
+ * repository and "start work" opens someone else's issue, while a pull request
7
+ * targets a repository nobody meant.
8
+ *
9
+ * The Enterprise Server cases matter as much as the github.com ones, because a
10
+ * host check that ignores the account's base URL would claim every remote on
11
+ * earth.
12
+ */
13
+
14
+ import { describe, it, expect } from 'bun:test';
15
+
16
+ import { githubWorkAdapter } from './adapter';
17
+
18
+ const dotCom: Record<string, string> = {};
19
+ const enterprise: Record<string, string> = { baseUrl: 'https://ghe.example.com' };
20
+
21
+ const parse = (url: string, credentials = dotCom) =>
22
+ githubWorkAdapter.locatorFromRemote(url, credentials);
23
+
24
+ describe('locatorFromRemote — github.com', () => {
25
+ it('reads an scp-style remote', () => {
26
+ expect(parse('git@github.com:acme/web.git')).toBe('acme/web');
27
+ });
28
+
29
+ it('reads an https remote, with or without .git', () => {
30
+ expect(parse('https://github.com/acme/web.git')).toBe('acme/web');
31
+ expect(parse('https://github.com/acme/web')).toBe('acme/web');
32
+ });
33
+
34
+ it('reads an ssh:// remote', () => {
35
+ expect(parse('ssh://git@github.com/acme/web.git')).toBe('acme/web');
36
+ });
37
+
38
+ it('tolerates a trailing slash', () => {
39
+ expect(parse('https://github.com/acme/web/')).toBe('acme/web');
40
+ });
41
+
42
+ it('keeps only owner/repo from a deeper URL', () => {
43
+ expect(parse('https://github.com/acme/web/tree/main/src')).toBe('acme/web');
44
+ });
45
+
46
+ it('rejects a URL that names no repository', () => {
47
+ expect(parse('https://github.com/acme')).toBeNull();
48
+ });
49
+
50
+ it('rejects another vendor', () => {
51
+ expect(parse('git@gitlab.com:acme/web.git')).toBeNull();
52
+ expect(parse('https://bitbucket.org/acme/web.git')).toBeNull();
53
+ });
54
+
55
+ it('rejects a host that merely ends with the right name', () => {
56
+ // `evilgithub.com` must not match `github.com` — a suffix check here would
57
+ // bind a project to an attacker-controlled remote.
58
+ expect(parse('https://evilgithub.com/acme/web.git')).toBeNull();
59
+ });
60
+
61
+ it('rejects rubbish rather than throwing', () => {
62
+ expect(parse('')).toBeNull();
63
+ expect(parse('not a url')).toBeNull();
64
+ });
65
+ });
66
+
67
+ describe('locatorFromRemote — Enterprise Server', () => {
68
+ it('reads a remote on the configured instance', () => {
69
+ expect(parse('git@ghe.example.com:acme/web.git', enterprise)).toBe('acme/web');
70
+ expect(parse('https://ghe.example.com/acme/web.git', enterprise)).toBe('acme/web');
71
+ });
72
+
73
+ it('does not claim github.com remotes', () => {
74
+ // An enterprise account has no business answering for a public repo: its
75
+ // token cannot read it, and binding would produce 404s that read as
76
+ // permission problems.
77
+ expect(parse('git@github.com:acme/web.git', enterprise)).toBeNull();
78
+ });
79
+
80
+ it('accepts a base URL that already points at the API root', () => {
81
+ expect(parse('git@ghe.example.com:acme/web.git', { baseUrl: 'https://ghe.example.com/api/v3' }))
82
+ .toBe('acme/web');
83
+ });
84
+
85
+ it('is case-insensitive about the host', () => {
86
+ expect(parse('git@GitHub.com:acme/web.git')).toBe('acme/web');
87
+ });
88
+ });