@conscience-technology/ovenn 0.7.4 → 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/AIMessage/AIMessage.module.css +10 -0
- package/assets/components/AIMessage/AIMessage.tsx +6 -2
- package/assets/components/AttachmentThumb/AttachmentThumb.tsx +1 -0
- package/assets/components/Breadcrumb/Breadcrumb.module.css +82 -23
- package/assets/components/Breadcrumb/Breadcrumb.tsx +44 -26
- package/assets/components/Breadcrumb/index.ts +1 -0
- package/assets/components/Button/Button.module.css +2 -4
- package/assets/components/Callout/Callout.module.css +44 -18
- package/assets/components/Callout/Callout.tsx +9 -4
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/Canvas/Canvas.module.css +13 -0
- package/assets/components/Canvas/Canvas.tsx +378 -94
- package/assets/components/Canvas/clipboard.ts +5 -1
- package/assets/components/Canvas/collision.ts +5 -1
- package/assets/components/Canvas/graph.ts +14 -5
- package/assets/components/Canvas/history.ts +11 -4
- package/assets/components/Canvas/index.ts +2 -1
- package/assets/components/Canvas/types.ts +36 -1
- package/assets/components/CanvasEdge/tokens.css +14 -1
- package/assets/components/CanvasNode/tokens.css +13 -10
- package/assets/components/ChatComposer/ChatComposer.tsx +1 -1
- package/assets/components/ChatInput/ChatInput.tsx +1 -1
- package/assets/components/ColorField/ColorField.module.css +6 -1
- package/assets/components/ColorPicker/ColorPicker.module.css +3 -0
- package/assets/components/CommandPalette/CommandPalette.module.css +114 -0
- package/assets/components/CommandPalette/CommandPalette.tsx +206 -21
- package/assets/components/CommandPalette/index.ts +1 -0
- package/assets/components/Drawer/Drawer.module.css +30 -0
- package/assets/components/Drawer/Drawer.tsx +75 -16
- package/assets/components/Drawer/index.ts +1 -0
- package/assets/components/FileIcon/FileIcon.tsx +1 -0
- package/assets/components/FileIcon/fileExtMap.ts +1 -0
- package/assets/components/Icon/Icon.tsx +3 -0
- package/assets/components/Input/Input.module.css +3 -3
- 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/Select/Select.module.css +1 -1
- package/assets/components/SocialLoginButton/SocialLoginButton.module.css +198 -0
- package/assets/components/SocialLoginButton/SocialLoginButton.tsx +86 -0
- package/assets/components/SocialLoginButton/assets/amazon.svg +1 -0
- package/assets/components/SocialLoginButton/assets/apple.svg +3 -0
- package/assets/components/SocialLoginButton/assets/discord.svg +3 -0
- package/assets/components/SocialLoginButton/assets/facebook-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/facebook.png +0 -0
- package/assets/components/SocialLoginButton/assets/github.svg +3 -0
- package/assets/components/SocialLoginButton/assets/google-mark.png +0 -0
- package/assets/components/SocialLoginButton/assets/kakao.svg +3 -0
- package/assets/components/SocialLoginButton/assets/line-icon.png +0 -0
- package/assets/components/SocialLoginButton/assets/line-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/linkedin-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/linkedin.png +0 -0
- package/assets/components/SocialLoginButton/assets/microsoft.svg +6 -0
- package/assets/components/SocialLoginButton/assets/naver.png +0 -0
- package/assets/components/SocialLoginButton/assets/slack.svg +17 -0
- package/assets/components/SocialLoginButton/assets/spotify.svg +3 -0
- package/assets/components/SocialLoginButton/assets/twitch.svg +21 -0
- package/assets/components/SocialLoginButton/assets/wechat.png +0 -0
- package/assets/components/SocialLoginButton/assets/x.svg +3 -0
- package/assets/components/SocialLoginButton/index.ts +2 -0
- package/assets/components/SocialLoginButton/provider-tokens.css +30 -0
- package/assets/components/SocialLoginButton/providers.ts +23 -0
- 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/_data.ts +1 -1
- package/assets/components/_utils.css +1 -0
- package/assets/components/component-registry.json +30 -1
- package/assets/components/index.ts +1 -0
- package/assets/components/side-effect-css.d.ts +5 -0
- package/assets/components/themeBootScript.ts +7 -1
- package/assets/components/tokens.css +14 -6
- package/assets/prompts/ASSEMBLY.md +4 -0
- package/assets/prompts/CASCADE.md +2 -2
- package/assets/prompts/CATALOG.md +2 -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/material.md +4 -4
- package/assets/prompts/axes/motion.md +1 -1
- package/assets/prompts/axes/shape.md +2 -2
- package/assets/prompts/axes/voice.md +1 -1
- package/assets/prompts/components/_variants.md +4 -4
- package/assets/prompts/components/accordion.md +4 -4
- package/assets/prompts/components/ai-message.md +6 -2
- package/assets/prompts/components/attachment-item.md +2 -2
- package/assets/prompts/components/breadcrumb.md +11 -5
- package/assets/prompts/components/button.md +3 -3
- package/assets/prompts/components/callout.md +8 -4
- package/assets/prompts/components/canvas-edge.md +1 -1
- package/assets/prompts/components/canvas-node.md +1 -1
- package/assets/prompts/components/canvas.md +24 -8
- 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 +55 -47
- package/assets/prompts/components/context-menu.md +5 -5
- package/assets/prompts/components/date-picker.md +2 -2
- package/assets/prompts/components/drawer.md +17 -3
- 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 +12 -12
- 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/social-login-button.md +117 -0
- 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/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +9 -9
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +37 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +113 -18
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +2 -2
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +3 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +99 -51
- 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/prompts/tokens/material.md +5 -2
- package/assets/prompts/tokens/radius.md +1 -1
- package/assets/prompts/use-cases/chat-chat-input.md +382 -74
- package/assets/prompts/use-cases/data-list-item.md +38 -431
- package/assets/prompts/use-cases/feedback-drawer.md +112 -33
- package/assets/prompts/use-cases/overlay-command-palette.md +2004 -0
- package/assets/prompts/use-cases/structure-canvas.md +1016 -0
- 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
|
@@ -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
|
+
}
|
package/src/commands/info.js
CHANGED
|
@@ -2,6 +2,8 @@ import {listDesignExamples, getDesignExample} from "../utils/design-examples.js"
|
|
|
2
2
|
import {join} from "node:path";
|
|
3
3
|
import {checkComponentUsage,readUsageProject,loadTypeScript,assessComponentPlan,LOCAL_USAGE_LIMITS} from '../utils/component-usage.js';
|
|
4
4
|
import {getAssetSources} from "../utils/assets.js";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { rulesContext } from "../utils/rules-context.js";
|
|
5
7
|
import {workflowContext, workflowPolicy, assessWorkflow} from "../utils/design-workflow.js";
|
|
6
8
|
/**
|
|
7
9
|
* `ovenn info <subcommand> [args]` — MCP tool 을 CLI 로 호출.
|
|
@@ -45,7 +47,7 @@ const SUBCOMMANDS = {
|
|
|
45
47
|
"list-design-examples": {toolName:"list_design_examples", buildArgs:({positional, flags})=>({query:positional.join(" ") || undefined, scope:flags.scope || undefined})},
|
|
46
48
|
"get-design-example": {toolName:"get_design_example", buildArgs:({positional})=>({id:positional[0]})},
|
|
47
49
|
"check-component-usage": {toolName:"check_component_usage",buildArgs:({flags})=>JSON.parse(readFileSync(String(flags.project),"utf8"))},
|
|
48
|
-
"get-design-workflow": {toolName: "get_design_workflow", buildArgs: ({flags}) => ({scope: flags.scope || "page", role: flags.role || "generator"})},
|
|
50
|
+
"get-design-workflow": {toolName: "get_design_workflow", buildArgs: ({flags}) => ({scope: flags.scope || "page", role: flags.role || "generator", ...(flags.phase ? {phase: String(flags.phase)} : {})})},
|
|
49
51
|
"check-design-review": {toolName: "check_design_review", buildArgs: ({flags}) => ({record: JSON.parse(readFileSync(String(flags.file), "utf8")),phase:flags.phase||'complete'})},
|
|
50
52
|
"list-brand-sets": {toolName: "list_brand_sets", buildArgs: () => ({})},
|
|
51
53
|
"get-brand-set": {toolName: "get_brand_set", buildArgs: ({positional}) => ({id: positional[0]})},
|
|
@@ -86,7 +88,7 @@ const SUBCOMMANDS = {
|
|
|
86
88
|
},
|
|
87
89
|
"get-rules": {
|
|
88
90
|
toolName: "get_rules",
|
|
89
|
-
buildArgs: () => ({}),
|
|
91
|
+
buildArgs: ({ flags }) => ({ ...(flags.components ? { components: String(flags.components).split(",").map((name) => name.trim()).filter(Boolean) } : {}), ...(flags.principles ? { principles: true } : {}) }),
|
|
90
92
|
},
|
|
91
93
|
"check-hardcoding": {
|
|
92
94
|
toolName: "check_hardcoding",
|
|
@@ -123,12 +125,12 @@ Subcommands:
|
|
|
123
125
|
get-token <name> Token declaration site and axis bindings
|
|
124
126
|
get-axis <name> Axis values and the tokens they drive
|
|
125
127
|
get-guide [topic] Guides (e.g. axes/shape, tokens/spacing, ASSEMBLY)
|
|
126
|
-
get-design-workflow [--scope=page]
|
|
128
|
+
get-design-workflow [--scope=page] [--phase=plan|build|review] Common workflow; --phase returns that phase only
|
|
127
129
|
check-component-usage --local [--entry=src/app/x,...] [--project=input.json] Actual component render use; --entry limits page/layout entries to path prefixes
|
|
128
130
|
check-design-review --file=workflow.json [--phase=preflight] Validate submitted evidence structure
|
|
129
|
-
get-rules
|
|
130
|
-
check-hardcoding --file=<path>
|
|
131
|
-
check-hardcoding --code="..." [--ext=css]
|
|
131
|
+
get-rules [--local] [--components=Input,Canvas] [--principles] RULES, plus only the listed components' rules
|
|
132
|
+
check-hardcoding --file=<path|folder> Offline rule check (same engine as ovenn check; exit 1 on errors)
|
|
133
|
+
check-hardcoding --code="..." [--ext=css] Add --endpoint=<url> to ask a running MCP server instead
|
|
132
134
|
|
|
133
135
|
Options:
|
|
134
136
|
--local Workflow commands: read installed source docs without MCP/network
|
|
@@ -166,6 +168,20 @@ export async function run(argv) {
|
|
|
166
168
|
if (!report.valid) process.exitCode = 1;
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
171
|
+
// Offline unless an endpoint is named: the consumer dev server does not serve /api/mcp, so a default MCP call only fails.
|
|
172
|
+
if (sub === "check-hardcoding" && !flags.endpoint) {
|
|
173
|
+
const { run: check } = await import("./check.js");
|
|
174
|
+
if (flags.code) {
|
|
175
|
+
const engine = await import(pathToFileURL(join(getAssetSources().skills, "ovenn-validate", "scripts", "lib", "engine.mjs")).href);
|
|
176
|
+
const violations = engine.validateSource({ code: String(flags.code), ext: `.${flags.ext ?? (String(flags.code).includes("<") ? "tsx" : "css")}` });
|
|
177
|
+
const report = { files: 1, violations, errors: violations.filter((v) => v.severity !== "review").length, reviews: 0 };
|
|
178
|
+
if (flags.json) console.log(JSON.stringify(report, null, 2)); else process.stdout.write(engine.formatReport(report));
|
|
179
|
+
if (report.errors) process.exitCode = 1;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!flags.file) throw new Error("Pass --file=<path or folder> or --code=...");
|
|
183
|
+
return check([String(flags.file), ...(flags.json ? ["--json"] : [])]);
|
|
184
|
+
}
|
|
169
185
|
if (flags.local && ["list-design-examples", "get-design-example"].includes(sub)) {
|
|
170
186
|
const projectPrompts = join(process.cwd(), "prompts");
|
|
171
187
|
const root = existsSync(join(projectPrompts, "design-examples/catalog.json")) ? projectPrompts : getAssetSources().prompts;
|
|
@@ -179,11 +195,19 @@ export async function run(argv) {
|
|
|
179
195
|
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
196
|
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;
|
|
181
197
|
}
|
|
198
|
+
// Local rules: the installed prompts/ (or the bundled copy), the same text MCP get_rules returns.
|
|
199
|
+
if(flags.local && sub==="get-rules") {
|
|
200
|
+
const root=existsSync(join(process.cwd(),"prompts/RULES.md"))?join(process.cwd(),"prompts"):getAssetSources().prompts;
|
|
201
|
+
const read=(name)=>{const file=join(root,name);return existsSync(file)?readFileSync(file,"utf8"):null;};
|
|
202
|
+
const components=flags.components?String(flags.components).split(",").map((name)=>name.trim()).filter(Boolean):[];
|
|
203
|
+
console.log(rulesContext({rules:read("RULES.md"),principles:read("PRINCIPLES.md"),components,withPrinciples:Boolean(flags.principles),readComponent:(slug)=>read(`components/${slug}.md`)}));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
182
206
|
if(flags.local && ["get-design-workflow","check-design-review"].includes(sub)) {
|
|
183
207
|
const root=existsSync(join(process.cwd(),"prompts/ASSEMBLY.md"))?join(process.cwd(),"prompts"):getAssetSources().prompts;
|
|
184
208
|
const assembly=readFileSync(join(root,"ASSEMBLY.md"),"utf8");
|
|
185
209
|
if(sub==='check-design-review'&&flags.phase==='preflight'){const registry=JSON.parse(readFileSync(join(getAssetSources().components,'component-registry.json'),'utf8'));const report=assessComponentPlan(JSON.parse(readFileSync(String(flags.file),'utf8')),registry);console.log(JSON.stringify({...report,evidence:'client-supplied; no UI write ordering is certified'},null,2));if(!report.valid)process.exitCode=1;return;}
|
|
186
|
-
const value=sub==="get-design-workflow"?workflowContext(assembly,readFileSync(join(root,"WORKFLOW_DESIGN.md"),"utf8"),{scope:flags.scope||"page",role:flags.role||"generator"}):{...assessWorkflow(JSON.parse(readFileSync(String(flags.file),"utf8")),workflowPolicy(assembly)),evidence:"client-supplied; structural validation only"};
|
|
210
|
+
const value=sub==="get-design-workflow"?workflowContext(assembly,readFileSync(join(root,"WORKFLOW_DESIGN.md"),"utf8"),{scope:flags.scope||"page",role:flags.role||"generator",phase:flags.phase?String(flags.phase):undefined}):{...assessWorkflow(JSON.parse(readFileSync(String(flags.file),"utf8")),workflowPolicy(assembly)),evidence:"client-supplied; structural validation only"};
|
|
187
211
|
console.log(JSON.stringify(value,null,2));return;
|
|
188
212
|
}
|
|
189
213
|
const def = SUBCOMMANDS[sub];
|
|
@@ -200,6 +224,7 @@ export async function run(argv) {
|
|
|
200
224
|
const timeout = flags.timeout ? Number(flags.timeout) : 15000;
|
|
201
225
|
if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 120000) throw new Error("--timeout must be between 1 and 120000 milliseconds");
|
|
202
226
|
const result = await callTool(endpoint, def.toolName, args, {timeout});
|
|
227
|
+
if(sub==='check-hardcoding'&&result.content?.some(item=>item.type==='text'&&item.text.startsWith('✗')))process.exitCode=1;
|
|
203
228
|
if(sub==='check-component-usage'){
|
|
204
229
|
try{const report=JSON.parse(result.content.find(item=>item.type==='text').text);if(!report.valid||!report.complete)process.exitCode=1;}catch{process.exitCode=1;}
|
|
205
230
|
}
|
package/src/commands/init.js
CHANGED
|
@@ -12,7 +12,8 @@ import { installBridges } from "../utils/client-bridges.js";
|
|
|
12
12
|
*
|
|
13
13
|
* 플래그:
|
|
14
14
|
* --dry 실제 쓰기 없이 어떤 파일이 생성될지만 출력
|
|
15
|
-
* --force 기존 파일 있어도
|
|
15
|
+
* --force 기존 파일 있어도 덮어쓰기. 이미 설치된 프로젝트에서는 `ovenn update --force`로
|
|
16
|
+
* 넘겨서 수정 감지·백업·롤백을 거친다 (조용한 통째 덮어쓰기 없음).
|
|
16
17
|
* --no-open 설치 후 dev 서버 자동 실행 + 브라우저 오픈 건너뛰기
|
|
17
18
|
*/
|
|
18
19
|
|
|
@@ -26,6 +27,8 @@ import { c, step, success, warn, info, kv } from "../utils/log.js";
|
|
|
26
27
|
import { computeFilesMap, writeMeta, loadMeta } from "../utils/meta.js";
|
|
27
28
|
import { sourceFiles, digest } from "../utils/managed-assets.js";
|
|
28
29
|
import { hasDevScript, startDevAndOpen } from "../utils/launch.js";
|
|
30
|
+
import { detectLegacy } from "../utils/legacy-ctds.js";
|
|
31
|
+
import { renderOvennRoute } from "../utils/route.js";
|
|
29
32
|
import { AGENTS_FILE, upsertAgentsBlock } from "../utils/agents.js";
|
|
30
33
|
import {
|
|
31
34
|
patchGlobalsCss,
|
|
@@ -86,6 +89,17 @@ export async function run(args) {
|
|
|
86
89
|
const assets = getAssetSources();
|
|
87
90
|
const componentPath = project.useSrcDir ? "src/components/ovenn" : "components/ovenn";
|
|
88
91
|
const previousMeta = loadMeta(resolve(cwd, componentPath));
|
|
92
|
+
// Copying skips folders that already exist, so re-running init on an install would leave old files in place.
|
|
93
|
+
// An existing Ovenn or legacy CTDS install goes through update, which replaces, migrates and cleans up.
|
|
94
|
+
// With --force too: a wholesale copy would silently discard local edits (tokens.css, module.css, prompts),
|
|
95
|
+
// while update --force keeps a backup, lists what it overwrote and can roll back.
|
|
96
|
+
const legacy = detectLegacy(cwd, project);
|
|
97
|
+
if (previousMeta?.files || legacy) {
|
|
98
|
+
info(legacy && !previousMeta?.files ? `Found a CTDS ${legacy.version} install. Migrating it with ovenn update${force ? " --force" : ""}.` : `Ovenn ${previousMeta.version} is already installed. Running ovenn update${force ? " --force" : ""} instead.`);
|
|
99
|
+
console.log("");
|
|
100
|
+
const { run: update } = await import("./update.js");
|
|
101
|
+
return update([...(dry ? ["--dry"] : []), ...(force ? ["--force"] : [])]);
|
|
102
|
+
}
|
|
89
103
|
const copiedRoots = [];
|
|
90
104
|
info(`Asset source: ${assets.mode === "bundled" ? "bundled" : "local repo"}`);
|
|
91
105
|
console.log("");
|
|
@@ -114,7 +128,7 @@ export async function run(args) {
|
|
|
114
128
|
continue;
|
|
115
129
|
}
|
|
116
130
|
if (existsSync(dst) && !force) {
|
|
117
|
-
warn(`Already exists (skipped,
|
|
131
|
+
warn(`Already exists (skipped): ${to}. Run ovenn update to refresh an install, or init --force to replace it.`);
|
|
118
132
|
continue;
|
|
119
133
|
}
|
|
120
134
|
step(dry ? `[dry] copy` : `copy`, `${label} -> ${to}`);
|
|
@@ -134,7 +148,7 @@ export async function run(args) {
|
|
|
134
148
|
step(dry ? `[dry] create` : `create`, `${project.appDir}/ovenn/page.tsx`);
|
|
135
149
|
if (!dry) {
|
|
136
150
|
mkdirSync(ovennRouteDir, { recursive: true });
|
|
137
|
-
writeFileSync(ovennPagePath, renderOvennRoute(
|
|
151
|
+
writeFileSync(ovennPagePath, renderOvennRoute(), "utf8");
|
|
138
152
|
}
|
|
139
153
|
}
|
|
140
154
|
|
|
@@ -279,19 +293,18 @@ export async function run(args) {
|
|
|
279
293
|
success("All required dependencies are already installed.");
|
|
280
294
|
}
|
|
281
295
|
|
|
282
|
-
// 3-7)
|
|
283
|
-
//
|
|
296
|
+
// 3-7) Checks and MCP. This project's dev server does not serve /api/mcp; MCP tools need an Ovenn MCP endpoint
|
|
297
|
+
// (the Ovenn docs app serves one). Offline commands cover the checks without it.
|
|
284
298
|
manualFallbacks.push({
|
|
285
|
-
title: `${c.bold("
|
|
299
|
+
title: `${c.bold("Checks and MCP")} (optional):`,
|
|
286
300
|
lang: "text",
|
|
287
301
|
body:
|
|
288
|
-
`
|
|
289
|
-
`
|
|
290
|
-
`
|
|
291
|
-
`
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
"To call it straight from the shell, run: ovenn info list-components / get-component / get-token ...",
|
|
302
|
+
`Offline rule check of your code: ovenn check (exit 1 on errors; use it in prebuild or CI)\n` +
|
|
303
|
+
`Offline component-use check: ovenn info check-component-usage --local\n` +
|
|
304
|
+
`Run the check automatically (opt-in): ovenn setup-checks --hook --prebuild --ci\n` +
|
|
305
|
+
`MCP tools (get_component, get_rules, ...) need an Ovenn MCP endpoint, for example the Ovenn docs app\n` +
|
|
306
|
+
`running locally at http://localhost:3000/api/mcp. This project does not serve /api/mcp itself.`,
|
|
307
|
+
note: "With an endpoint registered, the agent fetches only what it needs via tools like get_component('Button'), which keeps the context small.",
|
|
295
308
|
});
|
|
296
309
|
|
|
297
310
|
if (manualFallbacks.length > 0) {
|
|
@@ -348,23 +361,6 @@ export async function run(args) {
|
|
|
348
361
|
});
|
|
349
362
|
}
|
|
350
363
|
|
|
351
|
-
function renderOvennRoute(project) {
|
|
352
|
-
// 사용자 플젝 alias 호환성 — 상대경로로 안전하게.
|
|
353
|
-
// app/ovenn/page.tsx → ../../components/ovenn/Onboarding (useSrcDir도 동일 레벨)
|
|
354
|
-
const importPath = "../../components/ovenn/Onboarding";
|
|
355
|
-
return `/**
|
|
356
|
-
* Ovenn onboarding route.
|
|
357
|
-
* Generated by \`npx ovenn init\`. Edit freely — subsequent \`ovenn init\`
|
|
358
|
-
* runs will not overwrite this file unless you pass --force.
|
|
359
|
-
*/
|
|
360
|
-
import { OnboardingPage } from "${importPath}";
|
|
361
|
-
|
|
362
|
-
export default function Page() {
|
|
363
|
-
return <OnboardingPage />;
|
|
364
|
-
}
|
|
365
|
-
`;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
364
|
function renderLayoutSnippet(project) {
|
|
369
365
|
// app/layout.tsx → ../components/ovenn/ThemeController
|
|
370
366
|
const importPath = "../components/ovenn/ThemeController";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ovenn setup-checks` — opt-in automatic runs of `ovenn check`. Nothing is installed unless a flag asks for it.
|
|
3
|
+
*
|
|
4
|
+
* --hook Claude Code: check each file the agent edits, and show violations back to it (.claude/settings.json)
|
|
5
|
+
* --prebuild npm: run the check before `npm run build` (package.json scripts)
|
|
6
|
+
* --ci GitHub Actions: run the check on pushes and pull requests (.github/workflows/ovenn-check.yml)
|
|
7
|
+
* --dry print what would change without writing
|
|
8
|
+
*
|
|
9
|
+
* Existing settings and scripts are merged, never replaced; running it again changes nothing.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
|
|
14
|
+
export const CHECK_COMMAND = "npx --yes @conscience-technology/ovenn check";
|
|
15
|
+
export const HOOK_COMMAND = `${CHECK_COMMAND} --hook`;
|
|
16
|
+
const HOOK_MATCHER = "Edit|MultiEdit|Write";
|
|
17
|
+
const CI_FILE = ".github/workflows/ovenn-check.yml";
|
|
18
|
+
const CI_WORKFLOW = `# Added by \`ovenn setup-checks --ci\`. Runs Ovenn rule checks on the project's own code.
|
|
19
|
+
name: Ovenn check
|
|
20
|
+
on:
|
|
21
|
+
push:
|
|
22
|
+
pull_request:
|
|
23
|
+
jobs:
|
|
24
|
+
ovenn-check:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-node@v4
|
|
29
|
+
with:
|
|
30
|
+
node-version: "22"
|
|
31
|
+
- run: ${CHECK_COMMAND}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export async function run(args) {
|
|
35
|
+
const want = { hook: args.includes("--hook"), prebuild: args.includes("--prebuild"), ci: args.includes("--ci") };
|
|
36
|
+
if (args.includes("--all")) want.hook = want.prebuild = want.ci = true;
|
|
37
|
+
if (args.includes("--help") || !Object.values(want).some(Boolean)) {
|
|
38
|
+
console.log(`ovenn setup-checks [--hook] [--prebuild] [--ci] [--all] [--dry]
|
|
39
|
+
|
|
40
|
+
Opt-in automatic runs of \`ovenn check\` (exit 1 on errors). Pick any:
|
|
41
|
+
--hook Claude Code checks each file the agent edits and shows violations to the agent (.claude/settings.json)
|
|
42
|
+
--prebuild run the check before \`npm run build\` (package.json "prebuild")
|
|
43
|
+
--ci run the check in GitHub Actions (${CI_FILE})
|
|
44
|
+
Existing settings are merged, not replaced. Nothing changes without a flag.`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const root = process.cwd(), dry = args.includes("--dry"), results = [];
|
|
48
|
+
const write = (path, text) => { if (!dry) { mkdirSync(dirname(join(root, path)), { recursive: true }); writeFileSync(join(root, path), text); } };
|
|
49
|
+
|
|
50
|
+
if (want.hook) {
|
|
51
|
+
const path = ".claude/settings.json", file = join(root, path);
|
|
52
|
+
const settings = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : {};
|
|
53
|
+
const post = ((settings.hooks ??= {}).PostToolUse ??= []);
|
|
54
|
+
if (post.some((entry) => entry.hooks?.some((hook) => hook.command === HOOK_COMMAND))) results.push(`${path}: hook already present`);
|
|
55
|
+
else {
|
|
56
|
+
post.push({ matcher: HOOK_MATCHER, hooks: [{ type: "command", command: HOOK_COMMAND, timeout: 60 }] });
|
|
57
|
+
write(path, `${JSON.stringify(settings, null, 2)}\n`);
|
|
58
|
+
results.push(`${path}: added a PostToolUse hook (${HOOK_MATCHER}) that checks the edited file`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (want.prebuild) {
|
|
62
|
+
const path = "package.json", file = join(root, path);
|
|
63
|
+
if (!existsSync(file)) results.push(`${path}: not found, prebuild skipped`);
|
|
64
|
+
else {
|
|
65
|
+
const pkg = JSON.parse(readFileSync(file, "utf8")), scripts = (pkg.scripts ??= {});
|
|
66
|
+
const step = "npm run ovenn:check";
|
|
67
|
+
let changed = false;
|
|
68
|
+
if (scripts["ovenn:check"] !== CHECK_COMMAND) { scripts["ovenn:check"] = CHECK_COMMAND; changed = true; }
|
|
69
|
+
if (!scripts.prebuild) { scripts.prebuild = step; changed = true; }
|
|
70
|
+
else if (!scripts.prebuild.includes(step)) { scripts.prebuild = `${scripts.prebuild} && ${step}`; changed = true; }
|
|
71
|
+
if (changed) write(path, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
72
|
+
results.push(changed ? `${path}: "prebuild" runs ${step}` : `${path}: prebuild already runs the check`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (want.ci) {
|
|
76
|
+
if (existsSync(join(root, CI_FILE))) results.push(`${CI_FILE}: already exists, left unchanged`);
|
|
77
|
+
else { write(CI_FILE, CI_WORKFLOW); results.push(`${CI_FILE}: created`); }
|
|
78
|
+
}
|
|
79
|
+
console.log(`${dry ? "Dry run, nothing written.\n" : ""}${results.join("\n")}`);
|
|
80
|
+
}
|