design-brain-memory 0.9.3 → 0.9.4
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 +273 -0
- package/dist/agentBrowser.d.ts +0 -1
- package/dist/agentBrowser.js +13 -31
- package/dist/agentBrowser.js.map +1 -1
- package/dist/aggregate.d.ts +9 -0
- package/dist/aggregate.js +53 -0
- package/dist/aggregate.js.map +1 -0
- package/dist/batch.d.ts +16 -0
- package/dist/batch.js +44 -0
- package/dist/batch.js.map +1 -0
- package/dist/cli.js +250 -216
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts +60 -1
- package/dist/commands.js +323 -10
- package/dist/commands.js.map +1 -1
- package/dist/compare.d.ts +33 -0
- package/dist/compare.js +83 -0
- package/dist/compare.js.map +1 -0
- package/dist/componentGraph.d.ts +22 -0
- package/dist/componentGraph.js +106 -0
- package/dist/componentGraph.js.map +1 -0
- package/dist/contextLayer.d.ts +12 -0
- package/dist/contextLayer.js +263 -0
- package/dist/contextLayer.js.map +1 -0
- package/dist/cssInJs.d.ts +9 -0
- package/dist/cssInJs.js +124 -0
- package/dist/cssInJs.js.map +1 -0
- package/dist/extractFromUrl.d.ts +8 -0
- package/dist/extractFromUrl.js +508 -414
- package/dist/extractFromUrl.js.map +1 -1
- package/dist/graphView.d.ts +21 -0
- package/dist/graphView.js +492 -0
- package/dist/graphView.js.map +1 -0
- package/dist/index.d.ts +26 -11
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/knowledge.d.ts +20 -0
- package/dist/knowledge.js +208 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/liveView.d.ts +15 -0
- package/dist/liveView.js +475 -0
- package/dist/liveView.js.map +1 -0
- package/dist/llm.js +1 -9
- package/dist/llm.js.map +1 -1
- package/dist/moodboard.d.ts +3 -0
- package/dist/moodboard.js +152 -0
- package/dist/moodboard.js.map +1 -0
- package/dist/persona.d.ts +2 -2
- package/dist/persona.js +82 -210
- package/dist/persona.js.map +1 -1
- package/dist/query.js +1 -6
- package/dist/query.js.map +1 -1
- package/dist/render.d.ts +2 -10
- package/dist/render.js +80 -175
- package/dist/render.js.map +1 -1
- package/dist/reviewChecklist.d.ts +17 -0
- package/dist/reviewChecklist.js +126 -0
- package/dist/reviewChecklist.js.map +1 -0
- package/dist/scan.d.ts +19 -7
- package/dist/scan.js +132 -374
- package/dist/scan.js.map +1 -1
- package/dist/scorecard.d.ts +53 -0
- package/dist/scorecard.js +325 -0
- package/dist/scorecard.js.map +1 -0
- package/dist/skillPrompt.d.ts +1 -3
- package/dist/skillPrompt.js +22 -148
- package/dist/skillPrompt.js.map +1 -1
- package/dist/store.d.ts +2 -2
- package/dist/store.js +7 -9
- package/dist/store.js.map +1 -1
- package/dist/styleDictionary.d.ts +16 -0
- package/dist/styleDictionary.js +89 -0
- package/dist/styleDictionary.js.map +1 -0
- package/dist/svg.d.ts +5 -0
- package/dist/svg.js +162 -0
- package/dist/svg.js.map +1 -0
- package/dist/systemDiff.d.ts +28 -0
- package/dist/systemDiff.js +107 -0
- package/dist/systemDiff.js.map +1 -0
- package/dist/tailwind.d.ts +2 -0
- package/dist/tailwind.js +122 -0
- package/dist/tailwind.js.map +1 -0
- package/dist/taste.d.ts +3 -2
- package/dist/taste.js +349 -536
- package/dist/taste.js.map +1 -1
- package/dist/tasteRenderer.d.ts +2 -3
- package/dist/tasteRenderer.js +123 -119
- package/dist/tasteRenderer.js.map +1 -1
- package/dist/tokenNaming.d.ts +5 -0
- package/dist/tokenNaming.js +229 -0
- package/dist/tokenNaming.js.map +1 -0
- package/dist/tokens.d.ts +17 -0
- package/dist/tokens.js +44 -0
- package/dist/tokens.js.map +1 -0
- package/dist/trends.d.ts +12 -0
- package/dist/trends.js +178 -0
- package/dist/trends.js.map +1 -0
- package/dist/types.d.ts +47 -101
- package/dist/wiki.d.ts +10 -0
- package/dist/wiki.js +346 -0
- package/dist/wiki.js.map +1 -0
- package/dist/writingStyle.d.ts +38 -0
- package/dist/writingStyle.js +224 -0
- package/dist/writingStyle.js.map +1 -0
- package/package.json +5 -4
- package/dist/classify.d.ts +0 -21
- package/dist/classify.js +0 -205
- package/dist/classify.js.map +0 -1
- package/dist/scanRenderer.d.ts +0 -2
- package/dist/scanRenderer.js +0 -155
- package/dist/scanRenderer.js.map +0 -1
- package/dist/tasteDiff.d.ts +0 -19
- package/dist/tasteDiff.js +0 -340
- package/dist/tasteDiff.js.map +0 -1
- package/dist/tasteGenerate.d.ts +0 -12
- package/dist/tasteGenerate.js +0 -140
- package/dist/tasteGenerate.js.map +0 -1
- package/dist/tasteRefine.d.ts +0 -13
- package/dist/tasteRefine.js +0 -351
- package/dist/tasteRefine.js.map +0 -1
- package/dist/theatrical.d.ts +0 -5
- package/dist/theatrical.js +0 -258
- package/dist/theatrical.js.map +0 -1
- package/skills/SKILL.md +0 -36
- package/skills/design-brain/SKILL.md +0 -77
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const ACTION_VERBS = new Set([
|
|
2
|
+
'get', 'start', 'try', 'buy', 'sign', 'join', 'learn', 'discover',
|
|
3
|
+
'explore', 'create', 'build', 'download', 'view', 'see', 'read',
|
|
4
|
+
'watch', 'listen', 'subscribe', 'contact', 'request', 'book',
|
|
5
|
+
'schedule', 'apply', 'claim', 'unlock', 'activate', 'upgrade',
|
|
6
|
+
'shop', 'order', 'add', 'continue', 'submit', 'send', 'share',
|
|
7
|
+
]);
|
|
8
|
+
const TONE_MARKERS = {
|
|
9
|
+
conversational: ['you', "you'll", "you're", "we'll", "we're", "let's", "don't", "it's", "that's"],
|
|
10
|
+
formal: ['therefore', 'furthermore', 'consequently', 'regarding', 'herein', 'pursuant'],
|
|
11
|
+
urgent: ['now', 'today', 'limited', 'hurry', 'last chance', 'don\'t miss', 'act now', 'ending soon'],
|
|
12
|
+
friendly: ['hey', 'awesome', 'love', 'amazing', 'great', 'happy', 'enjoy', 'fun', 'easy'],
|
|
13
|
+
technical: ['api', 'sdk', 'integration', 'deploy', 'configure', 'implement', 'infrastructure'],
|
|
14
|
+
aspirational: ['transform', 'empower', 'revolutionize', 'reimagine', 'elevate', 'unlock potential'],
|
|
15
|
+
};
|
|
16
|
+
function classifyHeadingStyle(text) {
|
|
17
|
+
const trimmed = text.trim();
|
|
18
|
+
if (trimmed.endsWith('?'))
|
|
19
|
+
return 'question';
|
|
20
|
+
const firstWord = trimmed.split(/\s+/)[0]?.toLowerCase() ?? '';
|
|
21
|
+
if (ACTION_VERBS.has(firstWord))
|
|
22
|
+
return 'action';
|
|
23
|
+
if (trimmed.split(/\s+/).length <= 2)
|
|
24
|
+
return 'label';
|
|
25
|
+
return 'statement';
|
|
26
|
+
}
|
|
27
|
+
function extractActionVerb(text) {
|
|
28
|
+
const words = text.toLowerCase().trim().split(/\s+/);
|
|
29
|
+
for (const word of words) {
|
|
30
|
+
if (ACTION_VERBS.has(word))
|
|
31
|
+
return word;
|
|
32
|
+
}
|
|
33
|
+
return words[0] || '';
|
|
34
|
+
}
|
|
35
|
+
function detectTone(allText) {
|
|
36
|
+
const lower = allText.toLowerCase();
|
|
37
|
+
const detected = [];
|
|
38
|
+
for (const [tone, markers] of Object.entries(TONE_MARKERS)) {
|
|
39
|
+
const hits = markers.filter((m) => lower.includes(m)).length;
|
|
40
|
+
const threshold = Math.max(1, Math.floor(markers.length * 0.2));
|
|
41
|
+
if (hits >= threshold)
|
|
42
|
+
detected.push(tone);
|
|
43
|
+
}
|
|
44
|
+
return detected;
|
|
45
|
+
}
|
|
46
|
+
function avgWords(texts) {
|
|
47
|
+
if (texts.length === 0)
|
|
48
|
+
return 0;
|
|
49
|
+
const total = texts.reduce((sum, t) => sum + t.trim().split(/\s+/).filter(Boolean).length, 0);
|
|
50
|
+
return Math.round(total / texts.length);
|
|
51
|
+
}
|
|
52
|
+
export function analyzeWritingStyle(inspo) {
|
|
53
|
+
const components = inspo.analysis.components;
|
|
54
|
+
// Headings
|
|
55
|
+
const headingTags = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']);
|
|
56
|
+
const headings = [];
|
|
57
|
+
for (const comp of components) {
|
|
58
|
+
if (headingTags.has(comp.tag.toLowerCase()) && comp.text.trim()) {
|
|
59
|
+
headings.push({
|
|
60
|
+
tag: comp.tag.toLowerCase(),
|
|
61
|
+
text: comp.text.trim().slice(0, 120),
|
|
62
|
+
wordCount: comp.text.trim().split(/\s+/).length,
|
|
63
|
+
style: classifyHeadingStyle(comp.text),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// CTAs — buttons and links with action text
|
|
68
|
+
const ctaTags = new Set(['button', 'a']);
|
|
69
|
+
const ctas = [];
|
|
70
|
+
for (const comp of components) {
|
|
71
|
+
if (!ctaTags.has(comp.tag.toLowerCase()))
|
|
72
|
+
continue;
|
|
73
|
+
const text = comp.text.trim();
|
|
74
|
+
if (!text || text.length > 60)
|
|
75
|
+
continue;
|
|
76
|
+
const verb = extractActionVerb(text);
|
|
77
|
+
if (verb) {
|
|
78
|
+
ctas.push({
|
|
79
|
+
text,
|
|
80
|
+
selector: comp.selector,
|
|
81
|
+
actionVerb: verb,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Collect all visible text
|
|
86
|
+
const allTexts = components.map((c) => c.text.trim()).filter((t) => t.length > 3);
|
|
87
|
+
const allText = allTexts.join(' ');
|
|
88
|
+
// Tone detection
|
|
89
|
+
const toneMarkers = detectTone(allText);
|
|
90
|
+
// Text hierarchy — group by tag and compute avg word count
|
|
91
|
+
const tagTexts = new Map();
|
|
92
|
+
for (const comp of components) {
|
|
93
|
+
const tag = comp.tag.toLowerCase();
|
|
94
|
+
if (!comp.text.trim())
|
|
95
|
+
continue;
|
|
96
|
+
const list = tagTexts.get(tag) ?? [];
|
|
97
|
+
list.push(comp.text.trim());
|
|
98
|
+
tagTexts.set(tag, list);
|
|
99
|
+
}
|
|
100
|
+
const textHierarchy = [];
|
|
101
|
+
const hierarchyOrder = ['h1', 'h2', 'h3', 'p', 'span', 'a', 'button', 'li'];
|
|
102
|
+
for (const tag of hierarchyOrder) {
|
|
103
|
+
const texts = tagTexts.get(tag);
|
|
104
|
+
if (texts && texts.length > 0) {
|
|
105
|
+
textHierarchy.push({
|
|
106
|
+
level: tag,
|
|
107
|
+
count: texts.length,
|
|
108
|
+
avgWords: avgWords(texts),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Sentence stats
|
|
113
|
+
const sentences = allText.split(/[.!?]+/).filter((s) => s.trim().length > 5);
|
|
114
|
+
const avgSentenceLen = sentences.length > 0
|
|
115
|
+
? Math.round(sentences.reduce((sum, s) => sum + s.trim().split(/\s+/).length, 0) / sentences.length)
|
|
116
|
+
: 0;
|
|
117
|
+
const words = allText.split(/\s+/).filter(Boolean);
|
|
118
|
+
const avgWordLen = words.length > 0
|
|
119
|
+
? Math.round((words.reduce((sum, w) => sum + w.length, 0) / words.length) * 10) / 10
|
|
120
|
+
: 0;
|
|
121
|
+
return {
|
|
122
|
+
headings,
|
|
123
|
+
ctas: ctas.slice(0, 20),
|
|
124
|
+
toneMarkers,
|
|
125
|
+
textHierarchy,
|
|
126
|
+
avgSentenceLength: avgSentenceLen,
|
|
127
|
+
avgWordLength: avgWordLen,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function aggregateWritingStyles(inspirations) {
|
|
131
|
+
const headingStyleCounts = {};
|
|
132
|
+
const ctaMap = new Map();
|
|
133
|
+
const toneCounts = {};
|
|
134
|
+
let sentLenSum = 0;
|
|
135
|
+
let sentLenCount = 0;
|
|
136
|
+
const levelMap = new Map();
|
|
137
|
+
for (const inspo of inspirations) {
|
|
138
|
+
const style = analyzeWritingStyle(inspo);
|
|
139
|
+
for (const h of style.headings) {
|
|
140
|
+
headingStyleCounts[h.style] = (headingStyleCounts[h.style] ?? 0) + 1;
|
|
141
|
+
}
|
|
142
|
+
for (const cta of style.ctas) {
|
|
143
|
+
const key = cta.text.toLowerCase();
|
|
144
|
+
const existing = ctaMap.get(key) ?? { text: cta.text, verb: cta.actionVerb, count: 0 };
|
|
145
|
+
existing.count += 1;
|
|
146
|
+
ctaMap.set(key, existing);
|
|
147
|
+
}
|
|
148
|
+
for (const tone of style.toneMarkers) {
|
|
149
|
+
toneCounts[tone] = (toneCounts[tone] ?? 0) + 1;
|
|
150
|
+
}
|
|
151
|
+
if (style.avgSentenceLength > 0) {
|
|
152
|
+
sentLenSum += style.avgSentenceLength;
|
|
153
|
+
sentLenCount += 1;
|
|
154
|
+
}
|
|
155
|
+
for (const level of style.textHierarchy) {
|
|
156
|
+
const existing = levelMap.get(level.level) ?? { total: 0, wordSum: 0 };
|
|
157
|
+
existing.total += level.count;
|
|
158
|
+
existing.wordSum += level.avgWords * level.count;
|
|
159
|
+
levelMap.set(level.level, existing);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const topCtas = [...ctaMap.values()].sort((a, b) => b.count - a.count).slice(0, 15);
|
|
163
|
+
const textLevels = [];
|
|
164
|
+
for (const [level, data] of levelMap) {
|
|
165
|
+
textLevels.push({ level, count: data.total, avgWords: data.total > 0 ? Math.round(data.wordSum / data.total) : 0 });
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
headingStyles: headingStyleCounts,
|
|
169
|
+
topCtas,
|
|
170
|
+
tones: toneCounts,
|
|
171
|
+
avgSentenceLength: sentLenCount > 0 ? Math.round(sentLenSum / sentLenCount) : 0,
|
|
172
|
+
textLevels,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function renderWritingStyleMd(styles, projectId) {
|
|
176
|
+
const lines = [];
|
|
177
|
+
lines.push(`# Writing Style Analysis — ${projectId}\n`);
|
|
178
|
+
// Tone
|
|
179
|
+
const toneEntries = Object.entries(styles.tones).sort((a, b) => b[1] - a[1]);
|
|
180
|
+
if (toneEntries.length > 0) {
|
|
181
|
+
lines.push('## Tone\n');
|
|
182
|
+
for (const [tone, count] of toneEntries) {
|
|
183
|
+
lines.push(`- **${tone}** (${count} captures)`);
|
|
184
|
+
}
|
|
185
|
+
lines.push('');
|
|
186
|
+
}
|
|
187
|
+
// Heading styles
|
|
188
|
+
const headingEntries = Object.entries(styles.headingStyles).sort((a, b) => b[1] - a[1]);
|
|
189
|
+
if (headingEntries.length > 0) {
|
|
190
|
+
lines.push('## Heading Patterns\n');
|
|
191
|
+
lines.push('| Style | Count |');
|
|
192
|
+
lines.push('| --- | --- |');
|
|
193
|
+
for (const [style, count] of headingEntries) {
|
|
194
|
+
lines.push(`| ${style} | ${count} |`);
|
|
195
|
+
}
|
|
196
|
+
lines.push('');
|
|
197
|
+
}
|
|
198
|
+
// CTAs
|
|
199
|
+
if (styles.topCtas.length > 0) {
|
|
200
|
+
lines.push('## CTA Patterns\n');
|
|
201
|
+
lines.push('| Text | Action Verb | Occurrences |');
|
|
202
|
+
lines.push('| --- | --- | --- |');
|
|
203
|
+
for (const cta of styles.topCtas) {
|
|
204
|
+
lines.push(`| ${cta.text} | ${cta.verb} | ${cta.count} |`);
|
|
205
|
+
}
|
|
206
|
+
lines.push('');
|
|
207
|
+
}
|
|
208
|
+
// Text hierarchy
|
|
209
|
+
if (styles.textLevels.length > 0) {
|
|
210
|
+
lines.push('## Text Hierarchy\n');
|
|
211
|
+
lines.push('| Element | Count | Avg Words |');
|
|
212
|
+
lines.push('| --- | --- | --- |');
|
|
213
|
+
for (const level of styles.textLevels) {
|
|
214
|
+
lines.push(`| ${level.level} | ${level.count} | ${level.avgWords} |`);
|
|
215
|
+
}
|
|
216
|
+
lines.push('');
|
|
217
|
+
}
|
|
218
|
+
// Readability
|
|
219
|
+
lines.push('## Readability\n');
|
|
220
|
+
lines.push(`- **Avg sentence length:** ${styles.avgSentenceLength} words`);
|
|
221
|
+
lines.push('');
|
|
222
|
+
return lines.join('\n');
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=writingStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writingStyle.js","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memory",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "Relational markdown design memory powered by Agent Browser CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,15 +16,16 @@
|
|
|
16
16
|
"design-brain-memory": "dist/cli.js"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
"skills"
|
|
19
|
+
"dist"
|
|
21
20
|
],
|
|
22
21
|
"scripts": {
|
|
23
22
|
"build": "tsc -p tsconfig.json",
|
|
24
23
|
"clean": "rm -rf dist",
|
|
25
24
|
"dev": "tsx src/cli.ts",
|
|
26
25
|
"test": "npm run build && node --test tests/*.test.mjs",
|
|
27
|
-
"pack:dry": "npm pack --dry-run"
|
|
26
|
+
"pack:dry": "npm pack --dry-run",
|
|
27
|
+
"release:check": "npm run clean && npm run test && npm run pack:dry",
|
|
28
|
+
"prepublishOnly": "npm run release:check"
|
|
28
29
|
},
|
|
29
30
|
"keywords": [
|
|
30
31
|
"design",
|
package/dist/classify.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { AnimationToken, KeyframeStop, PhysicsParams, AnimationGroup } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Classify the motion intent of an animation based on its keyframe properties.
|
|
4
|
-
*/
|
|
5
|
-
export declare function classifyMotionIntent(keyframes: KeyframeStop[]): AnimationToken['motionIntent'];
|
|
6
|
-
/**
|
|
7
|
-
* Detect physics-based motion (spring/bounce) from keyframe value progressions.
|
|
8
|
-
* Looks for overshoot and oscillation around the final value.
|
|
9
|
-
*/
|
|
10
|
-
export declare function detectPhysics(keyframes: KeyframeStop[], trackProperty: string): PhysicsParams | null;
|
|
11
|
-
/**
|
|
12
|
-
* Map GSAP easing string to physics params when applicable.
|
|
13
|
-
*/
|
|
14
|
-
export declare function classifyGsapEasing(easeString: string | undefined | null): PhysicsParams | null;
|
|
15
|
-
/**
|
|
16
|
-
* Detect animation groups (staggered sequences) by matching tokens
|
|
17
|
-
* with the same motionIntent, library, duration, and easing but different delays.
|
|
18
|
-
*/
|
|
19
|
-
export declare function detectAnimationGroups<T extends Pick<AnimationToken, 'selector' | 'motionIntent' | 'library' | 'timing' | 'keyframes' | 'trigger'>>(tokens: T[]): Array<T & {
|
|
20
|
-
group?: AnimationGroup;
|
|
21
|
-
}>;
|
package/dist/classify.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classify the motion intent of an animation based on its keyframe properties.
|
|
3
|
-
*/
|
|
4
|
-
export function classifyMotionIntent(keyframes) {
|
|
5
|
-
if (keyframes.length === 0)
|
|
6
|
-
return 'complex';
|
|
7
|
-
const allProps = new Set();
|
|
8
|
-
for (const kf of keyframes) {
|
|
9
|
-
for (const prop of Object.keys(kf.properties)) {
|
|
10
|
-
allProps.add(prop);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const hasOpacity = allProps.has('opacity');
|
|
14
|
-
const hasTransform = allProps.has('transform');
|
|
15
|
-
const hasColor = allProps.has('backgroundColor') || allProps.has('color') || allProps.has('borderColor');
|
|
16
|
-
const hasClipPath = allProps.has('clipPath');
|
|
17
|
-
const hasWidthHeight = allProps.has('width') || allProps.has('height');
|
|
18
|
-
const categories = [];
|
|
19
|
-
if (hasOpacity)
|
|
20
|
-
categories.push('opacity');
|
|
21
|
-
if (hasTransform)
|
|
22
|
-
categories.push('transform');
|
|
23
|
-
if (hasColor)
|
|
24
|
-
categories.push('color');
|
|
25
|
-
if (hasClipPath || hasWidthHeight)
|
|
26
|
-
categories.push('reveal');
|
|
27
|
-
if (categories.length > 1)
|
|
28
|
-
return 'complex';
|
|
29
|
-
if (categories.length === 0)
|
|
30
|
-
return 'complex';
|
|
31
|
-
if (hasOpacity && !hasTransform)
|
|
32
|
-
return 'fade';
|
|
33
|
-
if (hasColor)
|
|
34
|
-
return 'color-shift';
|
|
35
|
-
if (hasClipPath || hasWidthHeight)
|
|
36
|
-
return 'reveal';
|
|
37
|
-
if (hasTransform) {
|
|
38
|
-
return classifyTransformIntent(keyframes);
|
|
39
|
-
}
|
|
40
|
-
return 'complex';
|
|
41
|
-
}
|
|
42
|
-
function classifyTransformIntent(keyframes) {
|
|
43
|
-
const transforms = keyframes
|
|
44
|
-
.map((kf) => kf.properties.transform ?? '')
|
|
45
|
-
.filter(Boolean);
|
|
46
|
-
const hasTranslate = transforms.some((t) => /translate[XY]?\s*\(/.test(t));
|
|
47
|
-
const hasScale = transforms.some((t) => /scale[XY]?\s*\(/.test(t));
|
|
48
|
-
const hasRotate = transforms.some((t) => /rotate[XYZ]?\s*\(/.test(t));
|
|
49
|
-
const count = [hasTranslate, hasScale, hasRotate].filter(Boolean).length;
|
|
50
|
-
if (count > 1)
|
|
51
|
-
return 'complex';
|
|
52
|
-
if (hasTranslate)
|
|
53
|
-
return 'slide';
|
|
54
|
-
if (hasScale)
|
|
55
|
-
return 'scale';
|
|
56
|
-
if (hasRotate)
|
|
57
|
-
return 'rotate';
|
|
58
|
-
return 'complex';
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Extract a numeric value from a transform function string.
|
|
62
|
-
* e.g., "translateX(100px)" → 100
|
|
63
|
-
*/
|
|
64
|
-
function extractNumericFromTransform(transformStr, fnName) {
|
|
65
|
-
const re = new RegExp(`${fnName}\\s*\\(\\s*(-?[\\d.]+)`);
|
|
66
|
-
const match = transformStr.match(re);
|
|
67
|
-
return match ? parseFloat(match[1]) : null;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Detect physics-based motion (spring/bounce) from keyframe value progressions.
|
|
71
|
-
* Looks for overshoot and oscillation around the final value.
|
|
72
|
-
*/
|
|
73
|
-
export function detectPhysics(keyframes, trackProperty) {
|
|
74
|
-
if (keyframes.length < 3)
|
|
75
|
-
return null;
|
|
76
|
-
const values = [];
|
|
77
|
-
for (const kf of keyframes) {
|
|
78
|
-
const transformStr = kf.properties.transform ?? kf.properties[trackProperty] ?? '';
|
|
79
|
-
const numericVal = extractNumericFromTransform(transformStr, trackProperty)
|
|
80
|
-
?? parseFloat(transformStr);
|
|
81
|
-
if (Number.isNaN(numericVal))
|
|
82
|
-
return null;
|
|
83
|
-
values.push(numericVal);
|
|
84
|
-
}
|
|
85
|
-
if (values.length < 3)
|
|
86
|
-
return null;
|
|
87
|
-
const finalValue = values[values.length - 1];
|
|
88
|
-
const startValue = values[0];
|
|
89
|
-
const range = Math.abs(finalValue - startValue);
|
|
90
|
-
if (range === 0)
|
|
91
|
-
return null;
|
|
92
|
-
// Count zero-crossings relative to final value
|
|
93
|
-
let crossings = 0;
|
|
94
|
-
let maxOvershoot = 0;
|
|
95
|
-
for (let i = 1; i < values.length - 1; i++) {
|
|
96
|
-
const prevDelta = values[i - 1] - finalValue;
|
|
97
|
-
const currDelta = values[i] - finalValue;
|
|
98
|
-
if (prevDelta * currDelta < 0) {
|
|
99
|
-
crossings++;
|
|
100
|
-
}
|
|
101
|
-
const overshoot = Math.abs(currDelta);
|
|
102
|
-
if (overshoot > maxOvershoot) {
|
|
103
|
-
maxOvershoot = overshoot;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Check if any intermediate value overshoots the final value
|
|
107
|
-
const overshoots = values.some((v, i) => {
|
|
108
|
-
if (i === 0 || i === values.length - 1)
|
|
109
|
-
return false;
|
|
110
|
-
if (finalValue > startValue)
|
|
111
|
-
return v > finalValue;
|
|
112
|
-
return v < finalValue;
|
|
113
|
-
});
|
|
114
|
-
if (!overshoots)
|
|
115
|
-
return null;
|
|
116
|
-
const overshootPercent = Math.round((maxOvershoot / range) * 100);
|
|
117
|
-
if (crossings >= 2) {
|
|
118
|
-
return {
|
|
119
|
-
type: 'spring',
|
|
120
|
-
oscillationCount: crossings,
|
|
121
|
-
overshootPercent,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
type: 'bounce',
|
|
126
|
-
oscillationCount: crossings || 1,
|
|
127
|
-
overshootPercent,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Map GSAP easing string to physics params when applicable.
|
|
132
|
-
*/
|
|
133
|
-
export function classifyGsapEasing(easeString) {
|
|
134
|
-
if (!easeString)
|
|
135
|
-
return null;
|
|
136
|
-
const lower = easeString.toLowerCase();
|
|
137
|
-
if (lower.includes('elastic')) {
|
|
138
|
-
return { type: 'spring', oscillationCount: 3 };
|
|
139
|
-
}
|
|
140
|
-
if (lower.includes('bounce')) {
|
|
141
|
-
return { type: 'bounce', oscillationCount: 4 };
|
|
142
|
-
}
|
|
143
|
-
if (lower.includes('back')) {
|
|
144
|
-
return { type: 'spring', oscillationCount: 1, overshootPercent: 10 };
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Detect animation groups (staggered sequences) by matching tokens
|
|
150
|
-
* with the same motionIntent, library, duration, and easing but different delays.
|
|
151
|
-
*/
|
|
152
|
-
export function detectAnimationGroups(tokens) {
|
|
153
|
-
if (tokens.length < 2) {
|
|
154
|
-
return tokens.map((t) => ({ ...t }));
|
|
155
|
-
}
|
|
156
|
-
// Group candidates by signature (same intent, library, duration, easing)
|
|
157
|
-
const buckets = new Map();
|
|
158
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
159
|
-
const t = tokens[i];
|
|
160
|
-
if (!t.timing)
|
|
161
|
-
continue;
|
|
162
|
-
const sig = `${t.motionIntent}|${t.library}|${t.timing.duration}|${t.timing.easing}|${keyframeSignature(t.keyframes)}`;
|
|
163
|
-
const bucket = buckets.get(sig) ?? [];
|
|
164
|
-
bucket.push({ index: i, delay: t.timing.delay });
|
|
165
|
-
buckets.set(sig, bucket);
|
|
166
|
-
}
|
|
167
|
-
const result = tokens.map((t) => ({ ...t }));
|
|
168
|
-
let groupCounter = 0;
|
|
169
|
-
for (const [, bucket] of buckets) {
|
|
170
|
-
if (bucket.length < 2)
|
|
171
|
-
continue;
|
|
172
|
-
// Sort by delay
|
|
173
|
-
bucket.sort((a, b) => a.delay - b.delay);
|
|
174
|
-
// Check if delays form a stagger pattern (roughly equal increments)
|
|
175
|
-
const deltas = [];
|
|
176
|
-
for (let i = 1; i < bucket.length; i++) {
|
|
177
|
-
deltas.push(bucket[i].delay - bucket[i - 1].delay);
|
|
178
|
-
}
|
|
179
|
-
const avgDelta = deltas.reduce((sum, d) => sum + d, 0) / deltas.length;
|
|
180
|
-
const isStagger = avgDelta > 0 && deltas.every((d) => Math.abs(d - avgDelta) <= avgDelta * 0.5);
|
|
181
|
-
if (!isStagger)
|
|
182
|
-
continue;
|
|
183
|
-
groupCounter++;
|
|
184
|
-
const groupId = `group-${groupCounter}`;
|
|
185
|
-
const leadDelay = bucket[0].delay;
|
|
186
|
-
for (let i = 0; i < bucket.length; i++) {
|
|
187
|
-
const entry = bucket[i];
|
|
188
|
-
result[entry.index] = {
|
|
189
|
-
...result[entry.index],
|
|
190
|
-
group: {
|
|
191
|
-
groupId,
|
|
192
|
-
role: i === 0 ? 'lead' : 'follower',
|
|
193
|
-
staggerDelay: i === 0 ? 0 : entry.delay - leadDelay,
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
function keyframeSignature(keyframes) {
|
|
201
|
-
if (!keyframes || keyframes.length === 0)
|
|
202
|
-
return '';
|
|
203
|
-
return keyframes.map((kf) => Object.keys(kf.properties).sort().join(',')).join('|');
|
|
204
|
-
}
|
|
205
|
-
//# sourceMappingURL=classify.js.map
|
package/dist/classify.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../src/classify.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAyB;IAC5D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IA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AAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtF,CAAC"}
|
package/dist/scanRenderer.d.ts
DELETED
package/dist/scanRenderer.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/* ─── ANSI helpers ─── */
|
|
2
|
-
const USE_COLOR = process.stdout.isTTY !== false;
|
|
3
|
-
const RESET = USE_COLOR ? '\x1b[0m' : '';
|
|
4
|
-
const BOLD = USE_COLOR ? '\x1b[1m' : '';
|
|
5
|
-
const DIM = USE_COLOR ? '\x1b[2m' : '';
|
|
6
|
-
const GREEN = USE_COLOR ? '\x1b[32m' : '';
|
|
7
|
-
const CYAN = USE_COLOR ? '\x1b[36m' : '';
|
|
8
|
-
const YELLOW = USE_COLOR ? '\x1b[33m' : '';
|
|
9
|
-
const WHITE = USE_COLOR ? '\x1b[37m' : '';
|
|
10
|
-
const MAGENTA = USE_COLOR ? '\x1b[35m' : '';
|
|
11
|
-
/* ─── Box drawing ─── */
|
|
12
|
-
const BOX_WIDTH = 48;
|
|
13
|
-
function topBorder(title) {
|
|
14
|
-
if (title) {
|
|
15
|
-
const label = `\u2500 ${title} `;
|
|
16
|
-
const rest = '\u2500'.repeat(Math.max(0, BOX_WIDTH - label.length - 1));
|
|
17
|
-
return ` ${DIM}\u250c${label}${rest}\u2510${RESET}`;
|
|
18
|
-
}
|
|
19
|
-
return ` ${DIM}\u250c${'\u2500'.repeat(BOX_WIDTH)}\u2510${RESET}`;
|
|
20
|
-
}
|
|
21
|
-
function bottomBorder() {
|
|
22
|
-
return ` ${DIM}\u2514${'\u2500'.repeat(BOX_WIDTH)}\u2518${RESET}`;
|
|
23
|
-
}
|
|
24
|
-
function boxLine(content, rawLength) {
|
|
25
|
-
const padding = Math.max(0, BOX_WIDTH - rawLength);
|
|
26
|
-
return ` ${DIM}\u2502${RESET} ${content}${' '.repeat(padding - 1)}${DIM}\u2502${RESET}`;
|
|
27
|
-
}
|
|
28
|
-
function emptyBoxLine() {
|
|
29
|
-
return ` ${DIM}\u2502${' '.repeat(BOX_WIDTH)}\u2502${RESET}`;
|
|
30
|
-
}
|
|
31
|
-
/* ─── Score bar ─── */
|
|
32
|
-
function scoreBar(label, value, max) {
|
|
33
|
-
const barWidth = 16;
|
|
34
|
-
const filled = Math.round((value / max) * barWidth);
|
|
35
|
-
const empty = barWidth - filled;
|
|
36
|
-
const bar = `${GREEN}\u2588${RESET}`.repeat(filled) + `${DIM}\u2591${RESET}`.repeat(empty);
|
|
37
|
-
const paddedLabel = label.padEnd(22);
|
|
38
|
-
const valueStr = `${value}`.padStart(2);
|
|
39
|
-
return `${paddedLabel}${bar} ${BOLD}${valueStr}${RESET}`;
|
|
40
|
-
}
|
|
41
|
-
function scoreBarRaw(label, value, max) {
|
|
42
|
-
// Raw length without ANSI
|
|
43
|
-
return label.padEnd(22).length + 16 + 2 + `${value}`.padStart(2).length;
|
|
44
|
-
}
|
|
45
|
-
/* ─── Checkmark lines ─── */
|
|
46
|
-
function check(text) {
|
|
47
|
-
return ` ${GREEN}\u2714${RESET} ${text}`;
|
|
48
|
-
}
|
|
49
|
-
/* ─── Framework display name ─── */
|
|
50
|
-
function frameworkName(fw) {
|
|
51
|
-
if (!fw)
|
|
52
|
-
return 'None detected';
|
|
53
|
-
const names = {
|
|
54
|
-
tailwind: 'Tailwind CSS',
|
|
55
|
-
chakra: 'Chakra UI',
|
|
56
|
-
mui: 'Material UI',
|
|
57
|
-
};
|
|
58
|
-
return names[fw] ?? fw;
|
|
59
|
-
}
|
|
60
|
-
/* ─── Main renderer ─── */
|
|
61
|
-
export function renderScanResults(result) {
|
|
62
|
-
const { tokens, score, persona, filesScanned, framework } = result;
|
|
63
|
-
console.log('');
|
|
64
|
-
// Header box
|
|
65
|
-
console.log(topBorder());
|
|
66
|
-
console.log(emptyBoxLine());
|
|
67
|
-
const title = `${BOLD}${CYAN}design-brain${RESET} v0.9.3`;
|
|
68
|
-
console.log(boxLine(title, 'design-brain v0.9.3'.length));
|
|
69
|
-
const subtitle = `${DIM}Relational design memory${RESET}`;
|
|
70
|
-
console.log(boxLine(subtitle, 'Relational design memory'.length));
|
|
71
|
-
console.log(emptyBoxLine());
|
|
72
|
-
console.log(bottomBorder());
|
|
73
|
-
console.log('');
|
|
74
|
-
// Checkmark summary
|
|
75
|
-
const isUrl = result.path.startsWith('http://') || result.path.startsWith('https://');
|
|
76
|
-
if (isUrl) {
|
|
77
|
-
console.log(check(`Scanned ${BOLD}${result.path}${RESET} (live site)`));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
console.log(check(`Scanned ${BOLD}${filesScanned}${RESET} files`));
|
|
81
|
-
}
|
|
82
|
-
console.log(check(`Found ${BOLD}${tokens.colors.length}${RESET} colors, ` +
|
|
83
|
-
`${BOLD}${tokens.fontFamilies.length}${RESET} fonts, ` +
|
|
84
|
-
`${BOLD}${tokens.spacingValues.length}${RESET} spacing values, ` +
|
|
85
|
-
`${BOLD}${tokens.transitions.length}${RESET} transitions`));
|
|
86
|
-
if (framework) {
|
|
87
|
-
console.log(check(`Detected framework: ${BOLD}${frameworkName(framework)}${RESET}`));
|
|
88
|
-
}
|
|
89
|
-
console.log(check(`Design Health Score: ${BOLD}${scoreColor(score.total)}${score.total}/100${RESET}`));
|
|
90
|
-
console.log('');
|
|
91
|
-
// Score breakdown box
|
|
92
|
-
console.log(topBorder('Design Health'));
|
|
93
|
-
console.log(emptyBoxLine());
|
|
94
|
-
const categories = [
|
|
95
|
-
['Color Discipline', score.colorDiscipline, 25],
|
|
96
|
-
['Typography System', score.typographySystem, 25],
|
|
97
|
-
['Spacing & Layout', score.spacingLayout, 25],
|
|
98
|
-
['Motion & Polish', score.motionPolish, 25],
|
|
99
|
-
];
|
|
100
|
-
for (const [label, value, max] of categories) {
|
|
101
|
-
const bar = scoreBar(label, value, max);
|
|
102
|
-
const rawLen = scoreBarRaw(label, value, max);
|
|
103
|
-
console.log(boxLine(bar, rawLen));
|
|
104
|
-
}
|
|
105
|
-
console.log(emptyBoxLine());
|
|
106
|
-
const totalBar = scoreBar('Total', score.total, 100);
|
|
107
|
-
const totalRawLen = scoreBarRaw('Total', score.total, 100);
|
|
108
|
-
console.log(boxLine(totalBar, totalRawLen));
|
|
109
|
-
console.log(emptyBoxLine());
|
|
110
|
-
console.log(bottomBorder());
|
|
111
|
-
console.log('');
|
|
112
|
-
// Persona box
|
|
113
|
-
console.log(topBorder('Your Design Persona'));
|
|
114
|
-
console.log(emptyBoxLine());
|
|
115
|
-
const personaLine = `${MAGENTA}\u{1f3a8}${RESET} ${BOLD}${persona.name}${RESET}`;
|
|
116
|
-
console.log(boxLine(personaLine, `\u{1f3a8} ${persona.name}`.length + 1));
|
|
117
|
-
// Tagline (wrapped)
|
|
118
|
-
const tagline = `${DIM}"${persona.tagline}"${RESET}`;
|
|
119
|
-
console.log(boxLine(tagline, `"${persona.tagline}"`.length));
|
|
120
|
-
console.log(emptyBoxLine());
|
|
121
|
-
// Reasoning (word-wrap to box width)
|
|
122
|
-
const reasonLines = wordWrap(persona.reasoning, BOX_WIDTH - 4);
|
|
123
|
-
for (const line of reasonLines) {
|
|
124
|
-
console.log(boxLine(`${DIM}${line}${RESET}`, line.length));
|
|
125
|
-
}
|
|
126
|
-
console.log(emptyBoxLine());
|
|
127
|
-
console.log(bottomBorder());
|
|
128
|
-
console.log('');
|
|
129
|
-
}
|
|
130
|
-
function scoreColor(total) {
|
|
131
|
-
if (total >= 75)
|
|
132
|
-
return GREEN;
|
|
133
|
-
if (total >= 50)
|
|
134
|
-
return YELLOW;
|
|
135
|
-
return '\x1b[31m'; // red
|
|
136
|
-
}
|
|
137
|
-
function wordWrap(text, maxWidth) {
|
|
138
|
-
const words = text.split(' ');
|
|
139
|
-
const lines = [];
|
|
140
|
-
let current = '';
|
|
141
|
-
for (const word of words) {
|
|
142
|
-
if (current.length + word.length + 1 > maxWidth) {
|
|
143
|
-
if (current)
|
|
144
|
-
lines.push(current);
|
|
145
|
-
current = word;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
current = current ? `${current} ${word}` : word;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (current)
|
|
152
|
-
lines.push(current);
|
|
153
|
-
return lines;
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=scanRenderer.js.map
|