@bridge-ds/mcp 0.0.0-stage → 0.3.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,431 @@
1
+ import { type HistoryEntry, type HistoryReport, type RevertResolution } from '@bridge-ds/core';
2
+ import type { BridgeContext } from './context.js';
3
+ /** The history report for this context: local git (first parent of HEAD) or GitHub (the ref, PRs folded). */
4
+ export declare function loadHistory(ctx: BridgeContext, limit?: number): Promise<HistoryReport>;
5
+ export interface HistoryArgs {
6
+ token?: string;
7
+ author?: string;
8
+ tier?: 1 | 2 | 3;
9
+ version?: string;
10
+ breaking?: boolean;
11
+ since?: string;
12
+ until?: string;
13
+ query?: string;
14
+ limit?: number;
15
+ includeChanges?: boolean;
16
+ }
17
+ export declare function getHistory(ctx: BridgeContext, a?: HistoryArgs): Promise<{
18
+ hint: string;
19
+ note?: string | undefined;
20
+ versions: {
21
+ version: string;
22
+ date: string;
23
+ pending: boolean;
24
+ prs: number[];
25
+ entries: number;
26
+ tokenChanges: number;
27
+ breaking: boolean;
28
+ bump: import("@bridge-ds/core").SemverBump;
29
+ }[];
30
+ total: number;
31
+ entries: {
32
+ moreChanges?: number | undefined;
33
+ changes?: {
34
+ fields?: ("value" | "description" | "type" | "extensions")[] | undefined;
35
+ after?: string | undefined;
36
+ before?: string | undefined;
37
+ file: string;
38
+ from?: string | undefined;
39
+ kind: "added" | "changed" | "renamed" | "removed";
40
+ path: string;
41
+ }[] | undefined;
42
+ bulk?: boolean | undefined;
43
+ version: string | undefined;
44
+ tier: 1 | 2 | 3;
45
+ bump: import("@bridge-ds/core").SemverBump;
46
+ breaking: boolean;
47
+ counts: import("@bridge-ds/core").HistoryCounts;
48
+ url?: string | undefined;
49
+ pr?: number | undefined;
50
+ id: string;
51
+ sha: string;
52
+ date: string;
53
+ author: string;
54
+ title: string;
55
+ why: string;
56
+ }[];
57
+ truncated?: string | undefined;
58
+ source: string;
59
+ currentVersion: string | null;
60
+ }>;
61
+ export declare function getTokenHistory(ctx: BridgeContext, a: {
62
+ path: string;
63
+ limit?: number;
64
+ }): Promise<{
65
+ hint: string;
66
+ path: string;
67
+ exists: boolean;
68
+ source: string;
69
+ total: number;
70
+ changes: {
71
+ descriptionBefore?: string | undefined;
72
+ descriptionAfter?: string | undefined;
73
+ after?: {} | null | undefined;
74
+ afterCss?: string | undefined;
75
+ before?: {} | null | undefined;
76
+ beforeCss?: string | undefined;
77
+ file: string;
78
+ mode: string;
79
+ pathThen?: string | undefined;
80
+ from?: string | undefined;
81
+ version: string | undefined;
82
+ kind: "added" | "changed" | "renamed" | "removed";
83
+ pr?: number | undefined;
84
+ entry: string;
85
+ date: string;
86
+ author: string;
87
+ title: string;
88
+ why: string;
89
+ }[];
90
+ } | {
91
+ note: string;
92
+ path: string;
93
+ exists: boolean;
94
+ source: string;
95
+ total: number;
96
+ changes: {
97
+ descriptionBefore?: string | undefined;
98
+ descriptionAfter?: string | undefined;
99
+ after?: {} | null | undefined;
100
+ afterCss?: string | undefined;
101
+ before?: {} | null | undefined;
102
+ beforeCss?: string | undefined;
103
+ file: string;
104
+ mode: string;
105
+ pathThen?: string | undefined;
106
+ from?: string | undefined;
107
+ version: string | undefined;
108
+ kind: "added" | "changed" | "renamed" | "removed";
109
+ pr?: number | undefined;
110
+ entry: string;
111
+ date: string;
112
+ author: string;
113
+ title: string;
114
+ why: string;
115
+ }[];
116
+ }>;
117
+ /** Finds an entry by id ("pr-12"), PR number ("#12", "12"), or sha (7 characters or more). */
118
+ export declare function findEntry(entries: HistoryEntry[], target: string): HistoryEntry;
119
+ export interface RestoreArg {
120
+ path: string;
121
+ /** History entry whose value to restore (its value AFTER that change), or use `value`. */
122
+ entry?: string;
123
+ /** "before": the value from before `entry` instead of after it. */
124
+ side?: 'before' | 'after';
125
+ value?: unknown;
126
+ file?: string;
127
+ mode?: Record<string, string>;
128
+ }
129
+ export interface PlanArgs {
130
+ target?: string;
131
+ restore?: RestoreArg;
132
+ /** Conflict key (path@file) -> keep-current | use-before. */
133
+ resolutions?: Record<string, RevertResolution>;
134
+ /** Shortcut: every conflict uses the value from before the change. */
135
+ restoreConflicts?: boolean;
136
+ }
137
+ /** Dry run: what undoing a change (or restoring a token) takes, conflicts included. Writes nothing. */
138
+ export declare function planRevertOp(ctx: BridgeContext, a: PlanArgs & {
139
+ includeBody?: boolean;
140
+ }): Promise<{
141
+ next: string;
142
+ prBody?: string | undefined;
143
+ tier: 1 | 2 | 3;
144
+ bump: import("@bridge-ds/core").SemverBump;
145
+ reasons: string[];
146
+ edits: string[];
147
+ conflicts: {
148
+ before?: string | undefined;
149
+ now?: unknown;
150
+ key: string;
151
+ path: string;
152
+ file: string;
153
+ reason: import("@bridge-ds/core").ConflictReason;
154
+ message: string;
155
+ later: string[];
156
+ resolution: RevertResolution;
157
+ }[];
158
+ skipped: string[];
159
+ changes: {
160
+ kind: "added" | "changed" | "renamed" | "removed";
161
+ path: string;
162
+ file: string;
163
+ before: string | undefined;
164
+ after: string | undefined;
165
+ }[];
166
+ contrast: {
167
+ moved: number;
168
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
169
+ sample: import("@bridge-ds/core").ContrastDelta[];
170
+ };
171
+ newErrors: import("@bridge-ds/core").LayerIssue[];
172
+ branch: string;
173
+ files: string[];
174
+ notes: string[];
175
+ reverts?: {
176
+ pr?: number | undefined;
177
+ id: string;
178
+ title: string;
179
+ date: string;
180
+ author: string;
181
+ } | undefined;
182
+ kind: "revert" | "restore";
183
+ title: string;
184
+ why?: string | undefined;
185
+ status: "ready" | "blocked" | "nothing-to-do";
186
+ }>;
187
+ /** Plans, then commits to a new local bridge/* branch or opens a PR on a new bridge/* branch. Never main. */
188
+ export declare function proposeRevert(ctx: BridgeContext, a: PlanArgs & {
189
+ dryRun?: boolean;
190
+ }): Promise<{
191
+ hint: string;
192
+ tier: 1 | 2 | 3;
193
+ bump: import("@bridge-ds/core").SemverBump;
194
+ reasons: string[];
195
+ edits: string[];
196
+ conflicts: {
197
+ before?: string | undefined;
198
+ now?: unknown;
199
+ key: string;
200
+ path: string;
201
+ file: string;
202
+ reason: import("@bridge-ds/core").ConflictReason;
203
+ message: string;
204
+ later: string[];
205
+ resolution: RevertResolution;
206
+ }[];
207
+ skipped: string[];
208
+ changes: {
209
+ kind: "added" | "changed" | "renamed" | "removed";
210
+ path: string;
211
+ file: string;
212
+ before: string | undefined;
213
+ after: string | undefined;
214
+ }[];
215
+ contrast: {
216
+ moved: number;
217
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
218
+ sample: import("@bridge-ds/core").ContrastDelta[];
219
+ };
220
+ newErrors: import("@bridge-ds/core").LayerIssue[];
221
+ branch: string;
222
+ files: string[];
223
+ notes: string[];
224
+ reverts?: {
225
+ pr?: number | undefined;
226
+ id: string;
227
+ title: string;
228
+ date: string;
229
+ author: string;
230
+ } | undefined;
231
+ kind: "revert" | "restore";
232
+ title: string;
233
+ why?: string | undefined;
234
+ status: "ready" | "blocked" | "nothing-to-do";
235
+ } | {
236
+ status: string;
237
+ prBody: string;
238
+ fileContents: {
239
+ path: string;
240
+ content: string;
241
+ }[];
242
+ tier: 1 | 2 | 3;
243
+ bump: import("@bridge-ds/core").SemverBump;
244
+ reasons: string[];
245
+ edits: string[];
246
+ conflicts: {
247
+ before?: string | undefined;
248
+ now?: unknown;
249
+ key: string;
250
+ path: string;
251
+ file: string;
252
+ reason: import("@bridge-ds/core").ConflictReason;
253
+ message: string;
254
+ later: string[];
255
+ resolution: RevertResolution;
256
+ }[];
257
+ skipped: string[];
258
+ changes: {
259
+ kind: "added" | "changed" | "renamed" | "removed";
260
+ path: string;
261
+ file: string;
262
+ before: string | undefined;
263
+ after: string | undefined;
264
+ }[];
265
+ contrast: {
266
+ moved: number;
267
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
268
+ sample: import("@bridge-ds/core").ContrastDelta[];
269
+ };
270
+ newErrors: import("@bridge-ds/core").LayerIssue[];
271
+ branch: string;
272
+ files: string[];
273
+ notes: string[];
274
+ reverts?: {
275
+ pr?: number | undefined;
276
+ id: string;
277
+ title: string;
278
+ date: string;
279
+ author: string;
280
+ } | undefined;
281
+ kind: "revert" | "restore";
282
+ title: string;
283
+ why?: string | undefined;
284
+ } | {
285
+ status: string;
286
+ message: string;
287
+ prBody: string;
288
+ fileContents: {
289
+ path: string;
290
+ content: string;
291
+ }[];
292
+ tier: 1 | 2 | 3;
293
+ bump: import("@bridge-ds/core").SemverBump;
294
+ reasons: string[];
295
+ edits: string[];
296
+ conflicts: {
297
+ before?: string | undefined;
298
+ now?: unknown;
299
+ key: string;
300
+ path: string;
301
+ file: string;
302
+ reason: import("@bridge-ds/core").ConflictReason;
303
+ message: string;
304
+ later: string[];
305
+ resolution: RevertResolution;
306
+ }[];
307
+ skipped: string[];
308
+ changes: {
309
+ kind: "added" | "changed" | "renamed" | "removed";
310
+ path: string;
311
+ file: string;
312
+ before: string | undefined;
313
+ after: string | undefined;
314
+ }[];
315
+ contrast: {
316
+ moved: number;
317
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
318
+ sample: import("@bridge-ds/core").ContrastDelta[];
319
+ };
320
+ newErrors: import("@bridge-ds/core").LayerIssue[];
321
+ branch: string;
322
+ files: string[];
323
+ notes: string[];
324
+ reverts?: {
325
+ pr?: number | undefined;
326
+ id: string;
327
+ title: string;
328
+ date: string;
329
+ author: string;
330
+ } | undefined;
331
+ kind: "revert" | "restore";
332
+ title: string;
333
+ why?: string | undefined;
334
+ } | {
335
+ status: string;
336
+ branch: string;
337
+ base: string;
338
+ commit: string;
339
+ prBody: string;
340
+ next: string;
341
+ tier: 1 | 2 | 3;
342
+ bump: import("@bridge-ds/core").SemverBump;
343
+ reasons: string[];
344
+ edits: string[];
345
+ conflicts: {
346
+ before?: string | undefined;
347
+ now?: unknown;
348
+ key: string;
349
+ path: string;
350
+ file: string;
351
+ reason: import("@bridge-ds/core").ConflictReason;
352
+ message: string;
353
+ later: string[];
354
+ resolution: RevertResolution;
355
+ }[];
356
+ skipped: string[];
357
+ changes: {
358
+ kind: "added" | "changed" | "renamed" | "removed";
359
+ path: string;
360
+ file: string;
361
+ before: string | undefined;
362
+ after: string | undefined;
363
+ }[];
364
+ contrast: {
365
+ moved: number;
366
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
367
+ sample: import("@bridge-ds/core").ContrastDelta[];
368
+ };
369
+ newErrors: import("@bridge-ds/core").LayerIssue[];
370
+ files: string[];
371
+ notes: string[];
372
+ reverts?: {
373
+ pr?: number | undefined;
374
+ id: string;
375
+ title: string;
376
+ date: string;
377
+ author: string;
378
+ } | undefined;
379
+ kind: "revert" | "restore";
380
+ title: string;
381
+ why?: string | undefined;
382
+ } | {
383
+ status: string;
384
+ branch: string;
385
+ commit: string;
386
+ pr: number;
387
+ url: string;
388
+ labels: string[];
389
+ draft: boolean;
390
+ tier: 1 | 2 | 3;
391
+ bump: import("@bridge-ds/core").SemverBump;
392
+ reasons: string[];
393
+ edits: string[];
394
+ conflicts: {
395
+ before?: string | undefined;
396
+ now?: unknown;
397
+ key: string;
398
+ path: string;
399
+ file: string;
400
+ reason: import("@bridge-ds/core").ConflictReason;
401
+ message: string;
402
+ later: string[];
403
+ resolution: RevertResolution;
404
+ }[];
405
+ skipped: string[];
406
+ changes: {
407
+ kind: "added" | "changed" | "renamed" | "removed";
408
+ path: string;
409
+ file: string;
410
+ before: string | undefined;
411
+ after: string | undefined;
412
+ }[];
413
+ contrast: {
414
+ moved: number;
415
+ newFailures: import("@bridge-ds/core").ContrastDelta[];
416
+ sample: import("@bridge-ds/core").ContrastDelta[];
417
+ };
418
+ newErrors: import("@bridge-ds/core").LayerIssue[];
419
+ files: string[];
420
+ notes: string[];
421
+ reverts?: {
422
+ pr?: number | undefined;
423
+ id: string;
424
+ title: string;
425
+ date: string;
426
+ author: string;
427
+ } | undefined;
428
+ kind: "revert" | "restore";
429
+ title: string;
430
+ why?: string | undefined;
431
+ }>;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ VERSION,
4
+ optionsFromArgv,
5
+ serveStdio
6
+ } from "./chunk-GABRGCKY.js";
7
+ import "./chunk-X455XY4E.js";
8
+
9
+ // src/index.ts
10
+ var argv = process.argv.slice(2);
11
+ if (argv.includes("--help") || argv.includes("-h")) {
12
+ process.stdout.write(`bridge-mcp ${VERSION}: Bridge design system MCP server (stdio)
13
+
14
+ Usage:
15
+ bridge-mcp [--root <dir>] local repo (default: current directory)
16
+ bridge-mcp --repo <owner/name> [--ref r] GitHub repo over the API
17
+
18
+ Env:
19
+ GITHUB_TOKEN optional. Without it Bridge is read-only. With it Bridge can open PRs on new
20
+ bridge/* branches (never main). Use a fine-grained token scoped to one repo.
21
+ `);
22
+ process.exit(0);
23
+ }
24
+ if (argv.includes("--version")) {
25
+ process.stdout.write(`${VERSION}
26
+ `);
27
+ process.exit(0);
28
+ }
29
+ serveStdio(optionsFromArgv(argv)).catch((e) => {
30
+ process.stderr.write(`bridge-mcp: ${e.message}
31
+ `);
32
+ process.exit(1);
33
+ });
package/dist/lib.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { type ContextOptions } from './context.js';
2
+ export { BridgeContext, type ContextOptions } from './context.js';
3
+ export { createServer, VERSION } from './server.js';
4
+ export { CONFIG_FILE, detectConfig, parseConfig, toConfigJson, type BridgeConfig } from './config.js';
5
+ export { core } from './core-adapter.js';
6
+ export { LocalSource, GitRefSource, GitHubSource, type RepoSource } from './source.js';
7
+ export { auditSnippet } from './audit.js';
8
+ export * as ops from './ops.js';
9
+ export * as history from './history.js';
10
+ export * as brand from './brand.js';
11
+ export * as requests from './requests.js';
12
+ export * as explorations from './explorations.js';
13
+ export * as drafts from './drafts.js';
14
+ export { DOCS_DRAFT_MODEL, anthropicReplyText, anthropicRequest, formatDocsJson, mergeDocsDraft, missingProse, parseDocsReply } from '@bridge-ds/core';
15
+ export interface ServeOptions extends ContextOptions {
16
+ }
17
+ /** Starts the stdio MCP server. Logs go to stderr: stdout belongs to the protocol. */
18
+ export declare function serveStdio(opts?: ServeOptions): Promise<void>;
19
+ /** Parses `--root <dir> --repo <owner/name> --ref <ref>`; token from GITHUB_TOKEN or BRIDGE_GITHUB_TOKEN. */
20
+ export declare function optionsFromArgv(argv: string[], env?: NodeJS.ProcessEnv): ServeOptions;
package/dist/lib.js ADDED
@@ -0,0 +1,60 @@
1
+ import {
2
+ BridgeContext,
3
+ DOCS_DRAFT_MODEL,
4
+ GitHubSource,
5
+ GitRefSource,
6
+ LocalSource,
7
+ VERSION,
8
+ anthropicReplyText,
9
+ anthropicRequest,
10
+ auditSnippet,
11
+ brand_exports,
12
+ core,
13
+ createServer,
14
+ detectConfig,
15
+ drafts_exports,
16
+ explorations_exports,
17
+ formatDocsJson,
18
+ history_exports,
19
+ mergeDocsDraft,
20
+ missingProse,
21
+ ops_exports,
22
+ optionsFromArgv,
23
+ parseDocsReply,
24
+ requests_exports,
25
+ serveStdio
26
+ } from "./chunk-GABRGCKY.js";
27
+ import {
28
+ CONFIG_FILE,
29
+ loadConfig,
30
+ toConfigJson
31
+ } from "./chunk-X455XY4E.js";
32
+ export {
33
+ BridgeContext,
34
+ CONFIG_FILE,
35
+ DOCS_DRAFT_MODEL,
36
+ GitHubSource,
37
+ GitRefSource,
38
+ LocalSource,
39
+ VERSION,
40
+ anthropicReplyText,
41
+ anthropicRequest,
42
+ auditSnippet,
43
+ brand_exports as brand,
44
+ core,
45
+ createServer,
46
+ detectConfig,
47
+ drafts_exports as drafts,
48
+ explorations_exports as explorations,
49
+ formatDocsJson,
50
+ history_exports as history,
51
+ mergeDocsDraft,
52
+ missingProse,
53
+ ops_exports as ops,
54
+ optionsFromArgv,
55
+ loadConfig as parseConfig,
56
+ parseDocsReply,
57
+ requests_exports as requests,
58
+ serveStdio,
59
+ toConfigJson
60
+ };
@@ -0,0 +1,16 @@
1
+ export interface Section {
2
+ level: number;
3
+ title: string;
4
+ slug: string;
5
+ body: string;
6
+ }
7
+ export declare const slug: (s: string) => string;
8
+ export declare function sections(md: string): Section[];
9
+ export declare function toc(md: string): {
10
+ level: number;
11
+ title: string;
12
+ slug: string;
13
+ }[];
14
+ /** Matches "4", "color", "Color", "contrast-commitments". Returns all matches, best first. */
15
+ export declare function findSection(md: string, query: string): Section[];
16
+ export declare function bullets(body: string): string[];