@buoy-design/cli 0.8.11 → 0.8.13
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/dist/mcp/file-context.d.ts +44 -0
- package/dist/mcp/file-context.d.ts.map +1 -0
- package/dist/mcp/file-context.js +175 -0
- package/dist/mcp/file-context.js.map +1 -0
- package/dist/mcp/server.d.ts +0 -5
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +95 -9
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/team-decisions.d.ts +33 -0
- package/dist/mcp/team-decisions.d.ts.map +1 -0
- package/dist/mcp/team-decisions.js +87 -0
- package/dist/mcp/team-decisions.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Component, DesignToken } from "@buoy-design/core";
|
|
2
|
+
import { type DriftIssue } from "./project.js";
|
|
3
|
+
export interface SourceFile {
|
|
4
|
+
/** Repository-relative path. */
|
|
5
|
+
path: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FileContextInput {
|
|
9
|
+
file: SourceFile;
|
|
10
|
+
/** Other source files in the same directory (and its parent), for "used nearby". */
|
|
11
|
+
neighbors: SourceFile[];
|
|
12
|
+
tokens: DesignToken[];
|
|
13
|
+
components: Component[];
|
|
14
|
+
/** Drift already in the file, from check_ui_against_design_system's engine. */
|
|
15
|
+
issues: DriftIssue[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compact on purpose: one short string per entry ("--color-brand #1a73e8 ×3")
|
|
19
|
+
* instead of objects that repeat category and source path, so the context an
|
|
20
|
+
* agent pulls stays a few hundred tokens even for large systems.
|
|
21
|
+
*/
|
|
22
|
+
export interface FileContext {
|
|
23
|
+
file: string;
|
|
24
|
+
/** Tokens this file already references, most used first: "name value ×uses". */
|
|
25
|
+
usedHere: string[];
|
|
26
|
+
/** Tokens neighbouring files reference that this one does not: "name value ×uses". */
|
|
27
|
+
usedNearby: string[];
|
|
28
|
+
/** Ordered steps per category the file deals in, e.g. spacing: ["--space-1 4px", ...]. */
|
|
29
|
+
scales: Record<string, string[]>;
|
|
30
|
+
/** Components to reuse before rebuilding: "Name path", "(imported)" when the file already imports it. */
|
|
31
|
+
components: string[];
|
|
32
|
+
/** Drift already in the file, at most a few. */
|
|
33
|
+
existingIssues: {
|
|
34
|
+
total: number;
|
|
35
|
+
top: string[];
|
|
36
|
+
};
|
|
37
|
+
note: string;
|
|
38
|
+
}
|
|
39
|
+
/** The ways a token can appear in source: `var(--color-buoy)`, `$space-2`, `bg-buoy`, `theme.colors.buoy`. */
|
|
40
|
+
export declare function tokenNeedles(name: string): RegExp[];
|
|
41
|
+
/** Which kinds of values a file deals in, from what it already contains. */
|
|
42
|
+
export declare function categoriesIn(content: string): Set<string>;
|
|
43
|
+
export declare function buildFileContext(input: FileContextInput): FileContext;
|
|
44
|
+
//# sourceMappingURL=file-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-context.d.ts","sourceRoot":"","sources":["../../src/mcp/file-context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,WAAW,UAAU;IACzB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,oFAAoF;IACpF,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,+EAA+E;IAC/E,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sFAAsF;IACtF,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0FAA0F;IAC1F,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACjC,yGAAyG;IACzG,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,gDAAgD;IAChD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;CACd;AAkCD,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBnD;AAQD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQzD;AA2BD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAmErE"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design context for one file, sized for an agent's prompt.
|
|
3
|
+
*
|
|
4
|
+
* A full token list (or a DESIGN.md) costs thousands of tokens on every
|
|
5
|
+
* request and gets lost in long prompts. An agent about to edit a file only
|
|
6
|
+
* needs what that file touches: the tokens already used there and next to
|
|
7
|
+
* it, the scale steps for the kinds of values it contains, the components it
|
|
8
|
+
* could reuse, and the drift already in it. This builds that, deterministic
|
|
9
|
+
* and small.
|
|
10
|
+
*/
|
|
11
|
+
import { basename, dirname } from "node:path";
|
|
12
|
+
import { formatTokenValue } from "./project.js";
|
|
13
|
+
const MAX_USED = 12;
|
|
14
|
+
const MAX_NEARBY = 8;
|
|
15
|
+
const MAX_STEPS = 10;
|
|
16
|
+
const MAX_COMPONENTS = 12;
|
|
17
|
+
const MAX_ISSUES = 5;
|
|
18
|
+
/** Categories whose tokens form an ordered scale worth listing as steps. */
|
|
19
|
+
const ORDERED_CATEGORIES = new Set(["spacing", "typography", "border", "sizing"]);
|
|
20
|
+
/** Letter-spacing and line-height tokens are often categorised as spacing but are not spacing steps. */
|
|
21
|
+
const NOT_A_STEP = /(?:^|-)(?:tracking|leading|letter-spacing|line-height)(?:-|$)/;
|
|
22
|
+
/**
|
|
23
|
+
* Tailwind v4 utilities each token namespace feeds: `--color-buoy` is used as
|
|
24
|
+
* `bg-buoy` or `text-buoy`, `--text-sm` only as `text-sm`. Matching only the
|
|
25
|
+
* namespace's own utilities keeps `--text-sm` from counting `rounded-sm`.
|
|
26
|
+
*/
|
|
27
|
+
const UTILITIES_BY_NAMESPACE = [
|
|
28
|
+
[/^colors?-/, "bg|text|border(?:-[trblxyse])?|ring|ring-offset|outline|fill|stroke|accent|caret|decoration|divide|placeholder|shadow|from|via|to"],
|
|
29
|
+
[/^(?:spacing|space)-/, "-?(?:p[xytrblse]?|m[xytrblse]?|gap(?:-[xy])?|space-[xy]|inset(?:-[xy])?|top|right|bottom|left|w|h|min-w|max-w|min-h|max-h|size|scroll-[mp][xytrbl]?)"],
|
|
30
|
+
[/^(?:text|font-size)-/, "text"],
|
|
31
|
+
[/^font-/, "font"],
|
|
32
|
+
[/^leading-/, "leading"],
|
|
33
|
+
[/^tracking-/, "tracking"],
|
|
34
|
+
[/^(?:radius|rounded)-/, "rounded(?:-[trblse]|-[tb][lr]|-[se][se])?"],
|
|
35
|
+
[/^shadow-/, "shadow"],
|
|
36
|
+
[/^border-/, "border(?:-[trblxyse])?"],
|
|
37
|
+
[/^z-/, "z"],
|
|
38
|
+
[/^ease-/, "ease"],
|
|
39
|
+
[/^duration-/, "duration"],
|
|
40
|
+
];
|
|
41
|
+
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42
|
+
/** The ways a token can appear in source: `var(--color-buoy)`, `$space-2`, `bg-buoy`, `theme.colors.buoy`. */
|
|
43
|
+
export function tokenNeedles(name) {
|
|
44
|
+
const bare = name.replace(/^--/, "").replace(/^\$/, "");
|
|
45
|
+
const needles = [new RegExp(`(?<![\\w-])${escapeRegExp(name)}(?![\\w-])`, "g")];
|
|
46
|
+
if (name.startsWith("--")) {
|
|
47
|
+
for (const [namespace, utilities] of UTILITIES_BY_NAMESPACE) {
|
|
48
|
+
if (!namespace.test(bare))
|
|
49
|
+
continue;
|
|
50
|
+
const suffix = bare.replace(namespace, "");
|
|
51
|
+
if (suffix)
|
|
52
|
+
needles.push(new RegExp(`(?<![\\w-])(?:${utilities})-${escapeRegExp(suffix)}(?![\\w-])`, "g"));
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (bare.includes(".")) {
|
|
57
|
+
// Dotted names (colors.brand.500) appear as brand-500 in classes and as is in JS.
|
|
58
|
+
const tail = bare.split(".").slice(1).join("-");
|
|
59
|
+
if (tail)
|
|
60
|
+
needles.push(new RegExp(`(?<![\\w-])[a-z]+-${escapeRegExp(tail)}(?![\\w-])`, "g"));
|
|
61
|
+
}
|
|
62
|
+
return needles;
|
|
63
|
+
}
|
|
64
|
+
function countUses(content, needles) {
|
|
65
|
+
let n = 0;
|
|
66
|
+
for (const re of needles)
|
|
67
|
+
n += content.match(re)?.length ?? 0;
|
|
68
|
+
return n;
|
|
69
|
+
}
|
|
70
|
+
/** Which kinds of values a file deals in, from what it already contains. */
|
|
71
|
+
export function categoriesIn(content) {
|
|
72
|
+
const found = new Set();
|
|
73
|
+
if (/#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(|oklch\(|\b(?:bg|text|border|ring|fill|stroke)-[a-z]+-?\d{0,3}\b|\bcolor\s*:/.test(content))
|
|
74
|
+
found.add("color");
|
|
75
|
+
if (/\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap|space-[xy])-[\d[]|\b(?:padding|margin|gap)\w*\s*:/.test(content))
|
|
76
|
+
found.add("spacing");
|
|
77
|
+
if (/\btext-(?:xs|sm|base|lg|[2-9]?xl|\[)|\bfont-?(?:size|weight)?\s*:|\bfontSize\b|\bleading-|\btracking-/.test(content))
|
|
78
|
+
found.add("typography");
|
|
79
|
+
if (/\brounded(?:-|\b)|\bborder-?radius\b|\bborderRadius\b/.test(content))
|
|
80
|
+
found.add("border");
|
|
81
|
+
if (/\bshadow(?:-|\b)|\bbox-shadow\b|\bboxShadow\b/.test(content))
|
|
82
|
+
found.add("shadow");
|
|
83
|
+
return found;
|
|
84
|
+
}
|
|
85
|
+
/** Sort a scale by its numeric value so agents see the steps in order. */
|
|
86
|
+
function numericValue(token) {
|
|
87
|
+
const v = token.value;
|
|
88
|
+
if (v.type === "spacing")
|
|
89
|
+
return v.unit === "rem" || v.unit === "em" ? v.value * 16 : v.value;
|
|
90
|
+
const m = /(-?\d*\.?\d+)\s*(px|rem|em)?/.exec(formatTokenValue(token));
|
|
91
|
+
if (!m)
|
|
92
|
+
return Number.POSITIVE_INFINITY;
|
|
93
|
+
const n = parseFloat(m[1]);
|
|
94
|
+
return m[2] === "rem" || m[2] === "em" ? n * 16 : n;
|
|
95
|
+
}
|
|
96
|
+
function importsIn(content) {
|
|
97
|
+
const names = new Set();
|
|
98
|
+
for (const m of content.matchAll(/import\s+(?:type\s+)?([\s\S]*?)\s+from\s+['"][^'"]+['"]/g)) {
|
|
99
|
+
for (const part of m[1].replace(/[{}]/g, ",").split(",")) {
|
|
100
|
+
const name = part.trim().split(/\s+as\s+/).pop()?.trim();
|
|
101
|
+
if (name && /^[A-Z]/.test(name))
|
|
102
|
+
names.add(name);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return names;
|
|
106
|
+
}
|
|
107
|
+
function componentPath(component) {
|
|
108
|
+
return "path" in component.source ? component.source.path : null;
|
|
109
|
+
}
|
|
110
|
+
export function buildFileContext(input) {
|
|
111
|
+
const { file, neighbors, tokens, components, issues } = input;
|
|
112
|
+
const live = tokens.filter((t) => !t.metadata?.deprecated);
|
|
113
|
+
const here = [];
|
|
114
|
+
const nearby = [];
|
|
115
|
+
const neighborText = neighbors.map((n) => n.content).join("\n");
|
|
116
|
+
for (const token of live) {
|
|
117
|
+
const needles = tokenNeedles(token.name);
|
|
118
|
+
const inFile = countUses(file.content, needles);
|
|
119
|
+
if (inFile > 0) {
|
|
120
|
+
here.push({ name: token.name, value: formatTokenValue(token), category: token.category, uses: inFile });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const around = neighborText ? countUses(neighborText, needles) : 0;
|
|
124
|
+
if (around > 0)
|
|
125
|
+
nearby.push({ name: token.name, value: formatTokenValue(token), category: token.category, uses: around });
|
|
126
|
+
}
|
|
127
|
+
here.sort((a, b) => b.uses - a.uses || a.name.localeCompare(b.name));
|
|
128
|
+
nearby.sort((a, b) => b.uses - a.uses || a.name.localeCompare(b.name));
|
|
129
|
+
// Scales only for the kinds of values this file actually deals in, and only
|
|
130
|
+
// where steps have an order. Colours and shadows are not a ladder; the
|
|
131
|
+
// used-here and used-nearby lists already carry the relevant ones.
|
|
132
|
+
const wanted = categoriesIn(file.content);
|
|
133
|
+
for (const t of here)
|
|
134
|
+
wanted.add(t.category);
|
|
135
|
+
const scales = {};
|
|
136
|
+
for (const category of wanted) {
|
|
137
|
+
if (!ORDERED_CATEGORIES.has(category))
|
|
138
|
+
continue;
|
|
139
|
+
const steps = live
|
|
140
|
+
.filter((t) => t.category === category && !NOT_A_STEP.test(t.name))
|
|
141
|
+
.sort((a, b) => numericValue(a) - numericValue(b) || a.name.localeCompare(b.name))
|
|
142
|
+
.map((t) => `${t.name} ${formatTokenValue(t)}`);
|
|
143
|
+
if (steps.length > 0)
|
|
144
|
+
scales[category] = steps.slice(0, MAX_STEPS);
|
|
145
|
+
}
|
|
146
|
+
const dir = dirname(file.path);
|
|
147
|
+
const parent = dirname(dir);
|
|
148
|
+
const imported = importsIn(file.content);
|
|
149
|
+
const self = basename(file.path).replace(/\.\w+$/, "");
|
|
150
|
+
const reusable = components
|
|
151
|
+
.map((c) => ({ name: c.name, path: componentPath(c) }))
|
|
152
|
+
.filter((c) => c.path !== null && c.path !== file.path && c.name !== self)
|
|
153
|
+
.map((c) => ({ ...c, imported: imported.has(c.name) }))
|
|
154
|
+
.filter((c) => c.imported || dirname(c.path) === dir || dirname(c.path) === parent)
|
|
155
|
+
.sort((a, b) => Number(b.imported) - Number(a.imported) || a.name.localeCompare(b.name));
|
|
156
|
+
const seen = new Set();
|
|
157
|
+
const uniqueComponents = reusable.filter((c) => !seen.has(c.name) && seen.add(c.name)).slice(0, MAX_COMPONENTS);
|
|
158
|
+
const note = live.length === 0
|
|
159
|
+
? "This repo has no design tokens; call list_design_tokens for the values its code already uses most."
|
|
160
|
+
: "Write values from usedHere and scales instead of new literals; reuse a listed component before writing a new one. After editing, run check_ui_against_design_system on this file.";
|
|
161
|
+
const used = (u) => `${u.name} ${u.value} ×${u.uses}`;
|
|
162
|
+
return {
|
|
163
|
+
file: file.path,
|
|
164
|
+
usedHere: here.slice(0, MAX_USED).map(used),
|
|
165
|
+
usedNearby: nearby.slice(0, MAX_NEARBY).map(used),
|
|
166
|
+
scales,
|
|
167
|
+
components: uniqueComponents.map((c) => `${c.name} ${c.path}${c.imported ? " (imported)" : ""}`),
|
|
168
|
+
existingIssues: {
|
|
169
|
+
total: issues.length,
|
|
170
|
+
top: issues.slice(0, MAX_ISSUES).map((i) => `line ${i.line ?? "?"}: ${typeof i.current === "string" ? i.current : JSON.stringify(i.current ?? "")}${i.suggested ? ` -> ${i.suggested}` : ""}`),
|
|
171
|
+
},
|
|
172
|
+
note,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=file-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-context.js","sourceRoot":"","sources":["../../src/mcp/file-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,gBAAgB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J,CAAC"}
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `buoy mcp serve`: a stdio MCP server that gives coding agents this repo's
|
|
3
|
-
* design system and checks their UI against it, so off-system values are
|
|
4
|
-
* caught while the agent writes instead of on the PR.
|
|
5
|
-
*/
|
|
6
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
2
|
export interface BuoyMcpOptions {
|
|
8
3
|
cwd: string;
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA0BpE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAgNtE;AAqBD,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvE"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -3,25 +3,47 @@
|
|
|
3
3
|
* design system and checks their UI against it, so off-system values are
|
|
4
4
|
* caught while the agent writes instead of on the PR.
|
|
5
5
|
*/
|
|
6
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
7
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
8
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
9
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
10
|
import { z } from "zod";
|
|
9
11
|
import { generateContext } from "../services/context-generator.js";
|
|
10
12
|
import { ScanOrchestrator } from "../scan/orchestrator.js";
|
|
11
|
-
import { checkDrift, findTokensByValue, loadProject,
|
|
13
|
+
import { checkDrift, findTokensByValue, loadProject, summarizeToken, } from "./project.js";
|
|
14
|
+
import { buildFileContext } from "./file-context.js";
|
|
15
|
+
import { configDecisions, fetchCloudDecisions, mergeDecisions } from "./team-decisions.js";
|
|
12
16
|
import { inferDesignSystem, normalizeLiteral, summarizeInferredSystem } from "../services/inferred-system.js";
|
|
13
17
|
const TOKEN_CACHE_MS = 30_000;
|
|
18
|
+
/** Without a filter, list_design_tokens returns a summary plus this many per category, not the whole system. */
|
|
19
|
+
const SLIM_PER_CATEGORY = 6;
|
|
20
|
+
const SOURCE_FILE = /\.(tsx|jsx|ts|js|vue|svelte|astro|css|scss|html)$/;
|
|
21
|
+
const MAX_NEIGHBORS = 20;
|
|
22
|
+
const MAX_NEIGHBOR_BYTES = 200_000;
|
|
23
|
+
/** Team decisions change on PR review, not per keystroke. */
|
|
24
|
+
const DECISIONS_CACHE_MS = 5 * 60_000;
|
|
14
25
|
export function createBuoyMcpServer(options) {
|
|
15
26
|
const server = new McpServer({ name: "buoy", version: options.version });
|
|
16
27
|
let project = null;
|
|
17
|
-
let
|
|
28
|
+
let scanCache = null;
|
|
18
29
|
const getProject = async () => (project ??= await loadProject(options.cwd));
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
const getScan = async () => {
|
|
31
|
+
if (scanCache && Date.now() - scanCache.at < TOKEN_CACHE_MS)
|
|
32
|
+
return scanCache;
|
|
33
|
+
const proj = await getProject();
|
|
34
|
+
const result = await new ScanOrchestrator(proj.config, proj.projectRoot).scan();
|
|
35
|
+
scanCache = { at: Date.now(), tokens: result.tokens, components: result.components };
|
|
36
|
+
return scanCache;
|
|
37
|
+
};
|
|
38
|
+
const getTokens = async () => (await getScan()).tokens;
|
|
39
|
+
const decisionsCache = new Map();
|
|
40
|
+
const getCloudDecisions = async (root, file) => {
|
|
41
|
+
const hit = decisionsCache.get(file);
|
|
42
|
+
if (hit && Date.now() - hit.at < DECISIONS_CACHE_MS)
|
|
43
|
+
return hit.value;
|
|
44
|
+
const value = await fetchCloudDecisions(root, file);
|
|
45
|
+
decisionsCache.set(file, { at: Date.now(), value });
|
|
46
|
+
return value;
|
|
25
47
|
};
|
|
26
48
|
let inferredCache = null;
|
|
27
49
|
// Repos with no tokens still have a de facto system: the values they use most.
|
|
@@ -36,7 +58,7 @@ export function createBuoyMcpServer(options) {
|
|
|
36
58
|
const json = (value) => ({ content: [{ type: "text", text: JSON.stringify(value, null, 2) }] });
|
|
37
59
|
server.registerTool("list_design_tokens", {
|
|
38
60
|
title: "List design tokens",
|
|
39
|
-
description: "Get this repository's design system: the colors, spacing, typography, radius, shadow and motion values it defines (CSS custom properties, Tailwind theme, tokens.json, Sass variables, DESIGN.md).
|
|
61
|
+
description: "Get this repository's design system: the colors, spacing, typography, radius, shadow and motion values it defines (CSS custom properties, Tailwind theme, tokens.json, Sass variables, DESIGN.md). Without arguments it returns a short summary (counts plus a few tokens per category) to keep context small; pass a category or name substring for the full list. When you are about to edit a specific file, prefer context_for_file, which returns only what that file needs. Repos with no tokens get the values their code already uses most. Categories: color, spacing, typography, shadow, border, sizing, motion, zIndex.",
|
|
40
62
|
inputSchema: {
|
|
41
63
|
category: z.string().optional().describe("Only tokens in this category"),
|
|
42
64
|
query: z.string().optional().describe("Case-insensitive substring of the token name"),
|
|
@@ -51,6 +73,20 @@ export function createBuoyMcpServer(options) {
|
|
|
51
73
|
const byCategory = {};
|
|
52
74
|
for (const t of tokens)
|
|
53
75
|
byCategory[t.category] = (byCategory[t.category] ?? 0) + 1;
|
|
76
|
+
if (!category && !q && !limit && tokens.length > 0) {
|
|
77
|
+
const sample = {};
|
|
78
|
+
for (const t of tokens) {
|
|
79
|
+
const list = (sample[t.category] ??= []);
|
|
80
|
+
if (list.length < SLIM_PER_CATEGORY)
|
|
81
|
+
list.push(summarizeToken(t));
|
|
82
|
+
}
|
|
83
|
+
return json({
|
|
84
|
+
total: tokens.length,
|
|
85
|
+
byCategory,
|
|
86
|
+
sample,
|
|
87
|
+
note: "Summary only. Pass category (or query) for the full list, or call context_for_file with the file you are editing to get just the tokens, scales and components it needs.",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
54
90
|
return json({
|
|
55
91
|
total: tokens.length,
|
|
56
92
|
byCategory,
|
|
@@ -85,6 +121,36 @@ export function createBuoyMcpServer(options) {
|
|
|
85
121
|
}
|
|
86
122
|
return json({ value, matches, suggestion: matches[0] ? `Use ${matches[0].name} instead of ${value}` : null });
|
|
87
123
|
});
|
|
124
|
+
server.registerTool("context_for_file", {
|
|
125
|
+
title: "Design context for the file you are editing",
|
|
126
|
+
description: "Before you edit a UI file, get only the design context it needs: tokens the file already uses, tokens its neighbours use, the scale steps for the kinds of values it contains (spacing, type, radius), components in the same folder or already imported that you should reuse, the drift already in it, and the team's decisions (values they chose to keep, which you must not replace, and values they always want flagged). Much smaller than the full token list. Then write values from it and run check_ui_against_design_system on the file.",
|
|
127
|
+
inputSchema: {
|
|
128
|
+
file: z.string().describe("Repository-relative or absolute path of the file you are about to edit (it may not exist yet)"),
|
|
129
|
+
},
|
|
130
|
+
}, async ({ file }) => {
|
|
131
|
+
const proj = await getProject();
|
|
132
|
+
const abs = isAbsolute(file) ? file : resolve(proj.projectRoot, file);
|
|
133
|
+
const rel = relative(proj.projectRoot, abs);
|
|
134
|
+
if (rel.startsWith("..") || isAbsolute(rel)) {
|
|
135
|
+
return json({ error: `${file} is outside the repository (${proj.projectRoot}).` });
|
|
136
|
+
}
|
|
137
|
+
const content = await readFile(abs, "utf8").catch(() => "");
|
|
138
|
+
const neighbors = await readNeighbors(proj.projectRoot, rel);
|
|
139
|
+
const { tokens, components } = await getScan();
|
|
140
|
+
const issues = content ? (await checkDrift(proj, [rel], tokens)).issues : [];
|
|
141
|
+
const context = buildFileContext({ file: { path: rel, content }, neighbors, tokens, components, issues });
|
|
142
|
+
const teamDecisions = mergeDecisions(configDecisions(proj.config, rel), await getCloudDecisions(proj.projectRoot, rel));
|
|
143
|
+
const withDecisions = {
|
|
144
|
+
...context,
|
|
145
|
+
teamDecisions,
|
|
146
|
+
...(teamDecisions.leaveAlone.length
|
|
147
|
+
? { note: `${context.note} Values in teamDecisions.leaveAlone are deliberate: keep them as written, even where they look off-scale.` }
|
|
148
|
+
: {}),
|
|
149
|
+
};
|
|
150
|
+
// Compact JSON: this tool exists to keep context small.
|
|
151
|
+
const body = tokens.length === 0 ? { ...withDecisions, ...(await inferredFallback()) } : withDecisions;
|
|
152
|
+
return { content: [{ type: "text", text: JSON.stringify(body) }] };
|
|
153
|
+
});
|
|
88
154
|
server.registerTool("check_ui_against_design_system", {
|
|
89
155
|
title: "Check UI code against the design system",
|
|
90
156
|
description: "After you edit UI code, check it against this repository's design system before you finish. Returns every hardcoded color, spacing, font, radius or shadow that should be a token, with the token to use. When an issue has an `edit`, replace line `edit.line` (currently `edit.before`) with `edit.after` exactly; it is a verified one-line swap. Pass the files you edited to check only those (fast); omit files to check the whole repository. Re-run until it reports no issues.",
|
|
@@ -132,6 +198,26 @@ export function createBuoyMcpServer(options) {
|
|
|
132
198
|
}
|
|
133
199
|
return server;
|
|
134
200
|
}
|
|
201
|
+
/** Source files in the same folder and its parent, so "used nearby" reflects the area being edited. */
|
|
202
|
+
async function readNeighbors(root, rel) {
|
|
203
|
+
const out = [];
|
|
204
|
+
let bytes = 0;
|
|
205
|
+
const dir = dirname(rel);
|
|
206
|
+
for (const folder of dir === "." ? ["."] : [dir, dirname(dir)]) {
|
|
207
|
+
const entries = await readdir(join(root, folder), { withFileTypes: true }).catch(() => []);
|
|
208
|
+
for (const entry of entries) {
|
|
209
|
+
if (out.length >= MAX_NEIGHBORS || bytes >= MAX_NEIGHBOR_BYTES)
|
|
210
|
+
return out;
|
|
211
|
+
const path = folder === "." ? entry.name : join(folder, entry.name);
|
|
212
|
+
if (!entry.isFile() || path === rel || !SOURCE_FILE.test(entry.name))
|
|
213
|
+
continue;
|
|
214
|
+
const content = await readFile(join(root, path), "utf8").catch(() => "");
|
|
215
|
+
bytes += content.length;
|
|
216
|
+
out.push({ path, content });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
135
221
|
export async function serveStdio(options) {
|
|
136
222
|
const server = createBuoyMcpServer(options);
|
|
137
223
|
await server.connect(new StdioServerTransport());
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9G,MAAM,cAAc,GAAG,MAAM,CAAC;AAO9B,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEzE,IAAI,OAAO,GAA0B,IAAI,CAAC;IAC1C,IAAI,UAAU,GAAiD,IAAI,CAAC;IAEpE,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,KAAK,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,CA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AAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAuB;IACtD,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BuoyConfig } from "../config/schema.js";
|
|
2
|
+
export interface TeamDecisions {
|
|
3
|
+
/** Values the team decided to keep: do not replace them. */
|
|
4
|
+
leaveAlone: string[];
|
|
5
|
+
/** Values or patterns the team always wants flagged: never write them. */
|
|
6
|
+
alwaysFlag: string[];
|
|
7
|
+
/** Where the decisions came from, or why the cloud part is missing. */
|
|
8
|
+
sources: string[];
|
|
9
|
+
}
|
|
10
|
+
/** Rules committed in .buoy.yaml that apply to this file. */
|
|
11
|
+
export declare function configDecisions(config: BuoyConfig, file: string): Pick<TeamDecisions, "leaveAlone" | "alwaysFlag">;
|
|
12
|
+
/** `git@github.com:o/r.git` or `https://github.com/o/r` → `o/r`. */
|
|
13
|
+
export declare function parseGitHubRepo(remote: string): string | null;
|
|
14
|
+
export interface CloudDecisions {
|
|
15
|
+
file: Array<{
|
|
16
|
+
value: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
source: string;
|
|
19
|
+
}>;
|
|
20
|
+
recurring: Array<{
|
|
21
|
+
value: string;
|
|
22
|
+
files: number;
|
|
23
|
+
reason: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/** Decisions from Buoy Cloud, or a short reason why there are none. */
|
|
27
|
+
export declare function fetchCloudDecisions(projectRoot: string, file: string, fetchImpl?: typeof fetch): Promise<CloudDecisions | {
|
|
28
|
+
unavailable: string;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function mergeDecisions(local: Pick<TeamDecisions, "leaveAlone" | "alwaysFlag">, cloud: CloudDecisions | {
|
|
31
|
+
unavailable: string;
|
|
32
|
+
}): TeamDecisions;
|
|
33
|
+
//# sourceMappingURL=team-decisions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-decisions.d.ts","sourceRoot":"","sources":["../../src/mcp/team-decisions.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMtD,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,uEAAuE;IACvE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAeD,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,YAAY,CAAC,CAMlH;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7D;AAWD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,SAAS,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE;AAED,uEAAuE;AACvE,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,cAAc,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBnD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,cAAc,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAWtJ"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The team's design decisions, for the file an agent is about to edit.
|
|
3
|
+
*
|
|
4
|
+
* Two sources: rules committed in `.buoy.yaml` (drift.ignore / enforce /
|
|
5
|
+
* promote, with their reasons), and, when the CLI is logged in, the values
|
|
6
|
+
* the team declined on pull requests (Buoy Cloud's remembered dismissals,
|
|
7
|
+
* e.g. a deliberate 12.5px). An agent that knows these before it writes
|
|
8
|
+
* neither "fixes" a deliberate value nor reintroduces a banned one.
|
|
9
|
+
*/
|
|
10
|
+
import { execFile } from "node:child_process";
|
|
11
|
+
import { promisify } from "node:util";
|
|
12
|
+
import { minimatch } from "minimatch";
|
|
13
|
+
import { getApiEndpoint, getApiToken } from "../cloud/config.js";
|
|
14
|
+
const run = promisify(execFile);
|
|
15
|
+
const CLOUD_TIMEOUT_MS = 2_000;
|
|
16
|
+
function describe(rule) {
|
|
17
|
+
const what = [rule.value && `${rule.value}`, rule.type && `type ${rule.type}`, rule.token && `token ${rule.token}`, rule.component && `component ${rule.component}`]
|
|
18
|
+
.filter(Boolean).join(", ") || "all drift";
|
|
19
|
+
const where = rule.file ? ` in ${rule.file}` : "";
|
|
20
|
+
return `${what}${where}${rule.reason ? `: ${rule.reason}` : ""}`;
|
|
21
|
+
}
|
|
22
|
+
function applies(rule, file) {
|
|
23
|
+
return !rule.file || minimatch(file, rule.file, { dot: true }) || file === rule.file;
|
|
24
|
+
}
|
|
25
|
+
/** Rules committed in .buoy.yaml that apply to this file. */
|
|
26
|
+
export function configDecisions(config, file) {
|
|
27
|
+
const drift = config.drift ?? {};
|
|
28
|
+
return {
|
|
29
|
+
leaveAlone: (drift?.ignore ?? []).filter((r) => applies(r, file)).map(describe),
|
|
30
|
+
alwaysFlag: [...(drift?.enforce ?? []), ...(drift?.promote ?? [])].filter((r) => applies(r, file)).map(describe),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** `git@github.com:o/r.git` or `https://github.com/o/r` → `o/r`. */
|
|
34
|
+
export function parseGitHubRepo(remote) {
|
|
35
|
+
const m = /github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/.exec(remote.trim());
|
|
36
|
+
return m ? `${m[1]}/${m[2]}` : null;
|
|
37
|
+
}
|
|
38
|
+
async function originRepo(projectRoot) {
|
|
39
|
+
try {
|
|
40
|
+
const { stdout } = await run("git", ["remote", "get-url", "origin"], { cwd: projectRoot, timeout: 1_000 });
|
|
41
|
+
return parseGitHubRepo(stdout);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Decisions from Buoy Cloud, or a short reason why there are none. */
|
|
48
|
+
export async function fetchCloudDecisions(projectRoot, file, fetchImpl = fetch) {
|
|
49
|
+
const token = getApiToken();
|
|
50
|
+
if (!token)
|
|
51
|
+
return { unavailable: "not logged in (run `buoy ahoy login` to include decisions from PR reviews)" };
|
|
52
|
+
const repo = await originRepo(projectRoot);
|
|
53
|
+
if (!repo)
|
|
54
|
+
return { unavailable: "no GitHub origin remote" };
|
|
55
|
+
const url = `${getApiEndpoint()}/api/v1/decisions?repo=${encodeURIComponent(repo)}&file=${encodeURIComponent(file)}`;
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetchImpl(url, {
|
|
58
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
59
|
+
signal: AbortSignal.timeout(CLOUD_TIMEOUT_MS),
|
|
60
|
+
});
|
|
61
|
+
if (res.status === 404)
|
|
62
|
+
return { unavailable: `${repo} is not on Buoy Cloud in this account` };
|
|
63
|
+
if (!res.ok)
|
|
64
|
+
return { unavailable: `Buoy Cloud returned ${res.status}` };
|
|
65
|
+
const body = (await res.json());
|
|
66
|
+
return { file: body.file ?? [], recurring: body.recurring ?? [] };
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return { unavailable: "Buoy Cloud did not answer in time" };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function mergeDecisions(local, cloud) {
|
|
73
|
+
const sources = [".buoy.yaml"];
|
|
74
|
+
const leaveAlone = [...local.leaveAlone];
|
|
75
|
+
if ("unavailable" in cloud) {
|
|
76
|
+
sources.push(`PR reviews: ${cloud.unavailable}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
sources.push("PR reviews (Buoy Cloud)");
|
|
80
|
+
for (const d of cloud.file)
|
|
81
|
+
leaveAlone.push(`${d.value} in this file: ${d.reason}`);
|
|
82
|
+
for (const d of cloud.recurring)
|
|
83
|
+
leaveAlone.push(`${d.value} (kept in ${d.files} files): ${d.reason}`);
|
|
84
|
+
}
|
|
85
|
+
return { leaveAlone: [...new Set(leaveAlone)].slice(0, 20), alwaysFlag: local.alwaysFlag.slice(0, 20), sources };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=team-decisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-decisions.js","sourceRoot":"","sources":["../../src/mcp/team-decisions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAChC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAa/B,SAAS,QAAQ,CAAC,IAAU;IAC1B,MAAM,IAAI,GA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AG,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACpF,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS;YAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;AACnH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-design/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.13",
|
|
4
4
|
"description": "Catch design drift before it ships",
|
|
5
5
|
"mcpName": "io.github.ahoybuoy/buoy",
|
|
6
6
|
"type": "module",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"yaml": "^2.8.2",
|
|
50
50
|
"zod": "^3.24.1",
|
|
51
51
|
"zod-validation-error": "^5.0.0",
|
|
52
|
-
"@buoy-design/core": "0.8.
|
|
53
|
-
"@buoy-design/scanners": "0.8.
|
|
52
|
+
"@buoy-design/core": "0.8.13",
|
|
53
|
+
"@buoy-design/scanners": "0.8.13"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^22.10.2",
|