From aa4a72996b2ffc99d40a2d0e78889c2e8e1ceac6 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 26 Jan 2025 22:33:41 -0800 Subject: [PATCH] getBlockType --- core/package-lock.json | 8 ++--- core/package.json | 2 +- gui/package-lock.json | 10 +++--- gui/package.json | 2 +- packages/config-yaml/package.json | 2 +- packages/config-yaml/src/index.ts | 1 + packages/config-yaml/src/load/getBlockType.ts | 32 +++++++++++++++++++ 7 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 packages/config-yaml/src/load/getBlockType.ts diff --git a/core/package-lock.json b/core/package-lock.json index 942ca3669..9562aea17 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.18", + "@continuedev/config-yaml": "^1.0.20", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -3038,9 +3038,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.18", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.18.tgz", - "integrity": "sha512-Un7ngLG+8pVWsnAQHBvtTK0Efc5rRCDCI7UhhpS20yCWjmo8yZzcLd3N4yb06DtdRJs2jqo9pSKxnt8ORL4l0Q==", + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.20.tgz", + "integrity": "sha512-MMCqE5khk5MnQc4udPOGCuXf8q+Zo01D4n4qbZu4oPV1foXHfQIZwQkWaQLJOJzzODZEBpgeJeJCknweYckgWg==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index bb20daed0..05beaca5c 100644 --- a/core/package.json +++ b/core/package.json @@ -46,7 +46,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.18", + "@continuedev/config-yaml": "^1.0.20", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/package-lock.json b/gui/package-lock.json index f2bb629f0..50061f21e 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.18", + "@continuedev/config-yaml": "^1.0.20", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -108,7 +108,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.18", + "@continuedev/config-yaml": "^1.0.20", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -556,9 +556,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.18", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.18.tgz", - "integrity": "sha512-Un7ngLG+8pVWsnAQHBvtTK0Efc5rRCDCI7UhhpS20yCWjmo8yZzcLd3N4yb06DtdRJs2jqo9pSKxnt8ORL4l0Q==", + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.20.tgz", + "integrity": "sha512-MMCqE5khk5MnQc4udPOGCuXf8q+Zo01D4n4qbZu4oPV1foXHfQIZwQkWaQLJOJzzODZEBpgeJeJCknweYckgWg==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index e5a18fc1e..cf5cbd0fa 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.18", + "@continuedev/config-yaml": "^1.0.20", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index e95995343..e9d11ad03 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.19", + "version": "1.0.22", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/index.ts b/packages/config-yaml/src/index.ts index 9ebf6cb32..0fcd5ae10 100644 --- a/packages/config-yaml/src/index.ts +++ b/packages/config-yaml/src/index.ts @@ -3,6 +3,7 @@ export * from "./interfaces/index.js"; export * from "./interfaces/SecretResult.js"; export * from "./interfaces/slugs.js"; export * from "./load/clientRender.js"; +export * from "./load/getBlockType.js"; export * from "./load/merge.js"; export * from "./load/proxySecretResolution.js"; export * from "./load/unroll.js"; diff --git a/packages/config-yaml/src/load/getBlockType.ts b/packages/config-yaml/src/load/getBlockType.ts new file mode 100644 index 000000000..680c3b644 --- /dev/null +++ b/packages/config-yaml/src/load/getBlockType.ts @@ -0,0 +1,32 @@ +import { ConfigYaml } from "../schemas/index.js"; + +export type BlockType = + | "models" + | "context" + | "docs" + | "tools" + | "mcpServers" + | "data" + | "rules" + | "prompts"; +export function getBlockType(block: ConfigYaml): BlockType { + if (block.context?.length) { + return "context"; + } else if (block.models?.length) { + return "models"; + } else if (block.docs?.length) { + return "docs"; + } else if (block.tools?.length) { + return "tools"; + } else if (block.mcpServers?.length) { + return "mcpServers"; + } else if (block.data?.length) { + return "data"; + } else if (block.rules?.length) { + return "rules"; + } else if (block.prompts?.length) { + return "prompts"; + } else { + throw new Error("Unknown block type"); + } +}