@conscience-technology/ovenn 0.7.3 → 0.7.5

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.
Files changed (150) hide show
  1. package/assets/components/AIMessage/AIMessage.module.css +10 -0
  2. package/assets/components/AIMessage/AIMessage.tsx +6 -2
  3. package/assets/components/Breadcrumb/Breadcrumb.module.css +82 -23
  4. package/assets/components/Breadcrumb/Breadcrumb.tsx +44 -26
  5. package/assets/components/Breadcrumb/index.ts +1 -0
  6. package/assets/components/Button/Button.module.css +2 -4
  7. package/assets/components/Callout/Callout.module.css +44 -18
  8. package/assets/components/Callout/Callout.tsx +9 -4
  9. package/assets/components/Callout/index.ts +1 -1
  10. package/assets/components/Canvas/Canvas.module.css +13 -0
  11. package/assets/components/Canvas/Canvas.tsx +378 -94
  12. package/assets/components/Canvas/clipboard.ts +5 -1
  13. package/assets/components/Canvas/collision.ts +5 -1
  14. package/assets/components/Canvas/graph.ts +14 -5
  15. package/assets/components/Canvas/history.ts +11 -4
  16. package/assets/components/Canvas/index.ts +2 -1
  17. package/assets/components/Canvas/types.ts +36 -1
  18. package/assets/components/CanvasEdge/tokens.css +14 -1
  19. package/assets/components/CanvasNode/tokens.css +13 -10
  20. package/assets/components/ChatInput/ChatInput.tsx +1 -1
  21. package/assets/components/ColorField/ColorField.module.css +6 -1
  22. package/assets/components/ColorPicker/ColorPicker.module.css +3 -0
  23. package/assets/components/CommandPalette/CommandPalette.module.css +115 -1
  24. package/assets/components/CommandPalette/CommandPalette.tsx +206 -21
  25. package/assets/components/CommandPalette/index.ts +1 -0
  26. package/assets/components/DatePicker/DatePicker.module.css +3 -2
  27. package/assets/components/Drawer/Drawer.module.css +30 -0
  28. package/assets/components/Drawer/Drawer.tsx +75 -16
  29. package/assets/components/Drawer/index.ts +1 -0
  30. package/assets/components/Icon/Icon.tsx +3 -0
  31. package/assets/components/Input/Input.module.css +4 -4
  32. package/assets/components/Select/Select.module.css +6 -2
  33. package/assets/components/SocialLoginButton/SocialLoginButton.module.css +198 -0
  34. package/assets/components/SocialLoginButton/SocialLoginButton.tsx +86 -0
  35. package/assets/components/SocialLoginButton/assets/amazon.svg +1 -0
  36. package/assets/components/SocialLoginButton/assets/apple.svg +3 -0
  37. package/assets/components/SocialLoginButton/assets/discord.svg +3 -0
  38. package/assets/components/SocialLoginButton/assets/facebook-white.png +0 -0
  39. package/assets/components/SocialLoginButton/assets/facebook.png +0 -0
  40. package/assets/components/SocialLoginButton/assets/github.svg +3 -0
  41. package/assets/components/SocialLoginButton/assets/google-mark.png +0 -0
  42. package/assets/components/SocialLoginButton/assets/kakao.svg +3 -0
  43. package/assets/components/SocialLoginButton/assets/line-icon.png +0 -0
  44. package/assets/components/SocialLoginButton/assets/line-white.png +0 -0
  45. package/assets/components/SocialLoginButton/assets/linkedin-white.png +0 -0
  46. package/assets/components/SocialLoginButton/assets/linkedin.png +0 -0
  47. package/assets/components/SocialLoginButton/assets/microsoft.svg +6 -0
  48. package/assets/components/SocialLoginButton/assets/naver.png +0 -0
  49. package/assets/components/SocialLoginButton/assets/slack.svg +17 -0
  50. package/assets/components/SocialLoginButton/assets/spotify.svg +3 -0
  51. package/assets/components/SocialLoginButton/assets/twitch.svg +21 -0
  52. package/assets/components/SocialLoginButton/assets/wechat.png +0 -0
  53. package/assets/components/SocialLoginButton/assets/x.svg +3 -0
  54. package/assets/components/SocialLoginButton/index.ts +2 -0
  55. package/assets/components/SocialLoginButton/provider-tokens.css +30 -0
  56. package/assets/components/SocialLoginButton/providers.ts +23 -0
  57. package/assets/components/TimePicker/TimePicker.module.css +3 -2
  58. package/assets/components/_data.ts +1 -1
  59. package/assets/components/_utils.css +2 -2
  60. package/assets/components/component-registry.json +30 -1
  61. package/assets/components/index.ts +1 -0
  62. package/assets/components/tokens.css +14 -15
  63. package/assets/prompts/ASSEMBLY.md +2 -0
  64. package/assets/prompts/CATALOG.md +1 -0
  65. package/assets/prompts/PRINCIPLES.md +1 -1
  66. package/assets/prompts/RULES.md +31 -0
  67. package/assets/prompts/axes/material.md +4 -4
  68. package/assets/prompts/axes/palette.md +1 -1
  69. package/assets/prompts/axes/shape.md +2 -2
  70. package/assets/prompts/axes/voice.md +2 -2
  71. package/assets/prompts/components/_variants.md +3 -3
  72. package/assets/prompts/components/accordion.md +1 -1
  73. package/assets/prompts/components/ai-message.md +6 -2
  74. package/assets/prompts/components/app-frame.md +2 -2
  75. package/assets/prompts/components/avatar.md +2 -2
  76. package/assets/prompts/components/badge.md +1 -1
  77. package/assets/prompts/components/breadcrumb.md +11 -5
  78. package/assets/prompts/components/button.md +2 -2
  79. package/assets/prompts/components/calendar.md +1 -1
  80. package/assets/prompts/components/callout.md +8 -4
  81. package/assets/prompts/components/canvas-edge.md +1 -1
  82. package/assets/prompts/components/canvas-node.md +2 -2
  83. package/assets/prompts/components/canvas.md +24 -8
  84. package/assets/prompts/components/chart-radial.md +1 -1
  85. package/assets/prompts/components/chart.md +1 -1
  86. package/assets/prompts/components/chat-reactions.md +1 -1
  87. package/assets/prompts/components/checkbox-card.md +3 -3
  88. package/assets/prompts/components/checkbox.md +1 -1
  89. package/assets/prompts/components/chip.md +4 -4
  90. package/assets/prompts/components/code-block.md +1 -1
  91. package/assets/prompts/components/combobox.md +3 -3
  92. package/assets/prompts/components/command-palette.md +52 -44
  93. package/assets/prompts/components/comment.md +2 -2
  94. package/assets/prompts/components/control-group.md +1 -1
  95. package/assets/prompts/components/data-table.md +1 -1
  96. package/assets/prompts/components/disclosure.md +1 -1
  97. package/assets/prompts/components/drawer.md +15 -1
  98. package/assets/prompts/components/dropdown-menu.md +1 -1
  99. package/assets/prompts/components/event-chip.md +2 -2
  100. package/assets/prompts/components/file-icon.md +1 -1
  101. package/assets/prompts/components/file-upload.md +1 -1
  102. package/assets/prompts/components/icon-button.md +1 -1
  103. package/assets/prompts/components/input.md +3 -3
  104. package/assets/prompts/components/list-item.md +1 -1
  105. package/assets/prompts/components/menu-item.md +2 -2
  106. package/assets/prompts/components/metric-card.md +1 -1
  107. package/assets/prompts/components/mini-calendar.md +1 -1
  108. package/assets/prompts/components/page-header.md +1 -1
  109. package/assets/prompts/components/segmented-chart.md +1 -1
  110. package/assets/prompts/components/sidebar.md +3 -3
  111. package/assets/prompts/components/skeleton.md +3 -3
  112. package/assets/prompts/components/social-login-button.md +117 -0
  113. package/assets/prompts/components/tab-strip.md +1 -1
  114. package/assets/prompts/components/table-cell.md +1 -1
  115. package/assets/prompts/components/table-header.md +1 -1
  116. package/assets/prompts/components/table-row-edit.md +3 -3
  117. package/assets/prompts/components/table-row.md +1 -1
  118. package/assets/prompts/components/table-toolbar.md +1 -1
  119. package/assets/prompts/components/timeline-view.md +2 -2
  120. package/assets/prompts/components/toast.md +1 -1
  121. package/assets/prompts/components/tooltip.md +3 -3
  122. package/assets/prompts/components/tree-nav.md +2 -2
  123. package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
  124. package/assets/prompts/design-examples/catalog.json +9 -9
  125. package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +37 -1
  126. package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +113 -18
  127. package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +2 -2
  128. package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +3 -1
  129. package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +99 -51
  130. package/assets/prompts/primitives/scroll.md +1 -1
  131. package/assets/prompts/tokens/color.md +4 -5
  132. package/assets/prompts/tokens/material.md +5 -2
  133. package/assets/prompts/tokens/radius.md +1 -1
  134. package/assets/prompts/use-cases/chat-chat-input.md +382 -74
  135. package/assets/prompts/use-cases/data-list-item.md +38 -431
  136. package/assets/prompts/use-cases/feedback-drawer.md +112 -33
  137. package/assets/prompts/use-cases/overlay-command-palette.md +2004 -0
  138. package/assets/prompts/use-cases/structure-canvas.md +1016 -0
  139. package/assets/skills/ovenn-validate/SKILL.md +1 -1
  140. package/assets/skills/ovenn-validate/scripts/lib/component-usage.js +27 -5
  141. package/assets/skills/ovenn-validate/scripts/rules/hard-rules.mjs +174 -0
  142. package/assets/skills/ovenn-validate/scripts/rules/hard-rules.test.mjs +57 -0
  143. package/assets/skills/ovenn-validate/scripts/validate.mjs +2 -0
  144. package/package.json +1 -1
  145. package/src/commands/info.js +5 -4
  146. package/src/commands/update.js +5 -1
  147. package/src/utils/agents.js +28 -17
  148. package/src/utils/client-bridges.js +4 -2
  149. package/src/utils/component-usage.js +27 -5
  150. package/src/utils/patch.js +2 -1
