@reqvire-org/ads 0.3.53 → 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 +9 -8
- package/dist/assets.mjs +1 -1
- package/dist/behaviors.mjs +6 -5
- package/dist/boundaries.mjs +5 -5
- package/dist/browser-audit.mjs +10 -5
- package/dist/bun-compiler.mjs +14 -7
- package/dist/check-service.mjs +83 -0
- package/dist/check.mjs +16 -17
- package/dist/cli.mjs +4 -2
- package/dist/config.mjs +17 -40
- package/dist/contracts.d.mts +9 -0
- package/dist/fonts-generated.mjs +2 -0
- 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/prompts.mjs +1 -1
- package/dist/mcp/server.mjs +79 -38
- package/dist/mcp/showcase-host.mjs +20 -7
- 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 +1 -1
- 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 +25 -28
- 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/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 +3 -2
- 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/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/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 +79 -43
- package/docs/BEHAVIORS.md +8 -7
- package/docs/CACHING.md +15 -6
- package/docs/CHANGELOG.md +61 -12
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +10 -25
- package/docs/GUIDE.md +64 -55
- package/docs/MCP.md +116 -151
- package/package.json +1 -1
- package/dist/contract-migration.mjs +0 -110
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { isInside } from "../config.mjs";
|
|
6
|
-
import { checkUnitFiles, inspectUnits, validateUnitId } from "../units.mjs";
|
|
7
|
-
import { textDiff } from "./text-diff.mjs";
|
|
8
|
-
import { migrateContractDraft } from "../contract-migration.mjs";
|
|
9
|
-
|
|
10
|
-
const hash = value => createHash("sha256").update(value).digest("hex");
|
|
11
|
-
const binary = bytes => bytes?.includes(0) || bytes && !Buffer.from(bytes.toString("utf8")).equals(bytes);
|
|
12
|
-
export function preparedFileDiff(file, left, right, original, next) {
|
|
13
|
-
if (!binary(left) && !binary(right)) return textDiff(file,left?.toString()??null,right?.toString()??null);
|
|
14
|
-
let diff;
|
|
15
|
-
try { diff=execFileSync("git",["diff","--no-index","--binary","--no-ext-diff","--no-textconv","--",left===null?"/dev/null":original,right===null?"/dev/null":next],{encoding:"utf8",maxBuffer:16*1024*1024}); }
|
|
16
|
-
catch(error){if(error.status!==1)throw error;diff=error.stdout;}
|
|
17
|
-
return diff.replace(/^diff --git .+$/m,`diff --git a/${file} b/${file}`);
|
|
18
|
-
}
|
|
19
|
-
function generated(options, relative) {
|
|
20
|
-
const target = path.join(options.root, ".ds", relative);
|
|
21
|
-
mkdirSync(path.dirname(target), {recursive:true});
|
|
22
|
-
if (realpathSync(path.dirname(target)) !== path.dirname(target)) throw new Error("Patch preparation output cannot resolve through symlinks.");
|
|
23
|
-
return target;
|
|
24
|
-
}
|
|
25
|
-
export function storePreparedPatch(options, patch) {
|
|
26
|
-
if (Buffer.byteLength(patch) > 16 * 1024 * 1024) throw new Error("Prepared Git patch exceeds 16 MiB.");
|
|
27
|
-
if (!patch) return {patch:null,patchFile:null};
|
|
28
|
-
const file = `.ds/patches/${randomUUID()}.patch`;
|
|
29
|
-
writeFileSync(generated(options,file.slice(4)),patch);
|
|
30
|
-
return {patchFile:file,bytes:Buffer.byteLength(patch)};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** A temporary copy of just one owner and its declared companions, not a project mirror. */
|
|
34
|
-
export function prepareUnitPatch(options, {unit, action = "create", draft}) {
|
|
35
|
-
validateUnitId(unit);
|
|
36
|
-
const inventory = inspectUnits(options);
|
|
37
|
-
if (action === "create" || action === "migrate") {
|
|
38
|
-
const owner = inventory.units.find(entry => entry.id === unit);
|
|
39
|
-
if(action==="migrate"&&!owner)throw new Error("Discover an existing owner before preparing its contract migration.");
|
|
40
|
-
const files = [...new Set([...(owner?.files ?? []), ...(owner?.companionFiles ?? []).map(entry => entry.path),
|
|
41
|
-
...(!owner ? ["ds.config.json"] : []),
|
|
42
|
-
...(/^(?:components|patterns|controllers|review)\//.test(unit) ? [path.relative(options.root,path.join(options.dsRoot,unit.startsWith("review/")?options.config.reviewEntry:options.config.publicEntry)).replaceAll("\\","/")] : [])])];
|
|
43
|
-
if (!owner && !/^(?:components|patterns|controllers|composition|review)\/.+/.test(unit)) throw new Error("Discover an existing unit or choose a new unoccupied component/pattern/controller/composition/review owner.");
|
|
44
|
-
if (/^(?:components|patterns|controllers|composition|review)\//.test(unit)) for (let directory=unit;directory!==".";directory=path.posix.dirname(directory)) {
|
|
45
|
-
const marker=path.join(options.dsRoot,directory,".gitkeep");
|
|
46
|
-
if (existsSync(marker) && realpathSync(marker)===marker && lstatSync(marker).isFile() && lstatSync(marker).size===0) {
|
|
47
|
-
const relative=path.relative(options.root,marker).replaceAll("\\","/");
|
|
48
|
-
if (!files.includes(relative)) files.push(relative);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
draft = randomUUID();
|
|
52
|
-
const base = generated(options,`patch-drafts/${draft}/manifest.json`), folder = path.join(path.dirname(base),"work");
|
|
53
|
-
const entries = [];
|
|
54
|
-
let bytes = 0;
|
|
55
|
-
for (const file of files) {
|
|
56
|
-
const absolute = path.resolve(options.root,file);
|
|
57
|
-
if (!isInside(options.root,absolute) || realpathSync(absolute) !== absolute || !lstatSync(absolute).isFile()) throw new Error("Draft inputs must be ordinary project source files.");
|
|
58
|
-
if (lstatSync(absolute).size > 16 * 1024 * 1024) throw new Error("Draft input exceeds 16 MiB.");
|
|
59
|
-
const content = readFileSync(absolute);
|
|
60
|
-
bytes += content.length;
|
|
61
|
-
if (entries.length >= 256 || bytes > 32 * 1024 * 1024) throw new Error("Owner draft exceeds 256 files/32 MiB. Prepare a targeted Git patch instead.");
|
|
62
|
-
for (const name of ["work","base"]) {
|
|
63
|
-
const target = path.join(path.dirname(base),name,file);
|
|
64
|
-
mkdirSync(path.dirname(target),{recursive:true}); writeFileSync(target,content);
|
|
65
|
-
}
|
|
66
|
-
entries.push({file,digest:hash(content)});
|
|
67
|
-
}
|
|
68
|
-
mkdirSync(folder,{recursive:true});
|
|
69
|
-
writeFileSync(base,JSON.stringify({schemaVersion:1,unit,entries}));
|
|
70
|
-
const prepared={draft,unit,directory:folder,files, next:"Edit only this draft, then call ads_prepare_patch with action: diff and this draft ID. Live source is unchanged; the resulting Git patch still requires ads_apply_patch and all its gates."};
|
|
71
|
-
return action === "migrate" ? migrateContractDraft(options,prepared) : prepared;
|
|
72
|
-
}
|
|
73
|
-
if (!/^[a-f0-9-]{36}$/.test(draft ?? "")) throw new Error("Use the draft ID returned by ads_prepare_patch.");
|
|
74
|
-
const base = path.join(options.root,".ds/patch-drafts",draft);
|
|
75
|
-
if (realpathSync(base) !== base) throw new Error("Draft paths cannot resolve through symlinks.");
|
|
76
|
-
const metadata = JSON.parse(readFileSync(path.join(base,"manifest.json"),"utf8"));
|
|
77
|
-
if (metadata.schemaVersion !== 1 || metadata.unit !== unit) throw new Error("Draft and selected unit do not match.");
|
|
78
|
-
if (action === "discard") {rmSync(base,{recursive:true});return {discarded:true,draft,unit};}
|
|
79
|
-
if (action !== "diff") throw new Error("Choose create, migrate, diff or discard.");
|
|
80
|
-
const files = new Set(metadata.entries.map(entry => entry.file));
|
|
81
|
-
function walk(directory) {
|
|
82
|
-
if (realpathSync(directory) !== directory) throw new Error("Draft directories cannot resolve through symlinks.");
|
|
83
|
-
for (const entry of readdirSync(directory,{withFileTypes:true})) {
|
|
84
|
-
const file = path.join(directory,entry.name);
|
|
85
|
-
if (entry.isDirectory()) walk(file);
|
|
86
|
-
else if (!entry.isFile() || lstatSync(file).nlink !== 1) throw new Error("Drafts contain ordinary unlinked source files only.");
|
|
87
|
-
else files.add(path.relative(path.join(base,"work"),file).replaceAll("\\","/"));
|
|
88
|
-
if (files.size > 256) throw new Error("Draft exceeds 256 files.");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
walk(path.join(base,"work"));
|
|
92
|
-
const changes = [];
|
|
93
|
-
let patch = "", bytes = 0;
|
|
94
|
-
for (const file of files) {
|
|
95
|
-
if (!file || path.isAbsolute(file) || file.includes("\\") || file.split("/").some(part => !part || part === "." || part === ".." || part.startsWith(".") && part !== ".gitkeep" && !/^\.(?:oxlintrc|linariarc|babelrc)(?:\.json)?$/.test(part))) throw new Error("Drafts use ordinary project-relative source paths.");
|
|
96
|
-
const original = path.join(base,"base",file), next = path.join(base,"work",file), live = path.join(options.root,file);
|
|
97
|
-
const read = file => {
|
|
98
|
-
if (!existsSync(file)) return null;
|
|
99
|
-
const stat = lstatSync(file);
|
|
100
|
-
if (realpathSync(file) !== file || !stat.isFile() || stat.nlink !== 1 || stat.size > 16 * 1024 * 1024) throw new Error("Draft inputs must be ordinary unlinked files no larger than 16 MiB.");
|
|
101
|
-
return readFileSync(file);
|
|
102
|
-
};
|
|
103
|
-
const expected = metadata.entries.find(entry => entry.file === file)?.digest ?? null;
|
|
104
|
-
const left = read(original), right = read(next), source = read(live);
|
|
105
|
-
if ((left && hash(left)) !== expected || (source && hash(source)) !== expected) throw new Error(`Source/baseline changed for ${file}; create a fresh owner draft.`);
|
|
106
|
-
if (left !== null && right !== null && left.equals(right) || left === null && right === null) continue;
|
|
107
|
-
bytes += (left?.length ?? 0) + (right?.length ?? 0);
|
|
108
|
-
if (bytes > 32 * 1024 * 1024) throw new Error("Draft changes exceed 32 MiB.");
|
|
109
|
-
const change = {path:file,originalContent:left === null ? null : binary(left) ? left : left.toString(),content:right === null ? null : binary(right) ? right : right.toString()};
|
|
110
|
-
changes.push(change);
|
|
111
|
-
patch += preparedFileDiff(file,left,right,original,next);
|
|
112
|
-
}
|
|
113
|
-
if (changes.length) checkUnitFiles(options,unit,changes,inventory,true);
|
|
114
|
-
return {unit,draft,changes:changes.map(entry=>entry.path),...storePreparedPatch(options,patch),next:"Apply with ads_apply_patch using this unit and patchFile. Preparation is not validation or publication."};
|
|
115
|
-
}
|