@bridge-ds/mcp 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.
- package/README.md +130 -2
- package/dist/audit.d.ts +15 -0
- package/dist/brand.d.ts +263 -0
- package/dist/chunk-6JO2AG6X.js +7365 -0
- package/dist/chunk-FJL6UTZG.js +1317 -0
- package/dist/components.d.ts +55 -0
- package/dist/config.d.ts +13 -0
- package/dist/context.d.ts +42 -0
- package/dist/core-adapter.d.ts +48 -0
- package/dist/drafts.d.ts +46 -0
- package/dist/explorations.d.ts +168 -0
- package/dist/history.d.ts +431 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -0
- package/dist/lib.d.ts +19 -0
- package/dist/lib.js +46 -0
- package/dist/markdown.d.ts +16 -0
- package/dist/ops.d.ts +721 -0
- package/dist/requests.d.ts +89 -0
- package/dist/server.d.ts +4 -0
- package/dist/source.d.ts +39 -0
- package/dist/src-ABJPOTKE.js +1125 -0
- package/package.json +65 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { BridgeConfig } from './config.js';
|
|
2
|
+
import type { RepoSource } from './source.js';
|
|
3
|
+
import type { TokenSet } from './core-adapter.js';
|
|
4
|
+
export interface PropInfo {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
optional: boolean;
|
|
8
|
+
default?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Literal values when the type is a local union alias (ButtonVariant -> primary | secondary ...). */
|
|
11
|
+
values?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ComponentSummary {
|
|
14
|
+
name: string;
|
|
15
|
+
family?: string;
|
|
16
|
+
summary?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function listComponentNames(source: RepoSource, config: BridgeConfig): Promise<{
|
|
19
|
+
name: string;
|
|
20
|
+
files: string[];
|
|
21
|
+
}[]>;
|
|
22
|
+
export declare function listComponents(source: RepoSource, config: BridgeConfig, withSummaries: boolean): Promise<ComponentSummary[]>;
|
|
23
|
+
export declare function parseProps(src: string, name: string): {
|
|
24
|
+
extends?: string;
|
|
25
|
+
props: PropInfo[];
|
|
26
|
+
} | null;
|
|
27
|
+
export declare function cssVarsUsed(css: string): string[];
|
|
28
|
+
export declare function getComponent(source: RepoSource, config: BridgeConfig, set: TokenSet | null, name: string): Promise<{
|
|
29
|
+
tokens: {
|
|
30
|
+
notTokens?: string[] | undefined;
|
|
31
|
+
used: string[];
|
|
32
|
+
};
|
|
33
|
+
stories: string[];
|
|
34
|
+
extends?: string | undefined;
|
|
35
|
+
props: PropInfo[];
|
|
36
|
+
docs?: Record<string, unknown> | undefined;
|
|
37
|
+
name: string;
|
|
38
|
+
family: string | undefined;
|
|
39
|
+
files: string[];
|
|
40
|
+
}>;
|
|
41
|
+
export interface ScaffoldInput {
|
|
42
|
+
name: string;
|
|
43
|
+
family: string;
|
|
44
|
+
summary: string;
|
|
45
|
+
element: string;
|
|
46
|
+
interactive: boolean;
|
|
47
|
+
basePrimitive?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function scaffoldComponent(source: RepoSource, config: BridgeConfig, set: TokenSet, input: ScaffoldInput): Promise<{
|
|
50
|
+
files: {
|
|
51
|
+
path: string;
|
|
52
|
+
content: string;
|
|
53
|
+
}[];
|
|
54
|
+
notes: string[];
|
|
55
|
+
}>;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BridgeConfig, CONFIG_FILE, loadConfig, toConfigJson } from '@bridge-ds/core';
|
|
2
|
+
export { CONFIG_FILE, loadConfig as parseConfig, toConfigJson, type BridgeConfig };
|
|
3
|
+
/** Where `bridge init` points "$schema" in a detected config. */
|
|
4
|
+
export declare const SCHEMA_URL = "https://raw.githubusercontent.com/peterbono/ai-design-system-demo/main/packages/core/bridge.config.schema.json";
|
|
5
|
+
/**
|
|
6
|
+
* Builds a config from a file list. `read` returns file contents (to tell token JSON from other JSON).
|
|
7
|
+
* Heuristic: finds the directory that holds the token files, maps sub-directories to tiers by name,
|
|
8
|
+
* and turns light/dark (and density) file names into modes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectConfig(files: string[], read: (p: string) => Promise<string | null>, extra?: {
|
|
11
|
+
repo?: string;
|
|
12
|
+
branch?: string;
|
|
13
|
+
}): Promise<BridgeConfig>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type BridgeConfig } from './config.js';
|
|
2
|
+
import { GitHubClient, type TokenSet } from './core-adapter.js';
|
|
3
|
+
import { type RepoSource } from './source.js';
|
|
4
|
+
export interface ContextOptions {
|
|
5
|
+
/** Local repo root (default: cwd). Ignored when `repo` is set. */
|
|
6
|
+
root?: string;
|
|
7
|
+
/** Remote mode: GitHub `owner/name`. */
|
|
8
|
+
repo?: string;
|
|
9
|
+
/** Remote ref to read (default: the repo's default branch). */
|
|
10
|
+
ref?: string;
|
|
11
|
+
/** GitHub token. Without one Bridge is read-only. */
|
|
12
|
+
token?: string;
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
apiUrl?: string;
|
|
15
|
+
rawUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class BridgeContext {
|
|
18
|
+
readonly mode: 'local' | 'remote';
|
|
19
|
+
readonly source: RepoSource;
|
|
20
|
+
readonly opts: ContextOptions;
|
|
21
|
+
readonly root?: string | undefined;
|
|
22
|
+
readonly isGit: boolean;
|
|
23
|
+
private cached?;
|
|
24
|
+
private cachedSet?;
|
|
25
|
+
private gh?;
|
|
26
|
+
private constructor();
|
|
27
|
+
static create(opts?: ContextOptions): Promise<BridgeContext>;
|
|
28
|
+
get ref(): string | undefined;
|
|
29
|
+
config(): Promise<{
|
|
30
|
+
config: BridgeConfig;
|
|
31
|
+
origin: 'file' | 'detected';
|
|
32
|
+
}>;
|
|
33
|
+
/** Token set at the current state. Local mode re-reads files on every call so edits show up at once. */
|
|
34
|
+
tokens(): Promise<TokenSet>;
|
|
35
|
+
/**
|
|
36
|
+
* GitHub client for reviews and remote writes, guarded by the config: protected branches plus the base
|
|
37
|
+
* branch are refused, new branches need the agent prefix. Local mode uses config.repo or the origin remote.
|
|
38
|
+
*/
|
|
39
|
+
github(): Promise<GitHubClient | null>;
|
|
40
|
+
get canWriteRemote(): boolean;
|
|
41
|
+
describe(): string;
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type BridgeConfig, type ChangeTier, type ContrastDelta, type ContrastPair, type EditResult, type ImpactEntry, type LayerIssue, type LayeredChange, type LayeredContrastResult, type LayeredResolution, type ProposalBodyInput, type Rgba, type SemverBump, type TokenEdit, changeTable, checkLayeredPair, comboKey, contrastDeltaTable, GitHubClient, GitHubError, LayeredTokenSet, parseRepo, rgbaToHex } from '@bridge-ds/core';
|
|
2
|
+
import type { RepoSource } from './source.js';
|
|
3
|
+
export type { Combo } from '@bridge-ds/core';
|
|
4
|
+
export type Issue = LayerIssue;
|
|
5
|
+
export type Resolved = LayeredResolution;
|
|
6
|
+
export type TokenSet = LayeredTokenSet;
|
|
7
|
+
export type ContrastResult = LayeredContrastResult;
|
|
8
|
+
export type TokenChange = LayeredChange;
|
|
9
|
+
export type TierResult = ChangeTier;
|
|
10
|
+
export type { ContrastDelta, ContrastPair, EditResult, ImpactEntry, TokenEdit };
|
|
11
|
+
export { GitHubClient, GitHubError, LayeredTokenSet };
|
|
12
|
+
/** Pair as MCP clients pass it: `{ fg, bg, min }`. */
|
|
13
|
+
export interface PairInput {
|
|
14
|
+
fg: string;
|
|
15
|
+
bg: string;
|
|
16
|
+
min: number;
|
|
17
|
+
}
|
|
18
|
+
export interface BridgeCore {
|
|
19
|
+
loadTokenSet(source: RepoSource, config: BridgeConfig): Promise<TokenSet>;
|
|
20
|
+
tokenSetFromFiles(config: BridgeConfig, files: Map<string, string>): TokenSet;
|
|
21
|
+
validate(set: TokenSet): Issue[];
|
|
22
|
+
parityIssues(set: TokenSet): Issue[];
|
|
23
|
+
readContrastPairs(source: RepoSource, config: BridgeConfig): Promise<ContrastPair[]>;
|
|
24
|
+
toPairs(input: PairInput[]): ContrastPair[];
|
|
25
|
+
runContrast(set: TokenSet, pairs: ContrastPair[], modes?: string[]): ContrastResult[];
|
|
26
|
+
checkPair: typeof checkLayeredPair;
|
|
27
|
+
contrastDelta(before: ContrastResult[], after: ContrastResult[]): ContrastDelta[];
|
|
28
|
+
applyEdits(set: TokenSet, edits: TokenEdit[]): EditResult;
|
|
29
|
+
coerceValue(input: unknown, type?: string, existing?: unknown): unknown;
|
|
30
|
+
diff(before: TokenSet, after: TokenSet): TokenChange[];
|
|
31
|
+
impact(before: TokenSet, after: TokenSet, direct: TokenChange[], limit?: number): {
|
|
32
|
+
total: number;
|
|
33
|
+
entries: ImpactEntry[];
|
|
34
|
+
};
|
|
35
|
+
/** The shared classifier (risk.ts in @bridge-ds/core). */
|
|
36
|
+
classify(changes: TokenChange[], otherFiles?: string[], config?: BridgeConfig): TierResult;
|
|
37
|
+
prBody(input: ProposalBodyInput): string;
|
|
38
|
+
changeset(pkg: string, bump: SemverBump, summary: string): string;
|
|
39
|
+
tokenTable: typeof changeTable;
|
|
40
|
+
contrastTable: typeof contrastDeltaTable;
|
|
41
|
+
slugify(text: string): string;
|
|
42
|
+
comboKey: typeof comboKey;
|
|
43
|
+
toRgba(v: unknown): Rgba | null;
|
|
44
|
+
rgbaToHex: typeof rgbaToHex;
|
|
45
|
+
parseRepo: typeof parseRepo;
|
|
46
|
+
}
|
|
47
|
+
export declare function readTokenFiles(source: RepoSource, config: BridgeConfig): Promise<Map<string, string>>;
|
|
48
|
+
export declare const core: BridgeCore;
|
package/dist/drafts.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PendingDrafts } from '@bridge-ds/core';
|
|
2
|
+
import type { BridgeContext } from './context.js';
|
|
3
|
+
/** Images larger than this are linked, not inlined (bytes of PNG). */
|
|
4
|
+
export declare const IMAGE_INLINE_MAX = 750000;
|
|
5
|
+
/** At most this many images inlined per call, so the answer stays small. */
|
|
6
|
+
export declare const IMAGES_PER_CALL = 8;
|
|
7
|
+
export interface InlineImage {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
itemId: string;
|
|
10
|
+
label: 'before' | 'after';
|
|
11
|
+
base64: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PendingDraftsAnswer {
|
|
14
|
+
repo: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
phrase: string;
|
|
17
|
+
sessions: (Pick<PendingDrafts, 'sessionId' | 'createdAt' | 'status' | 'items'> & {
|
|
18
|
+
briefs: string[];
|
|
19
|
+
})[];
|
|
20
|
+
voice: string[];
|
|
21
|
+
contract: string[];
|
|
22
|
+
next: string;
|
|
23
|
+
}
|
|
24
|
+
/** Pending sessions (newest first) or one session, with a brief per item and the images to inline. */
|
|
25
|
+
export declare function pendingDrafts(ctx: BridgeContext, a: {
|
|
26
|
+
sessionId?: string | undefined;
|
|
27
|
+
images?: boolean | undefined;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
answer: PendingDraftsAnswer;
|
|
30
|
+
images: InlineImage[];
|
|
31
|
+
}>;
|
|
32
|
+
/** Writes Claude's texts into a session (sanitized, status "drafted" once every item has one), retrying on 409. */
|
|
33
|
+
export declare function writeDrafts(ctx: BridgeContext, a: {
|
|
34
|
+
sessionId: string;
|
|
35
|
+
results: {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
summary: string;
|
|
39
|
+
}[];
|
|
40
|
+
}): Promise<{
|
|
41
|
+
next: string;
|
|
42
|
+
waiting?: string[] | undefined;
|
|
43
|
+
sessionId: string;
|
|
44
|
+
status: import("@bridge-ds/core").DraftSessionStatus;
|
|
45
|
+
results: import("@bridge-ds/core").DraftResult[];
|
|
46
|
+
}>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { explorationRules } from '@bridge-ds/core';
|
|
2
|
+
import { BridgeContext } from './context.js';
|
|
3
|
+
/** `explore/<slug>` from a branch, a slug or a name; throws with how to fix it when it cannot be one. */
|
|
4
|
+
export declare function toExplorationBranch(ref: string): string;
|
|
5
|
+
export interface StartExplorationInput {
|
|
6
|
+
name: string;
|
|
7
|
+
purpose: string;
|
|
8
|
+
useCase?: string | undefined;
|
|
9
|
+
experimental?: string[] | undefined;
|
|
10
|
+
author?: string | undefined;
|
|
11
|
+
dryRun?: boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* bridge_start_exploration / `bridge explore start`. With a GitHub token: the branch on GitHub from the default branch
|
|
15
|
+
* and a draft pull request labeled exploration. Without one, in a local git repo: a local branch with the note,
|
|
16
|
+
* nothing pushed, and the commands to push it and open the draft pull request.
|
|
17
|
+
*/
|
|
18
|
+
export declare function startExploration(ctx: BridgeContext, a: StartExplorationInput): Promise<{
|
|
19
|
+
branch: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
base: string;
|
|
22
|
+
title: string;
|
|
23
|
+
label: string;
|
|
24
|
+
note: {
|
|
25
|
+
path: string;
|
|
26
|
+
content: string;
|
|
27
|
+
};
|
|
28
|
+
prBody: string;
|
|
29
|
+
status: "dry-run";
|
|
30
|
+
} | {
|
|
31
|
+
pr: number;
|
|
32
|
+
url: string;
|
|
33
|
+
commit: string;
|
|
34
|
+
install: import("@bridge-ds/core").ExplorationInstall;
|
|
35
|
+
previews: {
|
|
36
|
+
app: string;
|
|
37
|
+
label: string;
|
|
38
|
+
url: string;
|
|
39
|
+
}[];
|
|
40
|
+
next: string;
|
|
41
|
+
branch: string;
|
|
42
|
+
slug: string;
|
|
43
|
+
base: string;
|
|
44
|
+
title: string;
|
|
45
|
+
label: string;
|
|
46
|
+
note: {
|
|
47
|
+
path: string;
|
|
48
|
+
content: string;
|
|
49
|
+
};
|
|
50
|
+
prBody: string;
|
|
51
|
+
status: "started";
|
|
52
|
+
} | {
|
|
53
|
+
commit: string;
|
|
54
|
+
next: string;
|
|
55
|
+
branch: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
base: string;
|
|
58
|
+
title: string;
|
|
59
|
+
label: string;
|
|
60
|
+
note: {
|
|
61
|
+
path: string;
|
|
62
|
+
content: string;
|
|
63
|
+
};
|
|
64
|
+
prBody: string;
|
|
65
|
+
status: "branch-created";
|
|
66
|
+
}>;
|
|
67
|
+
/** bridge_list_explorations / `bridge explore list`. */
|
|
68
|
+
export declare function listExplorations(ctx: BridgeContext, a?: {
|
|
69
|
+
state?: 'open' | 'closed' | 'all';
|
|
70
|
+
}): Promise<{
|
|
71
|
+
localBranches?: string[] | undefined;
|
|
72
|
+
localHint?: string | undefined;
|
|
73
|
+
repo: string;
|
|
74
|
+
label: string;
|
|
75
|
+
running: number;
|
|
76
|
+
total: number;
|
|
77
|
+
summary: string;
|
|
78
|
+
explorations: {
|
|
79
|
+
requests: {
|
|
80
|
+
number: number;
|
|
81
|
+
title: string;
|
|
82
|
+
url: string;
|
|
83
|
+
state: string;
|
|
84
|
+
}[];
|
|
85
|
+
number: number;
|
|
86
|
+
url: string;
|
|
87
|
+
branch: string;
|
|
88
|
+
slug: string;
|
|
89
|
+
name: string;
|
|
90
|
+
purpose: string;
|
|
91
|
+
useCase?: string | undefined;
|
|
92
|
+
status: import("@bridge-ds/core").ExplorationStatus;
|
|
93
|
+
draft: boolean;
|
|
94
|
+
author: string;
|
|
95
|
+
updatedAt: string;
|
|
96
|
+
previews: {
|
|
97
|
+
app: string;
|
|
98
|
+
label: string;
|
|
99
|
+
url: string;
|
|
100
|
+
}[];
|
|
101
|
+
install: import("@bridge-ds/core").ExplorationInstall;
|
|
102
|
+
}[];
|
|
103
|
+
}>;
|
|
104
|
+
/** `bridge explore promote`: ready for review, tier labels, exploration label and note removed, linked requests closed on merge. */
|
|
105
|
+
export declare function promoteExploration(ctx: BridgeContext, a: {
|
|
106
|
+
ref: string;
|
|
107
|
+
dryRun?: boolean | undefined;
|
|
108
|
+
}): Promise<{
|
|
109
|
+
closes: number[];
|
|
110
|
+
number: number;
|
|
111
|
+
url: string;
|
|
112
|
+
branch: string;
|
|
113
|
+
warnings: string[];
|
|
114
|
+
tier: import("@bridge-ds/core").RiskTier;
|
|
115
|
+
reasons: string[];
|
|
116
|
+
removeLabels: string[];
|
|
117
|
+
addLabels: string[];
|
|
118
|
+
removeFiles: string[];
|
|
119
|
+
body: string;
|
|
120
|
+
title: string;
|
|
121
|
+
markReady: true;
|
|
122
|
+
status: "promoted" | "dry-run";
|
|
123
|
+
}>;
|
|
124
|
+
export declare function closeExploration(ctx: BridgeContext, a: {
|
|
125
|
+
ref: string;
|
|
126
|
+
}): Promise<{
|
|
127
|
+
number: number;
|
|
128
|
+
url: string;
|
|
129
|
+
branch: string;
|
|
130
|
+
status: "closed";
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* The context a write aimed at an exploration branch reads from. Remote: the same repo at that branch (it must
|
|
134
|
+
* exist). Local: the working tree, which must have that branch checked out, so Claude works where the designer is.
|
|
135
|
+
*/
|
|
136
|
+
export declare function explorationContext(ctx: BridgeContext, ref: string, opts?: {
|
|
137
|
+
requireCheckout?: boolean;
|
|
138
|
+
}): Promise<{
|
|
139
|
+
ctx: BridgeContext;
|
|
140
|
+
branch: string;
|
|
141
|
+
}>;
|
|
142
|
+
/** Writes proposal files on an exploration: a commit on the GitHub branch (remote) or the checked-out working tree (local). */
|
|
143
|
+
export declare function writeToExploration(ctx: BridgeContext, branch: string, input: {
|
|
144
|
+
message: string;
|
|
145
|
+
files: {
|
|
146
|
+
path: string;
|
|
147
|
+
content: string | null;
|
|
148
|
+
}[];
|
|
149
|
+
}): Promise<{
|
|
150
|
+
status: "preview";
|
|
151
|
+
message: string;
|
|
152
|
+
branch?: undefined;
|
|
153
|
+
next?: undefined;
|
|
154
|
+
} | {
|
|
155
|
+
next: string;
|
|
156
|
+
pr?: number | undefined;
|
|
157
|
+
url?: string | undefined;
|
|
158
|
+
status: "committed";
|
|
159
|
+
branch: string;
|
|
160
|
+
commit: string;
|
|
161
|
+
message?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
status: "written";
|
|
164
|
+
branch: string;
|
|
165
|
+
next: string;
|
|
166
|
+
message?: undefined;
|
|
167
|
+
}>;
|
|
168
|
+
export { explorationRules };
|