@@ -9,6 +9,6 @@ description: 선언된 프로젝트 토큰과 사용처 리터럴, 미선언 변
9
9
 
10
10
  필요한 행동은 전체 `prompts/CATALOG.md`에서 찾고 해당 문서의 Do/Don't·Props와 실제 컴포넌트 코드를 확인한다. 클라이언트의 실행·캡처·독립 검수 기능이 없으면 원본의 검수 대기 계약을 따른다. 검사 통과를 화면 검수로 대신하지 않는다.
11
11
 
12
- 로컬 규칙 검사는 이 스킬의 `scripts/validate.mjs`를 사용한다. 결과는 자동 검사 증거이며 독립 시각 검수와 구분한다.
12
+ 로컬 규칙 검사는 이 스킬의 `scripts/validate.mjs`를 사용한다. 결과는 자동 검사 증거이며 독립 시각 검수와 구분한다. `hard/*` 규칙은 `prompts/RULES.md`의 필수 규칙 중 정적으로 잡히는 것(em dash·구분 문자·IconButton 라벨·placeholder 전용 입력·상호작용 중첩은 error, filled 배경·액티브바는 review)이다.
13
13
 
14
14
  조립 전 역할별 componentPlan과 실제 부품 사용 검증은 `prompts/ASSEMBLY.md`의 v2 계약을 따른다. MCP의 `check_component_usage` 또는 `ovenn info check-component-usage --local`로 확인한다.
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import {createRequire} from 'node:module';
4
4
  import {createHash} from 'node:crypto';
5
+ import {spawnSync} from 'node:child_process';
5
6
  import {normalizeSource,resolveSource,sourceGraph} from './source-graph.js';
6
7
  const hasText=value=>typeof value==='string'&&Boolean(value.trim());
7
8
  const list=value=>Array.isArray(value)?value:[];
@@ -29,9 +30,11 @@ export function assessComponentPlan(plan,registry,{files={},componentsPath='comp
29
30
  }
30
31
  return {valid:!violations.length,violations};
31
32
  }
