@once-ui-system/core 1.7.12 → 1.7.13
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/AGENTS.md +53 -0
- package/README.md +27 -0
- package/agent/once-ui-codegen.mdc +27 -0
- package/ai/catalog.json +2 -2
- package/ai/components/ContextMenu.json +2 -2
- package/ai/components/Table.json +17 -2
- package/ai/manifest.json +2 -2
- package/ai/spec.json +22 -7
- package/dist/AGENTS.md +53 -0
- package/dist/README.md +27 -0
- package/dist/agent/once-ui-codegen.mdc +27 -0
- package/dist/ai/catalog.json +2 -2
- package/dist/ai/components/ContextMenu.json +2 -2
- package/dist/ai/components/Table.json +17 -2
- package/dist/ai/manifest.json +2 -2
- package/dist/ai/spec.json +22 -7
- package/dist/components/ContextMenu.d.ts +2 -2
- package/dist/components/ContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu.js +3 -3
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/ElementType.d.ts.map +1 -1
- package/dist/components/ElementType.js +6 -4
- package/dist/components/ElementType.js.map +1 -1
- package/dist/components/Media.d.ts.map +1 -1
- package/dist/components/Media.js +6 -3
- package/dist/components/Media.js.map +1 -1
- package/dist/components/MediaVideoPlayer.d.ts +12 -0
- package/dist/components/MediaVideoPlayer.d.ts.map +1 -0
- package/dist/components/MediaVideoPlayer.js +246 -0
- package/dist/components/MediaVideoPlayer.js.map +1 -0
- package/dist/components/MediaVideoPlayer.module.scss +90 -0
- package/dist/components/Table.d.ts +34 -6
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js +114 -30
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Table.module.scss +174 -3
- package/dist/components/ThemeInit.d.ts.map +1 -1
- package/dist/components/ThemeInit.js +2 -1
- package/dist/components/ThemeInit.js.map +1 -1
- package/dist/components/Timeline.d.ts +1 -1
- package/dist/components/Timeline.d.ts.map +1 -1
- package/dist/components/Timeline.js +16 -52
- package/dist/components/Timeline.js.map +1 -1
- package/dist/data/emoji-data.json +8 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +7 -2
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/code/CodeBlock.impl.d.ts.map +1 -1
- package/dist/modules/code/CodeBlock.impl.js +11 -5
- package/dist/modules/code/CodeBlock.impl.js.map +1 -1
- package/dist/modules/seo/Schema.d.ts.map +1 -1
- package/dist/modules/seo/Schema.js +3 -4
- package/dist/modules/seo/Schema.js.map +1 -1
- package/dist/package.json +22 -3
- package/dist/server/og-url-validation.d.ts +10 -0
- package/dist/server/og-url-validation.d.ts.map +1 -0
- package/dist/server/og-url-validation.js +234 -0
- package/dist/server/og-url-validation.js.map +1 -0
- package/dist/server/og-utils.d.ts +5 -2
- package/dist/server/og-utils.d.ts.map +1 -1
- package/dist/server/og-utils.js +39 -14
- package/dist/server/og-utils.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/safe-html.d.ts +19 -0
- package/dist/utils/safe-html.d.ts.map +1 -0
- package/dist/utils/safe-html.js +43 -0
- package/dist/utils/safe-html.js.map +1 -0
- package/package.json +23 -3
- package/scripts/copy-files.js +103 -0
- package/scripts/generate-ai-spec.js +464 -0
- package/scripts/generate-emoji-data.js +128 -0
- package/scripts/init-agent.js +156 -0
- package/scripts/validate-ai-code.js +149 -0
package/dist/server/og-utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
+
import { fetchValidatedUrl, OGUrlValidationError, validateOgUrl, } from './og-url-validation';
|
|
2
3
|
function decodeHTMLEntities(text) {
|
|
3
4
|
return text.replace(/&(#?[a-zA-Z0-9]+);/g, (match, entity) => {
|
|
4
5
|
const entities = {
|
|
@@ -21,16 +22,16 @@ function decodeHTMLEntities(text) {
|
|
|
21
22
|
return entities[entity] || match;
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
async function fetchWithTimeout(url, timeout = 5000, userAgent = 'Mozilla/5.0 (compatible; OG-Fetcher/1.0)') {
|
|
25
|
+
async function fetchWithTimeout(url, timeout = 5000, userAgent = 'Mozilla/5.0 (compatible; OG-Fetcher/1.0)', validationOptions = {}) {
|
|
25
26
|
const controller = new AbortController();
|
|
26
27
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
27
28
|
try {
|
|
28
|
-
const response = await
|
|
29
|
+
const response = await fetchValidatedUrl(url, {
|
|
29
30
|
signal: controller.signal,
|
|
30
31
|
headers: {
|
|
31
|
-
'User-Agent': userAgent
|
|
32
|
-
}
|
|
33
|
-
});
|
|
32
|
+
'User-Agent': userAgent,
|
|
33
|
+
},
|
|
34
|
+
}, validationOptions);
|
|
34
35
|
clearTimeout(timeoutId);
|
|
35
36
|
return response;
|
|
36
37
|
}
|
|
@@ -39,17 +40,30 @@ async function fetchWithTimeout(url, timeout = 5000, userAgent = 'Mozilla/5.0 (c
|
|
|
39
40
|
throw error;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
function validationErrorResponse() {
|
|
44
|
+
return NextResponse.json({ error: 'URL is not allowed' }, { status: 400 });
|
|
45
|
+
}
|
|
42
46
|
export async function handleOGFetch(request, options = {}) {
|
|
43
|
-
const { timeout = 5000, userAgent = 'Mozilla/5.0 (compatible; OG-Fetcher/1.0)', decodeEntities = true } = options;
|
|
47
|
+
const { timeout = 5000, userAgent = 'Mozilla/5.0 (compatible; OG-Fetcher/1.0)', decodeEntities = true, allowedDomains, } = options;
|
|
44
48
|
const { searchParams } = new URL(request.url);
|
|
45
49
|
const url = searchParams.get('url');
|
|
46
50
|
if (!url) {
|
|
47
51
|
return NextResponse.json({ error: 'URL parameter is required' }, { status: 400 });
|
|
48
52
|
}
|
|
53
|
+
const validationOptions = { allowedDomains };
|
|
49
54
|
try {
|
|
50
|
-
|
|
55
|
+
await validateOgUrl(url, validationOptions);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof OGUrlValidationError) {
|
|
59
|
+
return validationErrorResponse();
|
|
60
|
+
}
|
|
61
|
+
return validationErrorResponse();
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const response = await fetchWithTimeout(url, timeout, userAgent, validationOptions);
|
|
51
65
|
if (!response.ok) {
|
|
52
|
-
throw new Error(`HTTP ${response.status}
|
|
66
|
+
throw new Error(`HTTP ${response.status}`);
|
|
53
67
|
}
|
|
54
68
|
const html = await response.text();
|
|
55
69
|
const ogData = {
|
|
@@ -89,24 +103,34 @@ export async function handleOGFetch(request, options = {}) {
|
|
|
89
103
|
}
|
|
90
104
|
catch (error) {
|
|
91
105
|
console.error('Error fetching OG data:', error);
|
|
92
|
-
return NextResponse.json({ error: 'Failed to fetch Open Graph data'
|
|
106
|
+
return NextResponse.json({ error: 'Failed to fetch Open Graph data' }, { status: 500 });
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
export async function handleOGProxy(request, options = {}) {
|
|
96
|
-
const { userAgent = 'Mozilla/5.0 (compatible; OG-Proxy/1.0)', cacheMaxAge = 3600 } = options;
|
|
110
|
+
const { userAgent = 'Mozilla/5.0 (compatible; OG-Proxy/1.0)', cacheMaxAge = 3600, allowedDomains, } = options;
|
|
97
111
|
const { searchParams } = new URL(request.url);
|
|
98
112
|
const url = searchParams.get('url');
|
|
99
113
|
if (!url) {
|
|
100
114
|
return NextResponse.json({ error: 'URL parameter is required' }, { status: 400 });
|
|
101
115
|
}
|
|
116
|
+
const validationOptions = { allowedDomains };
|
|
102
117
|
try {
|
|
103
|
-
|
|
118
|
+
await validateOgUrl(url, validationOptions);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof OGUrlValidationError) {
|
|
122
|
+
return validationErrorResponse();
|
|
123
|
+
}
|
|
124
|
+
return validationErrorResponse();
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const response = await fetchValidatedUrl(url, {
|
|
104
128
|
headers: {
|
|
105
129
|
'User-Agent': userAgent,
|
|
106
130
|
},
|
|
107
|
-
});
|
|
131
|
+
}, validationOptions);
|
|
108
132
|
if (!response.ok) {
|
|
109
|
-
return NextResponse.json({ error:
|
|
133
|
+
return NextResponse.json({ error: 'Failed to fetch image' }, { status: response.status >= 400 && response.status < 600 ? response.status : 502 });
|
|
110
134
|
}
|
|
111
135
|
const contentType = response.headers.get('content-type') || 'image/jpeg';
|
|
112
136
|
const buffer = await response.arrayBuffer();
|
|
@@ -119,7 +143,8 @@ export async function handleOGProxy(request, options = {}) {
|
|
|
119
143
|
}
|
|
120
144
|
catch (error) {
|
|
121
145
|
console.error('Error proxying image:', error);
|
|
122
|
-
return NextResponse.json({ error: 'Failed to proxy image'
|
|
146
|
+
return NextResponse.json({ error: 'Failed to proxy image' }, { status: 500 });
|
|
123
147
|
}
|
|
124
148
|
}
|
|
149
|
+
export { OGUrlValidationError, validateOgUrl } from './og-url-validation';
|
|
125
150
|
//# sourceMappingURL=og-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"og-utils.js","sourceRoot":"","sources":["../../src/server/og-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"og-utils.js","sourceRoot":"","sources":["../../src/server/og-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EAEpB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAgB7B,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3D,M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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes HTML special characters for safe insertion into HTML text nodes
|
|
3
|
+
* or attributes when content is not already sanitized HTML.
|
|
4
|
+
*/
|
|
5
|
+
export declare function escapeHtml(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Serializes a value for safe embedding inside HTML <script> tags.
|
|
8
|
+
* JSON.stringify escapes quotes and backslashes but not `<`, which allows
|
|
9
|
+
* `</script>` breakout when prop values are attacker-controlled.
|
|
10
|
+
*/
|
|
11
|
+
export declare function safeScriptJson(value: unknown): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a trimmed href when it is safe to use as a navigation target,
|
|
14
|
+
* otherwise `undefined`. Blocks `javascript:`, `data:`, and other non-allowlisted
|
|
15
|
+
* schemes (including variants with embedded whitespace/control characters).
|
|
16
|
+
* Scheme-less values (relative paths, `#hash`, `?query`) are allowed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sanitizeHref(href: string | null | undefined): string | undefined;
|
|
19
|
+
//# sourceMappingURL=safe-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-html.d.ts","sourceRoot":"","sources":["../../src/utils/safe-html.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAchF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes HTML special characters for safe insertion into HTML text nodes
|
|
3
|
+
* or attributes when content is not already sanitized HTML.
|
|
4
|
+
*/
|
|
5
|
+
export function escapeHtml(text) {
|
|
6
|
+
return text
|
|
7
|
+
.replace(/&/g, "&")
|
|
8
|
+
.replace(/</g, "<")
|
|
9
|
+
.replace(/>/g, ">")
|
|
10
|
+
.replace(/"/g, """)
|
|
11
|
+
.replace(/'/g, "'");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Serializes a value for safe embedding inside HTML <script> tags.
|
|
15
|
+
* JSON.stringify escapes quotes and backslashes but not `<`, which allows
|
|
16
|
+
* `</script>` breakout when prop values are attacker-controlled.
|
|
17
|
+
*/
|
|
18
|
+
export function safeScriptJson(value) {
|
|
19
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
20
|
+
}
|
|
21
|
+
const ALLOWED_HREF_SCHEMES = new Set(["http", "https", "mailto", "tel", "sms"]);
|
|
22
|
+
/**
|
|
23
|
+
* Returns a trimmed href when it is safe to use as a navigation target,
|
|
24
|
+
* otherwise `undefined`. Blocks `javascript:`, `data:`, and other non-allowlisted
|
|
25
|
+
* schemes (including variants with embedded whitespace/control characters).
|
|
26
|
+
* Scheme-less values (relative paths, `#hash`, `?query`) are allowed.
|
|
27
|
+
*/
|
|
28
|
+
export function sanitizeHref(href) {
|
|
29
|
+
if (href == null)
|
|
30
|
+
return undefined;
|
|
31
|
+
const trimmed = href.trim();
|
|
32
|
+
if (!trimmed)
|
|
33
|
+
return undefined;
|
|
34
|
+
const forScheme = trimmed.replace(/[\u0000-\u001F\u007F\s]/g, "");
|
|
35
|
+
const schemeMatch = forScheme.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);
|
|
36
|
+
if (schemeMatch) {
|
|
37
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
38
|
+
if (!ALLOWED_HREF_SCHEMES.has(scheme))
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return trimmed;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=safe-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-html.js","sourceRoot":"","sources":["../../src/utils/safe-html.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAA+B;IAC1D,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnE,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,OAAO,SAAS,CAAC;IAC1D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@once-ui-system/core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"description": "Once UI for Next.js NPM package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"once-ui",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"scss",
|
|
10
10
|
"design system",
|
|
11
11
|
"design framework",
|
|
12
|
-
"nextjs design system"
|
|
12
|
+
"nextjs design system",
|
|
13
|
+
"ai",
|
|
14
|
+
"agent",
|
|
15
|
+
"codegen"
|
|
13
16
|
],
|
|
14
17
|
"author": "Once UI",
|
|
15
18
|
"license": "MIT",
|
|
@@ -22,6 +25,21 @@
|
|
|
22
25
|
"url": "https://github.com/once-ui-system/core/issues"
|
|
23
26
|
},
|
|
24
27
|
"homepage": "https://docs.once-ui.com",
|
|
28
|
+
"onceUi": {
|
|
29
|
+
"harness": "./ai/manifest.json",
|
|
30
|
+
"bootstrap": [
|
|
31
|
+
"./ai/rules.compact.md",
|
|
32
|
+
"./ai/catalog.json"
|
|
33
|
+
],
|
|
34
|
+
"tasks": "./ai/tasks/index.json",
|
|
35
|
+
"validate": "./scripts/validate-ai-code.js",
|
|
36
|
+
"initAgent": "./scripts/init-agent.js",
|
|
37
|
+
"docs": "https://docs.once-ui.com/once-ui/ai-coding"
|
|
38
|
+
},
|
|
39
|
+
"bin": {
|
|
40
|
+
"once-ui-init-agent": "./scripts/init-agent.js",
|
|
41
|
+
"once-ui-validate-ai-code": "./scripts/validate-ai-code.js"
|
|
42
|
+
},
|
|
25
43
|
"main": "dist/index.js",
|
|
26
44
|
"exports": {
|
|
27
45
|
".": {
|
|
@@ -80,7 +98,8 @@
|
|
|
80
98
|
"./ai/tasks/*": "./ai/tasks/*",
|
|
81
99
|
"./ai/components/*": "./ai/components/*",
|
|
82
100
|
"./ai/examples/*": "./ai/examples/*",
|
|
83
|
-
"./ai/examples/blocks/*": "./ai/examples/blocks/*"
|
|
101
|
+
"./ai/examples/blocks/*": "./ai/examples/blocks/*",
|
|
102
|
+
"./AGENTS.md": "./AGENTS.md"
|
|
84
103
|
},
|
|
85
104
|
"scripts": {
|
|
86
105
|
"build": "pnpm clean && pnpm generate-emoji-data && pnpm generate-ai-spec && tsc --project tsconfig.build.json && pnpm copy-files && pnpm build:css",
|
|
@@ -97,6 +116,7 @@
|
|
|
97
116
|
"prepack": "pnpm build",
|
|
98
117
|
"generate-emoji-data": "node scripts/generate-emoji-data.js",
|
|
99
118
|
"generate-ai-spec": "node scripts/generate-ai-spec.js",
|
|
119
|
+
"init-agent": "node scripts/init-agent.js",
|
|
100
120
|
"validate-ai-code": "node scripts/validate-ai-code.js"
|
|
101
121
|
},
|
|
102
122
|
"dependencies": {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
// Function to copy directory recursively
|
|
5
|
+
function copyDir(src, dest) {
|
|
6
|
+
// Create destination directory if it doesn't exist
|
|
7
|
+
if (!fs.existsSync(dest)) {
|
|
8
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Read source directory
|
|
12
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
13
|
+
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const srcPath = path.join(src, entry.name);
|
|
16
|
+
const destPath = path.join(dest, entry.name);
|
|
17
|
+
|
|
18
|
+
if (entry.isDirectory()) {
|
|
19
|
+
// Recursively copy directory
|
|
20
|
+
copyDir(srcPath, destPath);
|
|
21
|
+
} else {
|
|
22
|
+
// Copy file if it's not a TypeScript file (TS files are handled by tsc)
|
|
23
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
24
|
+
if (![".ts", ".tsx"].includes(ext)) {
|
|
25
|
+
fs.copyFileSync(srcPath, destPath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Copy all style files and other assets
|
|
32
|
+
const srcDir = path.resolve(__dirname, "../src");
|
|
33
|
+
const destDir = path.resolve(__dirname, "../dist");
|
|
34
|
+
|
|
35
|
+
// Copy package.json with modifications
|
|
36
|
+
const packageJson = require("../package.json");
|
|
37
|
+
|
|
38
|
+
// Remove unnecessary fields for the published package
|
|
39
|
+
const fieldsToRemove = ["scripts", "devDependencies", "overrides"];
|
|
40
|
+
|
|
41
|
+
fieldsToRemove.forEach((field) => {
|
|
42
|
+
delete packageJson[field];
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Move some dependencies to peerDependencies
|
|
46
|
+
const peerDeps = {
|
|
47
|
+
react: packageJson.dependencies.react,
|
|
48
|
+
"react-dom": packageJson.dependencies["react-dom"],
|
|
49
|
+
next: packageJson.dependencies.next,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Add peer dependencies
|
|
53
|
+
packageJson.peerDependencies = {
|
|
54
|
+
...peerDeps,
|
|
55
|
+
react: ">=18.0.0",
|
|
56
|
+
"react-dom": ">=18.0.0",
|
|
57
|
+
next: ">=13.0.0",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Remove peer deps from dependencies
|
|
61
|
+
Object.keys(peerDeps).forEach((dep) => {
|
|
62
|
+
delete packageJson.dependencies[dep];
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Write the modified package.json to dist
|
|
66
|
+
fs.writeFileSync(path.resolve(destDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
67
|
+
|
|
68
|
+
// Copy README and AGENTS.md
|
|
69
|
+
if (fs.existsSync(path.resolve(__dirname, "../README.md"))) {
|
|
70
|
+
fs.copyFileSync(path.resolve(__dirname, "../README.md"), path.resolve(destDir, "README.md"));
|
|
71
|
+
}
|
|
72
|
+
if (fs.existsSync(path.resolve(__dirname, "../AGENTS.md"))) {
|
|
73
|
+
fs.copyFileSync(path.resolve(__dirname, "../AGENTS.md"), path.resolve(destDir, "AGENTS.md"));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Copy CLI scripts and agent templates for npm publish
|
|
77
|
+
const scriptsDir = path.resolve(destDir, "scripts");
|
|
78
|
+
fs.mkdirSync(scriptsDir, { recursive: true });
|
|
79
|
+
for (const script of ["init-agent.js", "validate-ai-code.js"]) {
|
|
80
|
+
fs.copyFileSync(
|
|
81
|
+
path.resolve(__dirname, script),
|
|
82
|
+
path.join(scriptsDir, script),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const agentSrc = path.resolve(__dirname, "../agent");
|
|
86
|
+
const agentDest = path.resolve(destDir, "agent");
|
|
87
|
+
if (fs.existsSync(agentSrc)) {
|
|
88
|
+
copyDir(agentSrc, agentDest);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Copy style files
|
|
92
|
+
console.log("Copying style files and other assets...");
|
|
93
|
+
copyDir(srcDir, destDir);
|
|
94
|
+
|
|
95
|
+
// Copy AI harness artifacts for npm publish
|
|
96
|
+
const aiDir = path.resolve(__dirname, "../ai");
|
|
97
|
+
const aiDest = path.resolve(destDir, "ai");
|
|
98
|
+
if (fs.existsSync(aiDir)) {
|
|
99
|
+
console.log("Copying AI artifacts...");
|
|
100
|
+
copyDir(aiDir, aiDest);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log("Files copied successfully!");
|