@myrialabs/clopen 0.4.39 → 0.4.40

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 (88) hide show
  1. package/backend/auth/permissions.ts +23 -0
  2. package/backend/database/crypto/secret-columns.ts +5 -1
  3. package/backend/database/migrations/078_create_worktree_branch_tables.ts +158 -0
  4. package/backend/database/migrations/index.ts +7 -0
  5. package/backend/database/queries/index.ts +6 -0
  6. package/backend/database/queries/worktree-branch-queries.ts +331 -0
  7. package/backend/db-client/cloning.test.ts +161 -0
  8. package/backend/db-client/cloning.ts +672 -0
  9. package/backend/db-client/connection-url.test.ts +117 -0
  10. package/backend/db-client/connection-url.ts +126 -0
  11. package/backend/db-client/drivers/mongodb.ts +2 -14
  12. package/backend/db-client/drivers/mysql.ts +2 -8
  13. package/backend/db-client/drivers/postgres.ts +10 -13
  14. package/backend/db-client/drivers/redis.ts +2 -6
  15. package/backend/db-client/env/detect.ts +438 -0
  16. package/backend/db-client/env/diff.ts +94 -0
  17. package/backend/db-client/env/env.test.ts +574 -0
  18. package/backend/db-client/env/index.ts +15 -0
  19. package/backend/db-client/env/naming.ts +202 -0
  20. package/backend/db-client/env/service.ts +487 -0
  21. package/backend/db-client/integrations/index.ts +7 -0
  22. package/backend/db-client/integrations/links.ts +41 -10
  23. package/backend/db-client/providers/neon/adapter.ts +522 -0
  24. package/backend/db-client/providers/neon/api-types.ts +182 -0
  25. package/backend/db-client/providers/neon/client.ts +298 -0
  26. package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
  27. package/backend/db-client/providers/neon/endpoints.ts +314 -0
  28. package/backend/db-client/providers/neon/list.test.ts +181 -0
  29. package/backend/db-client/providers/supabase/adapter.ts +25 -2
  30. package/backend/db-client/providers/types.ts +57 -0
  31. package/backend/env-files/discovery.ts +48 -0
  32. package/backend/env-files/edit.ts +213 -0
  33. package/backend/env-files/env-files.test.ts +515 -0
  34. package/backend/env-files/git.ts +27 -0
  35. package/backend/env-files/index.ts +44 -0
  36. package/backend/env-files/keys.ts +69 -0
  37. package/backend/env-files/parse.ts +157 -0
  38. package/backend/env-files/write.ts +229 -0
  39. package/backend/integrations/health.ts +18 -4
  40. package/backend/integrations/projections/types.ts +9 -2
  41. package/backend/integrations/registry/index.ts +3 -0
  42. package/backend/integrations/registry/providers/context7.ts +1 -0
  43. package/backend/integrations/registry/providers/firecrawl.ts +1 -0
  44. package/backend/integrations/registry/providers/github.ts +1 -0
  45. package/backend/integrations/registry/providers/neon.ts +55 -0
  46. package/backend/integrations/registry/providers/supabase.ts +1 -0
  47. package/backend/integrations/registry/providers/vercel.ts +1 -0
  48. package/backend/integrations/registry/types.ts +2 -0
  49. package/backend/work/start-work.ts +4 -0
  50. package/backend/worktrees/branching/engine.ts +557 -0
  51. package/backend/worktrees/branching/index.ts +56 -0
  52. package/backend/worktrees/branching/naming.test.ts +118 -0
  53. package/backend/worktrees/branching/naming.ts +97 -0
  54. package/backend/worktrees/branching/projector.test.ts +229 -0
  55. package/backend/worktrees/branching/projector.ts +139 -0
  56. package/backend/worktrees/branching/providers/neon.ts +220 -0
  57. package/backend/worktrees/branching/registry.ts +27 -0
  58. package/backend/worktrees/branching/service.ts +620 -0
  59. package/backend/worktrees/branching/suggest.test.ts +154 -0
  60. package/backend/worktrees/branching/suggest.ts +202 -0
  61. package/backend/worktrees/branching/types.ts +88 -0
  62. package/backend/worktrees/index.ts +7 -0
  63. package/backend/worktrees/service.ts +48 -1
  64. package/backend/ws/db-client/env.ts +142 -0
  65. package/backend/ws/db-client/index.ts +2 -0
  66. package/backend/ws/projects/index.ts +6 -1
  67. package/backend/ws/projects/info.ts +70 -6
  68. package/backend/ws/projects/overview.test.ts +108 -0
  69. package/backend/ws/projects/overview.ts +300 -0
  70. package/backend/ws/system/device-info.ts +307 -76
  71. package/backend/ws/worktrees/branching.ts +212 -0
  72. package/backend/ws/worktrees/crud.ts +33 -7
  73. package/backend/ws/worktrees/index.ts +14 -0
  74. package/dist/assets/{index-C8Gi-b6U.js → index-D4igjF6e.js} +1 -1
  75. package/dist/assets/{index-BrF6nqld.js → index-DONNwiXm.js} +1 -1
  76. package/dist/assets/main-BrfXH1bL.js +1205 -0
  77. package/dist/assets/main-CT1PygsW.css +1 -0
  78. package/dist/index.html +2 -2
  79. package/package.json +1 -1
  80. package/shared/constants/tool-icons.ts +6 -2
  81. package/shared/types/db-client/env.ts +192 -0
  82. package/shared/types/db-client/index.ts +1 -0
  83. package/shared/types/db-client/integrations.ts +30 -0
  84. package/shared/types/integrations.ts +9 -0
  85. package/shared/types/worktree-branching.ts +315 -0
  86. package/shared/utils/logger.ts +1 -0
  87. package/dist/assets/main-Bd3gb79F.css +0 -1
  88. package/dist/assets/main-Bo1hD7mt.js +0 -1191
