@reqvire-org/ads 0.3.52 → 0.4.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 +10 -9
- package/dist/assets.mjs +16 -2
- package/dist/behaviors.mjs +6 -5
- package/dist/boundaries.mjs +5 -5
- package/dist/browser-audit/first-render.mjs +22 -0
- package/dist/browser-audit/image-shape.mjs +36 -0
- package/dist/browser-audit/render-states.mjs +61 -35
- package/dist/browser-audit/worker.mjs +47 -12
- package/dist/browser-audit.mjs +75 -12
- package/dist/bun-compiler.mjs +14 -7
- package/dist/check-service.mjs +83 -0
- package/dist/check.mjs +20 -18
- package/dist/cli.mjs +5 -3
- package/dist/config.mjs +20 -41
- package/dist/contracts.d.mts +9 -0
- package/dist/finding-rules.mjs +8 -1
- package/dist/font-rules.mjs +103 -0
- package/dist/fonts-generated.mjs +32 -12
- package/dist/generated-entries.mjs +131 -0
- package/dist/icons.mjs +1 -1
- package/dist/init.mjs +11 -32
- package/dist/layers.mjs +7 -3
- package/dist/lint-config.mjs +4 -2
- package/dist/mcp/catalog.mjs +2 -1
- package/dist/mcp/context.mjs +3 -3
- package/dist/mcp/drafts.mjs +136 -121
- package/dist/mcp/mutations.mjs +65 -19
- package/dist/mcp/preview-watch.mjs +31 -5
- package/dist/mcp/preview-widget.bundle.js +50 -47
- package/dist/mcp/project-widget.bundle.js +45 -42
- package/dist/mcp/prompts.mjs +1 -1
- package/dist/mcp/server.mjs +81 -40
- package/dist/mcp/showcase-host.mjs +20 -7
- package/dist/mcp/widget.bundle.js +49 -46
- package/dist/oxlint.mjs +3 -2
- package/dist/program-cache.mjs +36 -0
- package/dist/public-api.mjs +2 -1
- package/dist/scenarios-compiler.mjs +82 -14
- package/dist/scenarios-vite.mjs +1 -1
- package/dist/scenarios.mjs +4 -3
- package/dist/showcase/client.bundle.js +27 -27
- package/dist/showcase/index.html +2 -2
- package/dist/skills/ads-break-ui/SKILL.md +25 -28
- package/dist/skills/ads-break-ui/references/behaviors.md +7 -6
- package/dist/skills/ads-break-ui/references/captures.md +7 -32
- package/dist/skills/ads-break-ui/references/contracts.md +58 -25
- package/dist/skills/ads-break-ui/references/drafts.md +59 -43
- package/dist/skills/ads-break-ui/references/evidence.md +1 -1
- package/dist/skills/ads-break-ui/references/guarded-editing.md +58 -47
- package/dist/skills/ads-break-ui/references/review.md +9 -8
- package/dist/skills/ads-break-ui/references/scenarios.md +1 -1
- package/dist/skills/ads-break-ui/references/validation.md +8 -4
- package/dist/skills/ads-break-ui/references/workflows.md +15 -8
- package/dist/skills/ads-designer/SKILL.md +30 -31
- package/dist/skills/ads-designer/references/accessibility.md +9 -5
- package/dist/skills/ads-designer/references/behaviors.md +7 -6
- package/dist/skills/ads-designer/references/branding.md +2 -2
- package/dist/skills/ads-designer/references/captures.md +7 -32
- package/dist/skills/ads-designer/references/cli.md +5 -1
- package/dist/skills/ads-designer/references/contracts.md +58 -25
- package/dist/skills/ads-designer/references/drafts.md +59 -43
- package/dist/skills/ads-designer/references/evidence.md +1 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -47
- package/dist/skills/ads-designer/references/performance.md +57 -6
- package/dist/skills/ads-designer/references/review.md +9 -8
- package/dist/skills/ads-designer/references/scenarios.md +1 -1
- package/dist/skills/ads-designer/references/validation.md +8 -4
- package/dist/skills/ads-designer/references/workflows.md +15 -8
- package/dist/skills/ads-import/SKILL.md +25 -28
- package/dist/skills/ads-import/references/behaviors.md +7 -6
- package/dist/skills/ads-import/references/captures.md +7 -32
- package/dist/skills/ads-import/references/cli.md +5 -1
- package/dist/skills/ads-import/references/contracts.md +58 -25
- package/dist/skills/ads-import/references/drafts.md +59 -43
- package/dist/skills/ads-import/references/evidence.md +1 -1
- package/dist/skills/ads-import/references/guarded-editing.md +58 -47
- package/dist/skills/ads-import/references/review.md +9 -8
- package/dist/skills/ads-import/references/scenarios.md +1 -1
- package/dist/skills/ads-import/references/validation.md +8 -4
- package/dist/skills/ads-import/references/workflows.md +15 -8
- package/dist/skills/ads-motion/SKILL.md +25 -28
- package/dist/skills/ads-motion/references/behaviors.md +7 -6
- package/dist/skills/ads-motion/references/captures.md +7 -32
- package/dist/skills/ads-motion/references/contracts.md +58 -25
- package/dist/skills/ads-motion/references/drafts.md +59 -43
- package/dist/skills/ads-motion/references/evidence.md +1 -1
- package/dist/skills/ads-motion/references/guarded-editing.md +58 -47
- package/dist/skills/ads-motion/references/review.md +9 -8
- package/dist/skills/ads-motion/references/scenarios.md +1 -1
- package/dist/skills/ads-motion/references/validation.md +8 -4
- package/dist/skills/ads-motion/references/workflows.md +15 -8
- package/dist/skills/ads-port/SKILL.md +25 -28
- package/dist/skills/ads-port/references/behaviors.md +7 -6
- package/dist/skills/ads-port/references/captures.md +7 -32
- package/dist/skills/ads-port/references/cli.md +5 -1
- package/dist/skills/ads-port/references/contracts.md +58 -25
- package/dist/skills/ads-port/references/drafts.md +59 -43
- package/dist/skills/ads-port/references/evidence.md +1 -1
- package/dist/skills/ads-port/references/guarded-editing.md +58 -47
- package/dist/skills/ads-port/references/native-implementation.md +6 -6
- package/dist/skills/ads-port/references/review.md +9 -8
- package/dist/skills/ads-port/references/scenarios.md +1 -1
- package/dist/skills/ads-port/references/validation.md +8 -4
- package/dist/skills/ads-port/references/workflows.md +15 -8
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/preact/ds.config.json +0 -14
- package/dist/starters/react/README.md +9 -5
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +1 -1
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +2 -2
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +3 -7
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/index.ts +4 -3
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/ds.config.json +0 -14
- package/dist/style-boundaries.mjs +7 -6
- package/dist/test-boundaries.mjs +2 -2
- package/dist/themes-watch.mjs +9 -3
- package/dist/token-fixtures.mjs +1 -1
- package/dist/unit-contracts.mjs +38 -4
- package/dist/units.mjs +16 -91
- package/dist/validation-checks.mjs +7 -1
- package/docs/ADS.md +10 -10
- package/docs/ARCHITECTURE.md +104 -44
- package/docs/BEHAVIORS.md +8 -7
- package/docs/CACHING.md +15 -6
- package/docs/CHANGELOG.md +107 -12
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +10 -25
- package/docs/GUIDE.md +98 -57
- package/docs/MCP.md +116 -151
- package/package.json +7 -7
- package/dist/contract-migration.mjs +0 -110
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
package/dist/init.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, writeFileSync, chmodSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import ts from "typescript";
|
|
5
4
|
import { isInside, loadConfig, sourceFiles, supportedFrameworks } from "./config.mjs";
|
|
6
5
|
import { foundationFiles } from "./token-policy.mjs";
|
|
7
6
|
import { generatedPaletteFile } from "./palette-generated.mjs";
|
|
7
|
+
import { generatedEntries } from "./generated-entries.mjs";
|
|
8
8
|
import { assertFrameworkCompiler } from "./ui-framework.mjs";
|
|
9
9
|
|
|
10
10
|
const tool = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
@@ -117,6 +117,11 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
117
117
|
const initialConfigFile=path.join(root,"ds.config.json"),initialConfig=existsSync(initialConfigFile)?JSON.parse(readFileSync(initialConfigFile,"utf8")):{};
|
|
118
118
|
const nativePreviewMissing=initialConfig.mcp?.previewManifest===undefined;
|
|
119
119
|
if(nativePreviewMissing)config.mcp.previewManifest=".ds/preview/manifest.json";
|
|
120
|
+
// ADS generates the barrels and the styles entry. A hand-written one stops init before any write.
|
|
121
|
+
for (const entry of [config.publicEntry, config.reviewEntry, config.stylesEntry]) {
|
|
122
|
+
const file = path.join(dsRoot, entry);
|
|
123
|
+
if (existsSync(file) && !/^(?:\/\/|\/\*) Generated by ADS/.test(readFileSync(file, "utf8"))) throw new Error(`${path.relative(root, file).replaceAll("\\", "/")} is hand-written, but ADS generates it. Move each public export into its owner's <Owner>.ads.exports.ts (token sheets feed the styles entry), delete the file and run ads init again.`);
|
|
124
|
+
}
|
|
120
125
|
if (framework !== undefined && !supportedFrameworks.includes(framework)) throw new Error("framework must be react or preact.");
|
|
121
126
|
if (framework !== undefined && config.framework !== null && framework !== config.framework) throw new Error(`ADS is configured for ${config.framework}; --framework ${framework} would change it. Migrate the project and update ds.config.json explicitly before running init.`);
|
|
122
127
|
const selectedFramework = framework ?? config.framework;
|
|
@@ -153,11 +158,7 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
153
158
|
function addMissing(file, content) { assertLocalFile(root, file); if (!existsSync(file)) updates.set(file, content); }
|
|
154
159
|
const tokenRoot = path.join(dsRoot, config.tokenDir);
|
|
155
160
|
const existingTokens = sourceFiles(tokenRoot).filter((file) => file.endsWith(".css"));
|
|
156
|
-
|
|
157
|
-
const file = path.join(tokenRoot, name);
|
|
158
|
-
addMissing(file, readFileSync(path.join(starter, "design-system/tokens", name)));
|
|
159
|
-
return file;
|
|
160
|
-
});
|
|
161
|
+
if (!existingTokens.length) for (const name of foundationFiles.filter((name) => existsSync(path.join(starter, "design-system/tokens", name)))) addMissing(path.join(tokenRoot, name), readFileSync(path.join(starter, "design-system/tokens", name)));
|
|
161
162
|
if (!existingTokens.length) {
|
|
162
163
|
// The renderer palette generated from the starter's token sheets, beside its theme sheet.
|
|
163
164
|
addMissing(path.join(tokenRoot, generatedPaletteFile), readFileSync(path.join(starter, "design-system/tokens", generatedPaletteFile)));
|
|
@@ -166,34 +167,10 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
166
167
|
const content = readFileSync(path.join(starter, "design-system/tokens", name), "utf8").replaceAll('"@ds/review"', JSON.stringify(`${config.publicAlias}/review`)).replaceAll('"@ds"', JSON.stringify(config.publicAlias));
|
|
167
168
|
addMissing(path.join(tokenRoot, name), content);
|
|
168
169
|
}
|
|
169
|
-
for (const name of ["TokenPreview.tsx"]) {
|
|
170
|
+
for (const name of ["TokenPreview.tsx", "TokenPreview.ads.contract.ts", "TokenPreview.ads.exports.ts"]) {
|
|
170
171
|
const content = readFileSync(starterFile(selectedFramework, `design-system/review/token-preview/${name}`), "utf8");
|
|
171
172
|
addMissing(path.join(dsRoot, "review/token-preview", name), content.replaceAll('"@ds"', JSON.stringify(config.publicAlias)));
|
|
172
173
|
}
|
|
173
|
-
const reviewFile = path.relative(root, path.join(dsRoot, "review/token-preview/TokenPreview.tsx")).replaceAll("\\", "/");
|
|
174
|
-
if (!config.boundaries.styleWrites.some(item => item.file === reviewFile)) config.boundaries.styleWrites.push({ file: reviewFile, properties: ["--ux-token-preview-value"] });
|
|
175
|
-
}
|
|
176
|
-
tokenFiles.sort((a, b) => foundationFiles.indexOf(path.basename(a)) - foundationFiles.indexOf(path.basename(b)) || a.localeCompare(b));
|
|
177
|
-
const stylesFile = path.join(dsRoot, config.stylesEntry);
|
|
178
|
-
const relativeImport = (from, to) => {
|
|
179
|
-
const relative = path.relative(path.dirname(from), to).split(path.sep).join("/");
|
|
180
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
181
|
-
};
|
|
182
|
-
addMissing(stylesFile, tokenFiles.map((file) => `@import ${JSON.stringify(relativeImport(stylesFile, file))};`).join("\n") + "\n");
|
|
183
|
-
const entryFile = path.join(dsRoot, config.publicEntry);
|
|
184
|
-
addMissing(entryFile, `// Export your project's public components and types here.\nimport ${JSON.stringify(relativeImport(entryFile, stylesFile))};\n`);
|
|
185
|
-
if (!existingTokens.length) {
|
|
186
|
-
const reviewEntry = path.join(dsRoot, config.reviewEntry);
|
|
187
|
-
const reviewExport = `export { TokenPreview } from ${JSON.stringify(relativeImport(reviewEntry, path.join(dsRoot, "review/token-preview/TokenPreview")))};\n`;
|
|
188
|
-
addMissing(reviewEntry, reviewExport);
|
|
189
|
-
if (existsSync(reviewEntry) && !readFileSync(reviewEntry, "utf8").includes("token-preview/TokenPreview")) throw new Error("The project owns an existing review entry. Add the new token renderer through that development API before initializing the foundation.");
|
|
190
|
-
if (existsSync(entryFile)) {
|
|
191
|
-
let current = readFileSync(entryFile, "utf8");
|
|
192
|
-
const ast = ts.createSourceFile(entryFile, current, ts.ScriptTarget.Latest, true);
|
|
193
|
-
for (const statement of [...ast.statements].reverse()) if (ts.isExportDeclaration(statement) && !statement.moduleSpecifier && statement.exportClause && ts.isNamedExports(statement.exportClause) && !statement.exportClause.elements.length) current = current.slice(0, statement.getStart(ast)) + current.slice(statement.end);
|
|
194
|
-
if (!ast.statements.some(statement => ts.isImportDeclaration(statement) || statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword))) current += `\nimport ${JSON.stringify(relativeImport(entryFile, stylesFile))};\n`;
|
|
195
|
-
if (current !== readFileSync(entryFile, "utf8")) updates.set(entryFile, current);
|
|
196
|
-
}
|
|
197
174
|
}
|
|
198
175
|
// Keeps a section folder that has nothing in it yet.
|
|
199
176
|
for (const section of ["components", "patterns", "controllers", "composition"]) {
|
|
@@ -210,7 +187,7 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
210
187
|
const saved = JSON.parse(original);
|
|
211
188
|
if (saved.framework === undefined || !existingTokens.length || nativePreviewMissing) {
|
|
212
189
|
const indent = original.match(/\n([\t ]+)"/)?.[1] ?? " ";
|
|
213
|
-
updates.set(configFile, `${JSON.stringify({ ...saved, framework: selectedFramework, ...(nativePreviewMissing?{mcp:{...saved.mcp,previewManifest:config.mcp.previewManifest}}:{})
|
|
190
|
+
updates.set(configFile, `${JSON.stringify({ ...saved, framework: selectedFramework, ...(nativePreviewMissing?{mcp:{...saved.mcp,previewManifest:config.mcp.previewManifest}}:{})}, null, indent)}\n`);
|
|
214
191
|
}
|
|
215
192
|
}
|
|
216
193
|
// The framework's scenario mount, as the starter has it.
|
|
@@ -223,5 +200,7 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
223
200
|
const nextPackage = `${JSON.stringify(pkg, null, indent)}\n`;
|
|
224
201
|
if (nextPackage !== originalPackage) updates.set(packageFile, nextPackage);
|
|
225
202
|
commit(root, updates);
|
|
203
|
+
// The styles entry and the barrels are generated from the token sheets and exports files.
|
|
204
|
+
commit(root, new Map(generatedEntries(loadConfig(root)).map(entry => [entry.file, entry.text])));
|
|
226
205
|
return { directory: root, framework: selectedFramework, packageManager: manager, toolDependency: { name: tool.name, spec }, updatedFiles: [...updates.keys()] };
|
|
227
206
|
}
|
package/dist/layers.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import selectorParser from "postcss-selector-parser";
|
|
|
5
5
|
import valueParser from "postcss-value-parser";
|
|
6
6
|
import { isDevelopmentFile, isInside, isStateVariable, isTestFile, isReviewFile } from "./config.mjs";
|
|
7
7
|
import { importResolver, styleAccessProperty } from "./boundaries.mjs";
|
|
8
|
+
import { ownerStylePolicy } from "./unit-contracts.mjs";
|
|
8
9
|
|
|
9
10
|
const guidance = "See ads://guides/layers. A component provides one cohesive UI capability; a pattern arranges capabilities into a reusable structure or workflow. Component count does not decide the layer.";
|
|
10
11
|
|
|
@@ -37,8 +38,11 @@ export function createLayerBoundaries(program, options, report) {
|
|
|
37
38
|
const { root, dsRoot, sourceRoot, config } = options;
|
|
38
39
|
const checker = program.getTypeChecker(), resolve = importResolver(options);
|
|
39
40
|
const sources = program.getSourceFiles().filter(source => isInside(root, source.fileName) && !source.isDeclarationFile && !source.fileName.split(path.sep).includes("node_modules"));
|
|
40
|
-
|
|
41
|
-
const
|
|
41
|
+
// Called for every syntax node and import edge: answer once per file.
|
|
42
|
+
const perFile = compute => { const known = new Map(); return file => { if (!known.has(file)) known.set(file, compute(file)); return known.get(file); }; };
|
|
43
|
+
const runtime = perFile(file => !isTestFile(file) && !isDevelopmentFile(file, options));
|
|
44
|
+
const sections = ["components", "patterns", "controllers", "composition", "review"].map(name => [name, path.join(dsRoot, name)]);
|
|
45
|
+
const layer = perFile(file => sections.find(([, directory]) => isInside(directory, file))?.[0] ?? (isInside(sourceRoot, file) && !isInside(dsRoot, file) ? "application" : "shared"));
|
|
42
46
|
const unalias = symbol => symbol?.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
43
47
|
const entry = program.getSourceFile(path.join(dsRoot, config.publicEntry));
|
|
44
48
|
const module = entry && checker.getSymbolAtLocation(entry);
|
|
@@ -281,7 +285,7 @@ export function createLayerBoundaries(program, options, report) {
|
|
|
281
285
|
css.walkDecls(declaration => valueParser(declaration.value).walk(node => {
|
|
282
286
|
if (node.type !== "function" || node.value !== "var") return;
|
|
283
287
|
const name = node.nodes.find(child => child.type === "word")?.value;
|
|
284
|
-
if ((componentVariables.has(name) || ownLayer === "review" && patternVariables.has(name) && !publicHooks.has(name)) && (isStateVariable(name) || !
|
|
288
|
+
if ((componentVariables.has(name) || ownLayer === "review" && patternVariables.has(name) && !publicHooks.has(name)) && (isStateVariable(name) || !ownerStylePolicy(options).componentVariables.includes(name))) styleReport(declaration, `${ownLayer === "review" ? "Review reads private product" : "Pattern reads private component"} variable ${name}.`);
|
|
285
289
|
}));
|
|
286
290
|
}
|
|
287
291
|
return { inspectDependencies, runtimeHelpers, collectComponentStyles, inspectStyles };
|
package/dist/lint-config.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { loadConfig } from "./config.mjs";
|
|
5
5
|
import { configurationFiles } from "./units.mjs";
|
|
6
6
|
import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
|
|
7
|
+
import { ownerStylePolicy } from "./unit-contracts.mjs";
|
|
7
8
|
|
|
8
|
-
export function createLintConfig(
|
|
9
|
+
export function createLintConfig(project) {
|
|
10
|
+
const { root, config } = project;
|
|
9
11
|
const names = new Set(["ads"]);
|
|
10
12
|
const projectPlugins = config.oxlint.plugins.map((plugin) => {
|
|
11
13
|
if (names.has(plugin.name)) throw new Error(`Duplicate or reserved Oxlint plugin name: ${plugin.name}`);
|
|
@@ -14,7 +16,7 @@ export function createLintConfig({ root, config }) {
|
|
|
14
16
|
if (!existsSync(specifier)) throw new Error(`Project plugin not found: ${plugin.path}`);
|
|
15
17
|
return { name: plugin.name, specifier };
|
|
16
18
|
});
|
|
17
|
-
const options = { projectRoot: root, sourceDir: config.sourceDir, dsDir: config.dsDir, publicAlias: config.publicAlias, publicEntry: config.publicEntry, reviewEntry: config.reviewEntry, stylesEntry: config.stylesEntry, inlineStyleFiles:
|
|
19
|
+
const options = { projectRoot: root, sourceDir: config.sourceDir, dsDir: config.dsDir, publicAlias: config.publicAlias, publicEntry: config.publicEntry, reviewEntry: config.reviewEntry, stylesEntry: config.stylesEntry, inlineStyleFiles: ownerStylePolicy(project).inlineStyleFiles,
|
|
18
20
|
configurationFiles: [...configurationFiles({ root, config, sourceRoot: path.resolve(root,config.sourceDir), dsRoot: path.resolve(root,config.dsDir) })].sort() };
|
|
19
21
|
return {
|
|
20
22
|
ignorePatterns: ["../ads-drafts/**", "**/*.ads", "**/*.ads.draft.*"],
|
package/dist/mcp/catalog.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { publicApi } from "../public-api.mjs";
|
|
|
7
7
|
import { projectDocumentFiles } from "../project-documents.mjs";
|
|
8
8
|
import { inspectUnitContracts } from "../unit-contracts.mjs";
|
|
9
9
|
import { inspectBehaviorLibraries } from "../behavior-libraries.mjs";
|
|
10
|
+
import { cachedProgram } from "../program-cache.mjs";
|
|
10
11
|
|
|
11
12
|
export const PROJECT_URI = "ads://project";
|
|
12
13
|
export const sourceUri = (file) => `${PROJECT_URI}/files/${file.split("/").map(encodeURIComponent).join("/")}`;
|
|
@@ -34,7 +35,7 @@ export function inspectCatalog(options, scenarios = [], libraries) {
|
|
|
34
35
|
const { root, dsRoot, config } = options;
|
|
35
36
|
const entry = path.join(dsRoot, config.publicEntry);
|
|
36
37
|
if (!existsSync(entry)) return [];
|
|
37
|
-
const program = inspectUnitContracts(options).program ??
|
|
38
|
+
const program = inspectUnitContracts(options).program ?? cachedProgram(`catalog:${options.root}`, [entry], { ...projectCompilerOptions(options), allowJs: true });
|
|
38
39
|
const checker = program.getTypeChecker();
|
|
39
40
|
libraries ??= inspectBehaviorLibraries(options, program);
|
|
40
41
|
const source = program.getSourceFile(entry);
|
package/dist/mcp/context.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { developmentRuntime, packageScriptCommand } from "../development-runtime
|
|
|
6
6
|
|
|
7
7
|
export const GUIDE_URI = "ads://project/guide";
|
|
8
8
|
// Put the task triggers and entry path first: some hosts shorten server guidance.
|
|
9
|
-
export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. Choose direct source editing or MCP-only editing using ads://guides/workflows, based on actual editor access and user preference, not mutations.enabled. With direct code access, edit owned files normally and use MCP for preview/checks; ordinary direct edits do not require drafts or ads_accept. MCP-only iterative design uses enabled draft tools, rendered review and exact-revision ads_accept; read ads://guides/drafts. Complete tracked proposals by accepting required drafts; accept dependencies first and review dependents again. Without a source editor or enabled mutation tools, inspection is available but editing is not.
|
|
9
|
+
export const serverInstructions = "Use ADS for UI work: components, patterns, controllers, hooks, tokens, themes, branding, layout, interaction, accessibility, motion and showcase review. Start with ads_status; if tools are not exposed, read ads://project/guide then ads://project/status. Use the returned projectRoot and commands. Choose direct source editing or MCP-only editing using ads://guides/workflows, based on actual editor access and user preference, not mutations.enabled. With direct code access, edit owned files normally and use MCP for preview/checks; ordinary direct edits do not require drafts or ads_accept. MCP-only iterative design uses enabled draft tools, rendered review and exact-revision ads_accept; read ads://guides/drafts. Complete tracked proposals by accepting required drafts; accept dependencies first and review dependents again. Without a source editor or enabled mutation tools, inspection is available but editing is not. Every MCP source change, including low-level repairs, goes through a draft: ads_create_draft, edit or patch it (ads_update_draft with patch), ads_show_draft, then ads_accept; only a draft can be accepted. Find existing public UI with ads_catalog; discover its previews with ads_scenarios and open ads_show_scenario. Starting ADS also serves its built-in showcase: use ads_status.showcaseUrl for browser review instead of starting another runtime/compiler or project browser app. Read one relevant ADS skill before editing. Inspect the real preview, edit its owned source, check the build and review again. Scope source/guides to the project, its instruction ancestry and user-selected import/reference sources; broad searches of /mnt or home are not ADS discovery. Domain-model/requirements work is a separate project workflow. For requested visual evidence, use ads_capture (accepted source, or a draft revision beside accepted); read ads://guides/captures for named targets, image resources and the current/candidate lifecycle. For behavior work, read ads://guides/behaviors and use ads_behaviors/ads_verify: scenario exercises are demonstrations, and registered guarantees need current passing execution evidence. For direct edits, use ads_validate with policy acceptance to enforce the project acceptance policy without applying source. Draft acceptance (and its dryRun) uses the same configured policy on its candidate, including the axe-core audit of the draft owners' own UI scenarios (acceptance.browserAudit owners; affected reaches every scenario the change touches; false skips it), with the full audit as a stage via ads_validate after a series of drafts; draft edit/show runs neither policy. Test registration alone does not gate acceptance. Use ads_validate with scope changed during editing, and the default full validation policy/scope after test/ownership/config migrations, before releases, or for explicit complete audits. Read ads://guides/validation; report actual scope/revision and inspect failures through ads_results. Execution replies are bounded summaries. Read only needed sections with ads_results(resultId, section, status, cursor); follow nextCursor without rerunning. For a failure, inspect its boundary and acceptance, then ads_investigate with the outcome's exact unit/check/runId; detail sections and artifacts load separately (ads://guides/evidence). Preserve valid APIs when source tracing is inconclusive. After targeted investigation, record suspected ADS defects with ads_report_bug or missing capabilities with ads_request_feature; read ads://guides/reporting. These are local untriaged reports, not established causes or upstream issues. Use the configured project framework and declared dependencies; MCP hosts supply no ad hoc APIs. MCP source checks do not replace browser tests; direct edits still need project checks. Reading HTML is not rendering, and reading a skill is not native activation. A running watcher is not proof of current source: inspect ads_status.build or ads://project/build after edits. Notifications may not reach the agent. Only explicitly enabled mutation tools edit project-owned ADS units after validation. Checks and compiler commands come from validated project configuration, never an ad hoc command argument.";
|
|
10
10
|
|
|
11
11
|
function manager(root, pkg) {
|
|
12
12
|
if (typeof pkg.packageManager === "string") return pkg.packageManager.split("@")[0];
|
|
@@ -65,9 +65,9 @@ Use this server for UI components/patterns, tokens/themes/branding, layout, inte
|
|
|
65
65
|
Inspection connects a public export to its owning source, available guides, token values and discovered preview IDs. Bounded tools keep discovery focused; explicit resource reads supply detail. Source metadata does not prove layout, interaction or motion. A scenario renders the real public implementation and its fixture context in either review surface.
|
|
66
66
|
5. Choose an editing route using ads://guides/workflows and the user's instructions. With direct design-system code access, edit owned files in the normal editor and use MCP for discovery, preview, captures and checks. Ordinary source edits do not require drafts or ads_accept, even if mutations are enabled. The default managed compiler rebuilds them automatically. For an external builder, mcp.previewWatch:false disables MCP-started compilation; the editor/builder must publish the ADS resource graph and build evidence (for example with ads compile .). Existing views can stay visible while changed-source evidence is stale, until verified updated output is published.
|
|
67
67
|
With MCP-only access and enabled mutation tools, read ads://guides/drafts. Discover owners with ads_units, create a coherent proposal with ads_create_draft, read/edit marked source through ads_read_file/ads_update_draft, inspect ads_show_draft in the browser, then ads_accept with its exact reviewed revision. Direct editors can choose this isolated workflow too. Complete tracked changes by accepting required drafts; accept dependencies first and review dependents again. Retain a proposal only when requested. No extra human approval step is implied. Without an editor or mutation tools, source editing is unavailable.
|
|
68
|
-
|
|
68
|
+
MCP edits always go through a draft; only a draft can be accepted. For focused repairs, create a one-owner draft and send a Git diff with ads_update_draft({id,revision,patch}); include the owner's scenarios, fixtures and its own .ads.exports.ts while preserving unrelated source. Coupled owners share one draft. Shared entries (public barrel, review entry, styles entry) are generated, and style permissions live in the owner's contract (styles.writes, styles.inline, customization). ads_accept with dryRun:true runs every acceptance check without writing; ads_prepare_token_samples reconciles explicit bindings into a draft. Configuration/guard/compiler changes use configuration, shared globals foundation, guides documentation and assets their discovered assets/* unit. Keep mandatory ADS gates. Never bypass a failed acceptance by switching to direct writes. Large patches can use patchFile under .ds/patches/. Reuse the local public API (${context.publicEntry}). Edit presentation in its ADS owner; keep application data/services/routing in application code and development fixtures beside their scenario; larger scenarios live in composition/. Demo framing and token renderers live in development-only review/, imported through ${context.review.importFrom}; never export them from the production barrel or import them into application runtime. Read ads://guides/review for review owners/aliases and ads://guides/contracts when editing static owner declarations, .ads. development roles, constrained paints/bindings or declarative APIs. Contract registration, source evidence and browser verification remain separate. Shared foundation Data is the only design-value catalogue. Components/patterns map shared roles; independent owner token namespaces and value sheets are rejected. Existing project font, text and spacing roles take precedence over divergent upstream constants. Read ads://guides/tokens for the source contract and overlap review. Linaria extracts owned styling. Inspect relevant tokens with ads_tokens and source/owning guides before edits.
|
|
69
69
|
6. ${route.validation} Registered commands: ${context.commands.map((command) => command.args?.join(" ") ?? `choose the project package manager for ${command.script}`).join("; ") || "none discovered; inspect the project's build setup"}. Run them from ${context.projectRoot}.
|
|
70
|
-
Execution replies from ads_verify and
|
|
70
|
+
Execution replies from ads_verify and ads_accept contain counts, acceptance and resultId, not full reports. Read only needed outcomes/diagnostics/captures with ads_results, following nextCursor with identical filters. A truncated row has recordIndex for bounded text ranges. For one failure, use ads_investigate with its unit/check/runId; read request/error/artifact sections only when needed. Results are retained by immutable run ID with bounded retention; exact investigation run IDs select retained historical evidence. Shared-server checks and accepted-source writes serialize; ADS_VALIDATION_LOCKED includes the holder and progress. A source edit can stop validation with ADS_SOURCE_CHANGED_DURING_RUN. Read ads_status.execution before retrying. Notifications do not establish freshness.
|
|
71
71
|
|
|
72
72
|
7. After edits, inspect ads_status.build or ads://project/build explicitly. Running/unreported/old output is not a current successful preview. Fix diagnostics in owned source, wait for rebuilding and invoke the preview tool again. Notifications may not start an agent turn.
|
|
73
73
|
|