@vedangiitb/qwintly-core 1.4.11 → 1.4.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/dist/ai/generate/gemini.client.js +1 -1
- package/dist/ai/generate/gemini.client.js.map +1 -1
- package/dist/ai/generate/generateClient.d.ts.map +1 -1
- package/dist/ai/generate/generateClient.js +7 -3
- package/dist/ai/generate/generateClient.js.map +1 -1
- package/dist/ai/prompts/codegen.prompt.js +1 -1
- package/dist/ai/prompts/codegen.prompt.js.map +1 -1
- package/dist/ai/prompts/helpers/promptParts.helper.d.ts +1 -1
- package/dist/ai/prompts/helpers/promptParts.helper.d.ts.map +1 -1
- package/dist/ai/prompts/helpers/promptParts.helper.js +1 -1
- package/dist/ai/prompts/helpers/promptParts.helper.js.map +1 -1
- package/dist/ai/prompts/planner.prompt.d.ts.map +1 -1
- package/dist/ai/prompts/planner.prompt.js +1 -0
- package/dist/ai/prompts/planner.prompt.js.map +1 -1
- package/dist/ai/toolLoop/helpers/aiCall.helper.d.ts +16 -0
- package/dist/ai/toolLoop/helpers/aiCall.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/aiCall.helper.js +23 -0
- package/dist/ai/toolLoop/helpers/aiCall.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/applyPatch.helper.d.ts +6 -0
- package/dist/ai/toolLoop/helpers/applyPatch.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/applyPatch.helper.js +10 -0
- package/dist/ai/toolLoop/helpers/applyPatch.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/errors.helper.d.ts +15 -0
- package/dist/ai/toolLoop/helpers/errors.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/errors.helper.js +50 -0
- package/dist/ai/toolLoop/helpers/errors.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/fsHelpers.d.ts +5 -0
- package/dist/ai/toolLoop/helpers/fsHelpers.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/fsHelpers.js +28 -0
- package/dist/ai/toolLoop/helpers/fsHelpers.js.map +1 -0
- package/dist/ai/toolLoop/helpers/patchRetry.helper.d.ts +11 -0
- package/dist/ai/toolLoop/helpers/patchRetry.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/patchRetry.helper.js +30 -0
- package/dist/ai/toolLoop/helpers/patchRetry.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/persistTokens.helpers.d.ts +7 -0
- package/dist/ai/toolLoop/helpers/persistTokens.helpers.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/persistTokens.helpers.js +25 -0
- package/dist/ai/toolLoop/helpers/persistTokens.helpers.js.map +1 -0
- package/dist/ai/toolLoop/{plannerTaskParser.d.ts → helpers/plannerTaskParser.d.ts} +1 -1
- package/dist/ai/toolLoop/helpers/plannerTaskParser.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/plannerTaskParser.js.map +1 -0
- package/dist/ai/toolLoop/helpers/readFile.helpers.d.ts +10 -0
- package/dist/ai/toolLoop/helpers/readFile.helpers.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/readFile.helpers.js +26 -0
- package/dist/ai/toolLoop/helpers/readFile.helpers.js.map +1 -0
- package/dist/ai/toolLoop/helpers/signatures.helper.d.ts +2 -0
- package/dist/ai/toolLoop/helpers/signatures.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/signatures.helper.js +23 -0
- package/dist/ai/toolLoop/helpers/signatures.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/toolArgs.helper.d.ts +12 -0
- package/dist/ai/toolLoop/helpers/toolArgs.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/toolArgs.helper.js +40 -0
- package/dist/ai/toolLoop/helpers/toolArgs.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/toolExecution.helper.d.ts +22 -0
- package/dist/ai/toolLoop/helpers/toolExecution.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/toolExecution.helper.js +75 -0
- package/dist/ai/toolLoop/helpers/toolExecution.helper.js.map +1 -0
- package/dist/ai/toolLoop/helpers/toolHandlers.helper.d.ts +6 -0
- package/dist/ai/toolLoop/helpers/toolHandlers.helper.d.ts.map +1 -0
- package/dist/ai/toolLoop/helpers/toolHandlers.helper.js +86 -0
- package/dist/ai/toolLoop/helpers/toolHandlers.helper.js.map +1 -0
- package/dist/ai/toolLoop/toolEventSummary.d.ts +28 -0
- package/dist/ai/toolLoop/toolEventSummary.d.ts.map +1 -0
- package/dist/ai/toolLoop/toolEventSummary.js +253 -0
- package/dist/ai/toolLoop/toolEventSummary.js.map +1 -0
- package/dist/ai/toolLoop/toolLoopContext.d.ts +0 -14
- package/dist/ai/toolLoop/toolLoopContext.d.ts.map +1 -1
- package/dist/ai/toolLoop/toolLoopContext.js +7 -50
- package/dist/ai/toolLoop/toolLoopContext.js.map +1 -1
- package/dist/ai/toolLoop/toolLoopRunner.d.ts +7 -6
- package/dist/ai/toolLoop/toolLoopRunner.d.ts.map +1 -1
- package/dist/ai/toolLoop/toolLoopRunner.js +49 -284
- package/dist/ai/toolLoop/toolLoopRunner.js.map +1 -1
- package/dist/ai/toolLoop/toolStatusMessage.d.ts +6 -0
- package/dist/ai/toolLoop/toolStatusMessage.d.ts.map +1 -0
- package/dist/ai/toolLoop/toolStatusMessage.js +140 -0
- package/dist/ai/toolLoop/toolStatusMessage.js.map +1 -0
- package/dist/ai/tools/helpers/applyPatch.helpers.d.ts.map +1 -1
- package/dist/ai/tools/helpers/applyPatch.helpers.js +9 -4
- package/dist/ai/tools/helpers/applyPatch.helpers.js.map +1 -1
- package/dist/ai/tools/helpers/fileSystem.helpers.d.ts.map +1 -1
- package/dist/ai/tools/helpers/fileSystem.helpers.js +7 -1
- package/dist/ai/tools/helpers/fileSystem.helpers.js.map +1 -1
- package/dist/ai/tools/helpers/pageConfigJson.helpers.d.ts +13 -0
- package/dist/ai/tools/helpers/pageConfigJson.helpers.d.ts.map +1 -1
- package/dist/ai/tools/helpers/pageConfigJson.helpers.js +51 -21
- package/dist/ai/tools/helpers/pageConfigJson.helpers.js.map +1 -1
- package/dist/ai/tools/implementations/applyPatch.impl.js +2 -2
- package/dist/ai/tools/implementations/applyPatch.impl.js.map +1 -1
- package/dist/ai/tools/implementations/createNewRoute.impl.js +1 -1
- package/dist/ai/tools/implementations/createNewRoute.impl.js.map +1 -1
- package/dist/ai/tools/implementations/deleteElement.impl.d.ts.map +1 -1
- package/dist/ai/tools/implementations/deleteElement.impl.js +5 -37
- package/dist/ai/tools/implementations/deleteElement.impl.js.map +1 -1
- package/dist/ai/tools/implementations/insertElement.impl.d.ts.map +1 -1
- package/dist/ai/tools/implementations/insertElement.impl.js +9 -46
- package/dist/ai/tools/implementations/insertElement.impl.js.map +1 -1
- package/dist/ai/tools/implementations/updateClassName.impl.d.ts.map +1 -1
- package/dist/ai/tools/implementations/updateClassName.impl.js +5 -37
- package/dist/ai/tools/implementations/updateClassName.impl.js.map +1 -1
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.d.ts.map +1 -1
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.js +4 -3
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.js.map +1 -1
- package/dist/ai/tools/implementations/updateProps.impl.d.ts.map +1 -1
- package/dist/ai/tools/implementations/updateProps.impl.js +5 -37
- package/dist/ai/tools/implementations/updateProps.impl.js.map +1 -1
- package/dist/ai/tools/schemas/createNewRoute.schema.d.ts.map +1 -1
- package/dist/ai/tools/schemas/createNewRoute.schema.js +1 -1
- package/dist/ai/tools/schemas/createNewRoute.schema.js.map +1 -1
- package/dist/ai/tools/schemas/deleteElement.schema.d.ts.map +1 -1
- package/dist/ai/tools/schemas/deleteElement.schema.js +1 -2
- package/dist/ai/tools/schemas/deleteElement.schema.js.map +1 -1
- package/dist/ai/tools/schemas/elementProps.schema.d.ts +101 -0
- package/dist/ai/tools/schemas/elementProps.schema.d.ts.map +1 -0
- package/dist/ai/tools/schemas/elementProps.schema.js +74 -0
- package/dist/ai/tools/schemas/elementProps.schema.js.map +1 -0
- package/dist/ai/tools/schemas/insertElement.schema.d.ts.map +1 -1
- package/dist/ai/tools/schemas/insertElement.schema.js +2 -74
- package/dist/ai/tools/schemas/insertElement.schema.js.map +1 -1
- package/dist/ai/tools/schemas/updateClassName.schema.d.ts.map +1 -1
- package/dist/ai/tools/schemas/updateClassName.schema.js +1 -2
- package/dist/ai/tools/schemas/updateClassName.schema.js.map +1 -1
- package/dist/ai/tools/schemas/updateProps.schema.d.ts +9 -9
- package/dist/ai/tools/schemas/updateProps.schema.d.ts.map +1 -1
- package/dist/ai/tools/schemas/updateProps.schema.js +3 -69
- package/dist/ai/tools/schemas/updateProps.schema.js.map +1 -1
- package/dist/image/unsplash.service.d.ts.map +1 -1
- package/dist/image/unsplash.service.js +6 -2
- package/dist/image/unsplash.service.js.map +1 -1
- package/dist/indexer/projectInfoIndex.d.ts.map +1 -1
- package/dist/indexer/projectInfoIndex.js +33 -25
- package/dist/indexer/projectInfoIndex.js.map +1 -1
- package/dist/types/styleConfig.d.ts.map +1 -1
- package/dist/types/styleConfig.js +2 -3
- package/dist/types/styleConfig.js.map +1 -1
- package/dist/utils/utils.d.ts +3 -0
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +8 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/workspace.d.ts +1 -1
- package/dist/utils/workspace.d.ts.map +1 -1
- package/dist/utils/workspace.js +6 -11
- package/dist/utils/workspace.js.map +1 -1
- package/package.json +1 -1
- package/dist/ai/toolLoop/plannerTaskParser.d.ts.map +0 -1
- package/dist/ai/toolLoop/plannerTaskParser.js.map +0 -1
- package/dist/ai/toolLoop/toolLoopRunnerUtils.d.ts +0 -51
- package/dist/ai/toolLoop/toolLoopRunnerUtils.d.ts.map +0 -1
- package/dist/ai/toolLoop/toolLoopRunnerUtils.js +0 -306
- package/dist/ai/toolLoop/toolLoopRunnerUtils.js.map +0 -1
- /package/dist/ai/toolLoop/{plannerTaskParser.js → helpers/plannerTaskParser.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertElement.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/insertElement.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"insertElement.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/insertElement.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,OAAO;IACP,UAAU;IACV,MAAM;IACN,MAAM;CACE,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,6SAA6S;IAC/S,UAAU,EAAE;QACV,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAA,2GAA2G;gBAC9H,WAAW,EACT,qTAAqT;aACxT;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EAAE,iDAAiD;aAC/D;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EACT,2KAA2K;aAC9K;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,KAAK;gBAChB,WAAW,EACT,6PAA6P;gBAC/P,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI,CAAC,MAAM;oBACjB,UAAU,EAAE;wBACV,EAAE,EAAE;4BACF,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,4GAA4G;yBAC1H;wBACD,QAAQ,EAAE;4BACR,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,iHAAiH;yBAC/H;wBACD,IAAI,EAAE;4BACJ,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,IAAI,EAAE,aAAa;4BACnB,WAAW,EACT,yIAAyI;yBAC5I;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,IAAI,CAAC,MAAM;4BACjB,WAAW,EAAE,wCAAwC;yBACtD;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,IAAI,CAAC,OAAO;4BAClB,WAAW,EAAE,iBAAiB;yBAC/B;wBACD,KAAK,EAAE,yBAAyB;qBACjC;oBACD,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC;iBACrC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC;KAC7C;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\nimport { BuilderElementPropsSchema } from \"./elementProps.schema.js\";\n\nexport const ELEMENT_TYPES = [\n \"fragment\",\n \"div\",\n \"text\",\n \"image\",\n \"button\",\n \"input\",\n \"textarea\",\n \"link\",\n \"icon\",\n] as const;\n\nexport const InsertElementSchema = {\n name: \"insert_element\",\n description:\n \"Inserts a tree of UI elements represented as a flat array of elements. One or more elements can have parentId set to 'parent' to be the roots (siblings inserted at the same level). Subsequent children point to their parent using temporary ID references (e.g., parentId set to parent's temporary id).\",\n parameters: {\n type: Type.OBJECT,\n properties: {\n route: {\n type: Type.STRING,\n pattern: String.raw`^(?:/(?:[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)?|[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)$`,\n description:\n \"The route to insert the element at. Use URL paths with forward slashes only. Examples: '/', '/about', '/pricing'. If you forget the leading '/', it will be assumed (e.g. 'about' -> '/about'). Never send Windows-style backslashes (e.g. '\\\\\\\\') or filesystem paths like 'app/pricing'. Never send empty string.\",\n },\n parent_id: {\n type: Type.STRING,\n description: \"The parent ID to insert the element tree under.\",\n },\n before_id: {\n type: Type.STRING,\n description:\n \"Optional. If provided, inserts the new root elements before the existing child element with this id (within parent_id's children list). If not found, appends at the end.\",\n },\n elements: {\n type: Type.ARRAY,\n description:\n \"Flat array of elements that form a tree. One or more elements can have parentId set to 'parent' to attach directly under the parent_id as siblings. Subsequent child elements should have parentId matching the temporary id of their parent in this array.\",\n items: {\n type: Type.OBJECT,\n properties: {\n id: {\n type: Type.STRING,\n description: \"A unique temporary ID for this element (e.g. 'root_sec', 'card_bg', 'btn_cta') to refer to it in parentId.\",\n },\n parentId: {\n type: Type.STRING,\n description: \"The temporary ID of the parent element in this list, or 'parent' to insert directly under the page's parent_id.\",\n },\n type: {\n type: Type.STRING,\n enum: ELEMENT_TYPES,\n description:\n \"Element type to render. Use 'text' for <p>, 'image' for <img>, 'link' for <a>, 'icon' for Lucide icon, 'fragment' renders children only\",\n },\n className: {\n type: Type.STRING,\n description: \"Tailwind CSS className (Tailwind only)\",\n },\n visible: {\n type: Type.BOOLEAN,\n description: \"Visibility flag\",\n },\n props: BuilderElementPropsSchema,\n },\n required: [\"id\", \"parentId\", \"type\"],\n },\n },\n },\n required: [\"route\", \"parent_id\", \"elements\"],\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateClassName.schema.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateClassName.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"updateClassName.schema.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateClassName.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAqBjC,CAAC"}
|
|
@@ -7,8 +7,7 @@ export const UpdateClassNameSchema = {
|
|
|
7
7
|
properties: {
|
|
8
8
|
route: {
|
|
9
9
|
type: Type.STRING,
|
|
10
|
-
|
|
11
|
-
pattern: "^(?:/(?:[A-Za-z0-9_.[\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\]-]+)*)?|[A-Za-z0-9_.[\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\]-]+)*)$",
|
|
10
|
+
pattern: String.raw `^(?:/(?:[A-Za-z0-9_.[\\\]-]+(?:/[A-Za-z0-9_.[\\\]-]+)*)?|[A-Za-z0-9_.[\\\]-]+(?:/[A-Za-z0-9_.[\\\]-]+)*)$`,
|
|
12
11
|
description: "The route to update the element at. Example: '/' or '/about'. If you forget the leading '/', it will be assumed (e.g. 'about' -> '/about').",
|
|
13
12
|
},
|
|
14
13
|
element_id: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateClassName.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateClassName.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,+NAA+N;IACjO,UAAU,EAAE;QACV,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,
|
|
1
|
+
{"version":3,"file":"updateClassName.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateClassName.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,+NAA+N;IACjO,UAAU,EAAE;QACV,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAA,2GAA2G;gBAC9H,WAAW,EACT,6IAA6I;aAChJ;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EAAE,sCAAsC;aACpD;YACD,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;SACjC;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC;KAC/C;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\r\n\r\nexport const UpdateClassNameSchema = {\n name: \"update_classname\",\n description:\n \"Updates className (only tailwind classes allowed). Give complete className. Prefer semantic token classes (bg-background, text-foreground, border-border, ring-ring, etc.); use update_global_styles to change global tokens.\",\n parameters: {\n type: Type.OBJECT,\n properties: {\n route: {\n type: Type.STRING,\n pattern: String.raw`^(?:/(?:[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)?|[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)$`,\n description:\n \"The route to update the element at. Example: '/' or '/about'. If you forget the leading '/', it will be assumed (e.g. 'about' -> '/about').\",\n },\n element_id: {\n type: Type.STRING,\n description: \"The id of the element to be updated.\",\n },\n className: { type: Type.STRING },\r\n },\r\n required: [\"route\", \"element_id\", \"className\"],\r\n },\r\n};\r\n"]}
|
|
@@ -5,15 +5,6 @@ export declare const UpdatePropsSchema: {
|
|
|
5
5
|
parameters: {
|
|
6
6
|
type: Type;
|
|
7
7
|
properties: {
|
|
8
|
-
route: {
|
|
9
|
-
type: Type;
|
|
10
|
-
pattern: string;
|
|
11
|
-
description: string;
|
|
12
|
-
};
|
|
13
|
-
element_id: {
|
|
14
|
-
type: Type;
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
8
|
onClick: {
|
|
18
9
|
type: Type;
|
|
19
10
|
properties: {
|
|
@@ -85,6 +76,15 @@ export declare const UpdatePropsSchema: {
|
|
|
85
76
|
type: Type;
|
|
86
77
|
description: string;
|
|
87
78
|
};
|
|
79
|
+
route: {
|
|
80
|
+
type: Type;
|
|
81
|
+
pattern: string;
|
|
82
|
+
description: string;
|
|
83
|
+
};
|
|
84
|
+
element_id: {
|
|
85
|
+
type: Type;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
88
|
};
|
|
89
89
|
required: string[];
|
|
90
90
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateProps.schema.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateProps.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"updateProps.schema.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateProps.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB7B,CAAC"}
|
|
@@ -1,27 +1,5 @@
|
|
|
1
1
|
import { Type } from "@google/genai";
|
|
2
|
-
|
|
3
|
-
type: Type.OBJECT,
|
|
4
|
-
properties: {
|
|
5
|
-
kind: {
|
|
6
|
-
type: Type.STRING,
|
|
7
|
-
enum: ["route", "back", "reload", "external"],
|
|
8
|
-
description: "What happens when the element is clicked. 'route' navigates within the app, 'external' opens a URL, 'back' goes back, 'reload' refreshes.",
|
|
9
|
-
},
|
|
10
|
-
href: {
|
|
11
|
-
type: Type.STRING,
|
|
12
|
-
description: "URL to navigate to (used for kind='route' and kind='external').",
|
|
13
|
-
},
|
|
14
|
-
replace: {
|
|
15
|
-
type: Type.BOOLEAN,
|
|
16
|
-
description: "For kind='route': replace history instead of pushing.",
|
|
17
|
-
},
|
|
18
|
-
newTab: {
|
|
19
|
-
type: Type.BOOLEAN,
|
|
20
|
-
description: "For kind='external': open link in a new tab.",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
required: ["kind"],
|
|
24
|
-
};
|
|
2
|
+
import { BuilderElementPropsSchema } from "./elementProps.schema.js";
|
|
25
3
|
export const UpdatePropsSchema = {
|
|
26
4
|
name: "update_props",
|
|
27
5
|
description: "Updates element code.",
|
|
@@ -30,58 +8,14 @@ export const UpdatePropsSchema = {
|
|
|
30
8
|
properties: {
|
|
31
9
|
route: {
|
|
32
10
|
type: Type.STRING,
|
|
33
|
-
|
|
34
|
-
pattern: "^(?:/(?:[A-Za-z0-9_.[\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\]-]+)*)?|[A-Za-z0-9_.[\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\]-]+)*)$",
|
|
11
|
+
pattern: String.raw `^(?:/(?:[A-Za-z0-9_.[\\\]-]+(?:/[A-Za-z0-9_.[\\\]-]+)*)?|[A-Za-z0-9_.[\\\]-]+(?:/[A-Za-z0-9_.[\\\]-]+)*)$`,
|
|
35
12
|
description: "The route to update the element at. Example: '/' or '/about'. If you forget the leading '/', it will be assumed (e.g. 'about' -> '/about').",
|
|
36
13
|
},
|
|
37
14
|
element_id: {
|
|
38
15
|
type: Type.STRING,
|
|
39
16
|
description: "The id of the element to be updated.",
|
|
40
17
|
},
|
|
41
|
-
|
|
42
|
-
text: {
|
|
43
|
-
type: Type.STRING,
|
|
44
|
-
description: "Text content used by 'text' (<p>), 'button' (label), and as a fallback for 'link' when it has no children.",
|
|
45
|
-
},
|
|
46
|
-
href: {
|
|
47
|
-
type: Type.STRING,
|
|
48
|
-
description: "For 'link': the href attribute (defaults to '#').",
|
|
49
|
-
},
|
|
50
|
-
placeholder: {
|
|
51
|
-
type: Type.STRING,
|
|
52
|
-
description: "For 'input' and 'textarea': placeholder shown when empty.",
|
|
53
|
-
},
|
|
54
|
-
alt: {
|
|
55
|
-
type: Type.STRING,
|
|
56
|
-
description: "For 'image': alt text for accessibility AND the query used to fetch a suitable Unsplash image (src is auto-resolved from alt).",
|
|
57
|
-
},
|
|
58
|
-
target: {
|
|
59
|
-
type: Type.STRING,
|
|
60
|
-
description: "For 'link': target attribute (e.g. '_blank').",
|
|
61
|
-
},
|
|
62
|
-
rel: {
|
|
63
|
-
type: Type.STRING,
|
|
64
|
-
description: "For 'link': rel attribute (e.g. 'noreferrer').",
|
|
65
|
-
},
|
|
66
|
-
value: {
|
|
67
|
-
type: Type.STRING,
|
|
68
|
-
description: "For 'input' and 'textarea': default value (maps to defaultValue).",
|
|
69
|
-
},
|
|
70
|
-
type: {
|
|
71
|
-
type: Type.STRING,
|
|
72
|
-
description: "For 'input': input type (e.g. 'text', 'email', 'password'). Defaults to 'text'.",
|
|
73
|
-
},
|
|
74
|
-
// icon
|
|
75
|
-
name: {
|
|
76
|
-
type: Type.STRING,
|
|
77
|
-
description: "For 'icon': Lucide icon name (e.g. 'ArrowRight', 'Menu').",
|
|
78
|
-
},
|
|
79
|
-
size: { type: Type.NUMBER, description: "For 'icon': size in px." },
|
|
80
|
-
color: { type: Type.STRING, description: "For 'icon': stroke color." },
|
|
81
|
-
strokeWidth: {
|
|
82
|
-
type: Type.NUMBER,
|
|
83
|
-
description: "For 'icon': stroke width.",
|
|
84
|
-
},
|
|
18
|
+
...BuilderElementPropsSchema.properties,
|
|
85
19
|
},
|
|
86
20
|
required: ["route", "element_id"],
|
|
87
21
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateProps.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateProps.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"updateProps.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateProps.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,uBAAuB;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAA,2GAA2G;gBAC9H,WAAW,EACT,6IAA6I;aAChJ;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EAAE,sCAAsC;aACpD;YACD,GAAG,yBAAyB,CAAC,UAAU;SACxC;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC;KAClC;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\nimport { BuilderElementPropsSchema } from \"./elementProps.schema.js\";\n\nexport const UpdatePropsSchema = {\n name: \"update_props\",\n description: \"Updates element code.\",\n parameters: {\n type: Type.OBJECT,\n properties: {\n route: {\n type: Type.STRING,\n pattern: String.raw`^(?:/(?:[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)?|[A-Za-z0-9_.[\\\\\\]-]+(?:/[A-Za-z0-9_.[\\\\\\]-]+)*)$`,\n description:\n \"The route to update the element at. Example: '/' or '/about'. If you forget the leading '/', it will be assumed (e.g. 'about' -> '/about').\",\n },\n element_id: {\n type: Type.STRING,\n description: \"The id of the element to be updated.\",\n },\n ...BuilderElementPropsSchema.properties,\n },\n required: [\"route\", \"element_id\"],\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsplash.service.d.ts","sourceRoot":"","sources":["../../src/image/unsplash.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsBF,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"unsplash.service.d.ts","sourceRoot":"","sources":["../../src/image/unsplash.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsBF,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,GAAG,SAAS,QAmBnD;AAoBD,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA6E/B;AAED,eAAO,MAAM,8BAA8B,GACzC,IAAI,cAAc,EAClB,KAAK,MAAM,KACV,OAAO,CAAC,IAAI,CAuBd,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,IAAI,cAAc,KACjB,OAAO,CAAC,IAAI,CAcd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
2
|
let unsplashConfig = null;
|
|
3
3
|
const cache = new Map();
|
|
4
4
|
async function fetchWithTimeout(url, options = {}) {
|
|
@@ -21,8 +21,12 @@ export function initUnsplash(config) {
|
|
|
21
21
|
unsplashConfig = null;
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
+
let cleanedUrl = url;
|
|
25
|
+
while (cleanedUrl.endsWith("/")) {
|
|
26
|
+
cleanedUrl = cleanedUrl.slice(0, -1);
|
|
27
|
+
}
|
|
24
28
|
unsplashConfig = {
|
|
25
|
-
url:
|
|
29
|
+
url: cleanedUrl,
|
|
26
30
|
accessKey,
|
|
27
31
|
};
|
|
28
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsplash.service.js","sourceRoot":"","sources":["../../src/image/unsplash.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"unsplash.service.js","sourceRoot":"","sources":["../../src/image/unsplash.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAoBjC,IAAI,cAAc,GAA0B,IAAI,CAAC;AAEjD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE/C,KAAK,UAAU,g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,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACnD,MAAM,8BAA8B,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,EAAE,QAAQ,CAAC;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,yBAAyB,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import crypto from \"node:crypto\";\r\nimport { BuilderElement } from \"../types/elements.js\";\r\n\r\nexport interface ResolvedImage {\r\n id: string;\r\n alt: string;\r\n imageUrl: string;\r\n thumbUrl: string;\r\n photographer: string;\r\n photographerUrl: string;\r\n unsplashUrl: string;\r\n width: number;\r\n height: number;\r\n}\r\n\r\ntype UnsplashConfig = {\r\n url: string;\r\n accessKey: string;\r\n};\r\n\r\nlet unsplashConfig: UnsplashConfig | null = null;\r\n\r\nconst cache = new Map<string, ResolvedImage>();\r\n\r\nasync function fetchWithTimeout(\r\n url: string,\r\n options: RequestInit = {},\r\n): Promise<Response> {\r\n const controller = new AbortController();\r\n const id = setTimeout(() => controller.abort(), 5000);\r\n try {\r\n return await fetch(url, {\r\n ...options,\r\n signal: controller.signal,\r\n });\r\n } finally {\r\n clearTimeout(id);\r\n }\r\n}\r\n\r\nexport function initUnsplash(\r\n config: Partial<UnsplashConfig> | null | undefined,\r\n) {\r\n const url = String(config?.url ?? \"\").trim();\r\n const accessKey = String(config?.accessKey ?? \"\").trim();\r\n\r\n if (!url || !accessKey) {\r\n unsplashConfig = null;\r\n return;\r\n }\r\n\r\n let cleanedUrl = url;\r\n while (cleanedUrl.endsWith(\"/\")) {\r\n cleanedUrl = cleanedUrl.slice(0, -1);\r\n }\r\n\r\n unsplashConfig = {\r\n url: cleanedUrl,\r\n accessKey,\r\n };\r\n}\r\n\r\nfunction hashIntent(imgQuery: string) {\r\n return crypto.createHash(\"sha256\").update(imgQuery).digest(\"hex\");\r\n}\r\n\r\nfunction scoreImage(photo: any) {\r\n let score = 0;\r\n\r\n score += (photo.likes || 0) * 0.3;\r\n\r\n if (photo.width > photo.height) {\r\n score += 50;\r\n }\r\n\r\n score += (photo.user.total_photos || 0) * 0.05;\r\n\r\n return score;\r\n}\r\n\r\nexport async function searchUnsplashImage(\r\n imgQuery: string,\r\n): Promise<ResolvedImage | null> {\r\n console.log(\"searchUnsplashImage\", imgQuery);\r\n const cfg = unsplashConfig;\r\n if (!cfg) throw new Error(\"Unsplash not configured\");\r\n\r\n const cacheKey = hashIntent(imgQuery);\r\n\r\n const cached = cache.get(cacheKey);\r\n\r\n if (cached) {\r\n return cached;\r\n }\r\n\r\n const params = new URLSearchParams({\r\n query: imgQuery,\r\n per_page: \"10\",\r\n });\r\n\r\n const response = await fetchWithTimeout(\r\n `${cfg.url}/search/photos?${params.toString()}`,\r\n {\r\n headers: {\r\n Authorization: `Client-ID ${cfg.accessKey}`,\r\n },\r\n },\r\n );\r\n\r\n if (!response.ok) {\r\n throw new Error(`Unsplash API failed: ${response.status}`);\r\n }\r\n\r\n const data = await response.json();\r\n\r\n const photos = data.results;\r\n\r\n if (!photos.length) {\r\n return null;\r\n }\r\n\r\n const ranked = [...photos].sort((a, b) => {\r\n return scoreImage(b) - scoreImage(a);\r\n });\r\n\r\n const top3 = ranked.slice(0, 3);\r\n\r\n const selected = top3[Math.floor(Math.random() * top3.length)];\r\n\r\n // IMPORTANT:\r\n // Required by Unsplash API terms\r\n // Tracks image download usage\r\n if (selected.links.download_location) {\r\n await fetchWithTimeout(selected.links.download_location, {\r\n headers: {\r\n Authorization: `Client-ID ${cfg.accessKey}`,\r\n },\r\n });\r\n }\r\n\r\n const resolved: ResolvedImage = {\r\n id: selected.id,\r\n alt: imgQuery,\r\n\r\n imageUrl: selected.urls.regular,\r\n thumbUrl: selected.urls.small,\r\n\r\n photographer: selected.user.name,\r\n photographerUrl: selected.user.links.html,\r\n\r\n unsplashUrl: selected.links.html,\r\n\r\n width: selected.width,\r\n height: selected.height,\r\n };\r\n\r\n cache.set(cacheKey, resolved);\r\n\r\n return resolved;\r\n}\r\n\r\nexport const resolveUnsplashImageForElement = async (\r\n el: BuilderElement,\r\n alt: string,\r\n): Promise<void> => {\r\n if (!unsplashConfig) return;\r\n const query = String(alt ?? \"\").trim();\r\n if (!query) return;\r\n if (el.props?.src) {\r\n console.log(\"src already exists, skipping\");\r\n return;\r\n }\r\n try {\r\n const resolved = await searchUnsplashImage(query);\r\n if (!resolved?.imageUrl) {\r\n console.log(resolved);\r\n return;\r\n }\r\n\r\n const anyEl = el as any;\r\n if (!anyEl.props || typeof anyEl.props !== \"object\") anyEl.props = {};\r\n anyEl.props.src = resolved.imageUrl;\r\n anyEl.props.alt = query;\r\n } catch (error) {\r\n console.error(error);\r\n // Ignore Unsplash lookup errors and still allow prop updates.\r\n }\r\n};\r\n\r\nexport const resolveUnsplashImagesDeep = async (\r\n el: BuilderElement,\r\n): Promise<void> => {\r\n const anyEl = el as any;\r\n\r\n if (anyEl?.type === \"image\") {\r\n const alt = String(anyEl?.props?.alt ?? \"\").trim();\r\n await resolveUnsplashImageForElement(el, alt);\r\n }\r\n\r\n const kids = anyEl?.children;\r\n if (Array.isArray(kids)) {\r\n for (const child of kids) {\r\n await resolveUnsplashImagesDeep(child);\r\n }\r\n }\r\n};\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectInfoIndex.d.ts","sourceRoot":"","sources":["../../src/indexer/projectInfoIndex.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"projectInfoIndex.d.ts","sourceRoot":"","sources":["../../src/indexer/projectInfoIndex.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAiG5D,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAkDtB"}
|
|
@@ -14,14 +14,10 @@ const computePageNameFromRoute = (pageRoute) => {
|
|
|
14
14
|
return "root";
|
|
15
15
|
return pageRoute.slice(1).split("/").join("-");
|
|
16
16
|
};
|
|
17
|
-
const
|
|
18
|
-
if (!config || !Array.isArray(config.elements))
|
|
19
|
-
return [];
|
|
20
|
-
const elements = config.elements;
|
|
21
|
-
// Let's find the root element (where type === "div" && id === "root") recursively
|
|
17
|
+
const findRootElement = (els) => {
|
|
22
18
|
let rootElement = null;
|
|
23
|
-
const findRoot = (
|
|
24
|
-
for (const el of
|
|
19
|
+
const findRoot = (items) => {
|
|
20
|
+
for (const el of items) {
|
|
25
21
|
if (el && typeof el === "object") {
|
|
26
22
|
if (el.type === "div" && el.id === "root") {
|
|
27
23
|
rootElement = el;
|
|
@@ -35,26 +31,28 @@ const extractSectionNamesFromParsedConfig = (config) => {
|
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
};
|
|
38
|
-
findRoot(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
findRoot(els);
|
|
35
|
+
return rootElement;
|
|
36
|
+
};
|
|
37
|
+
const extractRootSections = (rootElement) => {
|
|
38
|
+
if (!rootElement || !Array.isArray(rootElement.children))
|
|
39
|
+
return [];
|
|
40
|
+
const rootSections = [];
|
|
41
|
+
for (const child of rootElement.children) {
|
|
42
|
+
if (child &&
|
|
43
|
+
typeof child === "object" &&
|
|
44
|
+
child.type === "div" &&
|
|
45
|
+
child.id &&
|
|
46
|
+
child.id !== "root") {
|
|
47
|
+
const name = sectionNameFromId(child.id);
|
|
48
|
+
if (name) {
|
|
49
|
+
rootSections.push(name);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
|
-
if (rootSections.length > 0) {
|
|
54
|
-
return rootSections;
|
|
55
|
-
}
|
|
56
52
|
}
|
|
57
|
-
|
|
53
|
+
return rootSections;
|
|
54
|
+
};
|
|
55
|
+
const collectFallbackSections = (elements) => {
|
|
58
56
|
const seen = new Set();
|
|
59
57
|
const results = [];
|
|
60
58
|
const collectFallback = (els) => {
|
|
@@ -79,6 +77,16 @@ const extractSectionNamesFromParsedConfig = (config) => {
|
|
|
79
77
|
collectFallback(elements);
|
|
80
78
|
return results;
|
|
81
79
|
};
|
|
80
|
+
const extractSectionNamesFromParsedConfig = (config) => {
|
|
81
|
+
if (!config || !Array.isArray(config.elements))
|
|
82
|
+
return [];
|
|
83
|
+
const rootElement = findRootElement(config.elements);
|
|
84
|
+
const rootSections = extractRootSections(rootElement);
|
|
85
|
+
if (rootSections.length > 0) {
|
|
86
|
+
return rootSections;
|
|
87
|
+
}
|
|
88
|
+
return collectFallbackSections(config.elements);
|
|
89
|
+
};
|
|
82
90
|
export async function computeProjectInfo(rootDir) {
|
|
83
91
|
const routes = await getAvailableRoutes({
|
|
84
92
|
workspaceRoot: rootDir,
|
|
@@ -97,7 +105,7 @@ export async function computeProjectInfo(rootDir) {
|
|
|
97
105
|
sectionNames = extractSectionNamesFromParsedConfig(config);
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
|
-
catch
|
|
108
|
+
catch {
|
|
101
109
|
// Ignore reading/parsing errors, treat as no sections
|
|
102
110
|
}
|
|
103
111
|
const page = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectInfoIndex.js","sourceRoot":"","sources":["../../src/indexer/projectInfoIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAA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AAC,UAAU,CAAC,CAAC;YAC3C,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnC,YAAY,GAAG,mCAAmC,CAAC,MAAM,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;QAED,MAAM,IAAI,GAAW;YACnB,SAAS;YACT,QAAQ;YACR,WAAW;SACZ,CAAC;QAEF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBACjD,WAAW;gBACX,WAAW,EAAE,GAAG,WAAW,wBAAwB;aACpD,CAAC,CAAC,CAAC;QACN,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACpB,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE;QAChD,WAAW,EAAE,MAAM;KACpB,CAAC,CACH,CAAC;IAEF,OAAO;QACL,OAAO;QACP,sBAAsB,EAAE,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getAvailableRoutes,\n getPageConfigJsonPath,\n} from \"../ai/tools/helpers/pageConfigJson.helpers.js\";\nimport { ProjectInfo } from \"../types/projectInfo.types.js\";\nimport { readFile, safeReadDir } from \"../utils/workspace.js\";\n\ntype UiPage = ProjectInfo[\"uiPages\"][number];\n\nconst sectionNameFromId = (id: string): string => {\n if (!id) return \"\";\n if (id.endsWith(\"-section\")) return id.slice(0, -\"-section\".length);\n if (id.endsWith(\"-container\")) return id.slice(0, -\"-container\".length);\n return id;\n};\n\nconst computePageNameFromRoute = (pageRoute: string): string => {\n if (pageRoute === \"/\") return \"root\";\n return pageRoute.slice(1).split(\"/\").join(\"-\");\n};\n\nconst findRootElement = (els: any[]): any => {\n let rootElement: any = null;\n const findRoot = (items: any[]) => {\n for (const el of items) {\n if (el && typeof el === \"object\") {\n if (el.type === \"div\" && el.id === \"root\") {\n rootElement = el;\n return;\n }\n if (Array.isArray(el.children)) {\n findRoot(el.children);\n if (rootElement) return;\n }\n }\n }\n };\n findRoot(els);\n return rootElement;\n};\n\nconst extractRootSections = (rootElement: any): string[] => {\n if (!rootElement || !Array.isArray(rootElement.children)) return [];\n const rootSections: string[] = [];\n for (const child of rootElement.children) {\n if (\n child &&\n typeof child === \"object\" &&\n child.type === \"div\" &&\n child.id &&\n child.id !== \"root\"\n ) {\n const name = sectionNameFromId(child.id);\n if (name) {\n rootSections.push(name);\n }\n }\n }\n return rootSections;\n};\n\nconst collectFallbackSections = (elements: any[]): string[] => {\n const seen = new Set<string>();\n const results: string[] = [];\n const collectFallback = (els: any[]) => {\n for (const el of els) {\n if (el && typeof el === \"object\") {\n if (\n el.type === \"div\" &&\n el.id &&\n el.id !== \"root\" &&\n (el.id.endsWith(\"-section\") || el.id.endsWith(\"-container\"))\n ) {\n const sectionName = sectionNameFromId(el.id);\n if (sectionName && !seen.has(sectionName)) {\n seen.add(sectionName);\n results.push(sectionName);\n }\n }\n if (Array.isArray(el.children)) {\n collectFallback(el.children);\n }\n }\n }\n };\n collectFallback(elements);\n return results;\n};\n\nconst extractSectionNamesFromParsedConfig = (config: any): string[] => {\n if (!config || !Array.isArray(config.elements)) return [];\n\n const rootElement = findRootElement(config.elements);\n const rootSections = extractRootSections(rootElement);\n if (rootSections.length > 0) {\n return rootSections;\n }\n\n return collectFallbackSections(config.elements);\n};\n\nexport async function computeProjectInfo(\n rootDir: string,\n): Promise<ProjectInfo> {\n const routes = await getAvailableRoutes({\n workspaceRoot: rootDir,\n fs: { safeReadDir },\n });\n\n const uiPages: UiPage[] = [];\n\n for (const pageRoute of routes) {\n const pageName = computePageNameFromRoute(pageRoute);\n const description = `${pageName} page for this project`;\n\n let sectionNames: string[] = [];\n try {\n const configPath = getPageConfigJsonPath(rootDir, pageRoute);\n const content = await readFile(configPath);\n if (content) {\n const config = JSON.parse(content);\n sectionNames = extractSectionNamesFromParsedConfig(config);\n }\n } catch {\n // Ignore reading/parsing errors, treat as no sections\n }\n\n const page: UiPage = {\n pageRoute,\n pageName,\n description,\n };\n\n if (sectionNames.length > 0) {\n page.sections = sectionNames.map((sectionName) => ({\n sectionName,\n description: `${sectionName} section for this page`,\n }));\n }\n\n uiPages.push(page);\n }\n\n uiPages.sort((a, b) =>\n a.pageRoute.localeCompare(b.pageRoute, undefined, {\n sensitivity: \"base\",\n }),\n );\n\n return {\n uiPages,\n lastUpdatedPlanVersion: 1,\n };\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleConfig.d.ts","sourceRoot":"","sources":["../../src/types/styleConfig.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,+dAiCnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAoBF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"styleConfig.d.ts","sourceRoot":"","sources":["../../src/types/styleConfig.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,+dAiCnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAoBF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAiC9D;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoClC,CAAC"}
|
|
@@ -67,9 +67,8 @@ export function assertStyleConfig(config) {
|
|
|
67
67
|
}
|
|
68
68
|
const extraKeys = Object.keys(tokens).filter((k) => !STYLE_TOKEN_KEYS.includes(k));
|
|
69
69
|
if (extraKeys.length) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.join(", ")}`);
|
|
70
|
+
extraKeys.sort((a, b) => a.localeCompare(b));
|
|
71
|
+
throw new Error(`styleConfig.tokens contains unknown keys: ${extraKeys.join(", ")}`);
|
|
73
72
|
}
|
|
74
73
|
return { version, tokens: resolvedTokens };
|
|
75
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleConfig.js","sourceRoot":"","sources":["../../src/types/styleConfig.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,gBAAgB;IAChB,SAAS;IACT,mBAAmB;IACnB,SAAS;IACT,mBAAmB;IACnB,WAAW;IACX,qBAAqB;IACrB,OAAO;IACP,iBAAiB;IACjB,QAAQ;IACR,kBAAkB;IAClB,aAAa;IACb,QAAQ;IACR,OAAO;IACP,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,mBAAmB;IACnB,gBAAgB;IAChB,0BAA0B;IAC1B,eAAe;IACf,yBAAyB;IACzB,eAAe;IACf,aAAa;CACL,CAAC;AASX,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CA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AAE,wBAAwB;QAChC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,uBAAuB;QAC/B,OAAO,EAAE,wBAAwB;QACjC,iBAAiB,EAAE,uBAAuB;QAC1C,cAAc,EAAE,wBAAwB;QACxC,wBAAwB,EAAE,yBAAyB;QACnD,aAAa,EAAE,uBAAuB;QACtC,uBAAuB,EAAE,wBAAwB;QACjD,aAAa,EAAE,uBAAuB;QACtC,WAAW,EAAE,wBAAwB;KACtC;CACF,CAAC","sourcesContent":["export const STYLE_TOKEN_KEYS = [\n \"radius\",\n \"background\",\n \"foreground\",\n \"card\",\n \"cardForeground\",\n \"popover\",\n \"popoverForeground\",\n \"primary\",\n \"primaryForeground\",\n \"secondary\",\n \"secondaryForeground\",\n \"muted\",\n \"mutedForeground\",\n \"accent\",\n \"accentForeground\",\n \"destructive\",\n \"border\",\n \"input\",\n \"ring\",\n \"chart1\",\n \"chart2\",\n \"chart3\",\n \"chart4\",\n \"chart5\",\n \"sidebar\",\n \"sidebarForeground\",\n \"sidebarPrimary\",\n \"sidebarPrimaryForeground\",\n \"sidebarAccent\",\n \"sidebarAccentForeground\",\n \"sidebarBorder\",\n \"sidebarRing\",\n] as const;\n\nexport type StyleTokenKey = (typeof STYLE_TOKEN_KEYS)[number];\n\nexport type StyleConfig = {\n version: number;\n tokens: Record<StyleTokenKey, string>;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction assertSafeCssValue(key: string, value: string) {\n if (!value.trim()) {\n throw new Error(`styleConfig.tokens.${key} must be a non-empty string`);\n }\n if (value.includes(\"<\") || value.includes(\">\")) {\n throw new Error(`styleConfig.tokens.${key} contains forbidden characters`);\n }\n if (value.toLowerCase().includes(\"</style\")) {\n throw new Error(\n `styleConfig.tokens.${key} contains a forbidden substring (\"</style\")`,\n );\n }\n}\n\nexport function assertStyleConfig(config: unknown): StyleConfig {\n if (!isPlainObject(config)) throw new Error(\"styleConfig must be an object\");\n\n const version = config.version;\n if (typeof version !== \"number\" || !Number.isFinite(version)) {\n throw new Error(\"styleConfig.version must be a finite number\");\n }\n\n const tokens = (config as Record<string, unknown>).tokens;\n if (!isPlainObject(tokens))\n throw new Error(\"styleConfig.tokens must be an object\");\n\n const resolvedTokens = {} as Record<StyleTokenKey, string>;\n for (const key of STYLE_TOKEN_KEYS) {\n const rawValue = (tokens as Record<string, unknown>)[key];\n if (typeof rawValue !== \"string\") {\n throw new Error(`styleConfig.tokens.${key} must be a string`);\n }\n assertSafeCssValue(key, rawValue);\n resolvedTokens[key] = rawValue;\n }\n\n const extraKeys = Object.keys(tokens).filter(\n (k) => !(STYLE_TOKEN_KEYS as readonly string[]).includes(k),\n );\n if (extraKeys.length) {\n extraKeys.sort((a, b) => a.localeCompare(b));\n throw new Error(\n `styleConfig.tokens contains unknown keys: ${extraKeys.join(\", \")}`,\n );\n }\n\n return { version, tokens: resolvedTokens };\n}\n\nexport const defaultStyleConfigJson = {\n version: 1,\n tokens: {\n radius: \"0.85rem\",\n background: \"oklch(0.985 0.008 80.2)\",\n foreground: \"oklch(0.2 0.03 255.4)\",\n card: \"oklch(0.995 0.004 80.2)\",\n cardForeground: \"oklch(0.2 0.03 255.4)\",\n popover: \"oklch(0.995 0.004 80.2)\",\n popoverForeground: \"oklch(0.2 0.03 255.4)\",\n primary: \"oklch(0.62 0.16 199.4)\",\n primaryForeground: \"oklch(0.985 0.008 80.2)\",\n secondary: \"oklch(0.94 0.02 83.1)\",\n secondaryForeground: \"oklch(0.22 0.04 258.2)\",\n muted: \"oklch(0.95 0.01 85.6)\",\n mutedForeground: \"oklch(0.46 0.04 257.6)\",\n accent: \"oklch(0.9 0.06 78.4)\",\n accentForeground: \"oklch(0.22 0.04 258.2)\",\n destructive: \"oklch(0.57 0.21 25.6)\",\n border: \"oklch(0.89 0.02 82.5)\",\n input: \"oklch(0.92 0.02 82.5)\",\n ring: \"oklch(0.62 0.16 199.4)\",\n chart1: \"oklch(0.62 0.16 199.4)\",\n chart2: \"oklch(0.66 0.14 143.6)\",\n chart3: \"oklch(0.52 0.12 297.6)\",\n chart4: \"oklch(0.74 0.16 79.3)\",\n chart5: \"oklch(0.62 0.18 24.8)\",\n sidebar: \"oklch(0.975 0.01 82.5)\",\n sidebarForeground: \"oklch(0.2 0.03 255.4)\",\n sidebarPrimary: \"oklch(0.62 0.16 199.4)\",\n sidebarPrimaryForeground: \"oklch(0.985 0.008 80.2)\",\n sidebarAccent: \"oklch(0.94 0.02 83.1)\",\n sidebarAccentForeground: \"oklch(0.22 0.04 258.2)\",\n sidebarBorder: \"oklch(0.89 0.02 82.5)\",\n sidebarRing: \"oklch(0.62 0.16 199.4)\",\n },\n};\n"]}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare function assertNonEmptyString(value: unknown, field: string): asserts value is string;
|
|
2
|
+
export declare const computeBackoffMs: (attempt: number, baseMs: number, maxMs: number) => number;
|
|
3
|
+
export declare const sleep: (ms: number) => Promise<void>;
|
|
4
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
2
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB;AAED,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,OAAO,MAAM,WAMd,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,kBACsC,CAAC;AAEvE,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,KACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACoC,CAAC"}
|
package/dist/utils/utils.js
CHANGED
|
@@ -3,4 +3,12 @@ export function assertNonEmptyString(value, field) {
|
|
|
3
3
|
throw new Error(`\`${field}\` must be a non-empty string`);
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
+
export const computeBackoffMs = (attempt, baseMs, maxMs) => {
|
|
7
|
+
const exp = baseMs * Math.pow(2, Math.max(0, attempt - 1));
|
|
8
|
+
const capped = Math.min(maxMs, exp);
|
|
9
|
+
const jitter = capped * (0.2 * Math.random());
|
|
10
|
+
return Math.round(capped + jitter);
|
|
11
|
+
};
|
|
12
|
+
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
13
|
+
export const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
14
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,KAAa;IAEb,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,+BAA+B,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC","sourcesContent":["export function assertNonEmptyString(\r\n value: unknown,\r\n field: string,\r\n): asserts value is string {\r\n if (typeof value !== \"string\" || !value.trim()) {\r\n throw new Error(`\\`${field}\\` must be a non-empty string`);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,KAAa;IAEb,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,+BAA+B,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAe,EACf,MAAc,EACd,KAAa,EACb,EAAE;IACF,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAClC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACoB,EAAE,CACpC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["export function assertNonEmptyString(\r\n value: unknown,\r\n field: string,\r\n): asserts value is string {\r\n if (typeof value !== \"string\" || !value.trim()) {\r\n throw new Error(`\\`${field}\\` must be a non-empty string`);\r\n }\r\n}\r\n\r\nexport const computeBackoffMs = (\r\n attempt: number,\r\n baseMs: number,\r\n maxMs: number,\r\n) => {\r\n const exp = baseMs * Math.pow(2, Math.max(0, attempt - 1));\r\n const capped = Math.min(maxMs, exp);\r\n const jitter = capped * (0.2 * Math.random());\r\n return Math.round(capped + jitter);\r\n};\r\n\r\nexport const sleep = (ms: number) =>\r\n new Promise<void>((resolve) => setTimeout(resolve, Math.max(0, ms)));\r\n\r\nexport const isPlainObject = (\r\n value: unknown,\r\n): value is Record<string, unknown> =>\r\n typeof value === \"object\" && value !== null && !Array.isArray(value);\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dirent } from "fs";
|
|
1
|
+
import { Dirent } from "node:fs";
|
|
2
2
|
export declare function createFolder(path: string): Promise<void>;
|
|
3
3
|
export declare function removeFolder(path: string): Promise<void>;
|
|
4
4
|
export declare function createFile(path: string, content: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/utils/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/utils/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,iBAE9C;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,iBAE9C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAE7D;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAE5C;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,iBAEtD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,+BAEtC;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,6BAEzC;AASD,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,6BAO5C;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,mBAU1C;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,GAAG,EAAO,kBA0BjE;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,MASnD,CAAC"}
|
package/dist/utils/workspace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from "fs/promises";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
export async function createFolder(path) {
|
|
4
4
|
await fs.mkdir(path, { recursive: true });
|
|
5
5
|
}
|
|
@@ -7,12 +7,7 @@ export async function removeFolder(path) {
|
|
|
7
7
|
await fs.rm(path, { recursive: true, force: true });
|
|
8
8
|
}
|
|
9
9
|
export async function createFile(path, content) {
|
|
10
|
-
|
|
11
|
-
await fs.writeFile(path, content, "utf-8");
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
throw err;
|
|
15
|
-
}
|
|
10
|
+
await fs.writeFile(path, content, "utf-8");
|
|
16
11
|
}
|
|
17
12
|
export async function removeFile(path) {
|
|
18
13
|
await fs.rm(path, { force: true });
|
|
@@ -62,14 +57,14 @@ export async function readTsFiles(dir, results = []) {
|
|
|
62
57
|
return results; // directory doesn't exist → skip
|
|
63
58
|
}
|
|
64
59
|
const entries = await fs.readdir(dir);
|
|
65
|
-
const ALLOWED_EXT = [".ts", ".tsx"];
|
|
60
|
+
const ALLOWED_EXT = new Set([".ts", ".tsx"]);
|
|
66
61
|
for (const entry of entries) {
|
|
67
62
|
const fullPath = path.join(dir, entry);
|
|
68
63
|
const stat = await fs.stat(fullPath);
|
|
69
64
|
if (stat.isDirectory()) {
|
|
70
|
-
readTsFiles(fullPath, results);
|
|
65
|
+
await readTsFiles(fullPath, results);
|
|
71
66
|
}
|
|
72
|
-
else if (ALLOWED_EXT.
|
|
67
|
+
else if (ALLOWED_EXT.has(path.extname(entry))) {
|
|
73
68
|
results.push({
|
|
74
69
|
name: entry,
|
|
75
70
|
path: fullPath,
|