32
- export function checkComponentUsage(input,{ts=loadTypeScript()}={}) {
33
+ // Remote (MCP) requests stay small; the local CLI runs in-process on the consumer's own machine and may pass larger limits.
34
+ export const REMOTE_USAGE_LIMITS={files:500,chars:5000000},LOCAL_USAGE_LIMITS={files:5000,chars:50000000};
35
+ export function checkComponentUsage(input,{ts=loadTypeScript(),limits=REMOTE_USAGE_LIMITS}={}) {
33
36
  const files=Object.fromEntries(Object.entries(input.files||{}).map(([name,text])=>[normalizeSource(name),text]));
34
- if(Object.keys(files).length>500||Object.values(files).reduce((n,t)=>n+t.length,0)>5000000)throw new Error('Provide at most 500 source files / 5,000,000 characters.');
37
+ if(Object.keys(files).length>limits.files||Object.values(files).reduce((n,t)=>n+t.length,0)>limits.chars)throw new Error(`Provide at most ${limits.files.toLocaleString('en-US')} source files / ${limits.chars.toLocaleString('en-US')} characters.`);
35
38
  const registry=input.registry||[],base=normalizeSource(input.componentsPath||'components').replace(/\/$/,'')+'/',entries=input.entryFiles||Object.keys(files).filter(n=>/(?:page|layout)\.[jt]sx$/.test(n)),providers=new Set();
36
39
  const graph=sourceGraph(ts,files,entries,base),violations=[],unknown=graph.missing.map(reference=>({rule:'missing-source',reference})),uses=[],apiCalls=[],native=[],candidates=[];
37
40
  const parsed=new Map(Object.entries(graph.files).filter(([name])=>/\.[jt]sx?$/.test(name)).map(([name,text])=>[name,ts.createSourceFile(name,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX)]));
@@ -103,10 +106,29 @@ export function checkComponentUsage(input,{ts=loadTypeScript()}={}) {
103
106
  const sourceHash=digest(JSON.stringify(Object.entries(graph.files).sort(([a],[b])=>a.localeCompare(b))));
104
107
  return {version:'2',engineFingerprint:digest([checkComponentUsage,sourceGraph,resolveSource,normalizeSource,componentContract,componentExports,assessComponentPlan,exportFolder].map(fn=>fn.toString()).join('\n')),parserVersion:ts.version,valid:!violations.length,complete:!unknown.length&&Boolean(entries.length),sourceHash,registryHash:digest(JSON.stringify(registry)),uses,apiCalls,native,roles:roleResults,violations,unknown,coverage:{components:[...new Set(uses.map(u=>u.component))].sort(),authoredFiles:[...parsed.keys()].filter(n=>!n.startsWith(base))},limitations:['Static submitted-source analysis, not visual or behavioural certification. Semantic candidates and exceptions require evidence review. Internal child components are not counted as direct consumer calls. Engine fingerprint identifies the loaded host implementation; bundler transforms can produce different fingerprints.']};
105
108
  }
106
- export function readUsageProject(root,{componentsPath,planFile='.ovenn/component-plan.json'}={}){
109
+ /**
110
+ * Collect a consumer project for the local usage check.
111
+ * - `entry`: optional path prefixes (e.g. ["src/app/operate"]). Only page/layout files under them become entries,
112
+ * which lets a migration be checked one route at a time.
113
+ * - `ts`: when provided, files are pruned to the import graph reachable from the entries plus the files the
114
+ * component plan names, so large apps stay within the analysis limits.
115
+ */
116
+ export function readUsageProject(root,{componentsPath,planFile='.ovenn/component-plan.json',entry=[],ts}={}){
107
117
  componentsPath ||= ['components/ovenn','src/components/ovenn','components','web/components'].find(base=>fs.existsSync(path.join(root,base,'component-registry.json')));
108
118
  if(!componentsPath)throw new Error('Installed component registry not found. Set --components to the actual installation path.');
109
- const files={};function walk(dir,prefix=''){for(const e of fs.readdirSync(dir,{withFileTypes:true})){if(e.isSymbolicLink()||e.name.startsWith('.')||['node_modules','out','prompts'].includes(e.name))continue;const name=prefix+e.name;if(e.isDirectory())walk(path.join(dir,e.name),name+'/');else if(/\.[jt]sx?$/.test(name)&&!name.endsWith('.d.ts'))files[name]=fs.readFileSync(path.join(dir,e.name),'utf8');}}walk(root);
119
+ let files={};function walk(dir,prefix=''){for(const e of fs.readdirSync(dir,{withFileTypes:true})){if(e.isSymbolicLink()||e.name.startsWith('.')||['node_modules','out','prompts'].includes(e.name))continue;const name=prefix+e.name;if(e.isDirectory())walk(path.join(dir,e.name),name+'/');else if(/\.[jt]sx?$/.test(name)&&!name.endsWith('.d.ts'))files[name]=fs.readFileSync(path.join(dir,e.name),'utf8');}}walk(root);
110
120
  const registryPath=path.join(root,componentsPath,'component-registry.json'),registry=JSON.parse(fs.readFileSync(registryPath,'utf8'));let plan;try{plan=JSON.parse(fs.readFileSync(path.join(root,planFile),'utf8'));}catch{}
111
- return {files,registry,componentsPath,plan,entryFiles:Object.keys(files).filter(n=>/(?:^|\/)(?:page|layout)\.[jt]sx$/.test(n))};
121
+ const prefixes=[].concat(entry).filter(Boolean).map(p=>normalizeSource(p).replace(/\/$/,'')+'/');
122
+ let entryFiles=Object.keys(files).filter(n=>/(?:^|\/)(?:page|layout)\.[jt]sx$/.test(n));
123
+ if(prefixes.length){const scoped=entryFiles.filter(n=>prefixes.some(p=>n.startsWith(p)));if(!scoped.length)throw new Error(`No page/layout file under: ${prefixes.join(', ')}`);
124
+ // Ancestor layouts wrap every scoped route; without them providers such as ThemeController look missing.
125
+ const layouts=new Set();for(const file of scoped){let dir=path.posix.dirname(file);while(dir&&dir!=='.'){for(const name of entryFiles)if(name!==file&&path.posix.dirname(name)===dir&&/(?:^|\/)layout\.[jt]sx$/.test(name))layouts.add(name);dir=path.posix.dirname(dir);}}
126
+ entryFiles=[...new Set([...layouts,...scoped])];}
127
+ if(ts){const base=normalizeSource(componentsPath).replace(/\/$/,'')+'/';const keep=new Set([...Object.keys(sourceGraph(ts,files,entryFiles,base).files),...entryFiles]);for(const role of plan?.roles||[])for(const f of [...(role.sourceFiles||[]),...(role.evidence||[]),role.source].filter(Boolean))if(Object.hasOwn(files,normalizeSource(f)))keep.add(normalizeSource(f));files=Object.fromEntries(Object.entries(files).filter(([n])=>keep.has(n)));}
128
+ // `preserved` and `derived` roles compare against the pre-change file. Locally the committed version (git HEAD)
129
+ // is that baseline; without it every preserved role stays unknown and a migration can never be marked complete.
130
+ const baselineFiles={};
131
+ const wanted=new Set();for(const role of plan?.roles||[]){if(role?.strategy==='preserved')for(const f of role.sourceFiles||[])wanted.add(normalizeSource(f));if(role?.strategy==='derived'&&role.source)wanted.add(normalizeSource(role.source));}
132
+ for(const file of wanted){const head=spawnSync('git',['show',`HEAD:${file}`],{cwd:root,encoding:'utf8',maxBuffer:50*1024*1024});if(head.status===0)baselineFiles[file]=head.stdout;}
133
+ return {files,registry,componentsPath,plan,entryFiles,...(Object.keys(baselineFiles).length?{baselineFiles}:{})};
112
134
  }
@@ -0,0 +1,174 @@
1
+ // prompts/RULES.md의 필수 규칙 중 정적으로 잡을 수 있는 것.
2
+ // 접근성 계약(중첩 상호작용·라벨)은 error, 화면 문맥이 필요한 것(filled 배경·액티브바)은 review.
3
+ import { stripComments, lineOf, findBlocks } from '../lib/source-utils.mjs';
4
+
5
+ const SOURCE = 'prompts/RULES.md';
6
+ const INTERACTIVE = new Set(['button', 'a', 'Button', 'IconButton', 'Link']);
7
+ const FIELDS = new Set(['Input', 'Textarea', 'input', 'textarea']);
8
+ const FILLED_FIELDS = new Set(['Input', 'Textarea', 'Select', 'Combobox', 'MultiSelect', 'DatePicker', 'TimePicker']);
9
+
10
+ /** JSX 태그를 순서대로 돌려준다. 문자 단위 스캔이라 큰 파일에서도 선형 시간이다(stripComments 후 호출). */
11
+ function* tags(src) {
12
+ const n = src.length;
13
+ let i = 0;
14
+ while (i < n) {
15
+ const lt = src.indexOf('<', i);
16
+ if (lt < 0) return;
17
+ let j = lt + 1;
18
+ const closing = src[j] === '/';
19
+ if (closing) j++;
20
+ const nameStart = j;
21
+ while (j < n && /[A-Za-z0-9_.]/.test(src[j])) j++;
22
+ const name = src.slice(nameStart, j);
23
+ if (!name || !/^[A-Za-z]/.test(name)) { i = lt + 1; continue; }
24
+ // attributes: walk until ">" at brace depth 0 and outside quotes
25
+ let depth = 0, quote = null, k = j, ok = false;
26
+ while (k < n) {
27
+ const c = src[k];
28
+ if (quote) { if (c === quote) quote = null; k++; continue; }
29
+ if (c === '"' || c === "'" || c === '`') { quote = c; k++; continue; }
30
+ if (c === '{') depth++;
31
+ else if (c === '}') depth = Math.max(0, depth - 1);
32
+ else if (c === '>' && depth === 0) { ok = true; break; }
33
+ else if (c === '<' && depth === 0) break; // malformed; restart from here
34
+ k++;
35
+ }
36
+ if (!ok) { i = k; continue; }
37
+ const attrsRaw = src.slice(j, k);
38
+ const selfClosing = /\/\s*$/.test(attrsRaw);
39
+ yield { closing, name, attrs: selfClosing ? attrsRaw.replace(/\/\s*$/, '') : attrsRaw, selfClosing, index: lt, end: k + 1 };
40
+ i = k + 1;
41
+ }
42
+ }
43
+
44
+ function hasAttr(attrs, name) {
45
+ // boolean props (asChild) have no "="; attribute names end at whitespace, "=", "/" or the tag end
46
+ return new RegExp(`(^|\\s)${name.replace(/[-]/g, '\\-')}(?=\\s*=|\\s|/|$)`).test(attrs);
47
+ }
48
+ const hasSpread = (attrs) => /\{\s*\.\.\./.test(attrs);
49
+
50
+ /** em dash·en dash·생략부호·수사적 큰따옴표: 생성 문구 금지. JSX 텍스트와 문자열 리터럴만 본다. */
51
+ function checkTypography(src, ext) {
52
+ const violations = [];
53
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
54
+ const re = /[—–…“”]/g;
55
+ let m;
56
+ while ((m = re.exec(src))) {
57
+ // a string that is only the glyph ("—" as an empty-value placeholder) is data, not prose
58
+ const around = src.slice(Math.max(0, m.index - 1), m.index + 2);
59
+ if (/^["'`][—–…]["'`]$/.test(around)) continue;
60
+ violations.push({ line: lineOf(src, m.index), ruleId: 'hard/em-dash', message: `생성 문구에 ${m[0] === '…' ? '생략부호' : m[0] === '—' || m[0] === '–' ? 'dash' : '수사적 큰따옴표'}(${m[0]}) 금지`, suggest: '문장을 나누거나 쉼표·괄호로 바꾼다. 사용자 원문 인용이면 ovenn-validate-disable-next-line hard/em-dash', source: SOURCE });
61
+ }
62
+ return violations;
63
+ }
64
+
65
+ /** 메타 사이 가운뎃점 구분자(· • ∙): JSX 텍스트와 구분자만 담은 문자열에서만 본다. '|'는 타입 유니온과 구분할 수 없어 보지 않는다. */
66
+ function checkBulletSeparator(src, ext) {
67
+ const violations = [];
68
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
69
+ const seen = new Set();
70
+ const report = (index, glyph) => { if (seen.has(index)) return; seen.add(index); violations.push({ line: lineOf(src, index), ruleId: 'hard/bullet-separator', message: `구분 문자 '${glyph}' 금지: 라벨·메타 사이는 간격이나 hairline으로 나눈다`, suggest: 'gap 토큰 또는 EventListItem/meta-line의 hairline 구분을 쓴다', source: SOURCE }); };
71
+ // JSX text between tags/expressions, e.g. <span>{date} · {author}</span>
72
+ // non-empty text runs only; an empty match would not advance lastIndex and loop forever
73
+ const text = /(?<=[>}])([^<>{}]+)(?=[<{])/g;
74
+ let m;
75
+ while ((m = text.exec(src))) {
76
+ const g = m[1].match(/(?:^|\s)([·•∙])(?:\s|$)/);
77
+ if (g) report(m.index + g.index, g[1]);
78
+ }
79
+ // string literals that are only a separator: {" · "} or {" | "}
80
+ const lit = /["'`]\s*([·•∙])\s*["'`]/g;
81
+ while ((m = lit.exec(src))) report(m.index, m[1]);
82
+ return violations;
83
+ }
84
+
85
+ /** 아이콘 버튼은 접근 가능한 이름이 필수. */
86
+ function checkIconButtonLabel(src, ext) {
87
+ const violations = [];
88
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
89
+ for (const t of tags(src)) {
90
+ if (t.closing || t.name !== 'IconButton') continue;
91
+ if (hasAttr(t.attrs, 'aria-label') || hasAttr(t.attrs, 'aria-labelledby') || hasAttr(t.attrs, 'label')) continue;
92
+ violations.push({ line: lineOf(src, t.index), ruleId: 'hard/icon-button-label', severity: hasSpread(t.attrs) ? 'review' : 'error', message: 'IconButton에 aria-label이 없다: 스크린리더가 읽을 이름 필수', suggest: 'aria-label="동작 이름"을 넣는다', source: SOURCE });
93
+ }
94
+ return violations;
95
+ }
96
+
97
+ /** placeholder만 있고 라벨이 없는 입력: 값이 들어가면 힌트가 사라진다. */
98
+ function checkPlaceholderOnly(src, ext) {
99
+ const violations = [];
100
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
101
+ for (const t of tags(src)) {
102
+ if (t.closing || !FIELDS.has(t.name) || !hasAttr(t.attrs, 'placeholder')) continue;
103
+ if (hasAttr(t.attrs, 'label') || hasAttr(t.attrs, 'aria-label') || hasAttr(t.attrs, 'aria-labelledby') || hasAttr(t.attrs, 'id')) continue;
104
+ violations.push({ line: lineOf(src, t.index), ruleId: 'hard/placeholder-only', severity: hasSpread(t.attrs) ? 'review' : 'error', message: `${t.name}에 placeholder만 있고 라벨이 없다`, suggest: 'label 또는 aria-label을 지정한다. 외부 <label htmlFor>를 쓰면 id를 넣는다', source: SOURCE });
105
+ }
106
+ return violations;
107
+ }
108
+
109
+ /** 상호작용 요소 중첩: button 안 button, 링크 안 버튼 등. asChild 래퍼는 하나의 요소다. */
110
+ function checkNestedInteractive(src, ext) {
111
+ const violations = [];
112
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
113
+ const stack = [];
114
+ for (const t of tags(src)) {
115
+ if (t.closing) {
116
+ for (let i = stack.length - 1; i >= 0; i--) if (stack[i].name === t.name) { stack.splice(i); break; }
117
+ continue;
118
+ }
119
+ const interactive = INTERACTIVE.has(t.name) && !hasAttr(t.attrs, 'asChild');
120
+ if (interactive) {
121
+ const parent = stack.find((s) => s.interactive);
122
+ if (parent) violations.push({ line: lineOf(src, t.index), ruleId: 'hard/nested-interactive', message: `<${t.name}>이 <${parent.name}> 안에 있다: 상호작용 요소를 중첩하지 않는다`, suggest: '보조 동작은 형제로 두거나 Trigger에 asChild를 쓴다', source: SOURCE });
123
+ }
124
+ if (!t.selfClosing) stack.push({ name: t.name, interactive });
125
+ }
126
+ return violations;
127
+ }
128
+
129
+ /** filled 입력은 연한 배경 위에서 금지. 배경은 화면을 봐야 하므로 검토로 남긴다. */
130
+ function checkFilledField(src, ext) {
131
+ const violations = [];
132
+ if (!['.tsx', '.jsx'].includes(ext)) return violations;
133
+ for (const t of tags(src)) {
134
+ if (t.closing || !FILLED_FIELDS.has(t.name) || !/variant\s*=\s*["']filled["']/.test(t.attrs)) continue;
135
+ violations.push({ line: lineOf(src, t.index), ruleId: 'hard/filled-on-light', severity: 'review', message: `${t.name} variant="filled": 흰색·연한 배경 위에서는 금지(outline 사용). 실제 배경을 확인한다`, suggest: '연한 배경이면 variant="outline"', source: SOURCE });
136
+ }
137
+ return violations;
138
+ }
139
+
140
+ /** 탐색 액티브바: active/selected 선택자에 한쪽 변 border·inset shadow·가는 pseudo bar. */
141
+ function checkActiveBar(src, ext) {
142
+ const violations = [];
143
+ if (ext !== '.css') return violations;
144
+ let prevEnd = 0;
145
+ for (const b of findBlocks(src)) {
146
+ const selector = src.slice(prevEnd, b.start).replace(/[^{}]*}\s*/g, '').trim();
147
+ prevEnd = b.end + 1;
148
+ b.selector = selector;
149
+ // navigation/menu selection only; hover and focus rings (inset shadows) are a different contract
150
+ if (!/(active|selected|aria-current|data-state=["']?(active|on)|current)/i.test(selector)) continue;
151
+ if (/:(hover|focus)/i.test(selector)) continue;
152
+ if (!/(nav|menu|sidebar|tab|link|item|rail)/i.test(selector) && !/::?(before|after)/.test(selector)) continue;
153
+ const body = b.body;
154
+ const bar = body.match(/border-(?:left|right|inline-start|inline-end)\s*:\s*(?!0|none|transparent)[^;]+|box-shadow\s*:\s*inset\s+[^;]+|(?:^|;)\s*width\s*:\s*(?:2|3|4)px/i);
155
+ if (!bar) continue;
156
+ if (/width\s*:/.test(bar[0]) && !/::?(before|after)/.test(b.selector)) continue;
157
+ violations.push({ line: lineOf(src, b.start + 1 + (body.indexOf(bar[0]) >= 0 ? body.indexOf(bar[0]) : 0)), ruleId: 'hard/active-bar', severity: 'review', message: `선택 표시 액티브바로 보인다 (${b.selector.trim().slice(0, 60)}): 선택은 표면·글자색·굵기로 표시한다`, suggest: '바를 제거하거나, 꼭 필요하면 radius와 분리된 직선으로 둔다', source: SOURCE });
158
+ }
159
+ return violations;
160
+ }
161
+
162
+ export function checkHardRules(ctx) {
163
+ const src = stripComments(ctx.content, ctx.ext);
164
+ const violations = [
165
+ ...checkTypography(src, ctx.ext),
166
+ ...checkBulletSeparator(src, ctx.ext),
167
+ ...checkIconButtonLabel(src, ctx.ext),
168
+ ...checkPlaceholderOnly(src, ctx.ext),
169
+ ...checkNestedInteractive(src, ctx.ext),
170
+ ...checkFilledField(src, ctx.ext),
171
+ ...checkActiveBar(src, ctx.ext),
172
+ ];
173
+ return violations.map((v) => ({ severity: 'error', ...v }));
174
+ }
@@ -0,0 +1,57 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { checkHardRules } from './hard-rules.mjs';
4
+
5
+ const run = (content, ext = '.tsx') => checkHardRules({ content, ext, file: 'app/page.tsx', rel: 'app/page.tsx' });
6
+ const ids = (v) => v.map((x) => x.ruleId);
7
+
8
+ test('em dash, en dash and ellipsis in copy are errors; comments are ignored', () => {
9
+ const v = run('// 주석 — 무시\nexport const a = <p>저장 — 완료…</p>;');
10
+ assert.deepEqual(ids(v), ['hard/em-dash', 'hard/em-dash']);
11
+ assert.ok(v.every((x) => x.severity === 'error'));
12
+ assert.equal(run('export const a = <p>저장 완료</p>;').length, 0);
13
+ assert.equal(run('const none = "—"; const cell = <td>{value ?? "—"}</td>;').length, 0, 'a lone dash is an empty-value placeholder');
14
+ });
15
+
16
+ test('bullet separators between meta are flagged, logical OR and imports are not', () => {
17
+ assert.deepEqual(ids(run('const m = <span>{date} · {author}</span>;')), ['hard/bullet-separator']);
18
+ assert.equal(run('type V = "a" | "b"; const m = <span>{date} | {author}</span>;').length, 0, 'pipe is indistinguishable from unions; not checked');
19
+ assert.equal(run('const ok = a || b; const s = "x|y"; import { x } from "y";').length, 0);
20
+ });
21
+
22
+ test('IconButton needs an accessible name', () => {
23
+ assert.deepEqual(ids(run('<IconButton icon={<Icon name="x" />} onClick={f} />')), ['hard/icon-button-label']);
24
+ assert.equal(run('<IconButton aria-label="닫기" icon={<Icon name="x" />} />').length, 0);
25
+ const spread = run('<IconButton {...props} icon={<Icon name="x" />} />');
26
+ assert.equal(spread[0].severity, 'review');
27
+ });
28
+
29
+ test('placeholder-only fields are flagged; labelled ones pass', () => {
30
+ assert.deepEqual(ids(run('<Input placeholder="검색" value={q} onChange={set} />')), ['hard/placeholder-only']);
31
+ assert.equal(run('<Input label="검색" placeholder="이름" value={q} onChange={set} />').length, 0);
32
+ assert.equal(run('<label htmlFor="q">검색</label><input id="q" placeholder="이름" />').length, 0);
33
+ });
34
+
35
+ test('nested interactive elements are errors unless the wrapper is asChild', () => {
36
+ assert.deepEqual(ids(run('<Link href="/a"><Button>열기</Button></Link>')), ['hard/nested-interactive']);
37
+ assert.deepEqual(ids(run('<button><IconButton aria-label="x" icon={i} /></button>')), ['hard/nested-interactive']);
38
+ assert.equal(run('<DropdownMenu.Trigger asChild><Button>메뉴</Button></DropdownMenu.Trigger>').length, 0);
39
+ assert.equal(run('<Button asChild><Link href="/a">열기</Link></Button>').length, 0);
40
+ assert.equal(run('<div><Button>a</Button><Button>b</Button></div>').length, 0);
41
+ });
42
+
43
+ test('filled fields are reviews, not errors', () => {
44
+ const v = run('<Input label="이름" variant="filled" />');
45
+ assert.deepEqual(ids(v), ['hard/filled-on-light']);
46
+ assert.equal(v[0].severity, 'review');
47
+ });
48
+
49
+ test('active bars in css are reviews', () => {
50
+ const v = run('.item[data-active="true"] { border-left: 2px solid var(--primary); }', '.css');
51
+ assert.deepEqual(ids(v), ['hard/active-bar']);
52
+ assert.equal(v[0].severity, 'review');
53
+ assert.equal(run('.item[data-active="true"] { background: var(--bg-muted); font-weight: 600; }', '.css').length, 0);
54
+ assert.equal(run('.cell[data-selected] { box-shadow: inset 0 0 0 1px var(--primary); }', '.css').length, 0, 'calendar cell selection is not a nav bar');
55
+ assert.equal(run('.item[data-active]:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }', '.css').length, 0, 'focus rings are allowed');
56
+ assert.deepEqual(ids(run('.nav a[aria-current="page"]::before { content: ""; width: 3px; }', '.css')), ['hard/active-bar']);
57
+ });
@@ -6,6 +6,7 @@ import { checkHardcoded } from './rules/hardcoded.mjs';
6
6
  import { checkGhostTokens, loadDeclaredTokens } from './rules/ghost-tokens.mjs';
7
7
  import { checkMemoryRules } from './rules/memory-rules.mjs';
8
8
  import { checkDocSync } from './rules/doc-sync.mjs';
9
+ import { checkHardRules } from './rules/hard-rules.mjs';
9
10
 
10
11
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
12
  const REPO_ROOT = path.resolve(__dirname, '../../../..');
@@ -136,6 +137,7 @@ function run() {
136
137
  raw.push(...checkHardcoded(ctx));
137
138
  raw.push(...checkGhostTokens(ctx, declaredTokens));
138
139
  raw.push(...checkMemoryRules(ctx));
140
+ raw.push(...checkHardRules(ctx));
139
141
  }
140
142
 
141
143
  for (const v of raw) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conscience-technology/ovenn",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Ovenn — 하이브리드 디자인 시스템 설치 · 온보딩 CLI (shadcn식 코드 생성기)",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  import {listDesignExamples, getDesignExample} from "../utils/design-examples.js";
2
2
  import {join} from "node:path";
3
- import {checkComponentUsage,readUsageProject,loadTypeScript,assessComponentPlan} from '../utils/component-usage.js';
3
+ import {checkComponentUsage,readUsageProject,loadTypeScript,assessComponentPlan,LOCAL_USAGE_LIMITS} from '../utils/component-usage.js';
4
4
  import {getAssetSources} from "../utils/assets.js";
5
5
  import {workflowContext, workflowPolicy, assessWorkflow} from "../utils/design-workflow.js";
6
6
  /**
@@ -124,7 +124,7 @@ Subcommands:
124
124
  get-axis <name> Axis values and the tokens they drive
125
125
  get-guide [topic] Guides (e.g. axes/shape, tokens/spacing, ASSEMBLY)
126
126
  get-design-workflow [--scope=page] Common workflow and review schema
127
- check-component-usage --local [--project=input.json] Actual component render use
127
+ check-component-usage --local [--entry=src/app/x,...] [--project=input.json] Actual component render use; --entry limits page/layout entries to path prefixes
128
128
  check-design-review --file=workflow.json [--phase=preflight] Validate submitted evidence structure
129
129
  get-rules Global PRINCIPLES
130
130
  check-hardcoding --file=<path> [--ext=css] Quick CSS/TSX hardcoding scan
@@ -175,8 +175,9 @@ export async function run(argv) {
175
175
  return;
176
176
  }
177
177
  if(flags.local && sub==="check-component-usage") {
178
- const input=flags.project?JSON.parse(readFileSync(String(flags.project),"utf8")):readUsageProject(process.cwd(),{componentsPath:flags.components,planFile:flags.plan||".ovenn/component-plan.json"});
179
- const report=checkComponentUsage(input,{ts:loadTypeScript(process.cwd())});console.log(JSON.stringify(report,null,2));if(!report.valid||!report.complete)process.exitCode=1;return;
178
+ const ts=loadTypeScript(process.cwd());
179
+ const input=flags.project?JSON.parse(readFileSync(String(flags.project),"utf8")):readUsageProject(process.cwd(),{componentsPath:flags.components,planFile:flags.plan||".ovenn/component-plan.json",entry:flags.entry?String(flags.entry).split(","):[],ts});
180
+ const report=checkComponentUsage(input,{ts,limits:LOCAL_USAGE_LIMITS});console.log(JSON.stringify(report,null,2));if(!report.valid||!report.complete)process.exitCode=1;return;
180
181
  }
181
182
  if(flags.local && ["get-design-workflow","check-design-review"].includes(sub)) {
182
183
  const root=existsSync(join(process.cwd(),"prompts/ASSEMBLY.md"))?join(process.cwd(),"prompts"):getAssetSources().prompts;
@@ -1,4 +1,5 @@
1
1
  import { bridgeSources } from "../utils/client-bridges.js";
2
+ import { checkMissingDeps, renderInstallCmd } from "../utils/deps.js";
2
3
  import { existsSync, readFileSync } from "node:fs";
3
4
  import { join } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
@@ -61,5 +62,8 @@ export async function run(args) {
61
62
  const changes = plan.filter((item) => item.kind !== "unchanged" && !kept.has(item.path));
62
63
  if (changes.length || JSON.stringify(meta.pendingLocalEdits ?? []) !== JSON.stringify([...kept])) changes.push({path:metaFile,current:metaHash,content:Buffer.from(JSON.stringify(nextMeta,null,2)+"\n")});
63
64
  report.transaction = applyUpdate(root, changes);
64
- console.log(json ? JSON.stringify(report,null,2) : `${changes.length} files written; ${kept.size} local edits preserved.\n${report.transaction ? `Backup: .ovenn/updates/${report.transaction}\nRollback: ovenn update --rollback=${report.transaction}` : "Already up to date."}`);
65
+ // New components can bring new runtime packages (e.g. CodeBlock → shiki). Say so, or the consumer's typecheck fails after the update.
66
+ const { missing } = checkMissingDeps(root);
67
+ report.missingDependencies = missing;
68
+ console.log(json ? JSON.stringify(report,null,2) : `${changes.length} files written; ${kept.size} local edits preserved.\n${report.transaction ? `Backup: .ovenn/updates/${report.transaction}\nRollback: ovenn update --rollback=${report.transaction}` : "Already up to date."}${missing.length ? `\nInstall these packages (Ovenn components need them):\n ${renderInstallCmd(missing)}` : ""}`);
65
69
  }
@@ -9,25 +9,34 @@
9
9
  */
10
10
 
11
11
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
12
- import { join } from "node:path";
12
+ import { dirname, join } from "node:path";
13
13
 
14
14
  export const AGENTS_FILE = "AGENTS.md";
15
15
  const START = "<!-- ovenn:start -->";
16
16
  const END = "<!-- ovenn:end -->";
17
17
 
18
- /** 카탈로그 본문만 남기고(H1·안내문 제거) 섹션 제목을 한 단계 내린다. */
19
- function catalogBody(catalog) {
20
- const lines = catalog.split("\n");
21
- const first = lines.findIndex((l) => l.startsWith("## "));
22
- if (first < 0) return "";
23
- return lines
24
- .slice(first)
25
- .map((l) => (l.startsWith("## ") ? `#${l}` : l))
26
- .join("\n")
27
- .trim();
18
+ /** 카탈로그를 그룹별 이름 목록으로 압축한다. 용도 한 줄은 prompts/CATALOG.md에서 읽는다. */
19
+ function catalogNames(catalog) {
20
+ const groups = [];
21
+ let current = null;
22
+ for (const line of catalog.split("\n")) {
23
+ const heading = line.match(/^##\s+(.+)$/);
24
+ if (heading) { current = { title: heading[1].trim(), names: [] }; groups.push(current); continue; }
25
+ const entry = line.match(/^- \*\*(.+?)\*\* · `prompts\/components\/[a-z0-9-]+\.md`(.*?)(?: — |: )/);
26
+ if (entry && current) current.names.push(entry[2].includes("작업 중") ? `${entry[1]} (WIP, not installed)` : entry[1]);
27
+ }
28
+ return groups.filter((g) => g.names.length).map((g) => `- **${g.title}**: ${g.names.join(", ")}`).join("\n");
29
+ }
30
+
31
+ /** prompts/RULES.md 본문(H1 제외). 설치본에 RULES가 없으면 빈 문자열. */
32
+ function rulesBody(rules) {
33
+ if (!rules) return "";
34
+ const lines = rules.split("\n");
35
+ const first = lines.findIndex((l) => l.trim() && !l.startsWith("# "));
36
+ return first < 0 ? "" : lines.slice(first).map((l) => (l.startsWith("## ") ? `#${l}` : l)).join("\n").trim();
28
37
  }
29
38
 
30
- export function renderAgentsBlock(catalog, { componentsPath }) {
39
+ export function renderAgentsBlock(catalog, { componentsPath, rules = "" }) {
31
40
  return [
32
41
  START,
33
42
  "<!-- This block is managed by `ovenn init` and `ovenn update`. Edits inside will be overwritten on the next update. -->",
@@ -36,14 +45,15 @@ export function renderAgentsBlock(catalog, { componentsPath }) {
36
45
  "",
37
46
  `This project's UI runs on Ovenn. Component code lives in \`${componentsPath}/\` and the rule docs live in \`prompts/\`.`,
38
47
  "",
39
- "- Before any UI work, read `prompts/PRINCIPLES.md`, then execute `prompts/ASSEMBLY.md`. Screen review criteria and the independent reviewer contract live in `prompts/WORKFLOW_DESIGN.md`. These files are the source of truth for pages, partial UI and components.",
48
+ "- Before any UI work, read `prompts/PRINCIPLES.md`, then execute `prompts/ASSEMBLY.md`. Screen review criteria and the independent reviewer contract live in `prompts/WORKFLOW_DESIGN.md`. These files are the source of truth for pages, partial UI and components; they are read when UI work starts, not duplicated here.",
40
49
  "- With MCP, start with `get_rules` and `get_design_workflow`. File-based clients follow the same source documents. Record actual file/tool evidence; do not invent MCP calls or visual reviews.",
41
- "- Consult the full catalog below, then the selected component documentation and actual API. Use the actual selected components and verify componentPlan with check_component_usage (or ovenn info check-component-usage --local). Appearance remains adaptable under PRINCIPLES; reading docs is not reuse.",
50
+ "- Pick components from the catalog below, then read `prompts/CATALOG.md` for one-line purposes and `prompts/components/<slug>.md` for the actual API. Use the actual selected components and verify componentPlan with check_component_usage (or ovenn info check-component-usage --local). Appearance remains adaptable under PRINCIPLES except for the hard rules; reading docs is not reuse.",
42
51
  "- Theme and axis settings come from `ovenn.config.json` and `DESIGN.md`.",
43
52
  "",
53
+ ...(rulesBody(rules) ? ["### Hard rules (prompts/RULES.md)", "", rulesBody(rules), ""] : []),
44
54
  "### Component catalog",
45
55
  "",
46
- catalogBody(catalog),
56
+ catalogNames(catalog),
47
57
  END,
48
58
  ].join("\n");
49
59
  }
@@ -52,11 +62,12 @@ export function renderAgentsBlock(catalog, { componentsPath }) {
52
62
  * AGENTS.md에 블록을 생성·교체한다.
53
63
  * @returns {{ status: "created" | "updated" | "unchanged" | "failed", reason?: string }}
54
64
  */
55
- export function upsertAgentsBlock(cwd, catalogPath, { componentsPath, dry = false }) {
65
+ export function upsertAgentsBlock(cwd, catalogPath, { componentsPath, dry = false, rulesPath = join(dirname(catalogPath), "RULES.md") }) {
56
66
  if (!existsSync(catalogPath)) {
57
67
  return { status: "failed", reason: "prompts/CATALOG.md missing from the bundle" };
58
68
  }
59
- const block = renderAgentsBlock(readFileSync(catalogPath, "utf8"), { componentsPath });
69
+ const rules = existsSync(rulesPath) ? readFileSync(rulesPath, "utf8") : "";
70
+ const block = renderAgentsBlock(readFileSync(catalogPath, "utf8"), { componentsPath, rules });
60
71
  const filePath = join(cwd, AGENTS_FILE);
61
72
 
62
73
  if (!existsSync(filePath)) {
@@ -4,8 +4,10 @@ import { safePath } from './managed-assets.js';
4
4
 
5
5
  const start = '<!-- ovenn:client:start -->', end = '<!-- ovenn:client:end -->';
6
6
  export const clientBridges = {
7
- 'CLAUDE.md': `${start}\n# Ovenn\nRead @AGENTS.md. For any UI work execute @prompts/ASSEMBLY.md and use @prompts/WORKFLOW_DESIGN.md under @prompts/PRINCIPLES.md. These source files own the workflow.\n${end}`,
8
- '.cursor/rules/ovenn-workflow.mdc': `---\ndescription: Ovenn UI workflow\nalwaysApply: true\n---\n\n${start}\nFor UI work, read AGENTS.md, prompts/PRINCIPLES.md and execute prompts/ASSEMBLY.md. Review contract: prompts/WORKFLOW_DESIGN.md. Use these source documents rather than duplicating policy.\n${end}`,
7
+ // Only AGENTS.md (short intro + hard rules + component names) is loaded every turn.
8
+ // The full procedure documents are read when UI work starts, as the ovenn skills and AGENTS.md instruct.
9
+ 'CLAUDE.md': `${start}\n# Ovenn\nRead @AGENTS.md. Its hard rules apply to every UI change. Before any UI work read prompts/PRINCIPLES.md, then execute prompts/ASSEMBLY.md and review under prompts/WORKFLOW_DESIGN.md (the ovenn skills do this). Those files own the workflow; do not duplicate their policy here.\n${end}`,
10
+ '.cursor/rules/ovenn-workflow.mdc': `---\ndescription: Ovenn UI workflow\nalwaysApply: true\n---\n\n${start}\nAGENTS.md carries the Ovenn hard rules; they apply to every UI change. For UI work, read prompts/PRINCIPLES.md and execute prompts/ASSEMBLY.md. Review contract: prompts/WORKFLOW_DESIGN.md. Use these source documents rather than duplicating policy.\n${end}`,
9
11
  };
10
12
  export function mergeBridge(current, block) {
11
13
  const a=current.indexOf(start), b=current.indexOf(end);
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import {createRequire} from 'node:module';
4
4
  import {createHash} from 'node:crypto';
5
+ import {spawnSync} from 'node:child_process';
5
6
  import {normalizeSource,resolveSource,sourceGraph} from './source-graph.js';
6
7
  const hasText=value=>typeof value==='string'&&Boolean(value.trim());
7
8
  const list=value=>Array.isArray(value)?value:[];
@@ -29,9 +30,11 @@ export function assessComponentPlan(plan,registry,{files={},componentsPath='comp
29
30
  }
30
31
  return {valid:!violations.length,violations};
31
32
  }
32
- export function checkComponentUsage(input,{ts=loadTypeScript()}={}) {
33
+ // Remote (MCP) requests stay small; the local CLI runs in-process on the consumer's own machine and may pass larger limits.
34
+ export const REMOTE_USAGE_LIMITS={files:500,chars:5000000},LOCAL_USAGE_LIMITS={files:5000,chars:50000000};
35
+ export function checkComponentUsage(input,{ts=loadTypeScript(),limits=REMOTE_USAGE_LIMITS}={}) {
33
36
  const files=Object.fromEntries(Object.entries(input.files||{}).map(([name,text])=>[normalizeSource(name),text]));
34
- if(Object.keys(files).length>500||Object.values(files).reduce((n,t)=>n+t.length,0)>5000000)throw new Error('Provide at most 500 source files / 5,000,000 characters.');
37
+ if(Object.keys(files).length>limits.files||Object.values(files).reduce((n,t)=>n+t.length,0)>limits.chars)throw new Error(`Provide at most ${limits.files.toLocaleString('en-US')} source files / ${limits.chars.toLocaleString('en-US')} characters.`);
35
38
  const registry=input.registry||[],base=normalizeSource(input.componentsPath||'components').replace(/\/$/,'')+'/',entries=input.entryFiles||Object.keys(files).filter(n=>/(?:page|layout)\.[jt]sx$/.test(n)),providers=new Set();
36
39
  const graph=sourceGraph(ts,files,entries,base),violations=[],unknown=graph.missing.map(reference=>({rule:'missing-source',reference})),uses=[],apiCalls=[],native=[],candidates=[];
37
40
  const parsed=new Map(Object.entries(graph.files).filter(([name])=>/\.[jt]sx?$/.test(name)).map(([name,text])=>[name,ts.createSourceFile(name,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX)]));
@@ -103,10 +106,29 @@ export function checkComponentUsage(input,{ts=loadTypeScript()}={}) {
103
106
  const sourceHash=digest(JSON.stringify(Object.entries(graph.files).sort(([a],[b])=>a.localeCompare(b))));
104
107
  return {version:'2',engineFingerprint:digest([checkComponentUsage,sourceGraph,resolveSource,normalizeSource,componentContract,componentExports,assessComponentPlan,exportFolder].map(fn=>fn.toString()).join('\n')),parserVersion:ts.version,valid:!violations.length,complete:!unknown.length&&Boolean(entries.length),sourceHash,registryHash:digest(JSON.stringify(registry)),uses,apiCalls,native,roles:roleResults,violations,unknown,coverage:{components:[...new Set(uses.map(u=>u.component))].sort(),authoredFiles:[...parsed.keys()].filter(n=>!n.startsWith(base))},limitations:['Static submitted-source analysis, not visual or behavioural certification. Semantic candidates and exceptions require evidence review. Internal child components are not counted as direct consumer calls. Engine fingerprint identifies the loaded host implementation; bundler transforms can produce different fingerprints.']};
105
108
  }
106
- export function readUsageProject(root,{componentsPath,planFile='.ovenn/component-plan.json'}={}){
109
+ /**
110
+ * Collect a consumer project for the local usage check.
111
+ * - `entry`: optional path prefixes (e.g. ["src/app/operate"]). Only page/layout files under them become entries,
112
+ * which lets a migration be checked one route at a time.
113
+ * - `ts`: when provided, files are pruned to the import graph reachable from the entries plus the files the
114
+ * component plan names, so large apps stay within the analysis limits.
115
+ */
116
+ export function readUsageProject(root,{componentsPath,planFile='.ovenn/component-plan.json',entry=[],ts}={}){
107
117
  componentsPath ||= ['components/ovenn','src/components/ovenn','components','web/components'].find(base=>fs.existsSync(path.join(root,base,'component-registry.json')));
108
118
  if(!componentsPath)throw new Error('Installed component registry not found. Set --components to the actual installation path.');
109
- const files={};function walk(dir,prefix=''){for(const e of fs.readdirSync(dir,{withFileTypes:true})){if(e.isSymbolicLink()||e.name.startsWith('.')||['node_modules','out','prompts'].includes(e.name))continue;const name=prefix+e.name;if(e.isDirectory())walk(path.join(dir,e.name),name+'/');else if(/\.[jt]sx?$/.test(name)&&!name.endsWith('.d.ts'))files[name]=fs.readFileSync(path.join(dir,e.name),'utf8');}}walk(root);
119
+ let files={};function walk(dir,prefix=''){for(const e of fs.readdirSync(dir,{withFileTypes:true})){if(e.isSymbolicLink()||e.name.startsWith('.')||['node_modules','out','prompts'].includes(e.name))continue;const name=prefix+e.name;if(e.isDirectory())walk(path.join(dir,e.name),name+'/');else if(/\.[jt]sx?$/.test(name)&&!name.endsWith('.d.ts'))files[name]=fs.readFileSync(path.join(dir,e.name),'utf8');}}walk(root);
110
120
  const registryPath=path.join(root,componentsPath,'component-registry.json'),registry=JSON.parse(fs.readFileSync(registryPath,'utf8'));let plan;try{plan=JSON.parse(fs.readFileSync(path.join(root,planFile),'utf8'));}catch{}
111
- return {files,registry,componentsPath,plan,entryFiles:Object.keys(files).filter(n=>/(?:^|\/)(?:page|layout)\.[jt]sx$/.test(n))};
121
+ const prefixes=[].concat(entry).filter(Boolean).map(p=>normalizeSource(p).replace(/\/$/,'')+'/');
122
+ let entryFiles=Object.keys(files).filter(n=>/(?:^|\/)(?:page|layout)\.[jt]sx$/.test(n));
123
+ if(prefixes.length){const scoped=entryFiles.filter(n=>prefixes.some(p=>n.startsWith(p)));if(!scoped.length)throw new Error(`No page/layout file under: ${prefixes.join(', ')}`);
124
+ // Ancestor layouts wrap every scoped route; without them providers such as ThemeController look missing.
125
+ const layouts=new Set();for(const file of scoped){let dir=path.posix.dirname(file);while(dir&&dir!=='.'){for(const name of entryFiles)if(name!==file&&path.posix.dirname(name)===dir&&/(?:^|\/)layout\.[jt]sx$/.test(name))layouts.add(name);dir=path.posix.dirname(dir);}}
126
+ entryFiles=[...new Set([...layouts,...scoped])];}
127
+ if(ts){const base=normalizeSource(componentsPath).replace(/\/$/,'')+'/';const keep=new Set([...Object.keys(sourceGraph(ts,files,entryFiles,base).files),...entryFiles]);for(const role of plan?.roles||[])for(const f of [...(role.sourceFiles||[]),...(role.evidence||[]),role.source].filter(Boolean))if(Object.hasOwn(files,normalizeSource(f)))keep.add(normalizeSource(f));files=Object.fromEntries(Object.entries(files).filter(([n])=>keep.has(n)));}
128
+ // `preserved` and `derived` roles compare against the pre-change file. Locally the committed version (git HEAD)
129
+ // is that baseline; without it every preserved role stays unknown and a migration can never be marked complete.
130
+ const baselineFiles={};
131
+ const wanted=new Set();for(const role of plan?.roles||[]){if(role?.strategy==='preserved')for(const f of role.sourceFiles||[])wanted.add(normalizeSource(f));if(role?.strategy==='derived'&&role.source)wanted.add(normalizeSource(role.source));}
132
+ for(const file of wanted){const head=spawnSync('git',['show',`HEAD:${file}`],{cwd:root,encoding:'utf8',maxBuffer:50*1024*1024});if(head.status===0)baselineFiles[file]=head.stdout;}
133
+ return {files,registry,componentsPath,plan,entryFiles,...(Object.keys(baselineFiles).length?{baselineFiles}:{})};
112
134
  }
@@ -131,7 +131,8 @@ export function patchLayoutTsx(
131
131
  // 2) themeBootScript import + <head> 안 <script> 삽입
132
132
  if (!hasBoot) {
133
133
  next = insertAfterLastImport(next, `import { themeBootScript } from "${bootImportPath}";`);
134
- const scriptTag = `<script dangerouslySetInnerHTML={{ __html: themeBootScript() }} />`;
134
+ // init creates the onboarding route at /ovenn; the script's default (/onboarding) is the Ovenn repo's own route.
135
+ const scriptTag = `<script dangerouslySetInnerHTML={{ __html: themeBootScript({ onboardingPath: "/ovenn" }) }} />`;
135
136
  // <head>...</head> 쌍 매칭 우선. 없으면 self-closed <head />를 쌍 형태로 치환.
136
137
  const headPairRe = /<head(\s[^>]*)?>([\s\S]*?)<\/head>/;
137
138
  const headSelfRe = /<head(\s[^>]*)?\/>/;