@conscience-technology/ovenn 0.7.5 → 0.7.6
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 +43 -4
- package/assets/components/AttachmentThumb/AttachmentThumb.tsx +1 -0
- package/assets/components/ChatComposer/ChatComposer.tsx +1 -1
- package/assets/components/FileIcon/FileIcon.tsx +1 -0
- package/assets/components/FileIcon/fileExtMap.ts +1 -0
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +1 -1
- package/assets/components/Onboarding/OnboardingPage.tsx +13 -11
- package/assets/components/Onboarding/actions.ts +9 -9
- package/assets/components/TableRowEdit/TableRowEdit.tsx +2 -2
- package/assets/components/ThemeController.tsx +2 -2
- package/assets/components/TimelineView/TimelineView.tsx +4 -2
- package/assets/components/Tooltip/Tooltip.module.css +1 -0
- package/assets/components/_utils.css +1 -0
- package/assets/components/side-effect-css.d.ts +5 -0
- package/assets/components/themeBootScript.ts +7 -1
- package/assets/components/tokens.css +1 -0
- package/assets/prompts/ASSEMBLY.md +2 -0
- package/assets/prompts/CASCADE.md +2 -2
- package/assets/prompts/CATALOG.md +1 -1
- package/assets/prompts/PRINCIPLES.md +4 -8
- package/assets/prompts/RULES.md +19 -1
- package/assets/prompts/SLOTS.md +2 -4
- package/assets/prompts/WORKFLOW_DESIGN.md +0 -4
- package/assets/prompts/axes/icon.md +1 -1
- package/assets/prompts/axes/motion.md +1 -1
- package/assets/prompts/axes/voice.md +1 -1
- package/assets/prompts/components/_variants.md +3 -3
- package/assets/prompts/components/accordion.md +4 -4
- package/assets/prompts/components/attachment-item.md +2 -2
- package/assets/prompts/components/button.md +2 -2
- package/assets/prompts/components/card.md +1 -2
- package/assets/prompts/components/chart-bar.md +1 -1
- package/assets/prompts/components/chat-input.md +1 -1
- package/assets/prompts/components/checkbox.md +5 -5
- package/assets/prompts/components/color-field.md +2 -2
- package/assets/prompts/components/command-palette.md +3 -3
- package/assets/prompts/components/context-menu.md +5 -5
- package/assets/prompts/components/date-picker.md +2 -2
- package/assets/prompts/components/drawer.md +2 -2
- package/assets/prompts/components/dropdown-menu.md +3 -3
- package/assets/prompts/components/event-list-item.md +4 -4
- package/assets/prompts/components/file-icon.md +2 -2
- package/assets/prompts/components/gallery-item.md +1 -1
- package/assets/prompts/components/hint.md +3 -3
- package/assets/prompts/components/kanban.md +2 -3
- package/assets/prompts/components/list-item.md +11 -11
- package/assets/prompts/components/menu-item.md +2 -2
- package/assets/prompts/components/message-table.md +4 -4
- package/assets/prompts/components/onboarding.md +3 -3
- package/assets/prompts/components/page-header.md +6 -7
- package/assets/prompts/components/quotation-bar.md +1 -1
- package/assets/prompts/components/select.md +1 -1
- package/assets/prompts/components/shortcut.md +3 -3
- package/assets/prompts/components/sidebar.md +5 -4
- package/assets/prompts/components/stepper.md +1 -1
- package/assets/prompts/components/tab-strip.md +2 -2
- package/assets/prompts/components/table-row-edit.md +6 -6
- package/assets/prompts/components/table-row-select.md +1 -1
- package/assets/prompts/components/tabs.md +5 -2
- package/assets/prompts/components/textarea.md +1 -1
- package/assets/prompts/components/toast.md +3 -3
- package/assets/prompts/components/tooltip.md +3 -3
- package/assets/prompts/components/topbar.md +1 -1
- package/assets/prompts/primitives/scroll.md +1 -1
- package/assets/prompts/recipes/README.md +5 -6
- package/assets/prompts/recipes/meta-line.md +2 -2
- package/assets/prompts/recipes/page-header.md +2 -2
- package/assets/prompts/recipes/section-header.md +1 -1
- package/assets/prompts/themes/_SCHEMA.md +2 -2
- package/assets/skills/ovenn-validate/SKILL.md +1 -1
- package/assets/skills/ovenn-validate/scripts/lib/component-usage.js +7 -1
- package/assets/skills/ovenn-validate/scripts/lib/engine.mjs +105 -0
- package/assets/skills/ovenn-validate/scripts/lib/engine.test.mjs +46 -0
- package/assets/skills/ovenn-validate/scripts/lib/source-utils.mjs +5 -3
- package/assets/skills/ovenn-validate/scripts/rules/doc-sync.mjs +28 -5
- package/assets/skills/ovenn-validate/scripts/rules/doc-sync.test.mjs +15 -0
- package/assets/skills/ovenn-validate/scripts/rules/ghost-tokens.mjs +7 -0
- package/assets/skills/ovenn-validate/scripts/rules/hardcoded.mjs +61 -30
- package/assets/skills/ovenn-validate/scripts/rules/memory-rules.mjs +7 -4
- package/assets/skills/ovenn-validate/scripts/rules/memory-rules.test.mjs +3 -0
- package/assets/skills/ovenn-validate/scripts/validate.mjs +8 -136
- package/assets/skills/ovenn-wireframe/SKILL.md +1 -1
- package/bin/ovenn.js +8 -0
- package/package.json +2 -2
- package/src/commands/check.js +70 -0
- package/src/commands/info.js +32 -7
- package/src/commands/init.js +26 -30
- package/src/commands/setup-checks.js +80 -0
- package/src/commands/update.js +90 -18
- package/src/data/ctds-releases.json +1 -0
- package/src/utils/assets.js +5 -0
- package/src/utils/component-usage.js +7 -1
- package/src/utils/design-workflow.js +6 -2
- package/src/utils/doctor.js +7 -1
- package/src/utils/legacy-ctds.js +169 -0
- package/src/utils/managed-assets.js +16 -3
- package/src/utils/route.js +17 -0
- package/src/utils/rules-context.js +91 -0
- package/src/utils/update-transaction.js +16 -3
- package/assets/prompts/FEEDBACK_PROCESS.md +0 -19
- package/assets/prompts/GUIDE.md +0 -307
- package/assets/prompts/MEMORY.md +0 -202
- package/assets/prompts/TEMPLATE_PREVIEWS.md +0 -21
- package/assets/prompts/components/README.md +0 -84
|
@@ -29,17 +29,21 @@ function extractEnumsFromMd(src) {
|
|
|
29
29
|
const propsBlock = src.match(/```tsx[\s\S]*?```/);
|
|
30
30
|
if (propsBlock) {
|
|
31
31
|
const code = propsBlock[0];
|
|
32
|
-
|
|
32
|
+
// `trailingSlot={<Avatar size="xs" />}`: attributes of an element passed inside a prop belong to that child.
|
|
33
|
+
const rootLines = code.split('\n').filter((line) => !/\{\s*<[A-Z]\w*[^>]*\b(?:variant|size)\s*=/.test(line));
|
|
34
|
+
const rootCode = rootLines.join('\n');
|
|
35
|
+
for (const m of rootCode.matchAll(/\bvariant\s*=\s*["']([^"']+)["']/g)) {
|
|
33
36
|
for (const v of m[1].split(/\s*\|\s*/)) enums.variant.add(v.trim());
|
|
34
37
|
}
|
|
35
|
-
for (const m of
|
|
38
|
+
for (const m of rootCode.matchAll(/\bsize\s*=\s*["']([^"']+)["']/g)) {
|
|
36
39
|
for (const v of m[1].split(/\s*\|\s*/)) enums.size.add(v.trim());
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
const variantTableRe = /\|\s*`?([a-zA-Z][a-zA-Z0-9_-]*)`?\s*\|/g;
|
|
40
43
|
const variantSectionMatch = src.match(/###\s*Variant[\s\S]*?(?=\n### |\n## |$)/);
|
|
41
44
|
if (variantSectionMatch) {
|
|
42
|
-
|
|
45
|
+
// Only the section's first table; a later "상태 조합" table lists states, not variants.
|
|
46
|
+
const tableRows = (variantSectionMatch[0].match(/(?:^\|[^\n]+\|\n?)+/m)?.[0] ?? '').match(/\|[^\n]+\|/g) || [];
|
|
43
47
|
for (const row of tableRows) {
|
|
44
48
|
const first = row.match(/\|\s*`([^`]+)`/);
|
|
45
49
|
if (first) enums.variant.add(first[1]);
|
|
@@ -47,7 +51,8 @@ function extractEnumsFromMd(src) {
|
|
|
47
51
|
}
|
|
48
52
|
const sizeSectionMatch = src.match(/###\s*Size[\s\S]*?(?=\n### |\n## |$)/);
|
|
49
53
|
if (sizeSectionMatch) {
|
|
50
|
-
|
|
54
|
+
// Only the section's first table; a later "상태 조합" table lists states, not sizes.
|
|
55
|
+
const tableRows = (sizeSectionMatch[0].match(/(?:^\|[^\n]+\|\n?)+/m)?.[0] ?? '').match(/\|[^\n]+\|/g) || [];
|
|
51
56
|
for (const row of tableRows) {
|
|
52
57
|
const first = row.match(/\|\s*`([^`]+)`/);
|
|
53
58
|
if (first) enums.size.add(first[1]);
|
|
@@ -56,6 +61,17 @@ function extractEnumsFromMd(src) {
|
|
|
56
61
|
return enums;
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
const escape = (x) => x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
65
|
+
// Written as code, in bold, or inside a quoted union such as "sm | md | lg".
|
|
66
|
+
function mentionedAsCode(doc, value) {
|
|
67
|
+
if (new RegExp(`[\`"']${escape(value)}[\`"']|\\*\\*${escape(value)}\\*\\*`).test(doc)) return true;
|
|
68
|
+
return [...doc.matchAll(/[`"']([^`"'\n]*\|[^`"'\n]*)[`"']/g)].some((m) => m[1].split('|').map((t) => t.trim()).includes(value));
|
|
69
|
+
}
|
|
70
|
+
function presentInCode(tsx, value) {
|
|
71
|
+
if (/^--|[<>{}]/.test(value)) return true;
|
|
72
|
+
return new RegExp(`["'\`]${escape(value)}["'\`]|\\b${escape(value)}\\??\\s*:`).test(tsx);
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
function diffSets(aSet, bSet) {
|
|
60
76
|
const onlyA = [...aSet].filter((x) => !bSet.has(x));
|
|
61
77
|
const onlyB = [...bSet].filter((x) => !aSet.has(x));
|
|
@@ -84,7 +100,10 @@ export function checkDocSync(files, repoRoot) {
|
|
|
84
100
|
if (docM) docsByName.set(docM[1], { file: f, rel });
|
|
85
101
|
}
|
|
86
102
|
|
|
103
|
+
const internal = new Set();
|
|
104
|
+
if (fs.existsSync(manifestPath)) for (const entry of JSON.parse(fs.readFileSync(manifestPath, 'utf8')).entries ?? []) if (entry.status === 'internal') internal.add(entry.folder);
|
|
87
105
|
for (const [name, meta] of componentsByName) {
|
|
106
|
+
if (internal.has(name)) continue;
|
|
88
107
|
const kebab = pascalToKebab(name);
|
|
89
108
|
const doc = docsByName.get(kebab);
|
|
90
109
|
const tsxSrc = fs.readFileSync(meta.file, 'utf8');
|
|
@@ -108,7 +127,11 @@ export function checkDocSync(files, repoRoot) {
|
|
|
108
127
|
for (const field of ['variant', 'size']) {
|
|
109
128
|
if (tsxEnums[field].size === 0 && docEnums[field].size === 0) continue;
|
|
110
129
|
if (tsxEnums[field].size === 0 || docEnums[field].size === 0) continue;
|
|
111
|
-
|
|
130
|
+
// The structured extraction only reads the first tsx block and the Variant/Size tables, so check the rest too:
|
|
131
|
+
// a code value written as code anywhere in the doc is documented; a doc value that is another prop's literal
|
|
132
|
+
// (tone, layout, status), a prop or state name, a token or a placeholder is not a missing variant.
|
|
133
|
+
const onlyA = [...tsxEnums[field]].filter((x) => !docEnums[field].has(x) && !mentionedAsCode(docSrc, x));
|
|
134
|
+
const onlyB = [...docEnums[field]].filter((x) => !tsxEnums[field].has(x) && !presentInCode(tsxSrc, x));
|
|
112
135
|
if (onlyA.length > 0) {
|
|
113
136
|
violations.push({
|
|
114
137
|
rel: docRel,
|
|
@@ -89,3 +89,18 @@ test('manifest maps adapter docs to a shared component folder', (t) => {
|
|
|
89
89
|
const v = checkDocSync([md], root);
|
|
90
90
|
assert.equal(v.some((x) => x.ruleId === 'doc-sync/missing-code'), false);
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
test('documented elsewhere in the doc, child-element props and state tables are not mismatches', (t) => {
|
|
94
|
+
const root = makeRepo(t);
|
|
95
|
+
const tsx = writeFile(root, 'web/components/Widget/Widget.tsx',
|
|
96
|
+
'export type WidgetVariant = "a" | "b" | "framed";\nexport type WidgetSize = "sm" | "md" | "lg";\nexport interface P { disabled?: boolean }');
|
|
97
|
+
const md = writeFile(root, 'prompts/components/widget.md',
|
|
98
|
+
'### Props 시그니처\n```tsx\n<Widget\n variant="a | b"\n size="sm | md"\n slot={<Avatar size="xs" />}\n/>\n```\n- **framed**: 테두리와 그림자\n\n접기 버튼은 `size="sm | md | lg"`.\n\n### Variant 매트릭스\n| variant | 용도 |\n|---|---|\n| `a` | 기본 |\n\n**상태 조합:**\n\n| 상태 | 반응 |\n|---|---|\n| `disabled` | 흐림 |');
|
|
99
|
+
assert.deepEqual(checkDocSync([tsx, md], root).filter((x) => x.ruleId.startsWith('doc-sync/')), []);
|
|
100
|
+
});
|
|
101
|
+
test('internal components need no prompt document', (t) => {
|
|
102
|
+
const root = makeRepo(t);
|
|
103
|
+
fs.writeFileSync(path.join(root, 'component-manifest.json'), JSON.stringify({ entries: [{ folder: 'Boundary', status: 'internal', prompts: [] }] }));
|
|
104
|
+
const tsx = writeFile(root, 'web/components/Boundary/Boundary.tsx', 'export function Boundary() { return null; }');
|
|
105
|
+
assert.deepEqual(checkDocSync([tsx], root), []);
|
|
106
|
+
});
|
|
@@ -4,6 +4,7 @@ import { stripComments, lineOf } from '../lib/source-utils.mjs';
|
|
|
4
4
|
|
|
5
5
|
const DECL_RE = /--([\w-]+)\s*:/g;
|
|
6
6
|
const USE_RE = /var\(\s*--([\w-]+)(\s*,)?/g;
|
|
7
|
+
const RUNTIME_DECL_RE = /["'`]--([\w-]+)["'`]\s*[:,\]]/g;
|
|
7
8
|
const RUNTIME_TOKENS = new Set(['tail']);
|
|
8
9
|
const RUNTIME_TOKEN_PATTERNS = [
|
|
9
10
|
/^(?:tab-indicator|at-ph|fi)-/,
|
|
@@ -20,6 +21,10 @@ function collectCssDeclarations(directory, tokens) {
|
|
|
20
21
|
else if (entry.isFile() && entry.name.endsWith('.css')) {
|
|
21
22
|
const src = fs.readFileSync(full, 'utf8');
|
|
22
23
|
for (const match of src.matchAll(DECL_RE)) tokens.add(match[1]);
|
|
24
|
+
} else if (entry.isFile() && /\.[jt]sx?$/.test(entry.name) && !/\.test\./.test(entry.name)) {
|
|
25
|
+
// Properties set at runtime: style={{ "--canvas-zoom": zoom }} and el.style.setProperty("--x", v).
|
|
26
|
+
const src = fs.readFileSync(full, 'utf8');
|
|
27
|
+
for (const match of src.matchAll(RUNTIME_DECL_RE)) tokens.add(match[1]);
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -51,8 +56,10 @@ export function checkGhostTokens(ctx, declared) {
|
|
|
51
56
|
|
|
52
57
|
for (const m of src.matchAll(USE_RE)) {
|
|
53
58
|
const name = m[1];
|
|
59
|
+
// `var(--chart-${key})`: the name is completed at runtime.
|
|
54
60
|
if (
|
|
55
61
|
m[2] ||
|
|
62
|
+
name.endsWith('-') ||
|
|
56
63
|
name.startsWith('radix-') ||
|
|
57
64
|
RUNTIME_TOKENS.has(name) ||
|
|
58
65
|
RUNTIME_TOKEN_PATTERNS.some((pattern) => pattern.test(name))
|
|
@@ -5,24 +5,33 @@ const RGB_RE = /\b(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch)\s*\(/gi;
|
|
|
5
5
|
const SIZE_RE = /(?<![\w.-])(\d+(?:\.\d+)?)(px|rem|em)\b/g;
|
|
6
6
|
const TIME_RE = /(?<![\w.-])(\d+(?:\.\d+)?)(ms|s)\b/g;
|
|
7
7
|
const FONT_FAMILY_JSX_RE = /fontFamily\s*:\s*(["'`])([^"'`]+)\1/g;
|
|
8
|
+
const INLINE_SIZE_RE = /\b((?:padding|margin|gap|rowGap|columnGap|width|height|minWidth|minHeight|maxWidth|maxHeight|top|left|right|bottom|inset|fontSize|lineHeight|borderRadius|letterSpacing)(?:Top|Right|Bottom|Left|Inline|Block)?)\s*:\s*(\d+(?:\.\d+)?)\s*[,}]/g;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const CSS_WIDE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
11
|
+
// Same structural exclusions as the repository linter: grid tracks, the autofill inset trick and offscreen a11y hiding.
|
|
12
|
+
// Plus mask gradients, whose colours are alpha stops.
|
|
13
|
+
function isStructural(prop, value) {
|
|
14
|
+
return /^grid-(?:template-(?:columns|rows|areas)|area)$/.test(prop)
|
|
15
|
+
|| (prop === '-webkit-box-shadow' && /\binset\b/.test(value))
|
|
16
|
+
|| /translate\(\s*-?9999px/.test(value)
|
|
17
|
+
// Mask gradients use colours only as alpha stops (`#000` opaque, `transparent` clear).
|
|
18
|
+
|| /^(?:-webkit-)?mask(?:-image)?$/.test(prop);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Declarations of the whole stylesheet with their source offsets. A custom property may span several lines
|
|
22
|
+
// (`--ring:\n 0 0 0 2px oklch(...)`), so splitting line by line would misread its value as a plain use.
|
|
23
|
+
function declarations(src) {
|
|
10
24
|
const out = [];
|
|
11
|
-
let depth = 0;
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (c === '{' || c === '}') {
|
|
16
|
-
if (i > start) out.push({ text: line.slice(start, i), offset: start });
|
|
17
|
-
out.push({ text: c, offset: i });
|
|
18
|
-
start = i + 1;
|
|
19
|
-
} else if (c === ';' && depth === 0) {
|
|
20
|
-
out.push({ text: line.slice(start, i), offset: start });
|
|
21
|
-
start = i + 1;
|
|
22
|
-
} else if (c === '(') depth++;
|
|
25
|
+
let depth = 0, start = 0;
|
|
26
|
+
for (let i = 0; i <= src.length; i++) {
|
|
27
|
+
const c = src[i];
|
|
28
|
+
if (c === '(') depth++;
|
|
23
29
|
else if (c === ')') depth--;
|
|
30
|
+
else if (i === src.length || c === '{' || c === '}' || (c === ';' && depth === 0)) {
|
|
31
|
+
if (src.slice(start, i).trim()) out.push({ text: src.slice(start, i), offset: start });
|
|
32
|
+
start = i + 1;
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
|
-
if (start < line.length) out.push({ text: line.slice(start), offset: start });
|
|
26
35
|
return out;
|
|
27
36
|
}
|
|
28
37
|
|
|
@@ -30,27 +39,26 @@ function checkCss(ctx) {
|
|
|
30
39
|
const { content } = ctx;
|
|
31
40
|
const src = stripComments(content, '.css');
|
|
32
41
|
const violations = [];
|
|
33
|
-
const lines = src.split('\n');
|
|
34
|
-
|
|
35
|
-
for (let li = 0; li < lines.length; li++) {
|
|
36
|
-
const rawLine = lines[li];
|
|
37
|
-
const lineNo = li + 1;
|
|
38
|
-
const decls = splitDeclarations(rawLine);
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
for (const d of declarations(src)) {
|
|
44
|
+
{
|
|
41
45
|
const seg = d.text;
|
|
42
|
-
if (seg === '{' || seg === '}' || !seg.trim()) continue;
|
|
43
46
|
const colonIdx = seg.indexOf(':');
|
|
44
|
-
|
|
47
|
+
// A selector ending in a pseudo-class (`a:hover`) is not a declaration; only `prop: value` segments are.
|
|
48
|
+
if (colonIdx < 0 || !/^\s*[-\w]+\s*$/.test(seg.slice(0, colonIdx))) continue;
|
|
49
|
+
const hasColon = true;
|
|
50
|
+
const valueOffset = d.offset + (hasColon ? colonIdx + 1 : 0);
|
|
51
|
+
const lineAt = (m) => lineOf(src, valueOffset + m.index);
|
|
45
52
|
const propPart = hasColon ? seg.slice(0, colonIdx) : '';
|
|
46
53
|
const valuePart = hasColon ? seg.slice(colonIdx + 1) : seg;
|
|
47
54
|
const isCustomPropDecl = /--[\w-]+\s*$/.test(propPart.trim());
|
|
48
55
|
const propName = propPart.trim().toLowerCase();
|
|
56
|
+
if (isStructural(propName, valuePart)) continue;
|
|
49
57
|
|
|
50
58
|
if (!isCustomPropDecl) {
|
|
51
59
|
for (const m of valuePart.matchAll(HEX_RE)) {
|
|
52
60
|
violations.push({
|
|
53
|
-
line:
|
|
61
|
+
line: lineAt(m),
|
|
54
62
|
ruleId: 'hardcoded/hex-color',
|
|
55
63
|
message: `하드코딩된 hex 색상: ${m[0]}`,
|
|
56
64
|
suggest: 'var(--color-*) 토큰 사용',
|
|
@@ -58,7 +66,7 @@ function checkCss(ctx) {
|
|
|
58
66
|
}
|
|
59
67
|
for (const m of valuePart.matchAll(RGB_RE)) {
|
|
60
68
|
violations.push({
|
|
61
|
-
line:
|
|
69
|
+
line: lineAt(m),
|
|
62
70
|
ruleId: 'hardcoded/color-function',
|
|
63
71
|
message: `하드코딩된 색상 함수: ${m[1]}(...)`,
|
|
64
72
|
suggest: 'var(--color-*) 토큰 사용',
|
|
@@ -69,13 +77,14 @@ function checkCss(ctx) {
|
|
|
69
77
|
for (const m of valuePart.matchAll(SIZE_RE)) {
|
|
70
78
|
const num = parseFloat(m[1]);
|
|
71
79
|
const unit = m[2];
|
|
72
|
-
|
|
80
|
+
// 1px hairlines, font-relative em, and 999+ pill/offscreen values are idioms rather than design values.
|
|
81
|
+
if ((unit === 'px' && num === 1) || num === 0 || unit === 'em' || num >= 999) continue;
|
|
73
82
|
if (propName === 'border' || propName === 'border-width' || /^border-(top|right|bottom|left)(-width)?$/.test(propName)) {
|
|
74
83
|
if (num === 1 && unit === 'px') continue;
|
|
75
84
|
}
|
|
76
85
|
if (isCustomPropDecl) continue;
|
|
77
86
|
violations.push({
|
|
78
|
-
line:
|
|
87
|
+
line: lineAt(m),
|
|
79
88
|
ruleId: 'hardcoded/size',
|
|
80
89
|
message: `하드코딩된 크기: ${m[0]}`,
|
|
81
90
|
suggest: 'var(--space-*) / var(--size-*) / var(--radius-*) 토큰 사용',
|
|
@@ -86,7 +95,7 @@ function checkCss(ctx) {
|
|
|
86
95
|
if (isCustomPropDecl) continue;
|
|
87
96
|
if (propName === 'transition' || propName === 'animation' || propName.startsWith('transition-') || propName.startsWith('animation-')) {
|
|
88
97
|
violations.push({
|
|
89
|
-
line:
|
|
98
|
+
line: lineAt(m),
|
|
90
99
|
ruleId: 'hardcoded/time',
|
|
91
100
|
message: `하드코딩된 시간: ${m[0]}`,
|
|
92
101
|
suggest: 'var(--transition-*) / var(--duration-*) 토큰 사용',
|
|
@@ -96,9 +105,9 @@ function checkCss(ctx) {
|
|
|
96
105
|
|
|
97
106
|
if (propName === 'font-family' && !isCustomPropDecl) {
|
|
98
107
|
const value = valuePart.trim();
|
|
99
|
-
if (value && !/^var\(/.test(value)) {
|
|
108
|
+
if (value && !/^var\(/.test(value) && !CSS_WIDE.test(value)) {
|
|
100
109
|
violations.push({
|
|
101
|
-
line:
|
|
110
|
+
line: lineOf(src, valueOffset + valuePart.search(/\S/)),
|
|
102
111
|
ruleId: 'hardcoded/font-family',
|
|
103
112
|
message: `하드코딩된 폰트명: ${value}`,
|
|
104
113
|
suggest: 'var(--font-*) 토큰 사용',
|
|
@@ -111,6 +120,16 @@ function checkCss(ctx) {
|
|
|
111
120
|
return violations;
|
|
112
121
|
}
|
|
113
122
|
|
|
123
|
+
function styleObjects(src) {
|
|
124
|
+
const spans = [];
|
|
125
|
+
for (const m of src.matchAll(/style=\{\{/g)) {
|
|
126
|
+
let depth = 2, i = m.index + m[0].length;
|
|
127
|
+
for (; i < src.length && depth; i++) { if (src[i] === '{') depth++; else if (src[i] === '}') depth--; }
|
|
128
|
+
spans.push({ text: src.slice(m.index, i), offset: m.index });
|
|
129
|
+
}
|
|
130
|
+
return spans;
|
|
131
|
+
}
|
|
132
|
+
|
|
114
133
|
function checkJs(ctx) {
|
|
115
134
|
const { content, ext } = ctx;
|
|
116
135
|
const src = stripComments(content, ext);
|
|
@@ -126,6 +145,18 @@ function checkJs(ctx) {
|
|
|
126
145
|
});
|
|
127
146
|
}
|
|
128
147
|
|
|
148
|
+
// React reads a bare number on these style keys as px: `style={{ padding: 13 }}`. Only inside JSX style
|
|
149
|
+
// objects; the same keys elsewhere are geometry data (`{ left: 2, top: 3 }`), not styling.
|
|
150
|
+
for (const span of styleObjects(src)) for (const m of span.text.matchAll(INLINE_SIZE_RE)) {
|
|
151
|
+
if (Number(m[2]) <= 1) continue;
|
|
152
|
+
violations.push({
|
|
153
|
+
line: lineOf(src, span.offset + m.index),
|
|
154
|
+
ruleId: 'hardcoded/size',
|
|
155
|
+
message: `하드코딩된 크기: ${m[1]}: ${m[2]}`,
|
|
156
|
+
suggest: "style={{ padding: 'var(--space-*)' }} 또는 CSS Module 토큰",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
129
160
|
for (const m of src.matchAll(FONT_FAMILY_JSX_RE)) {
|
|
130
161
|
const line = lineOf(src, m.index);
|
|
131
162
|
violations.push({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stripComments, lineOf, findBlocks } from '../lib/source-utils.mjs';
|
|
2
2
|
|
|
3
|
+
// Uppercase is a selectable aesthetic default (RULES §0 row 7), so it is surfaced for review, never an error.
|
|
3
4
|
function checkUppercase(src, ext) {
|
|
4
5
|
const violations = [];
|
|
5
6
|
if (ext !== '.css') return violations;
|
|
@@ -10,16 +11,18 @@ function checkUppercase(src, ext) {
|
|
|
10
11
|
violations.push({
|
|
11
12
|
line: lineOf(src, b.start + 1 + m.index),
|
|
12
13
|
ruleId: 'memory/uppercase',
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
severity: 'review',
|
|
15
|
+
message: 'uppercase + letter-spacing 조합: 기본값은 사용하지 않음',
|
|
16
|
+
suggest: '프로젝트가 의도한 선택인지 확인하고, 아니면 text-transform과 letter-spacing을 제거',
|
|
15
17
|
});
|
|
16
18
|
} else if (/text-transform\s*:\s*uppercase/i.test(b.body)) {
|
|
17
19
|
const m = b.body.match(/text-transform\s*:\s*uppercase/i);
|
|
18
20
|
violations.push({
|
|
19
21
|
line: lineOf(src, b.start + 1 + m.index),
|
|
20
22
|
ruleId: 'memory/uppercase',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
severity: 'review',
|
|
24
|
+
message: 'uppercase: 기본값은 사용하지 않음',
|
|
25
|
+
suggest: '프로젝트가 의도한 선택인지 확인하고, 아니면 text-transform: uppercase 제거',
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
}
|
|
@@ -11,6 +11,9 @@ test('uppercase + letter-spacing flagged', () => {
|
|
|
11
11
|
assert.ok(v.some((x) => x.ruleId === 'memory/uppercase'));
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
test('uppercase is a review item, not an error (selectable default)', () => {
|
|
15
|
+
assert.ok(run('.a { text-transform: uppercase; }').every((x) => x.ruleId !== 'memory/uppercase' || x.severity === 'review'));
|
|
16
|
+
});
|
|
14
17
|
test('uppercase alone flagged', () => {
|
|
15
18
|
const v = run('.a { text-transform: uppercase; }');
|
|
16
19
|
assert.ok(v.some((x) => x.ruleId === 'memory/uppercase'));
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import {
|
|
6
|
-
import { checkGhostTokens, loadDeclaredTokens } from './rules/ghost-tokens.mjs';
|
|
7
|
-
import { checkMemoryRules } from './rules/memory-rules.mjs';
|
|
8
|
-
import { checkDocSync } from './rules/doc-sync.mjs';
|
|
9
|
-
import { checkHardRules } from './rules/hard-rules.mjs';
|
|
5
|
+
import { collectFiles, validateFiles, formatReport } from './lib/engine.mjs';
|
|
10
6
|
|
|
11
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
8
|
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
|
@@ -37,135 +33,11 @@ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
|
37
33
|
process.exit(args.length === 0 ? 1 : 0);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (c === '*') {
|
|
45
|
-
if (glob[i + 1] === '*') {
|
|
46
|
-
re += '.*';
|
|
47
|
-
i++;
|
|
48
|
-
if (glob[i + 1] === '/') i++;
|
|
49
|
-
} else {
|
|
50
|
-
re += '[^/]*';
|
|
51
|
-
}
|
|
52
|
-
} else if (c === '?') {
|
|
53
|
-
re += '[^/]';
|
|
54
|
-
} else if ('.+^$(){}|[]\\'.includes(c)) {
|
|
55
|
-
re += '\\' + c;
|
|
56
|
-
} else {
|
|
57
|
-
re += c;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
re += '$';
|
|
61
|
-
return new RegExp(re);
|
|
36
|
+
const files = collectFiles(REPO_ROOT, args);
|
|
37
|
+
if (files.length === 0) {
|
|
38
|
+
process.stderr.write(`매칭된 파일 없음: ${args.join(', ')}\n`);
|
|
39
|
+
process.exit(1);
|
|
62
40
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
68
|
-
} catch {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
for (const e of entries) {
|
|
72
|
-
if (e.name === 'node_modules' || e.name === '.next' || e.name === '.git') continue;
|
|
73
|
-
const full = path.join(dir, e.name);
|
|
74
|
-
if (e.isDirectory()) walk(full, out);
|
|
75
|
-
else if (e.isFile()) out.push(full);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function collectFiles(globs) {
|
|
80
|
-
const allFiles = [];
|
|
81
|
-
walk(REPO_ROOT, allFiles);
|
|
82
|
-
const matchers = globs.map((g) => globToRegex(g));
|
|
83
|
-
const matched = new Set();
|
|
84
|
-
for (const f of allFiles) {
|
|
85
|
-
const rel = path.relative(REPO_ROOT, f);
|
|
86
|
-
for (const m of matchers) {
|
|
87
|
-
if (m.test(rel)) {
|
|
88
|
-
matched.add(f);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return [...matched].sort();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function parseDisableComments(content) {
|
|
97
|
-
const disabled = new Map();
|
|
98
|
-
const lines = content.split('\n');
|
|
99
|
-
const re = /ovenn-validate-disable-next-line\s+([\w\-\/,\s]+)/;
|
|
100
|
-
for (let i = 0; i < lines.length; i++) {
|
|
101
|
-
const m = lines[i].match(re);
|
|
102
|
-
if (m) {
|
|
103
|
-
const ids = m[1].split(/[\s,]+/).filter(Boolean);
|
|
104
|
-
disabled.set(i + 2, new Set(ids));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return disabled;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function isDisabled(disabled, line, ruleId) {
|
|
111
|
-
const set = disabled.get(line);
|
|
112
|
-
if (!set) return false;
|
|
113
|
-
if (set.has(ruleId)) return true;
|
|
114
|
-
const prefix = ruleId.split('/')[0];
|
|
115
|
-
return set.has(prefix) || set.has(prefix + '/*');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function run() {
|
|
119
|
-
const files = collectFiles(args);
|
|
120
|
-
if (files.length === 0) {
|
|
121
|
-
process.stderr.write(`매칭된 파일 없음: ${args.join(', ')}\n`);
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const declaredTokens = loadDeclaredTokens(REPO_ROOT);
|
|
126
|
-
const violations = [];
|
|
127
|
-
|
|
128
|
-
for (const file of files) {
|
|
129
|
-
const ext = path.extname(file);
|
|
130
|
-
const rel = path.relative(REPO_ROOT, file);
|
|
131
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
132
|
-
const disabled = parseDisableComments(content);
|
|
133
|
-
const ctx = { file, rel, content, ext };
|
|
134
|
-
|
|
135
|
-
const raw = [];
|
|
136
|
-
if (ext === '.tsx' || ext === '.ts' || ext === '.jsx' || ext === '.js' || ext === '.css') {
|
|
137
|
-
raw.push(...checkHardcoded(ctx));
|
|
138
|
-
raw.push(...checkGhostTokens(ctx, declaredTokens));
|
|
139
|
-
raw.push(...checkMemoryRules(ctx));
|
|
140
|
-
raw.push(...checkHardRules(ctx));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
for (const v of raw) {
|
|
144
|
-
if (isDisabled(disabled, v.line, v.ruleId)) continue;
|
|
145
|
-
violations.push({ ...v, rel });
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
violations.push(...checkDocSync(files, REPO_ROOT));
|
|
150
|
-
|
|
151
|
-
const reviews = violations.filter((v) => v.severity === 'review');
|
|
152
|
-
const errors = violations.filter((v) => v.severity !== 'review');
|
|
153
|
-
|
|
154
|
-
if (violations.length === 0) {
|
|
155
|
-
process.stdout.write(`0개 위반 (${files.length}개 파일 검사)\n`);
|
|
156
|
-
process.exit(0);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
violations.sort((a, b) => a.rel.localeCompare(b.rel) || a.line - b.line);
|
|
160
|
-
const fileSet = new Set();
|
|
161
|
-
for (const v of violations) {
|
|
162
|
-
fileSet.add(v.rel);
|
|
163
|
-
const label = v.severity === 'review' ? 'REVIEW' : 'ERROR';
|
|
164
|
-
process.stdout.write(`${v.rel}:${v.line} — ${label} — ${v.ruleId} — ${v.message}\n`);
|
|
165
|
-
if (v.suggest) process.stdout.write(` 제안: ${v.suggest}\n`);
|
|
166
|
-
}
|
|
167
|
-
process.stdout.write(`\n${errors.length}개 오류, ${reviews.length}개 검토 (${fileSet.size}개 파일)\n`);
|
|
168
|
-
process.exit(errors.length > 0 ? 1 : 0);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
run();
|
|
41
|
+
const report = validateFiles(REPO_ROOT, files);
|
|
42
|
+
process.stdout.write(formatReport(report));
|
|
43
|
+
process.exit(report.errors > 0 ? 1 : 0);
|
|
@@ -5,7 +5,7 @@ description: 기존 화면·와이어프레임·레거시 컴포넌트를 Ovenn
|
|
|
5
5
|
|
|
6
6
|
# ovenn-wireframe
|
|
7
7
|
|
|
8
|
-
기존 UI를 Ovenn으로 바꾸는 작업의 진입점이다. 새 화면을 0부터 만드는 요청은 `ovenn-page`를 쓴다.
|
|
8
|
+
기존 UI를 Ovenn으로 바꾸는 작업의 진입점이다. 새 화면을 0부터 만드는 요청은 `ovenn-page`를 쓴다. 우선순위는 `prompts/RULES.md` §0 표가 정한다. 정책은 `prompts/PRINCIPLES.md`, 절차는 `prompts/ASSEMBLY.md`의 **기존 UI 전환: migration** 절, 검수 계약은 `prompts/WORKFLOW_DESIGN.md`다. MCP 연결 시 `get_rules`와 `get_design_workflow`로 같은 원본을 받는다.
|
|
9
9
|
|
|
10
10
|
## 전환 작업의 전제
|
|
11
11
|
|
package/bin/ovenn.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* 사용법:
|
|
6
6
|
* ovenn init [--dry] [--force]
|
|
7
7
|
* ovenn update [--dry] [--force]
|
|
8
|
+
* ovenn check [paths...] [--json]
|
|
8
9
|
* ovenn --help
|
|
9
10
|
* ovenn --version
|
|
10
11
|
*
|
|
@@ -34,6 +35,8 @@ if (cmd === "--version" || cmd === "-v") {
|
|
|
34
35
|
const commands = {
|
|
35
36
|
init: () => import("../src/commands/init.js").then((m) => m.run(rest)),
|
|
36
37
|
update: () => import("../src/commands/update.js").then((m) => m.run(rest)),
|
|
38
|
+
check: () => import("../src/commands/check.js").then((m) => m.run(rest)),
|
|
39
|
+
"setup-checks": () => import("../src/commands/setup-checks.js").then((m) => m.run(rest)),
|
|
37
40
|
info: () => import("../src/commands/info.js").then((m) => m.run(rest)),
|
|
38
41
|
};
|
|
39
42
|
|
|
@@ -61,6 +64,8 @@ Usage:
|
|
|
61
64
|
Commands:
|
|
62
65
|
init Install Ovenn into the current Next.js project (components, prompts, /ovenn route)
|
|
63
66
|
update Pull the latest Ovenn assets (local edits are preserved)
|
|
67
|
+
check Check project code against Ovenn rules offline (exit 1 on errors)
|
|
68
|
+
setup-checks Opt in to automatic checks: Claude Code hook, prebuild, CI
|
|
64
69
|
info Query Ovenn knowledge via MCP tools (ovenn info --help)
|
|
65
70
|
|
|
66
71
|
Options:
|
|
@@ -74,6 +79,9 @@ Examples:
|
|
|
74
79
|
ovenn init --no-open Skip the auto dev server launch and browser open
|
|
75
80
|
ovenn update Pull the latest and prompt only on conflicts
|
|
76
81
|
ovenn update --dry Preview changes and conflict count without writing
|
|
82
|
+
ovenn check Check app/, src/, components/ (skips components/ovenn)
|
|
83
|
+
ovenn check app/dashboard --json Check one folder and print JSON
|
|
84
|
+
ovenn setup-checks --hook --prebuild Check edited files and builds automatically (opt-in)
|
|
77
85
|
ovenn update --force Ignore local edits and overwrite everything (commit first)
|
|
78
86
|
ovenn info doctor --json Diagnose the local install without network
|
|
79
87
|
ovenn update --keep-local Preserve all conflicts in automation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conscience-technology/ovenn",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Ovenn — 하이브리드 디자인 시스템 설치 · 온보딩 CLI (shadcn식 코드 생성기)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"lottie-react": "^3.1.2",
|
|
72
72
|
"cmdk": "^1.1.1",
|
|
73
73
|
"react-aria-components": "^1.22.1",
|
|
74
|
-
"typescript": ">=5.0.0 <
|
|
74
|
+
"typescript": ">=5.0.0 <8.0.0",
|
|
75
75
|
"recharts": "^3.10.1",
|
|
76
76
|
"shiki": "^4.6.0"
|
|
77
77
|
},
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ovenn check` — Ovenn rule checks over the project's own code, without a server.
|
|
3
|
+
*
|
|
4
|
+
* Runs the engine bundled with this CLI (the same one behind the ovenn-validate skill and MCP check_hardcoding),
|
|
5
|
+
* so it works when .claude/ is git-ignored. Exit code 1 when any error is found, for hooks, prebuild and CI.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { getAssetSources } from "../utils/assets.js";
|
|
11
|
+
import { detectProject } from "../utils/detect.js";
|
|
12
|
+
|
|
13
|
+
// Project code a consumer writes. The installed Ovenn folder is vendor code and is only checked when named explicitly.
|
|
14
|
+
const DEFAULT_ROOTS = ["app", "src", "components", "lib", "pages", "styles", "ui"];
|
|
15
|
+
|
|
16
|
+
export async function run(args) {
|
|
17
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
18
|
+
console.log(`ovenn check [paths...] [--json]
|
|
19
|
+
|
|
20
|
+
Checks hardcoded values, undeclared tokens and the RULES.md checks that are machine-checkable.
|
|
21
|
+
Paths may be files, folders or globs. Without paths, checks ${DEFAULT_ROOTS.join(", ")} and skips components/ovenn.
|
|
22
|
+
Exit code: 0 when clean, 1 when an error is found.
|
|
23
|
+
Silence a justified case with /* ovenn-validate-disable-next-line <rule> */ or
|
|
24
|
+
/* ovenn-validate-disable-file <rule> -- <reason> */ (a reason is required).`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (args.includes("--hook")) return hook();
|
|
28
|
+
const root = process.cwd();
|
|
29
|
+
const json = args.includes("--json");
|
|
30
|
+
const paths = args.filter((arg) => !arg.startsWith("--"));
|
|
31
|
+
const project = detectProject(root);
|
|
32
|
+
const vendor = project.ok && project.useSrcDir ? "src/components/ovenn" : "components/ovenn";
|
|
33
|
+
const engine = await import(pathToFileURL(join(getAssetSources().skills, "ovenn-validate", "scripts", "lib", "engine.mjs")).href);
|
|
34
|
+
const targets = paths.length ? paths : DEFAULT_ROOTS.filter((dir) => existsSync(join(root, dir)));
|
|
35
|
+
const files = engine.collectFiles(root, targets, { exclude: paths.length ? [] : [vendor] }).filter((file) => engine.SOURCE_EXT.has(file.slice(file.lastIndexOf("."))));
|
|
36
|
+
if (!files.length) {
|
|
37
|
+
console.error(paths.length ? `No source files matched: ${paths.join(", ")}` : "No project source folders found. Pass the paths to check.");
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// Component docs and code sync is a check on the Ovenn repository itself; it needs the repository manifest.
|
|
42
|
+
const report = engine.validateFiles(root, files, { docSync: existsSync(join(root, "component-manifest.json")) });
|
|
43
|
+
if (json) console.log(JSON.stringify(report, null, 2));
|
|
44
|
+
else process.stdout.write(engine.formatReport(report));
|
|
45
|
+
if (report.errors > 0) process.exitCode = 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Claude Code PostToolUse hook (`ovenn setup-checks --hook`): the hook JSON arrives on stdin; only the edited file is
|
|
50
|
+
* checked. Violations go to stderr with exit code 2, which Claude Code shows to the agent so it fixes them next.
|
|
51
|
+
* Anything that is not the project's own source (vendor, docs, files outside the project) passes silently.
|
|
52
|
+
*/
|
|
53
|
+
async function hook() {
|
|
54
|
+
let input = {};
|
|
55
|
+
try { input = JSON.parse(readFileSync(0, "utf8") || "{}"); } catch { return; }
|
|
56
|
+
const root = process.env.CLAUDE_PROJECT_DIR || input.cwd || process.cwd();
|
|
57
|
+
// Edit/Write carry tool_input.file_path; MultiEdit may list them under tool_input.edits[].
|
|
58
|
+
const targets = [input.tool_input?.file_path, ...(input.tool_input?.edits ?? []).map((edit) => edit?.file_path)].filter((path) => typeof path === "string");
|
|
59
|
+
const engine = await import(pathToFileURL(join(getAssetSources().skills, "ovenn-validate", "scripts", "lib", "engine.mjs")).href);
|
|
60
|
+
const files = [...new Set(targets.map((target) => (isAbsolute(target) ? target : resolve(root, target))))].filter((file) => {
|
|
61
|
+
const rel = relative(root, file).split(sep).join("/");
|
|
62
|
+
return !rel.startsWith("..") && existsSync(file) && engine.SOURCE_EXT.has(file.slice(file.lastIndexOf("."))) && !/(^|\/)(node_modules|components\/ovenn|\.ovenn)\//.test(rel);
|
|
63
|
+
});
|
|
64
|
+
if (!files.length) return;
|
|
65
|
+
const report = engine.validateFiles(root, files, { docSync: false });
|
|
66
|
+
if (report.errors > 0) {
|
|
67
|
+
process.stderr.write(`ovenn check found rule violations in the file you just edited. Fix them before continuing:\n${engine.formatReport(report)}`);
|
|
68
|
+
process.exitCode = 2;
|
|
69
|
+
}
|
|
70
|
+
}
|