Skip to content

Commit b3628ec

Browse files
committedJan 27, 2025
rename AssistantRolled back to ConfigYaml
1 parent 938aaeb commit b3628ec

File tree

10 files changed

+45
-48
lines changed

10 files changed

+45
-48
lines changed
 

‎core/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
4747
"@aws-sdk/credential-providers": "^3.620.1",
4848
"@continuedev/config-types": "^1.0.13",
49-
"@continuedev/config-yaml": "^1.0.17",
49+
"@continuedev/config-yaml": "^1.0.18",
5050
"@continuedev/fetch": "^1.0.4",
5151
"@continuedev/llm-info": "^1.0.2",
5252
"@continuedev/openai-adapters": "^1.0.10",

‎gui/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"test:watch": "vitest"
1616
},
1717
"dependencies": {
18-
"@continuedev/config-yaml": "^1.0.17",
18+
"@continuedev/config-yaml": "^1.0.18",
1919
"@headlessui/react": "^1.7.17",
2020
"@heroicons/react": "^2.0.18",
2121
"@reduxjs/toolkit": "^2.3.0",

‎packages/config-yaml/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@continuedev/config-yaml",
3-
"version": "1.0.17",
3+
"version": "1.0.19",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

‎packages/config-yaml/src/converter.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ConfigJson } from "@continuedev/config-types";
2-
import { AssistantRolled } from "./schemas/index.js";
2+
import { ConfigYaml } from "./schemas/index.js";
33
import { ModelRoles } from "./schemas/models.js";
44

5-
type ModelYaml = NonNullable<AssistantRolled["models"]>[number];
6-
type ContextYaml = NonNullable<AssistantRolled["context"]>[number];
7-
type PromptYaml = NonNullable<AssistantRolled["prompts"]>[number];
5+
type ModelYaml = NonNullable<ConfigYaml["models"]>[number];
6+
type ContextYaml = NonNullable<ConfigYaml["context"]>[number];
7+
type PromptYaml = NonNullable<ConfigYaml["prompts"]>[number];
88

99
function convertModel(
1010
m: ConfigJson["models"][number],
@@ -68,9 +68,7 @@ function convertCustomCommand(
6868
};
6969
}
7070

