@vedangiitb/qwintly-core 1.3.16 → 1.3.18
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/prompts/codegen.prompt.d.ts.map +1 -1
- package/dist/ai/prompts/codegen.prompt.js +14 -12
- package/dist/ai/prompts/codegen.prompt.js.map +1 -1
- package/dist/ai/prompts/examples/codegen.examples.js +10 -10
- package/dist/ai/prompts/examples/codegen.examples.js.map +1 -1
- package/dist/ai/prompts/planner.prompt.d.ts.map +1 -1
- package/dist/ai/prompts/planner.prompt.js +9 -5
- package/dist/ai/prompts/planner.prompt.js.map +1 -1
- package/dist/ai/prompts/validator.prompt.d.ts.map +1 -1
- package/dist/ai/prompts/validator.prompt.js +9 -5
- package/dist/ai/prompts/validator.prompt.js.map +1 -1
- package/dist/ai/toolLoop/toolLoopRunner.d.ts +1 -0
- package/dist/ai/toolLoop/toolLoopRunner.d.ts.map +1 -1
- package/dist/ai/toolLoop/toolLoopRunner.js +11 -1
- package/dist/ai/toolLoop/toolLoopRunner.js.map +1 -1
- package/dist/ai/tools/helpers/pageConfigJson.helpers.d.ts.map +1 -1
- package/dist/ai/tools/helpers/pageConfigJson.helpers.js +15 -3
- package/dist/ai/tools/helpers/pageConfigJson.helpers.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/factories.d.ts +18 -0
- package/dist/ai/tools/implementations/factories.d.ts.map +1 -1
- package/dist/ai/tools/implementations/factories.js +4 -0
- package/dist/ai/tools/implementations/factories.js.map +1 -1
- package/dist/ai/tools/implementations/insertElement.impl.js +1 -1
- package/dist/ai/tools/implementations/insertElement.impl.js.map +1 -1
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.d.ts +22 -0
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.d.ts.map +1 -0
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.js +90 -0
- package/dist/ai/tools/implementations/updateGlobalStyles.impl.js.map +1 -0
- package/dist/ai/tools/schemas/insertElement.schema.js.map +1 -1
- package/dist/ai/tools/schemas/updateClassName.schema.js +1 -1
- package/dist/ai/tools/schemas/updateClassName.schema.js.map +1 -1
- package/dist/ai/tools/schemas/updateGlobalStyles.schema.d.ts +16 -0
- package/dist/ai/tools/schemas/updateGlobalStyles.schema.d.ts.map +1 -0
- package/dist/ai/tools/schemas/updateGlobalStyles.schema.js +16 -0
- package/dist/ai/tools/schemas/updateGlobalStyles.schema.js.map +1 -0
- package/dist/ai/tools/toolsets/codegenTools.d.ts.map +1 -1
- package/dist/ai/tools/toolsets/codegenTools.js +2 -0
- package/dist/ai/tools/toolsets/codegenTools.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2 -1
- package/dist/core.js.map +1 -1
- package/dist/tests/updateGlobalStyles.impl.test.d.ts +2 -0
- package/dist/tests/updateGlobalStyles.impl.test.d.ts.map +1 -0
- package/dist/tests/updateGlobalStyles.impl.test.js +133 -0
- package/dist/tests/updateGlobalStyles.impl.test.js.map +1 -0
- package/dist/types/styleConfig.d.ts +45 -0
- package/dist/types/styleConfig.d.ts.map +1 -0
- package/dist/types/styleConfig.js +113 -0
- package/dist/types/styleConfig.js.map +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { createListDirImpl } from "./listDir.impl.js";
|
|
|
6
6
|
import { createReadFileImpl } from "./readFile.impl.js";
|
|
7
7
|
import { createSearchImpl } from "./search.impl.js";
|
|
8
8
|
import { createUpdateClassNameImpl } from "./updateClassName.impl.js";
|
|
9
|
+
import { createUpdateGlobalStylesImpl } from "./updateGlobalStyles.impl.js";
|
|
9
10
|
import { createUpdatePropsImpl } from "./updateProps.impl.js";
|
|
10
11
|
import { createWriteFileImpl } from "./writeFile.impl.js";
|
|
11
12
|
export { DEFAULT_NOT_FOUND_RESPONSE } from "./workspaceDeps.js";
|
|
@@ -17,6 +18,7 @@ export { createListDirImpl } from "./listDir.impl.js";
|
|
|
17
18
|
export { createReadFileImpl } from "./readFile.impl.js";
|
|
18
19
|
export { createSearchImpl, } from "./search.impl.js";
|
|
19
20
|
export { createUpdateClassNameImpl } from "./updateClassName.impl.js";
|
|
21
|
+
export { createUpdateGlobalStylesImpl } from "./updateGlobalStyles.impl.js";
|
|
20
22
|
export { createUpdatePropsImpl } from "./updateProps.impl.js";
|
|
21
23
|
export { createWriteFileImpl } from "./writeFile.impl.js";
|
|
22
24
|
export const createWorkspaceToolImpls = (deps) => {
|
|
@@ -25,6 +27,7 @@ export const createWorkspaceToolImpls = (deps) => {
|
|
|
25
27
|
const listDirImpl = createListDirImpl(deps);
|
|
26
28
|
const searchImpl = createSearchImpl(deps);
|
|
27
29
|
const applyPatchImpl = createApplyPatchImpl(deps);
|
|
30
|
+
const updateGlobalStylesImpl = createUpdateGlobalStylesImpl(deps);
|
|
28
31
|
const createNewRouteImpl = createCreateNewRouteImpl(deps);
|
|
29
32
|
const deleteElementImpl = createDeleteElementImpl(deps);
|
|
30
33
|
const insertElementImpl = createInsertElementImpl(deps);
|
|
@@ -36,6 +39,7 @@ export const createWorkspaceToolImpls = (deps) => {
|
|
|
36
39
|
listDirImpl,
|
|
37
40
|
searchImpl,
|
|
38
41
|
applyPatchImpl,
|
|
42
|
+
updateGlobalStylesImpl,
|
|
39
43
|
createNewRouteImpl,
|
|
40
44
|
deleteElementImpl,
|
|
41
45
|
insertElementImpl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../../src/ai/tools/implementations/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,uBAAuB,E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1C,MAAM,cAAc,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE5D,OAAO;QACL,YAAY;QACZ,aAAa;QACb,WAAW;QACX,UAAU;QACV,cAAc;QACd,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,eAAe;QACf,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { createApplyPatchImpl } from \"./applyPatch.impl.js\";\nimport { createCreateNewRouteImpl } from \"./createNewRoute.impl.js\";\nimport { createDeleteElementImpl } from \"./deleteElement.impl.js\";\nimport { createInsertElementImpl } from \"./insertElement.impl.js\";\nimport { createListDirImpl } from \"./listDir.impl.js\";\nimport { createReadFileImpl } from \"./readFile.impl.js\";\nimport { createSearchImpl, type SearchDeps } from \"./search.impl.js\";\nimport { createUpdateClassNameImpl } from \"./updateClassName.impl.js\";\nimport { createUpdatePropsImpl } from \"./updateProps.impl.js\";\nimport { createWriteFileImpl } from \"./writeFile.impl.js\";\n\nexport { DEFAULT_NOT_FOUND_RESPONSE } from \"./workspaceDeps.js\";\nexport type {\n CoreDirent,\n CoreFs,\n WorkspaceDeps,\n} from \"./workspaceDeps.js\";\n\nexport { createApplyPatchImpl } from \"./applyPatch.impl.js\";\nexport { createCreateNewRouteImpl } from \"./createNewRoute.impl.js\";\nexport { createDeleteElementImpl } from \"./deleteElement.impl.js\";\nexport { createInsertElementImpl } from \"./insertElement.impl.js\";\nexport { createListDirImpl } from \"./listDir.impl.js\";\nexport { createReadFileImpl } from \"./readFile.impl.js\";\nexport {\n createSearchImpl,\n type SearchDeps,\n type SearchResult,\n} from \"./search.impl.js\";\nexport { createUpdateClassNameImpl } from \"./updateClassName.impl.js\";\nexport { createUpdatePropsImpl } from \"./updateProps.impl.js\";\nexport { createWriteFileImpl } from \"./writeFile.impl.js\";\n\nexport const createWorkspaceToolImpls = (deps: SearchDeps) => {\n const readFileImpl = createReadFileImpl(deps);\n const writeFileImpl = createWriteFileImpl(deps);\n const listDirImpl = createListDirImpl(deps);\n const searchImpl = createSearchImpl(deps);\n const applyPatchImpl = createApplyPatchImpl(deps);\n const createNewRouteImpl = createCreateNewRouteImpl(deps);\n const deleteElementImpl = createDeleteElementImpl(deps);\n const insertElementImpl = createInsertElementImpl(deps);\n const updatePropsImpl = createUpdatePropsImpl(deps);\n const updateClassNameImpl = createUpdateClassNameImpl(deps);\n\n return {\n readFileImpl,\n writeFileImpl,\n listDirImpl,\n searchImpl,\n applyPatchImpl,\n createNewRouteImpl,\n deleteElementImpl,\n insertElementImpl,\n updatePropsImpl,\n updateClassNameImpl,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../../src/ai/tools/implementations/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AA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iBAAiB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE5D,OAAO;QACL,YAAY;QACZ,aAAa;QACb,WAAW;QACX,UAAU;QACV,cAAc;QACd,sBAAsB;QACtB,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,eAAe;QACf,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { createApplyPatchImpl } from \"./applyPatch.impl.js\";\nimport { createCreateNewRouteImpl } from \"./createNewRoute.impl.js\";\nimport { createDeleteElementImpl } from \"./deleteElement.impl.js\";\nimport { createInsertElementImpl } from \"./insertElement.impl.js\";\nimport { createListDirImpl } from \"./listDir.impl.js\";\nimport { createReadFileImpl } from \"./readFile.impl.js\";\nimport { createSearchImpl, type SearchDeps } from \"./search.impl.js\";\nimport { createUpdateClassNameImpl } from \"./updateClassName.impl.js\";\nimport { createUpdateGlobalStylesImpl } from \"./updateGlobalStyles.impl.js\";\nimport { createUpdatePropsImpl } from \"./updateProps.impl.js\";\nimport { createWriteFileImpl } from \"./writeFile.impl.js\";\n\nexport { DEFAULT_NOT_FOUND_RESPONSE } from \"./workspaceDeps.js\";\nexport type {\n CoreDirent,\n CoreFs,\n WorkspaceDeps,\n} from \"./workspaceDeps.js\";\n\nexport { createApplyPatchImpl } from \"./applyPatch.impl.js\";\nexport { createCreateNewRouteImpl } from \"./createNewRoute.impl.js\";\nexport { createDeleteElementImpl } from \"./deleteElement.impl.js\";\nexport { createInsertElementImpl } from \"./insertElement.impl.js\";\nexport { createListDirImpl } from \"./listDir.impl.js\";\nexport { createReadFileImpl } from \"./readFile.impl.js\";\nexport {\n createSearchImpl,\n type SearchDeps,\n type SearchResult,\n} from \"./search.impl.js\";\nexport { createUpdateClassNameImpl } from \"./updateClassName.impl.js\";\nexport { createUpdateGlobalStylesImpl } from \"./updateGlobalStyles.impl.js\";\nexport { createUpdatePropsImpl } from \"./updateProps.impl.js\";\nexport { createWriteFileImpl } from \"./writeFile.impl.js\";\n\nexport const createWorkspaceToolImpls = (deps: SearchDeps) => {\n const readFileImpl = createReadFileImpl(deps);\n const writeFileImpl = createWriteFileImpl(deps);\n const listDirImpl = createListDirImpl(deps);\n const searchImpl = createSearchImpl(deps);\n const applyPatchImpl = createApplyPatchImpl(deps);\n const updateGlobalStylesImpl = createUpdateGlobalStylesImpl(deps);\n const createNewRouteImpl = createCreateNewRouteImpl(deps);\n const deleteElementImpl = createDeleteElementImpl(deps);\n const insertElementImpl = createInsertElementImpl(deps);\n const updatePropsImpl = createUpdatePropsImpl(deps);\n const updateClassNameImpl = createUpdateClassNameImpl(deps);\n\n return {\n readFileImpl,\n writeFileImpl,\n listDirImpl,\n searchImpl,\n applyPatchImpl,\n updateGlobalStylesImpl,\n createNewRouteImpl,\n deleteElementImpl,\n insertElementImpl,\n updatePropsImpl,\n updateClassNameImpl,\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveUnsplashImagesDeep } from "../../../image/unsplash.service.js";
|
|
2
|
-
import { InsertElementArgsZod } from "../validators/builderElement.zod.js";
|
|
3
2
|
import { ensureElementIds, extractAllIdsDeep, findElementById, getPageConfigJsonPath, parsePageConfigJson, stringifyPageConfigJson, writeFileAtomic, } from "../helpers/pageConfigJson.helpers.js";
|
|
3
|
+
import { InsertElementArgsZod } from "../validators/builderElement.zod.js";
|
|
4
4
|
export const createInsertElementImpl = (deps) => {
|
|
5
5
|
const { workspaceRoot, fs } = deps;
|
|
6
6
|
return async (route, parentId, element) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertElement.impl.js","sourceRoot":"","sources":["../../../../src/ai/tools/implementations/insertElement.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,
|
|
1
|
+
{"version":3,"file":"insertElement.impl.js","sourceRoot":"","sources":["../../../../src/ai/tools/implementations/insertElement.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAmB,EAAE,EAAE;IAC7D,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAEnC,OAAO,KAAK,EAAE,KAAa,EAAE,QAAgB,EAAE,OAAuB,EAAE,EAAE;QACxE,MAAM,UAAU,GAAG,oBAAoB,CAAC,SAAS,CAAC;YAChD,KAAK;YACL,SAAS,EAAE,QAAQ;YACnB,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,cAAc;gBACrB,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE;aACzC,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;QAEtE,IAAI,UAAkB,CAAC;QACvB,IAAI,CAAC;YACH,UAAU,GAAG,qBAAqB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;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,IAAI,IAAI,CAAC,CACd,CAAC;QACpB,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC;QAC1C,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QAElE,MAAM,SAAS,GAAG,MAAa,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC;YAC3D,SAAS,CAAC,QAAQ,GAAG,EAAE,CAAC;QACzB,SAAS,CAAC,QAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAExD,MAAM,KAAK,GAAG,uBAAuB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC;YACH,MAAM,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACzC,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,IAAI;gBACb,WAAW,EAAG,QAAgB,CAAC,EAAE;aAClC,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { resolveUnsplashImagesDeep } from \"../../../image/unsplash.service.js\";\nimport type { BuilderElement } from \"../../../types/elements.js\";\nimport {\n ensureElementIds,\n extractAllIdsDeep,\n findElementById,\n getPageConfigJsonPath,\n parsePageConfigJson,\n stringifyPageConfigJson,\n writeFileAtomic,\n} from \"../helpers/pageConfigJson.helpers.js\";\nimport { InsertElementArgsZod } from \"../validators/builderElement.zod.js\";\nimport { type WorkspaceDeps } from \"./workspaceDeps.js\";\n\nexport const createInsertElementImpl = (deps: WorkspaceDeps) => {\n const { workspaceRoot, fs } = deps;\n\n return async (route: string, parentId: string, element: BuilderElement) => {\n const parsedArgs = InsertElementArgsZod.safeParse({\n route,\n parent_id: parentId,\n element,\n });\n if (!parsedArgs.success) {\n return {\n success: false,\n error: \"invalid args\",\n error_detail: parsedArgs.error.flatten(),\n };\n }\n\n const parent_id = String(parentId ?? \"\").trim();\n if (!parent_id) return { success: false, error: \"invalid parent_id\" };\n\n let configPath: string;\n try {\n configPath = getPageConfigJsonPath(workspaceRoot, route);\n } catch (err) {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n\n let before = \"\";\n try {\n before = await fs.readFile(configPath);\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | null)?.code;\n if (code === \"ENOENT\") return { success: false, error: \"not found\" };\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n\n let parsed: ReturnType<typeof parsePageConfigJson>;\n try {\n parsed = parsePageConfigJson(before);\n } catch (err) {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n\n const elements = parsed.elements ?? [];\n const existingIds = extractAllIdsDeep(elements);\n ensureElementIds(elements, existingIds);\n\n // Clone + inject ids for the inserted element subtree.\n const toInsert = JSON.parse(\n JSON.stringify(element ?? null),\n ) as BuilderElement;\n await resolveUnsplashImagesDeep(toInsert);\n ensureElementIds([toInsert], existingIds);\n\n const parent = findElementById(elements, parent_id);\n if (!parent) return { success: false, error: \"parent not found\" };\n\n const anyParent = parent as any;\n if (!anyParent.children || !Array.isArray(anyParent.children))\n anyParent.children = [];\n (anyParent.children as BuilderElement[]).push(toInsert);\n\n const after = stringifyPageConfigJson({ elements });\n try {\n await writeFileAtomic(configPath, after);\n return {\n success: true,\n changed: true,\n inserted_id: (toInsert as any).id,\n };\n } catch (err) {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n };\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StyleTokenKey } from "../../../types/styleConfig.js";
|
|
2
|
+
import { type WorkspaceDeps } from "./workspaceDeps.js";
|
|
3
|
+
type UpdateGlobalStylesArgs = {
|
|
4
|
+
tokens: Partial<Record<StyleTokenKey, string>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const createUpdateGlobalStylesImpl: (deps: WorkspaceDeps) => (args: UpdateGlobalStylesArgs) => Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
error: string;
|
|
9
|
+
changed?: undefined;
|
|
10
|
+
file?: undefined;
|
|
11
|
+
version?: undefined;
|
|
12
|
+
created?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
success: boolean;
|
|
15
|
+
changed: boolean;
|
|
16
|
+
file: string;
|
|
17
|
+
version: number;
|
|
18
|
+
created: boolean;
|
|
19
|
+
error?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=updateGlobalStyles.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateGlobalStyles.impl.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/implementations/updateGlobalStyles.impl.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AAgBF,eAAO,MAAM,4BAA4B,GAAI,MAAM,aAAa,MAGhD,MAAM,sBAAsB;;;;;;;;;;;;;;EA2E3C,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { toWorkspacePath } from "../helpers/fileSystem.helpers.js";
|
|
3
|
+
import { writeFileAtomic } from "../helpers/pageConfigJson.helpers.js";
|
|
4
|
+
import { assertStyleConfig, defaultStyleConfigJson, STYLE_TOKEN_KEYS, } from "../../../types/styleConfig.js";
|
|
5
|
+
const STYLE_CONFIG_REL_PATH = path.posix.join("app", "styleConfig.json");
|
|
6
|
+
const parseStyleConfigOrDefault = (raw) => {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(String(raw ?? ""));
|
|
9
|
+
return assertStyleConfig(parsed);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return assertStyleConfig(defaultStyleConfigJson);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
export const createUpdateGlobalStylesImpl = (deps) => {
|
|
17
|
+
const { workspaceRoot, fs } = deps;
|
|
18
|
+
return async (args) => {
|
|
19
|
+
const tokensPatch = args?.tokens;
|
|
20
|
+
if (!isPlainObject(tokensPatch)) {
|
|
21
|
+
return { success: false, error: "invalid tokens" };
|
|
22
|
+
}
|
|
23
|
+
const allowedKeys = new Set(STYLE_TOKEN_KEYS);
|
|
24
|
+
const patchKeys = Object.keys(tokensPatch);
|
|
25
|
+
const unknownKeys = patchKeys.filter((k) => !allowedKeys.has(k));
|
|
26
|
+
if (unknownKeys.length > 0) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
error: `unknown token keys: ${unknownKeys.sort().join(", ")}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const configPath = toWorkspacePath(workspaceRoot, STYLE_CONFIG_REL_PATH);
|
|
33
|
+
let beforeConfig;
|
|
34
|
+
let existed = true;
|
|
35
|
+
try {
|
|
36
|
+
const raw = await fs.readFile(configPath);
|
|
37
|
+
beforeConfig = parseStyleConfigOrDefault(raw);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
const code = err?.code;
|
|
41
|
+
if (code !== "ENOENT") {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: err instanceof Error ? err.message : String(err),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
existed = false;
|
|
48
|
+
beforeConfig = assertStyleConfig(defaultStyleConfigJson);
|
|
49
|
+
}
|
|
50
|
+
const merged = {
|
|
51
|
+
version: beforeConfig.version,
|
|
52
|
+
tokens: {
|
|
53
|
+
...beforeConfig.tokens,
|
|
54
|
+
...tokensPatch,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
let validated;
|
|
58
|
+
try {
|
|
59
|
+
validated = assertStyleConfig(merged);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: err instanceof Error ? err.message : String(err),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const nextVersion = Number.isFinite(validated.version)
|
|
68
|
+
? validated.version + 1
|
|
69
|
+
: 1;
|
|
70
|
+
const afterConfig = { ...validated, version: nextVersion };
|
|
71
|
+
const after = JSON.stringify(afterConfig, null, 2) + "\n";
|
|
72
|
+
try {
|
|
73
|
+
await writeFileAtomic(configPath, after);
|
|
74
|
+
return {
|
|
75
|
+
success: true,
|
|
76
|
+
changed: true,
|
|
77
|
+
file: STYLE_CONFIG_REL_PATH,
|
|
78
|
+
version: nextVersion,
|
|
79
|
+
created: !existed,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: err instanceof Error ? err.message : String(err),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=updateGlobalStyles.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateGlobalStyles.impl.js","sourceR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{ writeFileAtomic } from \"../helpers/pageConfigJson.helpers.js\";\nimport {\n assertStyleConfig,\n defaultStyleConfigJson,\n STYLE_TOKEN_KEYS,\n type StyleConfig,\n type StyleTokenKey,\n} from \"../../../types/styleConfig.js\";\nimport { type WorkspaceDeps } from \"./workspaceDeps.js\";\n\ntype UpdateGlobalStylesArgs = {\n tokens: Partial<Record<StyleTokenKey, string>>;\n};\n\nconst STYLE_CONFIG_REL_PATH = path.posix.join(\"app\", \"styleConfig.json\");\n\nconst parseStyleConfigOrDefault = (raw: string): StyleConfig => {\n try {\n const parsed = JSON.parse(String(raw ?? \"\"));\n return assertStyleConfig(parsed);\n } catch {\n return assertStyleConfig(defaultStyleConfigJson);\n }\n};\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nexport const createUpdateGlobalStylesImpl = (deps: WorkspaceDeps) => {\n const { workspaceRoot, fs } = deps;\n\n return async (args: UpdateGlobalStylesArgs) => {\n const tokensPatch = (args as any)?.tokens;\n if (!isPlainObject(tokensPatch)) {\n return { success: false, error: \"invalid tokens\" };\n }\n\n const allowedKeys = new Set<string>(STYLE_TOKEN_KEYS as unknown as string[]);\n const patchKeys = Object.keys(tokensPatch);\n const unknownKeys = patchKeys.filter((k) => !allowedKeys.has(k));\n if (unknownKeys.length > 0) {\n return {\n success: false,\n error: `unknown token keys: ${unknownKeys.sort().join(\", \")}`,\n };\n }\n\n const configPath = toWorkspacePath(workspaceRoot, STYLE_CONFIG_REL_PATH);\n\n let beforeConfig: StyleConfig;\n let existed = true;\n try {\n const raw = await fs.readFile(configPath);\n beforeConfig = parseStyleConfigOrDefault(raw);\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | null)?.code;\n if (code !== \"ENOENT\") {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n existed = false;\n beforeConfig = assertStyleConfig(defaultStyleConfigJson);\n }\n\n const merged: StyleConfig = {\n version: beforeConfig.version,\n tokens: {\n ...beforeConfig.tokens,\n ...(tokensPatch as Partial<Record<StyleTokenKey, string>>),\n } as any,\n };\n\n let validated: StyleConfig;\n try {\n validated = assertStyleConfig(merged);\n } catch (err) {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n\n const nextVersion = Number.isFinite(validated.version)\n ? validated.version + 1\n : 1;\n const afterConfig: StyleConfig = { ...validated, version: nextVersion };\n\n const after = JSON.stringify(afterConfig, null, 2) + \"\\n\";\n try {\n await writeFileAtomic(configPath, after);\n return {\n success: true,\n changed: true,\n file: STYLE_CONFIG_REL_PATH,\n version: nextVersion,\n created: !existed,\n };\n } catch (err) {\n return {\n success: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n };\n};\n\n"]}
|
|
@@ -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;AAErC,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,mBAAmB,GAAG;IAC1B,IAAI,EAAE,IAAI,CAAC,MAAM;IACjB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC;YAC7C,WAAW,EACT,2IAA2I;SAC9I;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,WAAW,EACT,iEAAiE;SACpE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,CAAC,OAAO;YAClB,WAAW,EAAE,uDAAuD;SACrE;QACD,MAAM,EAAE;YACN,IAAI,EAAE,IA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AAW,EAAE,yCAAyC;aACvD;YACD,OAAO,EAAE;gBACP,GAAG,oBAAoB;gBACvB,WAAW,EAAE,wBAAwB;aACtC;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC;KAC5C;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\r\n\r\nexport const ELEMENT_TYPES = [\r\n \"fragment\",\r\n \"div\",\r\n \"text\",\r\n \"image\",\r\n \"button\",\r\n \"input\",\r\n \"textarea\",\r\n \"link\",\r\n \"icon\",\r\n] as const;\r\n\r\nconst OnClickActionSchema = {\r\n type: Type.OBJECT,\r\n properties: {\r\n kind: {\r\n type: Type.STRING,\r\n enum: [\"route\", \"back\", \"reload\", \"external\"],\r\n description:\r\n \"What happens when the element is clicked. 'route' navigates within the app, 'external' opens a URL, 'back' goes back, 'reload' refreshes.\",\r\n },\r\n href: {\r\n type: Type.STRING,\r\n description:\r\n \"URL to navigate to (used for kind='route' and kind='external').\",\r\n },\r\n replace: {\r\n type: Type.BOOLEAN,\r\n description: \"For kind='route': replace history instead of pushing.\",\r\n },\r\n newTab: {\r\n type: Type.BOOLEAN,\r\n description: \"For kind='external': open link in a new tab.\",\r\n },\r\n },\r\n required: [\"kind\"],\r\n};\r\n\r\nconst BuilderElementPropsSchema = {\r\n type: Type.OBJECT,\r\n properties: {\r\n onClick: OnClickActionSchema,\r\n text: {\r\n type: Type.STRING,\r\n description:\r\n \"Text content used by 'text' (<p>), 'button' (label), and as a fallback for 'link' when it has no children.\",\r\n },\r\n href: {\r\n type: Type.STRING,\r\n description: \"For 'link': the href attribute (defaults to '#').\",\r\n },\r\n placeholder: {\r\n type: Type.STRING,\r\n description: \"For 'input' and 'textarea': placeholder shown when empty.\",\r\n },\r\n alt: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'image': alt text for accessibility AND the query used to fetch a suitable Unsplash image (src is auto-resolved from alt).\",\r\n },\r\n target: {\r\n type: Type.STRING,\r\n description: \"For 'link': target attribute (e.g. '_blank').\",\r\n },\r\n rel: {\r\n type: Type.STRING,\r\n description: \"For 'link': rel attribute (e.g. 'noreferrer').\",\r\n },\r\n value: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'input' and 'textarea': default value (maps to defaultValue).\",\r\n },\r\n type: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'input': input type (e.g. 'text', 'email', 'password'). Defaults to 'text'.\",\r\n },\r\n\r\n // icon\r\n name: {\r\n type: Type.STRING,\r\n description: \"For 'icon': Lucide icon name (e.g. 'ArrowRight', 'Menu').\",\r\n },\r\n size: { type: Type.NUMBER, description: \"For 'icon': size in px.\" },\r\n color: { type: Type.STRING, description: \"For 'icon': stroke color.\" },\r\n strokeWidth: {\r\n type: Type.NUMBER,\r\n description: \"For 'icon': stroke width.\",\r\n },\r\n },\r\n};\r\n\r\n// NOTE: Gemini tool `parameters` schemas reject `$ref`, so true recursion isn't available here.\r\n// We unroll nesting to a reasonable max depth; for deeper trees, insert in multiple steps.\r\nconst buildBuilderElementSchema = (depth: number): any => {\r\n return {\r\n type: Type.OBJECT,\r\n properties: {\r\n type: {\r\n type: Type.STRING,\r\n enum: ELEMENT_TYPES,\r\n description:\r\n \"Element type to render. Use 'text' for <p>, 'image' forn <img>, 'link' for <a>, 'icon' for Lucide icon, 'fragment' renders children only\",\r\n },\r\n className: {\r\n type: Type.STRING,\r\n description: \"Tailwind CSS className (Tailwind only)\",\r\n },\r\n visible: {\r\n type: Type.BOOLEAN,\r\n description: \"Visibility flag\",\r\n },\r\n props: BuilderElementPropsSchema,\r\n children: {\r\n type: Type.ARRAY,\r\n description:\r\n \"Child elements. Each child can itself have children (children[].children[]...)\",\r\n items:\r\n depth > 0\r\n ? buildBuilderElementSchema(depth - 1)\r\n : {\r\n type: Type.OBJECT,\r\n description:\r\n \"Max depth reached. Insert deeper children separately using the returned inserted_id as parent_id\",\r\n },\r\n },\r\n },\r\n required: [\"type\"],\r\n };\r\n};\r\n\r\nexport const BuilderElementSchema: any = buildBuilderElementSchema(4);\r\n\r\nexport const InsertElementSchema = {\n name: \"insert_element\",\n description:\n \"Inserts element code. Use element.children to create nested UI. Each child is another BuilderElement and can itself have children.\",\n parameters: {\n type: Type.OBJECT,\n properties: {\n route: {\n type: Type.STRING,\n pattern: \"^/(?:[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'. 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 at.\",\n },\n element: {\r\n ...BuilderElementSchema,\r\n description: \"The element to insert.\",\r\n },\r\n },\r\n required: [\"route\", \"parent_id\", \"element\"],\r\n },\r\n};\r\n"]}
|
|
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;AAErC,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,mBAAmB,GAAG;IAC1B,IAAI,EAAE,IAAI,CAAC,MAAM;IACjB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC;YAC7C,WAAW,EACT,2IAA2I;SAC9I;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,WAAW,EACT,iEAAiE;SACpE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,CAAC,OAAO;YAClB,WAAW,EAAE,uDAAuD;SACrE;QACD,MAAM,EAAE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CAAC,MAAM;gBACjB,WAAW,EAAE,yCAAyC;aACvD;YACD,OAAO,EAAE;gBACP,GAAG,oBAAoB;gBACvB,WAAW,EAAE,wBAAwB;aACtC;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC;KAC5C;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\r\n\r\nexport const ELEMENT_TYPES = [\r\n \"fragment\",\r\n \"div\",\r\n \"text\",\r\n \"image\",\r\n \"button\",\r\n \"input\",\r\n \"textarea\",\r\n \"link\",\r\n \"icon\",\r\n] as const;\r\n\r\nconst OnClickActionSchema = {\r\n type: Type.OBJECT,\r\n properties: {\r\n kind: {\r\n type: Type.STRING,\r\n enum: [\"route\", \"back\", \"reload\", \"external\"],\r\n description:\r\n \"What happens when the element is clicked. 'route' navigates within the app, 'external' opens a URL, 'back' goes back, 'reload' refreshes.\",\r\n },\r\n href: {\r\n type: Type.STRING,\r\n description:\r\n \"URL to navigate to (used for kind='route' and kind='external').\",\r\n },\r\n replace: {\r\n type: Type.BOOLEAN,\r\n description: \"For kind='route': replace history instead of pushing.\",\r\n },\r\n newTab: {\r\n type: Type.BOOLEAN,\r\n description: \"For kind='external': open link in a new tab.\",\r\n },\r\n },\r\n required: [\"kind\"],\r\n};\r\n\r\nconst BuilderElementPropsSchema = {\r\n type: Type.OBJECT,\r\n properties: {\r\n onClick: OnClickActionSchema,\r\n text: {\r\n type: Type.STRING,\r\n description:\r\n \"Text content used by 'text' (<p>), 'button' (label), and as a fallback for 'link' when it has no children.\",\r\n },\r\n href: {\r\n type: Type.STRING,\r\n description: \"For 'link': the href attribute (defaults to '#').\",\r\n },\r\n placeholder: {\r\n type: Type.STRING,\r\n description: \"For 'input' and 'textarea': placeholder shown when empty.\",\r\n },\r\n alt: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'image': alt text for accessibility AND the query used to fetch a suitable Unsplash image (src is auto-resolved from alt).\",\r\n },\r\n target: {\r\n type: Type.STRING,\r\n description: \"For 'link': target attribute (e.g. '_blank').\",\r\n },\r\n rel: {\r\n type: Type.STRING,\r\n description: \"For 'link': rel attribute (e.g. 'noreferrer').\",\r\n },\r\n value: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'input' and 'textarea': default value (maps to defaultValue).\",\r\n },\r\n type: {\r\n type: Type.STRING,\r\n description:\r\n \"For 'input': input type (e.g. 'text', 'email', 'password'). Defaults to 'text'.\",\r\n },\r\n\r\n // icon\r\n name: {\r\n type: Type.STRING,\r\n description: \"For 'icon': Lucide icon name (e.g. 'ArrowRight', 'Menu').\",\r\n },\r\n size: { type: Type.NUMBER, description: \"For 'icon': size in px.\" },\r\n color: { type: Type.STRING, description: \"For 'icon': stroke color.\" },\r\n strokeWidth: {\r\n type: Type.NUMBER,\r\n description: \"For 'icon': stroke width.\",\r\n },\r\n },\r\n};\r\n\r\n// NOTE: Gemini tool `parameters` schemas reject `$ref`, so true recursion isn't available here.\r\n// We unroll nesting to a reasonable max depth; for deeper trees, insert in multiple steps.\r\nconst buildBuilderElementSchema = (depth: number): any => {\r\n return {\r\n type: Type.OBJECT,\r\n properties: {\r\n type: {\r\n type: Type.STRING,\r\n enum: ELEMENT_TYPES,\r\n description:\r\n \"Element type to render. Use 'text' for <p>, 'image' forn <img>, 'link' for <a>, 'icon' for Lucide icon, 'fragment' renders children only\",\r\n },\r\n className: {\r\n type: Type.STRING,\r\n description: \"Tailwind CSS className (Tailwind only)\",\r\n },\r\n visible: {\r\n type: Type.BOOLEAN,\r\n description: \"Visibility flag\",\r\n },\r\n props: BuilderElementPropsSchema,\r\n children: {\r\n type: Type.ARRAY,\r\n description:\r\n \"Child elements. Each child can itself have children (children[].children[]...)\",\r\n items:\r\n depth > 0\r\n ? buildBuilderElementSchema(depth - 1)\r\n : {\r\n type: Type.OBJECT,\r\n description:\r\n \"Max depth reached. Insert deeper children separately using the returned inserted_id as parent_id\",\r\n },\r\n },\r\n },\r\n required: [\"type\"],\r\n };\r\n};\r\n\r\nexport const BuilderElementSchema: any = buildBuilderElementSchema(4);\r\n\r\nexport const InsertElementSchema = {\r\n name: \"insert_element\",\r\n description:\r\n \"Inserts element code. Use element.children to create nested UI. Each child is another BuilderElement and can itself have children.\",\r\n parameters: {\r\n type: Type.OBJECT,\r\n properties: {\r\n route: {\r\n type: Type.STRING,\r\n pattern: \"^/(?:[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*)?$\",\r\n description:\r\n \"The route to insert the element at. Use URL paths with forward slashes only. Examples: '/', '/about', '/pricing'. Never send Windows-style backslashes (e.g. '\\\\\\\\') or filesystem paths like 'app/pricing'. Never send empty string.\",\r\n },\r\n parent_id: {\r\n type: Type.STRING,\r\n description: \"The parent id to insert the element at.\",\r\n },\r\n element: {\r\n ...BuilderElementSchema,\r\n description: \"The element to insert.\",\r\n },\r\n },\r\n required: [\"route\", \"parent_id\", \"element\"],\r\n },\r\n};\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "@google/genai";
|
|
2
2
|
export const UpdateClassNameSchema = {
|
|
3
3
|
name: "update_classname",
|
|
4
|
-
description: "Updates className (only tailwind classes allowed). Give complete className.",
|
|
4
|
+
description: "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.",
|
|
5
5
|
parameters: {
|
|
6
6
|
type: Type.OBJECT,
|
|
7
7
|
properties: {
|
|
@@ -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
|
|
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,WAAW,EACT,mEAAmE;aACtE;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,\r\n description:\r\n \"The route to update the element at. Example. '/' or '/about' etc.\",\r\n },\r\n element_id: {\r\n type: Type.STRING,\r\n description: \"The id of the element to be updated.\",\r\n },\r\n className: { type: Type.STRING },\r\n },\r\n required: [\"route\", \"element_id\", \"className\"],\r\n },\r\n};\r\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from "@google/genai";
|
|
2
|
+
export declare const UpdateGlobalStylesSchema: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: Type;
|
|
7
|
+
properties: {
|
|
8
|
+
tokens: {
|
|
9
|
+
type: Type;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
required: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=updateGlobalStyles.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateGlobalStyles.schema.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateGlobalStyles.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;CAepC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from "@google/genai";
|
|
2
|
+
export const UpdateGlobalStylesSchema = {
|
|
3
|
+
name: "update_global_styles",
|
|
4
|
+
description: "Updates global design tokens in app/styleConfig.json. Use this to change theme colors/radius used by semantic Tailwind classes like bg-background and text-foreground.",
|
|
5
|
+
parameters: {
|
|
6
|
+
type: Type.OBJECT,
|
|
7
|
+
properties: {
|
|
8
|
+
tokens: {
|
|
9
|
+
type: Type.OBJECT,
|
|
10
|
+
description: "Partial tokens patch. Keys must be one of the StyleTokenKey values (see types/styleConfig.ts). Values must be non-empty safe CSS strings. Unknown keys are rejected.",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
required: ["tokens"],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=updateGlobalStyles.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateGlobalStyles.schema.js","sourceRoot":"","sources":["../../../../src/ai/tools/schemas/updateGlobalStyles.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,wKAAwK;IAC1K,UAAU,EAAE;QACV,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EACT,sKAAsK;aACzK;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC","sourcesContent":["import { Type } from \"@google/genai\";\n\nexport const UpdateGlobalStylesSchema = {\n name: \"update_global_styles\",\n description:\n \"Updates global design tokens in app/styleConfig.json. Use this to change theme colors/radius used by semantic Tailwind classes like bg-background and text-foreground.\",\n parameters: {\n type: Type.OBJECT,\n properties: {\n tokens: {\n type: Type.OBJECT,\n description:\n \"Partial tokens patch. Keys must be one of the StyleTokenKey values (see types/styleConfig.ts). Values must be non-empty safe CSS strings. Unknown keys are rejected.\",\n },\n },\n required: [\"tokens\"],\n },\n};\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegenTools.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/toolsets/codegenTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"codegenTools.d.ts","sourceRoot":"","sources":["../../../../src/ai/tools/toolsets/codegenTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAWrC,eAAO,MAAM,YAAY,QAAO,IAAI,EAgBnC,CAAC"}
|
|
@@ -6,11 +6,13 @@ import { DeleteElementSchema } from "../schemas/deleteElement.schema.js";
|
|
|
6
6
|
import { InsertElementSchema } from "../schemas/insertElement.schema.js";
|
|
7
7
|
import { UpdateClassNameSchema } from "../schemas/updateClassName.schema.js";
|
|
8
8
|
import { UpdatePropsSchema } from "../schemas/updateProps.schema.js";
|
|
9
|
+
import { UpdateGlobalStylesSchema } from "../schemas/updateGlobalStyles.schema.js";
|
|
9
10
|
export const codegenTools = () => {
|
|
10
11
|
return [
|
|
11
12
|
{
|
|
12
13
|
functionDeclarations: [
|
|
13
14
|
ReadFileSchema,
|
|
15
|
+
UpdateGlobalStylesSchema,
|
|
14
16
|
CreateNewRouteSchema,
|
|
15
17
|
InsertElementSchema,
|
|
16
18
|
DeleteElementSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegenTools.js","sourceRoot":"","sources":["../../../../src/ai/tools/toolsets/codegenTools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"codegenTools.js","sourceRoot":"","sources":["../../../../src/ai/tools/toolsets/codegenTools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAW,EAAE;IACvC,OAAO;QACL;YACE,oBAAoB,EAAE;gBACpB,cAAc;gBACd,wBAAwB;gBACxB,oBAAoB;gBACpB,mBAAmB;gBACnB,mBAAmB;gBACnB,qBAAqB;gBACrB,iBAAiB;gBACjB,aAAa;gBACb,uBAAuB;aACxB;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Tool } from \"@google/genai\";\nimport { ReadFileSchema } from \"../schemas/readFile.schema.js\";\nimport { SubmitCodegenDoneSchema } from \"../schemas/submitCodegenDone.schema.js\";\nimport { ListDirSchema } from \"../schemas/listDir.schema.js\";\nimport { CreateNewRouteSchema } from \"../schemas/createNewRoute.schema.js\";\nimport { DeleteElementSchema } from \"../schemas/deleteElement.schema.js\";\nimport { InsertElementSchema } from \"../schemas/insertElement.schema.js\";\nimport { UpdateClassNameSchema } from \"../schemas/updateClassName.schema.js\";\nimport { UpdatePropsSchema } from \"../schemas/updateProps.schema.js\";\nimport { UpdateGlobalStylesSchema } from \"../schemas/updateGlobalStyles.schema.js\";\n\nexport const codegenTools = (): Tool[] => {\n return [\n {\n functionDeclarations: [\n ReadFileSchema,\n UpdateGlobalStylesSchema,\n CreateNewRouteSchema,\n InsertElementSchema,\n DeleteElementSchema,\n UpdateClassNameSchema,\n UpdatePropsSchema,\n ListDirSchema,\n SubmitCodegenDoneSchema,\n ],\n },\n ];\n};\n"]}
|
package/dist/core.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class QwintlyCore {
|
|
|
38
38
|
private readonly redisStatusPublisher;
|
|
39
39
|
private readonly projectOpsRepo;
|
|
40
40
|
constructor(options: QwintlyCoreOptions);
|
|
41
|
-
runAiFlow(initialContents: any[], tools: Tool[], handlers: Record<string, ToolHandler>, maxSteps: number, terminalToolNames: string[]): Promise<ToolLoopResult>;
|
|
41
|
+
runAiFlow(initialContents: any[], tools: Tool[], handlers: Record<string, ToolHandler>, maxSteps: number, terminalToolNames: string[], persistResponse?: (modelInput: any, modelOutput: any) => Promise<void>): Promise<ToolLoopResult>;
|
|
42
42
|
streamLog(message: string, eventType: EventType, displayedSummary?: boolean): Promise<void>;
|
|
43
43
|
buildProjectInfoIdx(): Promise<ProjectInfo>;
|
|
44
44
|
private buildIndex;
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAGL,WAAW,EACX,cAAc,EACf,MAAM,iCAAiC,CAAC;AAazC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAiBF,qBAAa,WAAW;IACtB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,SAAS,EAAE,MAAM,CAAC;I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YAQ1C,UAAU;IAMX,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAIxC,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAIxC,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAI5C,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAY7E"}
|
package/dist/core.js
CHANGED
|
@@ -45,7 +45,7 @@ export class QwintlyCore {
|
|
|
45
45
|
initializeToolCallsRepository(options.supabase.endpoint, options.supabase.secret, options.sessionId);
|
|
46
46
|
console.log(`QwintlyCore initialized (chatId=${this.chatId}, sessionId=${this.sessionId})`);
|
|
47
47
|
}
|
|
48
|
-
async runAiFlow(initialContents, tools, handlers, maxSteps, terminalToolNames) {
|
|
48
|
+
async runAiFlow(initialContents, tools, handlers, maxSteps, terminalToolNames, persistResponse) {
|
|
49
49
|
if (!this.aiClient) {
|
|
50
50
|
throw new Error("AI client not initialized. Please provide 'gemini' config to use runAiFlow.");
|
|
51
51
|
}
|
|
@@ -60,6 +60,7 @@ export class QwintlyCore {
|
|
|
60
60
|
toolCallingMode: options.toolCallingMode,
|
|
61
61
|
}),
|
|
62
62
|
logger: this.streamLog.bind(this),
|
|
63
|
+
persistResponse,
|
|
63
64
|
};
|
|
64
65
|
const result = await runToolLoop(toolLoopOptions);
|
|
65
66
|
return result;
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,WAAW,GAIZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B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AAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACzD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,cAAc,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { FunctionCallingConfigMode, Tool } from \"@google/genai\";\nimport { getClient } from \"./ai/generate/generateClient.js\";\nimport {\n runToolLoop,\n RunToolLoopOptions,\n ToolHandler,\n ToolLoopResult,\n} from \"./ai/toolLoop/toolLoopRunner.js\";\nimport { initUnsplash } from \"./image/unsplash.service.js\";\nimport { buildCodegenIndex } from \"./indexer/codegenIndex.js\";\nimport { buildPlannerIndex } from \"./indexer/plannerIndex.js\";\nimport { computeProjectInfo } from \"./indexer/projectInfoIndex.js\";\nimport { buildValidatorIndex } from \"./indexer/validatorIndex.js\";\nimport { statusService } from \"./logging/genStatus.service.js\";\nimport { SendStatusToRedis } from \"./logging/redis.service.js\";\nimport { ContextRepository } from \"./repository/context.repository.js\";\nimport { GenStatusRepository } from \"./repository/genStatus.repository.js\";\nimport { ProjectOpsRepository } from \"./repository/projectOperations.repository.js\";\nimport { applyOperations } from \"./services/syncEditOps.service.js\";\nimport { initializeToolCallsRepository } from \"./services/toolcallPersist.service.js\";\nimport { EventType, GenStep } from \"./types/events.js\";\nimport {\n CodegenIndex,\n PlannerIndex,\n ValidatorIndex,\n} from \"./types/index/index.types.js\";\nimport type { ProjectInfo } from \"./types/projectInfo.types.js\";\nimport { assertNonEmptyString } from \"./utils/utils.js\";\n\nexport type QwintlyCoreOptions = {\n chatId: string;\n sessionId: string;\n workspacePath: string;\n source: string;\n step: GenStep;\n supabase: { endpoint: string; secret: string };\n upstash: { url: string; token: string };\n unsplash: { url: string; accessKey: string };\n gemini?: { apiKey: string; model?: string };\n};\n\ntype AiResponseOptions = {\n tools?: Tool[];\n toolCallingMode?: FunctionCallingConfigMode;\n};\n\ntype AiClient = {\n aiResponse: (\n request: unknown,\n options?: AiResponseOptions,\n ) => Promise<{\n functionCalls?: any[];\n text?: string;\n }>;\n};\n\nexport class QwintlyCore {\n public readonly chatId: string;\n public readonly sessionId: string;\n public readonly workspacePath: string;\n public readonly source: string;\n public readonly step: GenStep;\n\n private readonly aiClient?: AiClient;\n private readonly statusRepo: GenStatusRepository;\n private readonly ctxRepo: ContextRepository;\n private readonly redisStatusPublisher: SendStatusToRedis;\n private readonly projectOpsRepo: ProjectOpsRepository;\n\n constructor(options: QwintlyCoreOptions) {\n assertNonEmptyString(options.chatId, \"chatId\");\n assertNonEmptyString(options.sessionId, \"sessionId\");\n assertNonEmptyString(options.workspacePath, \"workspacePath\");\n assertNonEmptyString(options.source, \"source\");\n assertNonEmptyString(options.step, \"step\");\n assertNonEmptyString(options.supabase?.endpoint, \"supabase.endpoint\");\n assertNonEmptyString(options.supabase?.secret, \"supabase.secret\");\n assertNonEmptyString(options.upstash?.url, \"upstash.url\");\n assertNonEmptyString(options.upstash?.token, \"upstash.token\");\n\n this.chatId = options.chatId;\n this.sessionId = options.sessionId;\n this.workspacePath = options.workspacePath;\n this.source = options.source;\n this.step = options.step;\n\n if (options.unsplash?.url && options.unsplash?.accessKey) {\n initUnsplash({\n url: options.unsplash.url,\n accessKey: options.unsplash.accessKey,\n });\n }\n\n if (options.gemini?.apiKey) {\n this.aiClient = getClient(\n \"gemini\",\n options.gemini.apiKey,\n options.gemini.model,\n ) as AiClient;\n }\n\n this.statusRepo = new GenStatusRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.ctxRepo = new ContextRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.projectOpsRepo = new ProjectOpsRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.redisStatusPublisher = new SendStatusToRedis(\n options.upstash.url,\n options.upstash.token,\n );\n initializeToolCallsRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n options.sessionId,\n );\n\n console.log(\n `QwintlyCore initialized (chatId=${this.chatId}, sessionId=${this.sessionId})`,\n );\n }\n\n public async runAiFlow(\n initialContents: any[],\n tools: Tool[],\n handlers: Record<string, ToolHandler>,\n maxSteps: number,\n terminalToolNames: string[],\n ): Promise<ToolLoopResult> {\n if (!this.aiClient) {\n throw new Error(\n \"AI client not initialized. Please provide 'gemini' config to use runAiFlow.\",\n );\n }\n const toolLoopOptions: RunToolLoopOptions = {\n initialContents: initialContents,\n tools: tools,\n handlers: handlers,\n maxSteps: maxSteps,\n terminalToolNames: terminalToolNames,\n aiCall: (request, options) =>\n this.aiClient!.aiResponse(request, {\n tools: options.tools,\n toolCallingMode: options.toolCallingMode,\n }),\n logger: this.streamLog.bind(this),\n };\n\n const result = await runToolLoop(toolLoopOptions);\n return result;\n }\n\n public async streamLog(\n message: string,\n eventType: EventType,\n displayedSummary: boolean = false,\n ): Promise<void> {\n try {\n assertNonEmptyString(message, \"message\");\n await statusService(\n this.chatId,\n this.sessionId,\n eventType,\n this.step,\n message,\n this.source,\n {\n repository: {\n persist: this.statusRepo.persistStatusMessage.bind(this.statusRepo),\n },\n publisher: {\n publish: this.redisStatusPublisher.sendStatusToRedis.bind(\n this.redisStatusPublisher,\n ),\n },\n },\n displayedSummary,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n public async buildProjectInfoIdx(): Promise<ProjectInfo> {\n const projectInfo = await computeProjectInfo(this.workspacePath);\n\n await this.ctxRepo.updateProjectInfo(this.chatId, projectInfo);\n\n return projectInfo;\n }\n\n private async buildIndex<T>(\n builder: (path: string) => Promise<T>,\n ): Promise<T> {\n return builder(this.workspacePath);\n }\n\n public async buildPlannerIdx(): Promise<PlannerIndex> {\n return this.buildIndex(buildPlannerIndex);\n }\n\n public async buildCodegenIdx(): Promise<CodegenIndex> {\n return this.buildIndex(buildCodegenIndex);\n }\n\n public async buildValidatorIdx(): Promise<ValidatorIndex> {\n return this.buildIndex(buildValidatorIndex);\n }\n\n public async syncEditOps(genId: string, workspace: string): Promise<boolean> {\n if (!genId) return false;\n const projectOpsRepo = this.projectOpsRepo;\n const ops = await projectOpsRepo.fetchProjectOperations(genId);\n if (!ops || ops.length === 0) return false;\n const appliedIds = await applyOperations(ops, workspace);\n if (appliedIds.length > 0) {\n await projectOpsRepo.markOperationsApplied(appliedIds);\n }\n const isModified = appliedIds.length > 0;\n return isModified;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,WAAW,GAIZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAQtF,OAAO,EAAE,oBAAoB,EAAE,M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,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAE/D,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,UAAU,CACtB,OAAqC;QAErC,OAAO,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,eAAe;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,eAAe;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,SAAiB;QACvD,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC3C,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACzD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,cAAc,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { FunctionCallingConfigMode, Tool } from \"@google/genai\";\nimport { getClient } from \"./ai/generate/generateClient.js\";\nimport {\n runToolLoop,\n RunToolLoopOptions,\n ToolHandler,\n ToolLoopResult,\n} from \"./ai/toolLoop/toolLoopRunner.js\";\nimport { initUnsplash } from \"./image/unsplash.service.js\";\nimport { buildCodegenIndex } from \"./indexer/codegenIndex.js\";\nimport { buildPlannerIndex } from \"./indexer/plannerIndex.js\";\nimport { computeProjectInfo } from \"./indexer/projectInfoIndex.js\";\nimport { buildValidatorIndex } from \"./indexer/validatorIndex.js\";\nimport { statusService } from \"./logging/genStatus.service.js\";\nimport { SendStatusToRedis } from \"./logging/redis.service.js\";\nimport { ContextRepository } from \"./repository/context.repository.js\";\nimport { GenStatusRepository } from \"./repository/genStatus.repository.js\";\nimport { ProjectOpsRepository } from \"./repository/projectOperations.repository.js\";\nimport { applyOperations } from \"./services/syncEditOps.service.js\";\nimport { initializeToolCallsRepository } from \"./services/toolcallPersist.service.js\";\nimport { EventType, GenStep } from \"./types/events.js\";\nimport {\n CodegenIndex,\n PlannerIndex,\n ValidatorIndex,\n} from \"./types/index/index.types.js\";\nimport type { ProjectInfo } from \"./types/projectInfo.types.js\";\nimport { assertNonEmptyString } from \"./utils/utils.js\";\n\nexport type QwintlyCoreOptions = {\n chatId: string;\n sessionId: string;\n workspacePath: string;\n source: string;\n step: GenStep;\n supabase: { endpoint: string; secret: string };\n upstash: { url: string; token: string };\n unsplash: { url: string; accessKey: string };\n gemini?: { apiKey: string; model?: string };\n};\n\ntype AiResponseOptions = {\n tools?: Tool[];\n toolCallingMode?: FunctionCallingConfigMode;\n};\n\ntype AiClient = {\n aiResponse: (\n request: unknown,\n options?: AiResponseOptions,\n ) => Promise<{\n functionCalls?: any[];\n text?: string;\n }>;\n};\n\nexport class QwintlyCore {\n public readonly chatId: string;\n public readonly sessionId: string;\n public readonly workspacePath: string;\n public readonly source: string;\n public readonly step: GenStep;\n\n private readonly aiClient?: AiClient;\n private readonly statusRepo: GenStatusRepository;\n private readonly ctxRepo: ContextRepository;\n private readonly redisStatusPublisher: SendStatusToRedis;\n private readonly projectOpsRepo: ProjectOpsRepository;\n\n constructor(options: QwintlyCoreOptions) {\n assertNonEmptyString(options.chatId, \"chatId\");\n assertNonEmptyString(options.sessionId, \"sessionId\");\n assertNonEmptyString(options.workspacePath, \"workspacePath\");\n assertNonEmptyString(options.source, \"source\");\n assertNonEmptyString(options.step, \"step\");\n assertNonEmptyString(options.supabase?.endpoint, \"supabase.endpoint\");\n assertNonEmptyString(options.supabase?.secret, \"supabase.secret\");\n assertNonEmptyString(options.upstash?.url, \"upstash.url\");\n assertNonEmptyString(options.upstash?.token, \"upstash.token\");\n\n this.chatId = options.chatId;\n this.sessionId = options.sessionId;\n this.workspacePath = options.workspacePath;\n this.source = options.source;\n this.step = options.step;\n\n if (options.unsplash?.url && options.unsplash?.accessKey) {\n initUnsplash({\n url: options.unsplash.url,\n accessKey: options.unsplash.accessKey,\n });\n }\n\n if (options.gemini?.apiKey) {\n this.aiClient = getClient(\n \"gemini\",\n options.gemini.apiKey,\n options.gemini.model,\n ) as AiClient;\n }\n\n this.statusRepo = new GenStatusRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.ctxRepo = new ContextRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.projectOpsRepo = new ProjectOpsRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n );\n this.redisStatusPublisher = new SendStatusToRedis(\n options.upstash.url,\n options.upstash.token,\n );\n initializeToolCallsRepository(\n options.supabase.endpoint,\n options.supabase.secret,\n options.sessionId,\n );\n\n console.log(\n `QwintlyCore initialized (chatId=${this.chatId}, sessionId=${this.sessionId})`,\n );\n }\n\n public async runAiFlow(\n initialContents: any[],\n tools: Tool[],\n handlers: Record<string, ToolHandler>,\n maxSteps: number,\n terminalToolNames: string[],\n persistResponse?: (modelInput: any, modelOutput: any) => Promise<void>,\n ): Promise<ToolLoopResult> {\n if (!this.aiClient) {\n throw new Error(\n \"AI client not initialized. Please provide 'gemini' config to use runAiFlow.\",\n );\n }\n const toolLoopOptions: RunToolLoopOptions = {\n initialContents: initialContents,\n tools: tools,\n handlers: handlers,\n maxSteps: maxSteps,\n terminalToolNames: terminalToolNames,\n aiCall: (request, options) =>\n this.aiClient!.aiResponse(request, {\n tools: options.tools,\n toolCallingMode: options.toolCallingMode,\n }),\n logger: this.streamLog.bind(this),\n persistResponse,\n };\n\n const result = await runToolLoop(toolLoopOptions);\n return result;\n }\n\n public async streamLog(\n message: string,\n eventType: EventType,\n displayedSummary: boolean = false,\n ): Promise<void> {\n try {\n assertNonEmptyString(message, \"message\");\n await statusService(\n this.chatId,\n this.sessionId,\n eventType,\n this.step,\n message,\n this.source,\n {\n repository: {\n persist: this.statusRepo.persistStatusMessage.bind(this.statusRepo),\n },\n publisher: {\n publish: this.redisStatusPublisher.sendStatusToRedis.bind(\n this.redisStatusPublisher,\n ),\n },\n },\n displayedSummary,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n public async buildProjectInfoIdx(): Promise<ProjectInfo> {\n const projectInfo = await computeProjectInfo(this.workspacePath);\n\n await this.ctxRepo.updateProjectInfo(this.chatId, projectInfo);\n\n return projectInfo;\n }\n\n private async buildIndex<T>(\n builder: (path: string) => Promise<T>,\n ): Promise<T> {\n return builder(this.workspacePath);\n }\n\n public async buildPlannerIdx(): Promise<PlannerIndex> {\n return this.buildIndex(buildPlannerIndex);\n }\n\n public async buildCodegenIdx(): Promise<CodegenIndex> {\n return this.buildIndex(buildCodegenIndex);\n }\n\n public async buildValidatorIdx(): Promise<ValidatorIndex> {\n return this.buildIndex(buildValidatorIndex);\n }\n\n public async syncEditOps(genId: string, workspace: string): Promise<boolean> {\n if (!genId) return false;\n const projectOpsRepo = this.projectOpsRepo;\n const ops = await projectOpsRepo.fetchProjectOperations(genId);\n if (!ops || ops.length === 0) return false;\n const appliedIds = await applyOperations(ops, workspace);\n if (appliedIds.length > 0) {\n await projectOpsRepo.markOperationsApplied(appliedIds);\n }\n const isModified = appliedIds.length > 0;\n return isModified;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateGlobalStyles.impl.test.d.ts","sourceRoot":"","sources":["../../src/tests/updateGlobalStyles.impl.test.ts"],"names":[],"mappings":""}
|