@@ -0,0 +1,157 @@
1
+ /**
2
+ * A dotenv reader that remembers where everything was.
3
+ *
4
+ * `dotenv` and friends answer "what is the value of KEY", which is the wrong
5
+ * question for a writer: updating a variable IN PLACE means knowing which lines
6
+ * held it, whether it was quoted, and whether it was commented out. A parse
7
+ * that returns a plain object throws all of that away and leaves rewriting the
8
+ * file as the only option — which is how tools end up reformatting comments and
9
+ * ordering that the user put there on purpose.
10
+ *
11
+ * Commented assignments are returned too, marked. `.env.example` is often the
12
+ * only record of the variable names a project expects, and half of those files
13
+ * document optional settings as `# REDIS_URL=`, so a detector that ignored
14
+ * comments would miss the shape it exists to find.
15
+ */
16
+
17
+ /** One `KEY=value`, and where it lives. */
18
+ export interface DotenvAssignment {
19
+ key: string;
20
+ value: string;
21
+ /** The original text, including every line the value spans. */
22
+ raw: string;
23
+ /** 0-based index of the first line. */
24
+ line: number;
25
+ /** How many lines the assignment spans — more than one for a quoted value. */
26
+ lineCount: number;
27
+ exported: boolean;
28
+ /** True for `# KEY=value`: documentation, not configuration. */
29
+ commented: boolean;
30
+ }
31
+
32
+ /**
33
+ * `[^\r\n]*` rather than `.*`, and the reason is a bug this had.
34
+ *
35
+ * In JavaScript `.` does not match `\r`, so on a file written on Windows every
36
+ * line ends one character past what `.*$` can reach and the pattern matched
37
+ * NOTHING — a CRLF dotenv file parsed as empty, which would have made detection
38
+ * find no variables and every write append a duplicate.
39
+ */
40
+ const ASSIGNMENT = /^(\s*)(#+\s*)?(export\s+)?([A-Za-z_][A-Za-z0-9_]*)[ \t]*=([^\r\n]*)\r?$/;
41
+
42
+ /** Decode a double-quoted value's escapes. Single quotes are literal. */
43
+ function unescapeDouble(raw: string): string {
44
+ return raw.replace(/\\([nrt"'\\$`])/g, (_match, char: string) => {
45
+ if (char === 'n') return '\n';
46
+ if (char === 'r') return '\r';
47
+ if (char === 't') return '\t';
48
+ return char;
49
+ });
50
+ }
51
+
52
+ /**
53
+ * The index of the quote that closes the value, or -1.
54
+ *
55
+ * Only a double-quoted value honours backslash escapes, which is what every
56
+ * reader in common use does — inside single quotes a backslash is a backslash,
57
+ * so skipping the next character there would read past a legitimate close.
58
+ */
59
+ function findClosingQuote(body: string, quote: string): number {
60
+ for (let index = 0; index < body.length; index += 1) {
61
+ if (quote === '"' && body[index] === '\\') {
62
+ index += 1;
63
+ continue;
64
+ }
65
+ if (body[index] === quote) return index;
66
+ }
67
+ return -1;
68
+ }
69
+
70
+ /**
71
+ * Read a value that may run past the end of its first line.
72
+ *
73
+ * Returns how many EXTRA lines were consumed so the caller can keep its own
74
+ * line index honest — the whole reason this module exists.
75
+ */
76
+ function readValue(
77
+ first: string,
78
+ lines: string[],
79
+ index: number
80
+ ): { value: string; extraLines: number } {
81
+ const trimmed = first.trimStart();
82
+ const quote = trimmed[0];
83
+
84
+ if (quote !== '"' && quote !== "'" && quote !== '`') {
85
+ // Unquoted. Everything from an unescaped `#` onwards is a comment, which
86
+ // is what every reader in common use does.
87
+ const withoutComment = trimmed.split('#')[0] ?? '';
88
+ return { value: withoutComment.trim(), extraLines: 0 };
89
+ }
90
+
91
+ let body = trimmed.slice(1);
92
+ let extraLines = 0;
93
+
94
+ for (;;) {
95
+ const closing = findClosingQuote(body, quote);
96
+ if (closing !== -1) {
97
+ const inner = body.slice(0, closing);
98
+ return { value: quote === '"' ? unescapeDouble(inner) : inner, extraLines };
99
+ }
100
+
101
+ const next = lines[index + extraLines + 1];
102
+ // Unterminated at end of file. Taking what there is beats discarding the
103
+ // assignment: the caller is deciding whether to rewrite this line, and a
104
+ // key it cannot see is a key it would append a duplicate of.
105
+ if (next === undefined) {
106
+ return { value: quote === '"' ? unescapeDouble(body) : body, extraLines };
107
+ }
108
+ body = `${body}\n${next}`;
109
+ extraLines += 1;
110
+ }
111
+ }
112
+
113
+ export function parseDotenv(content: string): DotenvAssignment[] {
114
+ const lines = content.split('\n');
115
+ const found: DotenvAssignment[] = [];
116
+
117
+ for (let index = 0; index < lines.length; index += 1) {
118
+ const match = ASSIGNMENT.exec(lines[index]);
119
+ if (!match) continue;
120
+
121
+ const [, , hash, exported, key, rest] = match;
122
+ const { value, extraLines } = readValue(rest, lines, index);
123
+ const lineCount = extraLines + 1;
124
+
125
+ found.push({
126
+ key,
127
+ value,
128
+ raw: lines.slice(index, index + lineCount).join('\n'),
129
+ line: index,
130
+ lineCount,
131
+ exported: Boolean(exported),
132
+ commented: Boolean(hash)
133
+ });
134
+
135
+ index += extraLines;
136
+ }
137
+
138
+ return found;
139
+ }
140
+
141
+ /**
142
+ * The assignment a reader would actually use for `key`, or null.
143
+ *
144
+ * The LAST one wins, and commented ones do not count — the two rules that
145
+ * decide whether writing a variable will have any effect.
146
+ */
147
+ export function effectiveAssignment(
148
+ assignments: DotenvAssignment[],
149
+ key: string
150
+ ): DotenvAssignment | null {
151
+ let winner: DotenvAssignment | null = null;
152
+ for (const assignment of assignments) {
153
+ if (assignment.commented) continue;
154
+ if (assignment.key === key) winner = assignment;
155
+ }
156
+ return winner;
157
+ }
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Putting variables into a project's dotenv file.
3
+ *
4
+ * One rule is a hard refusal: **never a file git TRACKS.** For DB Client the
5
+ * cost is committing a live database password; for worktree branching it is
6
+ * worse — "Apply to Main" would carry the branch connection string into the
7
+ * main project, overwriting the real one with a URL pointing at a database that
8
+ * deleting the worktree destroys. Both are refused and reported rather than
9
+ * written and hoped about, and the refusal is overridable only where the caller
10
+ * says so explicitly.
11
+ *
12
+ * Nothing here throws for an ordinary failure. Every caller has already done
13
+ * the expensive, visible thing the user asked for — created a worktree, linked
14
+ * a database — and a variable that did not land is worth a sentence, not an
15
+ * exception that undoes the rest.
16
+ */
17
+
18
+ import fs from 'fs/promises';
19
+ import path from 'path';
20
+ import { removeEnvKeys, upsertEnvKeys } from './edit';
21
+ import { isSafeEnvFileName } from './keys';
22
+ import { isTrackedInGit } from './git';
23
+ import { debug } from '$shared/utils/logger';
24
+
25
+ export type EnvWriteStatus = 'written' | 'unchanged' | 'skipped-tracked' | 'failed';
26
+
27
+ export interface EnvWriteResult {
28
+ status: EnvWriteStatus;
29
+ /** One sentence, naming what happened and what to do. Null when it worked. */
30
+ detail: string | null;
31
+ fileName: string;
32
+ updated: string[];
33
+ appended: string[];
34
+ }
35
+
36
+ export interface EnvWriteInput {
37
+ root: string;
38
+ fileName: string;
39
+ vars: Record<string, string>;
40
+ /** A comment above the appended lines, naming where they came from. */
41
+ note?: string;
42
+ /** Write even though git tracks the file. The caller must have asked. */
43
+ allowTracked?: boolean;
44
+ }
45
+
46
+ /** The file as it is, or an empty string when it does not exist yet. */
47
+ export async function readEnvFile(
48
+ root: string,
49
+ fileName: string
50
+ ): Promise<{ text: string; exists: boolean }> {
51
+ try {
52
+ return { text: await fs.readFile(path.join(root, fileName), 'utf-8'), exists: true };
53
+ } catch {
54
+ return { text: '', exists: false };
55
+ }
56
+ }
57
+
58
+ export interface EnvWritePlan {
59
+ fileName: string;
60
+ exists: boolean;
61
+ /** The file as it is now. */
62
+ current: string;
63
+ /** The file as it would be. */
64
+ next: string;
65
+ updated: string[];
66
+ appended: string[];
67
+ unchanged: string[];
68
+ /** True when git tracks the target, which refuses the write by default. */
69
+ tracked: boolean;
70
+ }
71
+
72
+ /**
73
+ * Work out the write without performing it.
74
+ *
75
+ * Exists so the panel can show a diff of someone's own configuration file
76
+ * before touching it, and so `writeEnvVars` and the preview can never disagree
77
+ * about what would happen.
78
+ */
79
+ export async function planEnvWrite(input: EnvWriteInput): Promise<EnvWritePlan> {
80
+ if (!isSafeEnvFileName(input.fileName)) {
81
+ throw new Error(`"${input.fileName}" is not a dotenv file in the project root.`);
82
+ }
83
+
84
+ const [{ text, exists }, tracked] = await Promise.all([
85
+ readEnvFile(input.root, input.fileName),
86
+ isTrackedInGit(input.root, input.fileName)
87
+ ]);
88
+
89
+ const result = upsertEnvKeys(text, input.vars, { note: input.note });
90
+
91
+ return {
92
+ fileName: input.fileName,
93
+ exists,
94
+ current: text,
95
+ next: result.text,
96
+ updated: result.updated,
97
+ appended: result.appended,
98
+ unchanged: result.unchanged,
99
+ tracked
100
+ };
101
+ }
102
+
103
+ export async function writeEnvVars(input: EnvWriteInput): Promise<EnvWriteResult> {
104
+ const empty = { fileName: input.fileName, updated: [], appended: [] };
105
+
106
+ let plan: EnvWritePlan;
107
+ try {
108
+ plan = await planEnvWrite(input);
109
+ } catch (error) {
110
+ return { status: 'failed', detail: messageOf(error), ...empty };
111
+ }
112
+
113
+ if (plan.tracked && !input.allowTracked) {
114
+ return {
115
+ status: 'skipped-tracked',
116
+ detail: `git tracks ${input.fileName}, so writing a password into it would commit one — add it to .gitignore or pick a file that is ignored.`,
117
+ ...empty
118
+ };
119
+ }
120
+
121
+ if (plan.next === plan.current && plan.exists) {
122
+ return {
123
+ status: 'unchanged',
124
+ detail: null,
125
+ fileName: input.fileName,
126
+ updated: [],
127
+ appended: []
128
+ };
129
+ }
130
+
131
+ try {
132
+ await fs.writeFile(path.join(input.root, input.fileName), plan.next, 'utf-8');
133
+ debug.log('env-files', `Wrote ${plan.updated.length + plan.appended.length} variable(s) into ${input.fileName}`);
134
+ return {
135
+ status: 'written',
136
+ detail: null,
137
+ fileName: input.fileName,
138
+ updated: plan.updated,
139
+ appended: plan.appended
140
+ };
141
+ } catch (error) {
142
+ return { status: 'failed', detail: `Could not write ${input.fileName}: ${messageOf(error)}`, ...empty };
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Take the managed block and every replaced value back out.
148
+ *
149
+ * Silent about a missing file: there is nothing to undo, which is the outcome
150
+ * the caller wanted.
151
+ */
152
+ export async function clearEnvVars(input: {
153
+ root: string;
154
+ fileName: string;
155
+ keys: string[];
156
+ /** Remove an appended key only while it still holds this value. */
157
+ values?: Record<string, string>;
158
+ }): Promise<{ changed: boolean }> {
159
+ if (!isSafeEnvFileName(input.fileName)) return { changed: false };
160
+ const target = path.join(input.root, input.fileName);
161
+ try {
162
+ const existing = await fs.readFile(target, 'utf-8');
163
+ const next = removeEnvKeys(existing, input.keys, { values: input.values });
164
+ if (next === existing) return { changed: false };
165
+ await fs.writeFile(target, next, 'utf-8');
166
+ return { changed: true };
167
+ } catch {
168
+ // The file is gone, or was never written. Either way there is no block.
169
+ return { changed: false };
170
+ }
171
+ }
172
+
173
+ function messageOf(error: unknown): string {
174
+ return error instanceof Error ? error.message : String(error);
175
+ }
176
+
177
+ /**
178
+ * Worktree branching's write, in its own words.
179
+ *
180
+ * IN PLACE, like every other write here. A worktree is a FILE COPY of the
181
+ * project and therefore already carries the project's own `DATABASE_URL` — so
182
+ * an earlier version appended a marked block at the end and relied on readers
183
+ * taking the last assignment. It worked and it read as if it did not: the
184
+ * project's value sat untouched at the top of the file, and anyone opening it
185
+ * saw their own database named first. Replacing the line where it stands says
186
+ * what is true, and the previous value survives as the comment above it.
187
+ *
188
+ * A tracked file is refused outright with no override, because the danger there
189
+ * is not a committed password but "Apply to Main" overwriting the real database
190
+ * URL with a disposable one.
191
+ */
192
+ export async function writeWorktreeEnv(input: {
193
+ worktreeRoot: string;
194
+ fileName: string;
195
+ vars: Record<string, string>;
196
+ note?: string;
197
+ }): Promise<{ status: 'written' | 'skipped-tracked' | 'failed'; detail: string | null }> {
198
+ const result = await writeEnvVars({
199
+ root: input.worktreeRoot,
200
+ fileName: input.fileName,
201
+ vars: input.vars,
202
+ note: input.note
203
+ });
204
+
205
+ if (result.status === 'skipped-tracked') {
206
+ return {
207
+ status: 'skipped-tracked',
208
+ detail: `git tracks ${input.fileName}, so writing to it would carry the branch connection string into the main project — add it to .gitignore or point branching at a file that is ignored.`
209
+ };
210
+ }
211
+ // "Unchanged" means the block already said exactly this, which is a write
212
+ // that succeeded — reporting it as anything else would light up the retry.
213
+ if (result.status === 'unchanged') return { status: 'written', detail: null };
214
+ return { status: result.status, detail: result.detail };
215
+ }
216
+
217
+ /** Put a worktree's dotenv file back the way branching found it. */
218
+ export async function clearWorktreeEnv(
219
+ worktreeRoot: string,
220
+ fileName: string,
221
+ vars: Record<string, string> = {}
222
+ ): Promise<void> {
223
+ await clearEnvVars({
224
+ root: worktreeRoot,
225
+ fileName,
226
+ keys: Object.keys(vars),
227
+ values: vars
228
+ });
229
+ }
@@ -38,11 +38,26 @@ export type AccountProbe = (
38
38
  projectId: string | null
39
39
  ) => Promise<{ status: IntegrationStatus; detail: string | null } | null>;
40
40
 
41
- const providerProbes = new Map<string, AccountProbe>();
41
+ /**
42
+ * Probes per provider, in registration order.
43
+ *
44
+ * A LIST rather than one entry, because a provider can serve more than one
45
+ * surface: Neon offers `database` to DB Client and `worktree-branching` to the
46
+ * worktree manager, and each surface registers the probe that speaks for its
47
+ * own capability. A map would have let whichever module loaded last silently
48
+ * replace the other's, so an account using only the losing capability would
49
+ * report on something it had switched off.
50
+ *
51
+ * They are tried in order and the first non-null answer wins, which is exactly
52
+ * what the "returns null when it has nothing to say" contract was written for.
53
+ */
54
+ const providerProbes = new Map<string, AccountProbe[]>();
42
55
 
43
56
  /** Register a provider-specific probe. Called at module load by the surface. */
44
57
  export function registerAccountProbe(provider: string, probe: AccountProbe): void {
45
- providerProbes.set(provider, probe);
58
+ const existing = providerProbes.get(provider);
59
+ if (existing) existing.push(probe);
60
+ else providerProbes.set(provider, [probe]);
46
61
  }
47
62
 
48
63
  /**
@@ -66,8 +81,7 @@ export async function checkAccountHealth(accountId: string): Promise<{ status: I
66
81
  // A surface probe is the more specific answer when there is one: it talks to
67
82
  // the API the credential was issued for, rather than to an MCP server that
68
83
  // happens to accept the same token.
69
- const providerProbe = providerProbes.get(account.provider);
70
- if (providerProbe) {
84
+ for (const providerProbe of providerProbes.get(account.provider) ?? []) {
71
85
  try {
72
86
  const result = await providerProbe(accountId, account.project_id);
73
87
  if (result) {
@@ -7,8 +7,15 @@
7
7
  *
8
8
  * One projector per capability — but ONLY for capabilities whose surface owns a
9
9
  * table to write into. `agent-tools` writes an `mcp_servers` row, `database`
10
- * writes `db_client_connections` ones, and `worktree-branching` and
11
- * `notifications` are registered by the tasks that build those surfaces.
10
+ * writes `db_client_connections` ones, `worktree-branching` writes them too —
11
+ * one per live worktree branch, from `worktree_branches` — and `notifications`
12
+ * is registered by the task that builds that surface.
13
+ *
14
+ * TWO CAPABILITIES CAN TARGET THE SAME TABLE, and one account can carry both: a
15
+ * Neon account owns a connection for the project it linked AND one per worktree
16
+ * branch it cut. That works only because migration 077 widened the projection
17
+ * key with `target_id`; releasing by capability alone would tear down the
18
+ * other's rows on every pass.
12
19
  *
13
20
  * A projector returns a LIST. Agent tools happens to produce exactly one row
14
21
  * per account, but that is a fact about MCP presets rather than about
@@ -10,6 +10,7 @@
10
10
  import context7 from './providers/context7';
11
11
  import firecrawl from './providers/firecrawl';
12
12
  import github from './providers/github';
13
+ import neon from './providers/neon';
13
14
  import supabase from './providers/supabase';
14
15
  import vercel from './providers/vercel';
15
16
  import type { IntegrationProvider } from './types';
@@ -23,6 +24,7 @@ export const PROVIDERS: readonly IntegrationProvider[] = [
23
24
  context7,
24
25
  firecrawl,
25
26
  github,
27
+ neon,
26
28
  supabase,
27
29
  vercel
28
30
  ];
@@ -46,6 +48,7 @@ export function toProviderInfo(provider: IntegrationProvider): IntegrationProvid
46
48
  category: provider.category,
47
49
  description: provider.description,
48
50
  docsUrl: provider.docsUrl,
51
+ consoleUrl: provider.consoleUrl,
49
52
  authMethod: provider.authMethod,
50
53
  credentialFields: provider.credentialFields,
51
54
  capabilities: [...provider.capabilities],
@@ -16,6 +16,7 @@ export default defineProvider({
16
16
  description:
17
17
  'Pulls current, version-accurate documentation for a library straight into the session, so the agent stops writing against the API it remembers.',
18
18
  docsUrl: 'https://context7.com',
19
+ consoleUrl: 'https://context7.com',
19
20
  authMethod: 'api-key',
20
21
  capabilities: ['agent-tools'],
21
22
  credentialFields: [
@@ -15,6 +15,7 @@ export default defineProvider({
15
15
  description:
16
16
  'Crawls and converts live sites into clean markdown. Pairs with the browser automation tools rather than replacing them — this is for reading a site at scale, not driving one.',
17
17
  docsUrl: 'https://firecrawl.dev',
18
+ consoleUrl: 'https://firecrawl.dev',
18
19
  authMethod: 'api-key',
19
20
  capabilities: ['agent-tools'],
20
21
  credentialFields: [
@@ -39,6 +39,7 @@ export default defineProvider({
39
39
  description:
40
40
  'Issues, pull requests and Actions for the repository this project pushes to. Start work on an issue in its own worktree, open and merge pull requests, and send a failing CI run into the chat.',
41
41
  docsUrl: 'https://github.com/settings/tokens/new?scopes=repo,read:org&description=Clopen',
42
+ consoleUrl: 'https://github.com',
42
43
  authMethod: 'api-key',
43
44
  capabilities: ['work', 'agent-tools'],
44
45
  // Connecting GitHub means "show me my work", not "give every agent GitHub
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Neon — the first provider behind the `worktree-branching` capability, and the
3
+ * second behind `database`.
4
+ *
5
+ * ONE CREDENTIAL, TWO CAPABILITIES, which is the shape this provider was picked
6
+ * to prove. The same API key both lists projects for DB Client and cuts a
7
+ * branch for a worktree, so making it two accounts would mean pasting one key
8
+ * twice and rotating it in two places — the mistake `Task 3` refused for Vercel
9
+ * teams and `Task 4` refused for Supabase projects.
10
+ *
11
+ * Worth knowing about Neon's keys: they come in two scopes. A PERSONAL key
12
+ * reaches the projects its user owns; an ORGANISATION key reaches that
13
+ * organisation's and nothing else. Neither is wrong and the difference is
14
+ * invisible until a project the user can plainly see in the console is missing
15
+ * from the list, so the credential help names it rather than leaving it to be
16
+ * discovered.
17
+ *
18
+ * NO `agent-tools`, even though Neon ships an MCP server. That server uses its
19
+ * own OAuth — a different audience from this REST key — so declaring it would
20
+ * mean projecting a row this credential cannot fill, which is the same reason
21
+ * `Task 3` left Vercel's MCP alone.
22
+ *
23
+ * NO `inbound-events`. Neon's webhooks are an organisation-level billing and
24
+ * usage feed, not something any surface here subscribes to yet.
25
+ */
26
+
27
+ import { defineProvider } from '../define';
28
+
29
+ export default defineProvider({
30
+ id: 'neon',
31
+ name: 'Neon',
32
+ category: 'database',
33
+ description:
34
+ 'Serverless Postgres in DB Client, plus a database branch per worktree: creating a worktree cuts a copy-on-write branch and points its connection string at it, and deleting the worktree deletes the branch.',
35
+ docsUrl: 'https://console.neon.tech/app/settings/api-keys',
36
+ consoleUrl: 'https://console.neon.tech',
37
+ authMethod: 'api-key',
38
+ capabilities: ['database', 'worktree-branching'],
39
+ // Both ON by default. Unlike GitHub's `agent-tools` — which hands an agent
40
+ // write access to every repository and therefore has to be asked for —
41
+ // neither of these does anything until the user points a project at a
42
+ // database, so defaulting them off would only add a step before the feature
43
+ // they connected the account for.
44
+ credentialFields: [
45
+ {
46
+ name: 'apiKey',
47
+ label: 'API key',
48
+ placeholder: 'napi_…',
49
+ help:
50
+ 'Neon console → Account settings → API keys. A PERSONAL key reaches the projects you own; an ORGANISATION key reaches only that organisation\'s. Pick the one that owns the database you want to branch.',
51
+ isSecret: true,
52
+ isRequired: true
53
+ }
54
+ ]
55
+ });
@@ -40,6 +40,7 @@ export default defineProvider({
40
40
  description:
41
41
  'Postgres projects as connections in DB Client, with the Supabase surface on top: migrations and what is still pending, RLS policies and the security advisor, edge functions, storage buckets, auth users, and generated TypeScript types written into the project.',
42
42
  docsUrl: 'https://supabase.com/dashboard/account/tokens',
43
+ consoleUrl: 'https://supabase.com/dashboard',
43
44
  authMethod: 'api-key',
44
45
  capabilities: ['database'],
45
46
  credentialFields: [
@@ -28,6 +28,7 @@ export default defineProvider({
28
28
  description:
29
29
  'Deployments for the project this repository builds to. Watch a build as it runs, send a failed build log into the chat, open a preview build in the browser panel, and redeploy, cancel, roll back or promote from here.',
30
30
  docsUrl: 'https://vercel.com/account/tokens',
31
+ consoleUrl: 'https://vercel.com/dashboard',
31
32
  authMethod: 'api-key',
32
33
  capabilities: ['deployments'],
33
34
  credentialFields: [
@@ -83,6 +83,8 @@ export interface IntegrationProvider {
83
83
  category: IntegrationCategory;
84
84
  description: string;
85
85
  docsUrl?: string;
86
+ /** The provider's own dashboard, for what Clopen cannot do — see `IntegrationProviderInfo`. */
87
+ consoleUrl?: string;
86
88
  authMethod: IntegrationAuthMethod;
87
89
  credentialFields: IntegrationCredentialField[];
88
90
  /** Everything this provider is able to offer. */
@@ -41,6 +41,10 @@ function slugify(text: string, maxWords = 6): string {
41
41
  return text
42
42
  .toLowerCase()
43
43
  .normalize('NFKD')
44
+ // Combining marks are dropped rather than left for the character class to
45
+ // turn into spaces: `ü` decomposes to `u` + a diaeresis, and without this
46
+ // an issue titled "münchen" produces the branch `mu-nchen`.
47
+ .replace(/[\u0300-\u036f]/g, '')
44
48
  .replace(/[^\w\s-]/g, ' ')
45
49
  .trim()
46
50
  .split(/[\s_-]+/)