@conscience-technology/ovenn 0.7.3 → 0.7.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.
Files changed (68) hide show
  1. package/assets/components/CommandPalette/CommandPalette.module.css +1 -1
  2. package/assets/components/DatePicker/DatePicker.module.css +3 -2
  3. package/assets/components/Input/Input.module.css +1 -1
  4. package/assets/components/Select/Select.module.css +5 -1
  5. package/assets/components/TimePicker/TimePicker.module.css +3 -2
  6. package/assets/components/_utils.css +2 -2
  7. package/assets/components/tokens.css +1 -9
  8. package/assets/prompts/PRINCIPLES.md +1 -1
  9. package/assets/prompts/RULES.md +31 -0
  10. package/assets/prompts/axes/palette.md +1 -1
  11. package/assets/prompts/axes/voice.md +2 -2
  12. package/assets/prompts/components/_variants.md +2 -2
  13. package/assets/prompts/components/accordion.md +1 -1
  14. package/assets/prompts/components/app-frame.md +2 -2
  15. package/assets/prompts/components/avatar.md +2 -2
  16. package/assets/prompts/components/badge.md +1 -1
  17. package/assets/prompts/components/button.md +1 -1
  18. package/assets/prompts/components/calendar.md +1 -1
  19. package/assets/prompts/components/canvas-node.md +1 -1
  20. package/assets/prompts/components/chart-radial.md +1 -1
  21. package/assets/prompts/components/chart.md +1 -1
  22. package/assets/prompts/components/chat-reactions.md +1 -1
  23. package/assets/prompts/components/checkbox-card.md +3 -3
  24. package/assets/prompts/components/checkbox.md +1 -1
  25. package/assets/prompts/components/chip.md +4 -4
  26. package/assets/prompts/components/code-block.md +1 -1
  27. package/assets/prompts/components/combobox.md +3 -3
  28. package/assets/prompts/components/comment.md +2 -2
  29. package/assets/prompts/components/control-group.md +1 -1
  30. package/assets/prompts/components/data-table.md +1 -1
  31. package/assets/prompts/components/disclosure.md +1 -1
  32. package/assets/prompts/components/dropdown-menu.md +1 -1
  33. package/assets/prompts/components/event-chip.md +2 -2
  34. package/assets/prompts/components/file-icon.md +1 -1
  35. package/assets/prompts/components/file-upload.md +1 -1
  36. package/assets/prompts/components/icon-button.md +1 -1
  37. package/assets/prompts/components/input.md +3 -3
  38. package/assets/prompts/components/menu-item.md +2 -2
  39. package/assets/prompts/components/metric-card.md +1 -1
  40. package/assets/prompts/components/mini-calendar.md +1 -1
  41. package/assets/prompts/components/page-header.md +1 -1
  42. package/assets/prompts/components/segmented-chart.md +1 -1
  43. package/assets/prompts/components/sidebar.md +3 -3
  44. package/assets/prompts/components/skeleton.md +3 -3
  45. package/assets/prompts/components/tab-strip.md +1 -1
  46. package/assets/prompts/components/table-cell.md +1 -1
  47. package/assets/prompts/components/table-header.md +1 -1
  48. package/assets/prompts/components/table-row-edit.md +3 -3
  49. package/assets/prompts/components/table-row.md +1 -1
  50. package/assets/prompts/components/table-toolbar.md +1 -1
  51. package/assets/prompts/components/timeline-view.md +2 -2
  52. package/assets/prompts/components/toast.md +1 -1
  53. package/assets/prompts/components/tooltip.md +3 -3
  54. package/assets/prompts/components/tree-nav.md +2 -2
  55. package/assets/prompts/primitives/scroll.md +1 -1
  56. package/assets/prompts/tokens/color.md +4 -5
  57. package/assets/skills/ovenn-validate/SKILL.md +1 -1
  58. package/assets/skills/ovenn-validate/scripts/lib/component-usage.js +27 -5
  59. package/assets/skills/ovenn-validate/scripts/rules/hard-rules.mjs +174 -0
  60. package/assets/skills/ovenn-validate/scripts/rules/hard-rules.test.mjs +57 -0
  61. package/assets/skills/ovenn-validate/scripts/validate.mjs +2 -0
  62. package/package.json +1 -1
  63. package/src/commands/info.js +5 -4
  64. package/src/commands/update.js +5 -1
  65. package/src/utils/agents.js +28 -17
  66. package/src/utils/client-bridges.js +4 -2
  67. package/src/utils/component-usage.js +27 -5
  68. package/src/utils/patch.js +2 -1
@@ -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[^>]*)?\/>/;