71-
function convertMcp(
72-
mcp: any,
73-
): NonNullable<AssistantRolled["mcpServers"]>[number] {
71+
function convertMcp(mcp: any): NonNullable<ConfigYaml["mcpServers"]>[number] {
7472
const { transport } = mcp;
7573
const { command, args, env } = transport;
7674

@@ -84,7 +82,7 @@ function convertMcp(
8482

8583
function convertDoc(
8684
doc: NonNullable<ConfigJson["docs"]>[number],
87-
): NonNullable<AssistantRolled["docs"]>[number] {
85+
): NonNullable<ConfigYaml["docs"]>[number] {
8886
return {
8987
name: doc.title,
9088
startUrl: doc.startUrl,
@@ -93,9 +91,7 @@ function convertDoc(
9391
};
9492
}
9593

96-
export function convertJsonToYamlConfig(
97-
configJson: ConfigJson,
98-
): AssistantRolled {
94+
export function convertJsonToYamlConfig(configJson: ConfigJson): ConfigYaml {
9995
// models
10096
const models = configJson.models.map((m) => convertModel(m, ["chat"]));
10197
const autocompleteModels = Array.isArray(configJson.tabAutocompleteModel)
@@ -130,7 +126,7 @@ export function convertJsonToYamlConfig(
130126
// docs
131127
const docs = configJson.docs?.map(convertDoc);
132128

133-
const configYaml: AssistantRolled = {
129+
const configYaml: ConfigYaml = {
134130
name: "Continue Config",
135131
version: "0.0.1",
136132
models,

‎packages/config-yaml/src/load/merge.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { AssistantRolled } from "../schemas/index.js";
1+
import { ConfigYaml } from "../schemas/index.js";
22

33
export function mergePackages(
4-
current: AssistantRolled,
5-
incoming: AssistantRolled,
6-
): AssistantRolled {
4+
current: ConfigYaml,
5+
incoming: ConfigYaml,
6+
): ConfigYaml {
77
return {
88
...current,
99
models: [...(current.models ?? []), ...(incoming.models ?? [])],

‎packages/config-yaml/src/load/unroll.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import {
77
PackageSlug,
88
} from "../interfaces/slugs.js";
99
import {
10-
AssistantRolled,
11-
assistantRolledSchema,
1210
AssistantUnrolled,
1311
assistantUnrolledSchema,
1412
Block,
1513
blockSchema,
14+
ConfigYaml,
15+
configYamlSchema,
1616
} from "../schemas/index.js";
1717

18-
export function parseAssistantRolled(configYaml: string): AssistantRolled {
18+
export function parseConfigYaml(configYaml: string): ConfigYaml {
1919
try {
2020
const parsed = YAML.parse(configYaml);
21-
const result = assistantRolledSchema.parse(parsed);
21+
const result = configYamlSchema.parse(parsed);
2222
return result;
2323
} catch (e: any) {
2424
console.log(configYaml);
@@ -123,9 +123,6 @@ function extractFQSNMap(
123123
return secretToFQSNMap(secrets, parentPackages);
124124
}
125125

126-
/**
127-
* Loading an assistant is equivalent to loading a package without params
128-
*/
129126
export async function unrollAssistant(
130127
fullSlug: string,
131128
registry: Registry,
@@ -134,25 +131,32 @@ export async function unrollAssistant(
134131

135132
// Request the content from the registry
136133
const rawContent = await registry.getContent(assistantSlug);
134+
return unrollAssistantFromContent(assistantSlug, rawContent, registry);
135+
}
137136

137+
export async function unrollAssistantFromContent(
138+
assistantSlug: FullSlug,
139+
rawYaml: string,
140+
registry: Registry,
141+
): Promise<AssistantUnrolled> {
138142
// Convert the raw YAML to unrolled config
139143
const templateData: TemplateData = {
140144
// no inputs to an assistant
141145
inputs: {},
142146
// at this stage, secrets are mapped to a (still templated) FQSN
143-
secrets: extractFQSNMap(rawContent, [assistantSlug]),
147+
secrets: extractFQSNMap(rawYaml, [assistantSlug]),
144148
// Built-in variables
145149
continue: {},
146150
};
147151

148152
// Render the template
149153
const templatedYaml = fillTemplateVariables(
150-
rawContent,
154+
rawYaml,
151155
flattenTemplateData(templateData),
152156
);
153157

154158
// Parse string to Zod-validated YAML
155-
let parsedYaml = parseAssistantRolled(templatedYaml);
159+
let parsedYaml = parseConfigYaml(templatedYaml);
156160

157161
// Unroll blocks
158162
const unrolledAssistant = await unrollBlocks(
@@ -165,7 +169,7 @@ export async function unrollAssistant(
165169
}
166170

167171
export async function unrollBlocks(
168-
assistant: AssistantRolled,
172+
assistant: ConfigYaml,
169173
assistantFullSlug: FullSlug,
170174
registry: Registry,
171175
): Promise<AssistantUnrolled> {
@@ -174,10 +178,7 @@ export async function unrollBlocks(
174178
version: assistant.version,
175179
};
176180

177-
const sections: (keyof Omit<
178-
AssistantRolled,
179-
"name" | "version" | "rules"
180-
>)[] = [
181+
const sections: (keyof Omit<ConfigYaml, "name" | "version" | "rules">)[] = [
181182
"models",
182183
"context",
183184
"data",

‎packages/config-yaml/src/schemas/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const blockItemWrapperSchema = <T extends z.AnyZodObject>(schema: T) =>
4848
export const blockOrSchema = <T extends z.AnyZodObject>(schema: T) =>
4949
z.union([schema, blockItemWrapperSchema(schema)]);
5050

51-
export const assistantRolledSchema = z.object({
51+
export const configYamlSchema = z.object({
5252
name: z.string(),
5353
version: z.string(),
5454
models: z
@@ -82,7 +82,7 @@ export const assistantRolledSchema = z.object({
8282
docs: z.array(blockOrSchema(docSchema)).optional(),
8383
});
8484

85-
export type AssistantRolled = z.infer<typeof assistantRolledSchema>;
85+
export type ConfigYaml = z.infer<typeof configYamlSchema>;
8686

8787
export const assistantUnrolledSchema = z.object({
8888
name: z.string(),

‎packages/config-yaml/src/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AssistantRolled, assistantRolledSchema } from "./schemas/index.js";
1+
import { ConfigYaml, configYamlSchema } from "./schemas/index.js";
22

33
export interface ConfigValidationError {
44
fatal: boolean;
@@ -12,12 +12,12 @@ export interface ConfigResult<T> {
1212
}
1313

1414
export function validateConfigYaml(
15-
config: AssistantRolled,
15+
config: ConfigYaml,
1616
): ConfigValidationError[] {
1717
const errors: ConfigValidationError[] = [];
1818

1919
try {
20-
assistantRolledSchema.parse(config);
20+
configYamlSchema.parse(config);
2121
} catch (e: any) {
2222
return [
2323
{

0 commit comments

Comments
 (0)