merge staging
This commit is contained in:
commit
1f8cd98bf9
53 changed files with 4142 additions and 5747 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -13,6 +13,9 @@
|
|||
"args": ["-l"]
|
||||
}
|
||||
},
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": "explicit"
|
||||
},
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"search.exclude": {
|
||||
"**/package-lock.json": true,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { logDevData } from "../../util/devdata";
|
||||
import { DataLogger } from "../../data/log";
|
||||
import { COUNT_COMPLETION_REJECTED_AFTER } from "../../util/parameters";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { getUriFileExtension } from "../../util/uri";
|
||||
|
|
@ -96,7 +96,14 @@ export class AutocompleteLoggingService {
|
|||
}
|
||||
|
||||
private logAutocompleteOutcome(outcome: AutocompleteOutcome) {
|
||||
logDevData("autocomplete", outcome);
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "autocomplete",
|
||||
data: {
|
||||
...outcome,
|
||||
useFileSuffix: true, // from outdated schema
|
||||
},
|
||||
});
|
||||
|
||||
const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome;
|
||||
void Telemetry.capture(
|
||||
"autocomplete",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export class ConfigHandler {
|
|||
private profiles: ProfileLifecycleManager[] | null = null; // null until profiles are loaded
|
||||
private selectedProfileId: string | null = null;
|
||||
private localProfileManager: ProfileLifecycleManager;
|
||||
private controlPlaneClient: ControlPlaneClient;
|
||||
controlPlaneClient: ControlPlaneClient;
|
||||
|
||||
initializedPromise: Promise<void>;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,10 +82,12 @@ export const defaultConfig: SerializedContinueConfig = {
|
|||
models: [],
|
||||
contextProviders: defaultContextProvidersVsCode,
|
||||
slashCommands: defaultSlashCommandsVscode,
|
||||
data: [],
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersJetBrains,
|
||||
slashCommands: defaultSlashCommandsJetBrains,
|
||||
data: [],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ import {
|
|||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { validateConfig } from "./validation.js";
|
||||
import { getModelByRole } from "./util";
|
||||
import { validateConfig } from "./validation.js";
|
||||
|
||||
export function resolveSerializedConfig(
|
||||
filepath: string,
|
||||
|
|
@ -687,6 +687,7 @@ async function finalToBrowserConfig(
|
|||
v ? llmToSerializedModelDescription(v) : null,
|
||||
]),
|
||||
) as Record<ModelRole, ModelDescription | null>, // TODO better types here
|
||||
// data not included here because client doesn't need
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { ConfigResult, AssistantUnrolled } from "@continuedev/config-yaml";
|
||||
import { AssistantUnrolled, ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ async function configYamlToContinueConfig(
|
|||
rerank: null,
|
||||
summarize: null,
|
||||
},
|
||||
data: config.data,
|
||||
};
|
||||
|
||||
// Models
|
||||
|
|
|
|||
19
core/core.ts
19
core/core.ts
|
|
@ -30,14 +30,14 @@ import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
|
|||
import { callTool } from "./tools/callTool";
|
||||
import { ChatDescriber } from "./util/chatDescriber";
|
||||
import { clipboardCache } from "./util/clipboardCache";
|
||||
import { logDevData } from "./util/devdata";
|
||||
import { DevDataSqliteDb } from "./util/devdataSqlite";
|
||||
import { DataLogger } from "./data/log";
|
||||
import { DevDataSqliteDb } from "./data/devdataSqlite";
|
||||
import { GlobalContext } from "./util/GlobalContext";
|
||||
import historyManager from "./util/history";
|
||||
import {
|
||||
editConfigJson,
|
||||
getConfigJsonPath,
|
||||
setupInitialDotContinueDirectory,
|
||||
migrateV1DevDataFiles,
|
||||
} from "./util/paths";
|
||||
import { localPathToUri } from "./util/pathToUri";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
|
|
@ -94,7 +94,7 @@ export class Core {
|
|||
private readonly onWrite: (text: string) => Promise<void> = async () => {},
|
||||
) {
|
||||
// Ensure .continue directory is created
|
||||
setupInitialDotContinueDirectory();
|
||||
migrateV1DevDataFiles();
|
||||
|
||||
this.codebaseIndexingState = {
|
||||
status: "loading",
|
||||
|
|
@ -102,6 +102,7 @@ export class Core {
|
|||
progress: 0,
|
||||
};
|
||||
|
||||
const ideInfoPromise = messenger.request("getIdeInfo", undefined);
|
||||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
const sessionInfoPromise = messenger.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
|
|
@ -146,6 +147,12 @@ export class Core {
|
|||
}),
|
||||
);
|
||||
|
||||
// Dev Data Logger
|
||||
const dataLogger = DataLogger.getInstance();
|
||||
dataLogger.core = this;
|
||||
dataLogger.ideInfoPromise = ideInfoPromise;
|
||||
dataLogger.ideSettingsPromise = ideSettingsPromise;
|
||||
|
||||
// Codebase Indexer and ContinueServerClient depend on IdeSettings
|
||||
let codebaseIndexerResolve: (_: any) => void | undefined;
|
||||
this.codebaseIndexerPromise = new Promise(
|
||||
|
|
@ -259,8 +266,8 @@ export class Core {
|
|||
});
|
||||
|
||||
// Dev data
|
||||
on("devdata/log", (msg) => {
|
||||
logDevData(msg.data.tableName, msg.data.data);
|
||||
on("devdata/log", async (msg) => {
|
||||
void DataLogger.getInstance().logDevData(msg.data);
|
||||
});
|
||||
|
||||
// Edit config
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ import sqlite3 from "sqlite3";
|
|||
|
||||
import { DatabaseConnection } from "../indexing/refreshIndex.js";
|
||||
|
||||
import { getDevDataSqlitePath } from "./paths.js";
|
||||
import { getDevDataSqlitePath } from "../util/paths.js";
|
||||
|
||||
/* The Dev Data SQLITE table is only used for local tokens generated */
|
||||
export class DevDataSqliteDb {
|
||||
static db: DatabaseConnection | null = null;
|
||||
|
||||
226
core/data/log.ts
Normal file
226
core/data/log.ts
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import {
|
||||
allDevEventNames,
|
||||
DataLogLevel,
|
||||
DevDataLogEvent,
|
||||
devDataVersionedSchemas,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import * as URI from "uri-js";
|
||||
import { fileURLToPath } from "url";
|
||||
import { ZodObject } from "zod";
|
||||
import { Core } from "../core.js";
|
||||
import { IdeInfo, IdeSettings } from "../index.js";
|
||||
import { getDevDataFilePath } from "../util/paths.js";
|
||||
import { joinPathsToUri } from "../util/uri.js";
|
||||
|
||||
const DEFAULT_DEV_DATA_LEVEL: DataLogLevel = "all";
|
||||
export const LOCAL_DEV_DATA_VERSION = "0.2.0";
|
||||
export class DataLogger {
|
||||
private static instance: DataLogger | null = null;
|
||||
core?: Core;
|
||||
ideSettingsPromise?: Promise<IdeSettings>;
|
||||
ideInfoPromise?: Promise<IdeInfo>;
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static getInstance(): DataLogger {
|
||||
if (DataLogger.instance === null) {
|
||||
DataLogger.instance = new DataLogger();
|
||||
}
|
||||
return DataLogger.instance;
|
||||
}
|
||||
|
||||
async addBaseValues(
|
||||
body: Record<string, any>,
|
||||
eventName: string,
|
||||
schema: string,
|
||||
zodSchema: ZodObject<any>,
|
||||
): Promise<Record<string, any>> {
|
||||
const newBody = { ...body };
|
||||
const ideSettings = await this.ideSettingsPromise;
|
||||
const ideInfo = await this.ideInfoPromise;
|
||||
|
||||
if ("eventName" in zodSchema.shape) {
|
||||
newBody.eventName = eventName;
|
||||
}
|
||||
if ("timestamp" in zodSchema.shape) {
|
||||
newBody.timestamp = new Date().toISOString();
|
||||
}
|
||||
if ("schema" in zodSchema.shape) {
|
||||
newBody.schema = schema;
|
||||
}
|
||||
if ("userAgent" in zodSchema.shape) {
|
||||
newBody.userAgent = ideInfo
|
||||
? `${ideInfo.name}/${ideInfo.version} (Continue/${ideInfo.extensionVersion})`
|
||||
: "Unknown/Unknown (Continue/Unknown)";
|
||||
}
|
||||
if ("selectedProfileId" in zodSchema.shape) {
|
||||
newBody.selectedProfileId =
|
||||
this.core?.configHandler.currentProfile?.profileDescription.id ?? "";
|
||||
}
|
||||
if ("userId" in zodSchema.shape) {
|
||||
newBody.userId = ideSettings?.userToken ?? "";
|
||||
}
|
||||
|
||||
return newBody;
|
||||
}
|
||||
|
||||
async logDevData(event: DevDataLogEvent) {
|
||||
// Local logs (always on for all levels)
|
||||
try {
|
||||
const filepath: string = getDevDataFilePath(
|
||||
event.name,
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
);
|
||||
const localSchema =
|
||||
devDataVersionedSchemas[LOCAL_DEV_DATA_VERSION]["all"][event.name];
|
||||
|
||||
if (!localSchema) {
|
||||
throw new Error(
|
||||
`Schema ${LOCAL_DEV_DATA_VERSION} doesn't exist at level "all"`,
|
||||
);
|
||||
}
|
||||
|
||||
const eventDataWithBaseValues = await this.addBaseValues(
|
||||
event.data,
|
||||
event.name,
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
localSchema,
|
||||
);
|
||||
|
||||
const parsed = localSchema?.safeParse(eventDataWithBaseValues);
|
||||
if (parsed?.success) {
|
||||
fs.writeFileSync(filepath, `${JSON.stringify(parsed.data)}\n`, {
|
||||
flag: "a",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error logging local dev data:", error);
|
||||
}
|
||||
|
||||
// Remote logs
|
||||
const config = (await this.core?.configHandler.loadConfig())?.config;
|
||||
if (config?.data?.length) {
|
||||
await Promise.allSettled(
|
||||
config.data.map(async (dataConfig) => {
|
||||
try {
|
||||
// First extract the data schema based on the version and level
|
||||
const { schema } = dataConfig;
|
||||
|
||||
const level = dataConfig.level ?? DEFAULT_DEV_DATA_LEVEL;
|
||||
|
||||
// Skip event if `events` is specified and does not include the event
|
||||
const events = dataConfig.events ?? allDevEventNames;
|
||||
if (!events.includes(event.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const versionSchemas = devDataVersionedSchemas[schema];
|
||||
if (!versionSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data to non-existent version ${schema}`,
|
||||
);
|
||||
}
|
||||
|
||||
const levelSchemas = versionSchemas[level];
|
||||
if (!levelSchemas) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data at level ${level} for version ${schema} which does not exist`,
|
||||
);
|
||||
}
|
||||
|
||||
const zodSchema = levelSchemas[event.name];
|
||||
if (!zodSchema) {
|
||||
throw new Error(
|
||||
`Attempting to log dev data for event ${event.name} at level ${level} for version ${schema}: no schema found`,
|
||||
);
|
||||
}
|
||||
|
||||
const eventDataWithBaseValues = await this.addBaseValues(
|
||||
event.data,
|
||||
event.name,
|
||||
schema,
|
||||
zodSchema,
|
||||
);
|
||||
|
||||
const parsed = zodSchema.safeParse(eventDataWithBaseValues);
|
||||
if (!parsed.success) {
|
||||
throw new Error(
|
||||
`Failed to parse event data for event ${event.name} and schema ${schema}\n:${parsed.error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
const uriComponents = URI.parse(dataConfig.destination);
|
||||
|
||||
// Send to remote server
|
||||
if (
|
||||
uriComponents.scheme === "https" ||
|
||||
uriComponents.scheme === "http"
|
||||
) {
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if (dataConfig.apiKey) {
|
||||
headers["Authorization"] = `Bearer ${dataConfig.apiKey}`;
|
||||
}
|
||||
|
||||
// For events going to Continue, overwrite the access token
|
||||
if (
|
||||
uriComponents.host?.endsWith(".continue.dev") ||
|
||||
uriComponents.host === "continue.dev"
|
||||
) {
|
||||
//
|
||||
const accessToken =
|
||||
await this.core?.configHandler.controlPlaneClient.getAccessToken();
|
||||
headers["Authorization"] = `Bearer ${accessToken}`;
|
||||
}
|
||||
const profileId =
|
||||
this.core?.configHandler.currentProfile?.profileDescription
|
||||
.id ?? "";
|
||||
const response = await fetchwithRequestOptions(
|
||||
dataConfig.destination,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
name: event.name,
|
||||
data: parsed.data,
|
||||
schema,
|
||||
level,
|
||||
profileId,
|
||||
}),
|
||||
},
|
||||
dataConfig.requestOptions,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Post request failed. ${response.status}: ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
} else if (uriComponents.scheme === "file") {
|
||||
// Write to jsonc file for local file URIs
|
||||
const dirUri = joinPathsToUri(dataConfig.destination, schema);
|
||||
const dirPath = fileURLToPath(dirUri);
|
||||
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
}
|
||||
const filepath = path.join(dirPath, `${event.name}.jsonl`);
|
||||
const jsonLine = JSON.stringify(event.data);
|
||||
fs.writeFileSync(filepath, `${jsonLine}\n`, { flag: "a" });
|
||||
} else {
|
||||
throw new Error(`Unsupported URI scheme ${uriComponents.scheme}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Error logging data to ${dataConfig.destination}: ${error instanceof Error ? error.message : error}`,
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
5
core/index.d.ts
vendored
5
core/index.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
import { DataDestination, ModelRole } from "@continuedev/config-yaml";
|
||||
import Parser from "web-tree-sitter";
|
||||
import { GetGhTokenArgs } from "./protocol/ide";
|
||||
declare global {
|
||||
|
|
@ -1147,6 +1147,7 @@ export interface SerializedContinueConfig {
|
|||
experimental?: ExperimentalConfig;
|
||||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
data?: DataDestination[];
|
||||
}
|
||||
|
||||
export type ConfigMergeType = "merge" | "overwrite";
|
||||
|
|
@ -1199,6 +1200,7 @@ export interface Config {
|
|||
experimental?: ExperimentalConfig;
|
||||
/** Analytics configuration */
|
||||
analytics?: AnalyticsConfig;
|
||||
data?: DataDestination[];
|
||||
}
|
||||
|
||||
// in the actual Continue source code
|
||||
|
|
@ -1221,6 +1223,7 @@ export interface ContinueConfig {
|
|||
tools: Tool[];
|
||||
modelsByRole: Record<ModelRole, ILLM[]>;
|
||||
selectedModelByRole: Record<ModelRole, ILLM | null>;
|
||||
data?: DataDestination[];
|
||||
}
|
||||
|
||||
export interface BrowserSerializedContinueConfig {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import { findLlmInfo } from "@continuedev/llm-info";
|
||||
import {
|
||||
|
|
@ -7,6 +8,8 @@ import {
|
|||
} from "@continuedev/openai-adapters";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
import { DevDataSqliteDb } from "../data/devdataSqlite.js";
|
||||
import { DataLogger } from "../data/log.js";
|
||||
import {
|
||||
CacheBehavior,
|
||||
ChatMessage,
|
||||
|
|
@ -21,8 +24,6 @@ import {
|
|||
RequestOptions,
|
||||
TemplateType,
|
||||
} from "../index.js";
|
||||
import { logDevData } from "../util/devdata.js";
|
||||
import { DevDataSqliteDb } from "../util/devdataSqlite.js";
|
||||
import mergeJson from "../util/merge.js";
|
||||
import { renderChatMessage } from "../util/messageContent.js";
|
||||
import { isOllamaInstalled } from "../util/ollamaHelper.js";
|
||||
|
|
@ -56,7 +57,6 @@ import {
|
|||
toCompleteBody,
|
||||
toFimBody,
|
||||
} from "./openaiTypeConverters.js";
|
||||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
|
||||
export abstract class BaseLLM implements ILLM {
|
||||
static providerName: string;
|
||||
|
|
@ -288,7 +288,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
return this.templateMessages(msgs);
|
||||
}
|
||||
|
||||
private _compileLogMessage(
|
||||
private _compilePromptForLog(
|
||||
prompt: string,
|
||||
completionOptions: CompletionOptions,
|
||||
): string {
|
||||
|
|
@ -343,11 +343,14 @@ export abstract class BaseLLM implements ILLM {
|
|||
generatedTokens,
|
||||
);
|
||||
|
||||
logDevData("tokens_generated", {
|
||||
model: model,
|
||||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "tokensGenerated",
|
||||
data: {
|
||||
model: model,
|
||||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +450,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
options,
|
||||
);
|
||||
|
||||
return { completionOptions, log, raw };
|
||||
return { completionOptions, logEnabled: log, raw };
|
||||
}
|
||||
|
||||
private _formatChatMessages(messages: ChatMessage[]): string {
|
||||
|
|
@ -500,12 +503,15 @@ export abstract class BaseLLM implements ILLM {
|
|||
signal: AbortSignal,
|
||||
options: LLMFullCompletionOptions = {},
|
||||
): AsyncGenerator<string> {
|
||||
const { completionOptions, log } = this._parseCompletionOptions(options);
|
||||
const { completionOptions, logEnabled } =
|
||||
this._parseCompletionOptions(options);
|
||||
|
||||
const fimLog = `Prefix: ${prefix}\nSuffix: ${suffix}`;
|
||||
if (log) {
|
||||
if (logEnabled) {
|
||||
if (this.writeLog) {
|
||||
await this.writeLog(this._compileLogMessage(fimLog, completionOptions));
|
||||
await this.writeLog(
|
||||
this._compilePromptForLog(fimLog, completionOptions),
|
||||
);
|
||||
}
|
||||
if (this.llmRequestHook) {
|
||||
this.llmRequestHook(completionOptions.model, fimLog);
|
||||
|
|
@ -541,7 +547,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
this._logTokensGenerated(completionOptions.model, fimLog, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
if (logEnabled && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
|
|
@ -557,7 +563,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
signal: AbortSignal,
|
||||
options: LLMFullCompletionOptions = {},
|
||||
) {
|
||||
const { completionOptions, log, raw } =
|
||||
const { completionOptions, logEnabled, raw } =
|
||||
this._parseCompletionOptions(options);
|
||||
|
||||
let prompt = pruneRawPromptFromTop(
|
||||
|
|
@ -571,9 +577,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
prompt = this._templatePromptLikeMessages(prompt);
|
||||
}
|
||||
|
||||
if (log) {
|
||||
if (logEnabled) {
|
||||
if (this.writeLog) {
|
||||
await this.writeLog(this._compileLogMessage(prompt, completionOptions));
|
||||
await this.writeLog(
|
||||
this._compilePromptForLog(prompt, completionOptions),
|
||||
);
|
||||
}
|
||||
if (this.llmRequestHook) {
|
||||
this.llmRequestHook(completionOptions.model, prompt);
|
||||
|
|
@ -618,7 +626,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
} finally {
|
||||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
if (logEnabled && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
}
|
||||
|
|
@ -636,7 +644,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
signal: AbortSignal,
|
||||
options: LLMFullCompletionOptions = {},
|
||||
) {
|
||||
const { completionOptions, log, raw } =
|
||||
const { completionOptions, logEnabled, raw } =
|
||||
this._parseCompletionOptions(options);
|
||||
|
||||
let prompt = pruneRawPromptFromTop(
|
||||
|
|
@ -650,9 +658,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
prompt = this._templatePromptLikeMessages(prompt);
|
||||
}
|
||||
|
||||
if (log) {
|
||||
if (logEnabled) {
|
||||
if (this.writeLog) {
|
||||
await this.writeLog(this._compileLogMessage(prompt, completionOptions));
|
||||
await this.writeLog(
|
||||
this._compilePromptForLog(prompt, completionOptions),
|
||||
);
|
||||
}
|
||||
if (this.llmRequestHook) {
|
||||
this.llmRequestHook(completionOptions.model, prompt);
|
||||
|
|
@ -675,7 +685,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
if (logEnabled && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
|
|
@ -719,7 +729,8 @@ export abstract class BaseLLM implements ILLM {
|
|||
signal: AbortSignal,
|
||||
options: LLMFullCompletionOptions = {},
|
||||
): AsyncGenerator<ChatMessage, PromptLog> {
|
||||
let { completionOptions, log } = this._parseCompletionOptions(options);
|
||||
let { completionOptions, logEnabled } =
|
||||
this._parseCompletionOptions(options);
|
||||
|
||||
completionOptions = this._modifyCompletionOptions(completionOptions);
|
||||
|
||||
|
|
@ -728,9 +739,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
const prompt = this.templateMessages
|
||||
? this.templateMessages(messages)
|
||||
: this._formatChatMessages(messages);
|
||||
if (log) {
|
||||
if (logEnabled) {
|
||||
if (this.writeLog) {
|
||||
await this.writeLog(this._compileLogMessage(prompt, completionOptions));
|
||||
await this.writeLog(
|
||||
this._compilePromptForLog(prompt, completionOptions),
|
||||
);
|
||||
}
|
||||
if (this.llmRequestHook) {
|
||||
this.llmRequestHook(completionOptions.model, prompt);
|
||||
|
|
@ -797,7 +810,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
if (logEnabled && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
|
|
|
|||
3479
core/package-lock.json
generated
3479
core/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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.31",
|
||||
"@continuedev/config-yaml": "^1.0.38",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { DevDataLogEvent } from "../../packages/config-yaml/src/schemas/data";
|
||||
import { GlobalContextModelSelections } from "../util/GlobalContext";
|
||||
|
||||
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
|
||||
|
|
@ -46,7 +47,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
"history/delete": [{ id: string }, void];
|
||||
"history/load": [{ id: string }, Session];
|
||||
"history/save": [Session, void];
|
||||
"devdata/log": [{ tableName: string; data: any }, void];
|
||||
"devdata/log": [DevDataLogEvent, void];
|
||||
"config/addOpenAiKey": [string, void];
|
||||
"config/addModel": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
acceptDiff: [{ filepath: string; streamId?: string }, void];
|
||||
rejectDiff: [{ filepath: string; streamId?: string }, void];
|
||||
"edit/sendPrompt": [
|
||||
{ prompt: MessageContent; range: RangeInFileWithContents },
|
||||
void,
|
||||
];
|
||||
"edit/acceptReject": [
|
||||
{ accept: boolean; onlyFirst: boolean; filepath: string },
|
||||
{
|
||||
prompt: MessageContent;
|
||||
range: RangeInFileWithContents;
|
||||
selectedModelTitle: string;
|
||||
},
|
||||
void,
|
||||
];
|
||||
"edit/exit": [{ shouldFocusEditor: boolean }, void];
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
import fs from "fs";
|
||||
|
||||
import { getDevDataFilePath } from "./paths.js";
|
||||
|
||||
export function logDevData(tableName: string, data: any) {
|
||||
const filepath: string = getDevDataFilePath(tableName);
|
||||
const jsonLine = JSON.stringify(data);
|
||||
fs.writeFileSync(filepath, `${jsonLine}\n`, { flag: "a" });
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import dotenv from "dotenv";
|
|||
import { IdeType, SerializedContinueConfig } from "../";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
import { DevEventName } from "../../packages/config-yaml/src/schemas/data";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ export function getContinueRcPath(): string {
|
|||
return continuercPath;
|
||||
}
|
||||
|
||||
export function devDataPath(): string {
|
||||
function getDevDataPath(): string {
|
||||
const sPath = path.join(getContinueGlobalPath(), "dev_data");
|
||||
if (!fs.existsSync(sPath)) {
|
||||
fs.mkdirSync(sPath);
|
||||
|
|
@ -211,11 +212,18 @@ export function devDataPath(): string {
|
|||
}
|
||||
|
||||
export function getDevDataSqlitePath(): string {
|
||||
return path.join(devDataPath(), "devdata.sqlite");
|
||||
return path.join(getDevDataPath(), "devdata.sqlite");
|
||||
}
|
||||
|
||||
export function getDevDataFilePath(fileName: string): string {
|
||||
return path.join(devDataPath(), `${fileName}.jsonl`);
|
||||
export function getDevDataFilePath(
|
||||
eventName: DevEventName,
|
||||
schema: string,
|
||||
): string {
|
||||
const versionPath = path.join(getDevDataPath(), schema);
|
||||
if (!fs.existsSync(versionPath)) {
|
||||
fs.mkdirSync(versionPath);
|
||||
}
|
||||
return path.join(versionPath, `${String(eventName)}.jsonl`);
|
||||
}
|
||||
|
||||
export function editConfigJson(
|
||||
|
|
@ -377,23 +385,33 @@ export function getEsbuildBinaryPath(): string {
|
|||
return path.join(getContinueUtilsPath(), "esbuild");
|
||||
}
|
||||
|
||||
export function getStagingEnvironmentDotFilePath(): string {
|
||||
return path.join(getContinueGlobalPath(), ".staging");
|
||||
export function migrateV1DevDataFiles() {
|
||||
const devDataPath = getDevDataPath();
|
||||
function moveToV1FolderIfExists(
|
||||
oldFileName: string,
|
||||
newFileName: DevEventName,
|
||||
) {
|
||||
const oldFilePath = path.join(devDataPath, `${oldFileName}.jsonl`);
|
||||
if (fs.existsSync(oldFilePath)) {
|
||||
const newFilePath = getDevDataFilePath(newFileName, "0.1.0");
|
||||
if (!fs.existsSync(newFilePath)) {
|
||||
fs.copyFileSync(oldFilePath, newFilePath);
|
||||
fs.unlinkSync(oldFilePath);
|
||||
} else {
|
||||
console.warn(
|
||||
`V1 Dev data migration: ${newFilePath} already exists, skipping ${oldFileName}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
moveToV1FolderIfExists("tokens_generated", "tokensGenerated");
|
||||
moveToV1FolderIfExists("chat", "chatFeedback");
|
||||
moveToV1FolderIfExists("quickEdit", "quickEdit");
|
||||
moveToV1FolderIfExists("autocomplete", "autocomplete");
|
||||
}
|
||||
|
||||
export function setupInitialDotContinueDirectory() {
|
||||
const devDataTypes = [
|
||||
"chat",
|
||||
"autocomplete",
|
||||
"quickEdit",
|
||||
"tokens_generated",
|
||||
];
|
||||
devDataTypes.forEach((p) => {
|
||||
const devDataPath = getDevDataFilePath(p);
|
||||
if (!fs.existsSync(devDataPath)) {
|
||||
fs.writeFileSync(devDataPath, "");
|
||||
}
|
||||
});
|
||||
export function getStagingEnvironmentDotFilePath(): string {
|
||||
return path.join(getContinueGlobalPath(), ".staging");
|
||||
}
|
||||
|
||||
export function getDiffsDirectoryPath(): string {
|
||||
|
|
|
|||
6
extensions/vscode/package-lock.json
generated
6
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.268",
|
||||
"version": "0.9.269",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.268",
|
||||
"version": "0.9.269",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
@ -106,7 +106,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.31",
|
||||
"@continuedev/config-yaml": "^1.0.35",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ import { VerticalDiffManager } from "./diff/vertical/manager";
|
|||
import EditDecorationManager from "./quickEdit/EditDecorationManager";
|
||||
import { QuickEdit, QuickEditShowParams } from "./quickEdit/QuickEditQuickPick";
|
||||
import { Battery } from "./util/battery";
|
||||
import { VsCodeIde } from "./VsCodeIde";
|
||||
import { getMetaKeyLabel } from "./util/util";
|
||||
import { VsCodeIde } from "./VsCodeIde";
|
||||
|
||||
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
import { LOCAL_DEV_DATA_VERSION } from "core/data/log";
|
||||
import { startLocalOllama } from "core/util/ollamaHelper";
|
||||
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
|
||||
let fullScreenPanel: vscode.WebviewPanel | undefined;
|
||||
|
||||
|
|
@ -984,7 +985,10 @@ const getCommandsMap: (
|
|||
});
|
||||
if (feedback) {
|
||||
const client = await continueServerClientPromise;
|
||||
const completionsPath = getDevDataFilePath("autocomplete");
|
||||
const completionsPath = getDevDataFilePath(
|
||||
"autocomplete",
|
||||
LOCAL_DEV_DATA_VERSION,
|
||||
);
|
||||
|
||||
const lastLines = await readLastLines.read(completionsPath, 2);
|
||||
client.sendFeedback(feedback, lastLines);
|
||||
|
|
|
|||
|
|
@ -287,13 +287,10 @@ export class VsCodeMessenger {
|
|||
const prompt = msg.data.prompt;
|
||||
const { start, end } = msg.data.range.range;
|
||||
const verticalDiffManager = await verticalDiffManagerPromise;
|
||||
const modelTitle = await this.webviewProtocol.request(
|
||||
"getDefaultModelTitle",
|
||||
undefined,
|
||||
);
|
||||
|
||||
const fileAfterEdit = await verticalDiffManager.streamEdit(
|
||||
stripImages(prompt),
|
||||
modelTitle,
|
||||
msg.data.selectedModelTitle,
|
||||
"edit",
|
||||
undefined,
|
||||
undefined,
|
||||
|
|
@ -308,30 +305,6 @@ export class VsCodeMessenger {
|
|||
fileAfterEdit,
|
||||
});
|
||||
});
|
||||
this.onWebview("edit/acceptReject", async (msg) => {
|
||||
const { onlyFirst, accept, filepath } = msg.data;
|
||||
if (accept && onlyFirst) {
|
||||
// Accept first
|
||||
vscode.commands.executeCommand(
|
||||
"continue.acceptVerticalDiffBlock",
|
||||
filepath,
|
||||
0,
|
||||
);
|
||||
} else if (accept) {
|
||||
vscode.commands.executeCommand("continue.acceptDiff", filepath);
|
||||
// Accept all
|
||||
} else if (onlyFirst) {
|
||||
// Reject first
|
||||
vscode.commands.executeCommand(
|
||||
"continue.rejectVerticalDiffBlock",
|
||||
filepath,
|
||||
0,
|
||||
);
|
||||
} else {
|
||||
// Reject all
|
||||
vscode.commands.executeCommand("continue.rejectDiff", filepath);
|
||||
}
|
||||
});
|
||||
this.onWebview("edit/exit", async (msg) => {
|
||||
if (msg.data.shouldFocusEditor) {
|
||||
const activeEditor = vscode.window.activeTextEditor;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { IDE } from "core";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { logDevData } from "core/util/devdata";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
|
|
@ -9,6 +8,7 @@ import { VerticalDiffManager } from "../diff/vertical/manager";
|
|||
import { FileSearch } from "../util/FileSearch";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
import { DataLogger } from "core/data/log";
|
||||
import { getContextProviderQuickPickVal } from "./ContextProvidersQuickPick";
|
||||
import { appendToHistory, getHistoryQuickPickVal } from "./HistoryQuickPick";
|
||||
import { getModelQuickPickVal } from "./ModelSelectionQuickPick";
|
||||
|
|
@ -225,13 +225,18 @@ export class QuickEdit {
|
|||
break;
|
||||
}
|
||||
let model = await this.getCurModelTitle();
|
||||
logDevData("quickEdit", {
|
||||
prompt,
|
||||
path,
|
||||
label,
|
||||
diffs: this.verticalDiffManager.logDiffs,
|
||||
model,
|
||||
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "quickEdit",
|
||||
data: {
|
||||
prompt,
|
||||
path,
|
||||
label,
|
||||
diffs: this.verticalDiffManager.logDiffs,
|
||||
model,
|
||||
},
|
||||
});
|
||||
|
||||
quickPick.dispose();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
5018
gui/package-lock.json
generated
5018
gui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -15,7 +15,7 @@
|
|||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.31",
|
||||
"@continuedev/config-yaml": "^1.0.38",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
|
|||
|
|
@ -22,8 +22,12 @@ export default function FeedbackButtons({ item }: FeedbackButtonsProps) {
|
|||
if (item.promptLogs?.length) {
|
||||
for (const promptLog of item.promptLogs) {
|
||||
ideMessenger.post("devdata/log", {
|
||||
tableName: "chat",
|
||||
data: { ...promptLog, feedback, sessionId },
|
||||
name: "chatFeedback",
|
||||
data: {
|
||||
...promptLog,
|
||||
feedback,
|
||||
sessionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export const handleJetBrainsOSRMetaKeyIssues = (
|
|||
|
||||
if (e.key in handlers) {
|
||||
e.stopPropagation();
|
||||
debugger;
|
||||
e.preventDefault();
|
||||
handlers[e.key]();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,6 +338,7 @@ export function Chat() {
|
|||
ideMessenger.post("edit/sendPrompt", {
|
||||
prompt,
|
||||
range: codeToEdit[0] as RangeInFileWithContents,
|
||||
selectedModelTitle,
|
||||
});
|
||||
|
||||
dispatch(submitEdit(prompt));
|
||||
|
|
|
|||
|
|
@ -61,6 +61,34 @@ export const streamNormalInput = createAsyncThunk<
|
|||
// Attach prompt log
|
||||
if (next.done && next.value) {
|
||||
dispatch(addPromptCompletionPair([next.value]));
|
||||
|
||||
try {
|
||||
if (state.session.mode === "chat") {
|
||||
extra.ideMessenger.post("devdata/log", {
|
||||
name: "chatInteraction",
|
||||
data: {
|
||||
prompt: next.value.prompt,
|
||||
completion: next.value.completion,
|
||||
modelProvider: defaultModel.provider,
|
||||
modelTitle: defaultModel.title,
|
||||
sessionId: state.session.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
// else if (state.session.mode === "edit") {
|
||||
// extra.ideMessenger.post("devdata/log", {
|
||||
// name: "editInteraction",
|
||||
// data: {
|
||||
// prompt: next.value.prompt,
|
||||
// completion: next.value.completion,
|
||||
// modelProvider: defaultModel.provider,
|
||||
// modelTitle: defaultModel.title,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
} catch (e) {
|
||||
console.error("Failed to send dev data interaction log", e);
|
||||
}
|
||||
}
|
||||
|
||||
// If it's a tool call that is automatically accepted, we should call it
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export const streamResponseAfterToolCall = createAsyncThunk<
|
|||
content: renderContextItems(toolOutput),
|
||||
toolCallId,
|
||||
};
|
||||
|
||||
debugger;
|
||||
dispatch(streamUpdate([newMessage]));
|
||||
dispatch(
|
||||
addContextItemsAtIndex({
|
||||
|
|
|
|||
338
packages/config-yaml/package-lock.json
generated
338
packages/config-yaml/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.35",
|
||||
"version": "1.0.38",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
@ -12,12 +12,14 @@
|
|||
"author": "Continue Dev, Inc.",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8",
|
||||
"@continuedev/config-types": "^1.0.14"
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.2.3",
|
||||
"ts-node": "^10.9.2"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export * from "./load/getBlockType.js";
|
|||
export * from "./load/merge.js";
|
||||
export * from "./load/proxySecretResolution.js";
|
||||
export * from "./load/unroll.js";
|
||||
export * from "./schemas/data/index.js";
|
||||
export * from "./schemas/index.js";
|
||||
export type { ModelConfig, ModelRole } from "./schemas/models.js";
|
||||
export * from "./validation.js";
|
||||
|
|
|
|||
42
packages/config-yaml/src/schemas/data/autocomplete/index.ts
Normal file
42
packages/config-yaml/src/schemas/data/autocomplete/index.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { z } from "zod";
|
||||
import { completionOptionsSchema } from "../../models.js";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const autocompleteEventAllSchema = baseDevDataAllSchema.extend({
|
||||
// Tab autocomplete options - TODO - old json version?
|
||||
disable: z.boolean(),
|
||||
useFileSuffix: z.boolean(),
|
||||
maxPromptTokens: z.number(),
|
||||
debounceDelay: z.number(),
|
||||
maxSuffixPercentage: z.number(),
|
||||
prefixPercentage: z.number(),
|
||||
transform: z.boolean().optional(),
|
||||
template: z.string().optional(),
|
||||
multilineCompletions: z.enum(["always", "never", "auto"]),
|
||||
slidingWindowPrefixPercentage: z.number(),
|
||||
slidingWindowSize: z.number(),
|
||||
useCache: z.boolean(),
|
||||
onlyMyCode: z.boolean(),
|
||||
useRecentlyEdited: z.boolean(),
|
||||
useImports: z.boolean().optional(),
|
||||
|
||||
// Other
|
||||
accepted: z.boolean().optional(),
|
||||
time: z.number(),
|
||||
prefix: z.string(),
|
||||
suffix: z.string(),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
modelProvider: z.string(),
|
||||
modelName: z.string(),
|
||||
cacheHit: z.boolean(),
|
||||
filepath: z.string(),
|
||||
gitRepo: z.string().optional(),
|
||||
completionId: z.string(),
|
||||
uniqueId: z.string(),
|
||||
timestamp: z.number(),
|
||||
|
||||
// DEPRECATED - no more nested objects after v0.1.0, all flat values
|
||||
completionOptions: completionOptionsSchema.optional(),
|
||||
disableInFiles: z.array(z.string()).optional(),
|
||||
});
|
||||
43
packages/config-yaml/src/schemas/data/autocomplete/v0.1.0.ts
Normal file
43
packages/config-yaml/src/schemas/data/autocomplete/v0.1.0.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { autocompleteEventAllSchema } from "./index.js";
|
||||
|
||||
export const autocompleteEventSchema_0_1_0 = autocompleteEventAllSchema.pick({
|
||||
disable: true,
|
||||
useFileSuffix: true,
|
||||
maxPromptTokens: true,
|
||||
debounceDelay: true,
|
||||
maxSuffixPercentage: true,
|
||||
prefixPercentage: true,
|
||||
transform: true,
|
||||
template: true,
|
||||
multilineCompletions: true,
|
||||
slidingWindowPrefixPercentage: true,
|
||||
slidingWindowSize: true,
|
||||
useCache: true,
|
||||
onlyMyCode: true,
|
||||
useRecentlyEdited: true,
|
||||
disableInFiles: true,
|
||||
useImports: true,
|
||||
accepted: true,
|
||||
time: true,
|
||||
prefix: true,
|
||||
suffix: true,
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelProvider: true,
|
||||
modelName: true,
|
||||
completionOptions: true,
|
||||
cacheHit: true,
|
||||
filepath: true,
|
||||
gitRepo: true,
|
||||
completionId: true,
|
||||
uniqueId: true,
|
||||
timestamp: true,
|
||||
});
|
||||
|
||||
export const autocompleteEventSchema_0_1_0_noCode =
|
||||
autocompleteEventSchema_0_1_0.omit({
|
||||
prefix: true,
|
||||
suffix: true,
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
50
packages/config-yaml/src/schemas/data/autocomplete/v0.2.0.ts
Normal file
50
packages/config-yaml/src/schemas/data/autocomplete/v0.2.0.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { autocompleteEventAllSchema } from "./index.js";
|
||||
|
||||
export const autocompleteEventSchema_0_2_0 = autocompleteEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// autocomplete-specific
|
||||
disable: true,
|
||||
maxPromptTokens: true,
|
||||
debounceDelay: true,
|
||||
maxSuffixPercentage: true,
|
||||
prefixPercentage: true,
|
||||
transform: true,
|
||||
template: true,
|
||||
multilineCompletions: true,
|
||||
slidingWindowPrefixPercentage: true,
|
||||
slidingWindowSize: true,
|
||||
useCache: true,
|
||||
onlyMyCode: true,
|
||||
useRecentlyEdited: true,
|
||||
useImports: true,
|
||||
accepted: true,
|
||||
time: true,
|
||||
prefix: true,
|
||||
suffix: true,
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelProvider: true,
|
||||
modelName: true,
|
||||
cacheHit: true,
|
||||
filepath: true,
|
||||
gitRepo: true,
|
||||
completionId: true,
|
||||
uniqueId: true,
|
||||
|
||||
// Note objects (completionOptions and disableInfiles) removed from 0.1.0 => 0.2.0
|
||||
});
|
||||
|
||||
export const autocompleteEventSchema_0_2_0_noCode =
|
||||
autocompleteEventSchema_0_2_0.omit({
|
||||
prefix: true,
|
||||
suffix: true,
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
11
packages/config-yaml/src/schemas/data/base.ts
Normal file
11
packages/config-yaml/src/schemas/data/base.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const baseDevDataAllSchema = z.object({
|
||||
eventName: z.string(),
|
||||
schema: z.string(),
|
||||
timestamp: z.string().datetime(),
|
||||
userId: z.string(),
|
||||
userAgent: z.string(),
|
||||
selectedProfileId: z.string(),
|
||||
// gitCommitHash: z.string(),
|
||||
});
|
||||
11
packages/config-yaml/src/schemas/data/chatFeedback/index.ts
Normal file
11
packages/config-yaml/src/schemas/data/chatFeedback/index.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { z } from "zod";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const chatFeedbackEventAllSchema = baseDevDataAllSchema.extend({
|
||||
modelTitle: z.string(),
|
||||
completionOptions: z.object({}),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
feedback: z.boolean().optional(),
|
||||
sessionId: z.string().uuid(),
|
||||
});
|
||||
16
packages/config-yaml/src/schemas/data/chatFeedback/v0.1.0.ts
Normal file
16
packages/config-yaml/src/schemas/data/chatFeedback/v0.1.0.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { chatFeedbackEventAllSchema } from "./index.js";
|
||||
|
||||
export const chatFeedbackEventSchema_0_1_0 = chatFeedbackEventAllSchema.pick({
|
||||
modelTitle: true,
|
||||
completionOptions: true,
|
||||
prompt: true,
|
||||
completion: true,
|
||||
feedback: true,
|
||||
sessionId: true,
|
||||
});
|
||||
|
||||
export const chatFeedbackEventSchema_0_1_0_noCode =
|
||||
chatFeedbackEventSchema_0_1_0.omit({
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
24
packages/config-yaml/src/schemas/data/chatFeedback/v0.2.0.ts
Normal file
24
packages/config-yaml/src/schemas/data/chatFeedback/v0.2.0.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { chatFeedbackEventAllSchema } from "./index.js";
|
||||
|
||||
export const chatFeedbackEventSchema_0_2_0 = chatFeedbackEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// other
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelTitle: true,
|
||||
feedback: true,
|
||||
sessionId: true,
|
||||
});
|
||||
|
||||
export const chatFeedbackEventSchema_0_2_0_noCode =
|
||||
chatFeedbackEventSchema_0_2_0.omit({
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import { z } from "zod";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const chatInteractionEventAllSchema = baseDevDataAllSchema.extend({
|
||||
modelProvider: z.string(),
|
||||
modelTitle: z.string(),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
sessionId: z.string(),
|
||||
});
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { chatInteractionEventAllSchema } from "./index.js";
|
||||
|
||||
export const chatInteractionEventSchema_0_2_0 =
|
||||
chatInteractionEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// other
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelTitle: true,
|
||||
modelProvider: true,
|
||||
sessionId: true,
|
||||
});
|
||||
|
||||
export const chatInteractionEventSchema_0_2_0_noCode =
|
||||
chatInteractionEventSchema_0_2_0.omit({
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const editInteractionEventAllSchema = baseDevDataAllSchema.extend({
|
||||
modelProvider: z.string(),
|
||||
modelTitle: z.string(),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
});
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import { editInteractionEventAllSchema } from "./index.js";
|
||||
|
||||
export const editInteractionEventSchema_0_2_0 =
|
||||
editInteractionEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// other
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelTitle: true,
|
||||
modelProvider: true,
|
||||
});
|
||||
|
||||
export const editInteractionEventSchema_0_2_0_noCode =
|
||||
editInteractionEventSchema_0_2_0.omit({
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
15
packages/config-yaml/src/schemas/data/editOutcome/index.ts
Normal file
15
packages/config-yaml/src/schemas/data/editOutcome/index.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { z } from "zod";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const editOutcomeEventAllSchema = baseDevDataAllSchema.extend({
|
||||
modelProvider: z.string(),
|
||||
modelTitle: z.string(),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
previousCode: z.string(),
|
||||
newCode: z.string(),
|
||||
previousCodeLines: z.number(),
|
||||
newCodeLines: z.number(),
|
||||
lineChange: z.number(),
|
||||
accepted: z.boolean(),
|
||||
});
|
||||
24
packages/config-yaml/src/schemas/data/editOutcome/v0.2.0.ts
Normal file
24
packages/config-yaml/src/schemas/data/editOutcome/v0.2.0.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { editOutcomeEventAllSchema } from "./index.js";
|
||||
|
||||
export const editOutcomeEventSchema_0_2_0 = editOutcomeEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// other
|
||||
prompt: true,
|
||||
completion: true,
|
||||
modelTitle: true,
|
||||
modelProvider: true,
|
||||
accepted: true,
|
||||
});
|
||||
|
||||
export const editOutcomeEventSchema_0_2_0_noCode =
|
||||
editOutcomeEventSchema_0_2_0.omit({
|
||||
prompt: true,
|
||||
completion: true,
|
||||
});
|
||||
128
packages/config-yaml/src/schemas/data/index.ts
Normal file
128
packages/config-yaml/src/schemas/data/index.ts
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import { z } from "zod";
|
||||
import { autocompleteEventAllSchema } from "./autocomplete/index.js";
|
||||
import { requestOptionsSchema } from "../models.js";
|
||||
import {
|
||||
autocompleteEventSchema_0_1_0,
|
||||
autocompleteEventSchema_0_1_0_noCode,
|
||||
} from "./autocomplete/v0.1.0.js";
|
||||
import {
|
||||
quickEditEventSchema_0_1_0,
|
||||
quickEditEventSchema_0_1_0_noCode,
|
||||
} from "./quickEdit/v0.1.0.js";
|
||||
import {
|
||||
autocompleteEventSchema_0_2_0,
|
||||
autocompleteEventSchema_0_2_0_noCode,
|
||||
} from "./autocomplete/v0.2.0.js";
|
||||
import { quickEditEventAllSchema } from "./quickEdit/index.js";
|
||||
import { chatFeedbackEventAllSchema } from "./chatFeedback/index.js";
|
||||
import { tokensGeneratedEventAllSchema } from "./tokensGenerated/index.js";
|
||||
import {
|
||||
chatFeedbackEventSchema_0_1_0,
|
||||
chatFeedbackEventSchema_0_1_0_noCode,
|
||||
} from "./chatFeedback/v0.1.0.js";
|
||||
import {
|
||||
tokensGeneratedEventSchema_0_1_0,
|
||||
tokensGeneratedEventSchema_0_1_0_noCode,
|
||||
} from "./tokensGenerated/v0.1.0.js";
|
||||
import {
|
||||
chatFeedbackEventSchema_0_2_0,
|
||||
chatFeedbackEventSchema_0_2_0_noCode,
|
||||
} from "./chatFeedback/v0.2.0.js";
|
||||
import {
|
||||
tokensGeneratedEventSchema_0_2_0,
|
||||
tokensGeneratedEventSchema_0_2_0_noCode,
|
||||
} from "./tokensGenerated/v0.2.0.js";
|
||||
import { chatInteractionEventAllSchema } from "./chatInteraction/index.js";
|
||||
import {
|
||||
chatInteractionEventSchema_0_2_0,
|
||||
chatInteractionEventSchema_0_2_0_noCode,
|
||||
} from "./chatInteraction/v0.2.0.js";
|
||||
import { editInteractionEventAllSchema } from "./editInteraction/index.js";
|
||||
|
||||
const semverRegex =
|
||||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
||||
|
||||
const dataLevel = z.union([z.literal("all"), z.literal("noCode")]);
|
||||
|
||||
export const dataSchema = z.object({
|
||||
name: z.string(),
|
||||
destination: z.string().url(),
|
||||
schema: z.string().regex(semverRegex, {
|
||||
message: "Version must follow semver format, e.g. 0.2.0",
|
||||
}),
|
||||
level: dataLevel.optional(),
|
||||
events: z.array(z.string()).optional(), // Could do literals e.g. "autocomplete", "chat" but want to allow some flexibility later
|
||||
requestOptions: requestOptionsSchema.optional(),
|
||||
apiKey: z.string().optional(),
|
||||
});
|
||||
|
||||
export type DataDestination = z.infer<typeof dataSchema>;
|
||||
export type DataLogLevel = z.infer<typeof dataLevel>;
|
||||
|
||||
// Schemas for data that the log function should have
|
||||
// In order to build event bodies for ALL versions of an event
|
||||
const devEventAllVersionDataSchemas = z.object({
|
||||
autocomplete: autocompleteEventAllSchema,
|
||||
quickEdit: quickEditEventAllSchema,
|
||||
chatFeedback: chatFeedbackEventAllSchema,
|
||||
tokensGenerated: tokensGeneratedEventAllSchema,
|
||||
chatInteraction: chatInteractionEventAllSchema,
|
||||
// editInteraction: editInteractionEventAllSchema,
|
||||
});
|
||||
|
||||
// Version and level specific schemas are organized here
|
||||
export const devDataVersionedSchemas = {
|
||||
["0.1.0" as string]: {
|
||||
all: {
|
||||
autocomplete: autocompleteEventSchema_0_1_0,
|
||||
quickEdit: quickEditEventSchema_0_1_0,
|
||||
chatFeedback: chatFeedbackEventSchema_0_1_0,
|
||||
tokensGenerated: tokensGeneratedEventSchema_0_1_0,
|
||||
},
|
||||
noCode: {
|
||||
autocomplete: autocompleteEventSchema_0_1_0_noCode,
|
||||
quickEdit: quickEditEventSchema_0_1_0_noCode,
|
||||
chatFeedback: chatFeedbackEventSchema_0_1_0_noCode,
|
||||
tokensGenerated: tokensGeneratedEventSchema_0_1_0_noCode,
|
||||
},
|
||||
},
|
||||
["0.2.0" as string]: {
|
||||
all: {
|
||||
autocomplete: autocompleteEventSchema_0_2_0,
|
||||
chatFeedback: chatFeedbackEventSchema_0_2_0,
|
||||
tokensGenerated: tokensGeneratedEventSchema_0_2_0,
|
||||
chatInteraction: chatInteractionEventSchema_0_2_0,
|
||||
// editInteraction: editInteractionEventSchema_0_2_0,
|
||||
},
|
||||
noCode: {
|
||||
autocomplete: autocompleteEventSchema_0_2_0_noCode,
|
||||
chatFeedback: chatFeedbackEventSchema_0_2_0_noCode,
|
||||
tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode,
|
||||
chatInteraction: chatInteractionEventSchema_0_2_0_noCode,
|
||||
// editInteraction: editInteractionEventSchema_0_2_0_noCode,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
type DevEventDataSchemas = z.infer<typeof devEventAllVersionDataSchemas>;
|
||||
export type DevEventName = keyof DevEventDataSchemas;
|
||||
type DevEventAllVersionsSchema<T extends DevEventName> = DevEventDataSchemas[T];
|
||||
|
||||
export type DevDataLogEvent = {
|
||||
[K in DevEventName]: {
|
||||
name: K;
|
||||
data: Omit<
|
||||
DevEventAllVersionsSchema<K>,
|
||||
| "eventName"
|
||||
| "schema"
|
||||
| "timestamp"
|
||||
| "userId"
|
||||
| "userAgent"
|
||||
| "selectedProfileId"
|
||||
>;
|
||||
};
|
||||
}[DevEventName];
|
||||
|
||||
export const allDevEventNames = Object.keys(
|
||||
devEventAllVersionDataSchemas.shape,
|
||||
) as DevEventName[];
|
||||
16
packages/config-yaml/src/schemas/data/quickEdit/index.ts
Normal file
16
packages/config-yaml/src/schemas/data/quickEdit/index.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const quickEditEventAllSchema = z.object({
|
||||
prompt: z.string(),
|
||||
path: z.string().optional(),
|
||||
label: z.string(),
|
||||
diffs: z
|
||||
.array(
|
||||
z.object({
|
||||
type: z.enum(["new", "old", "same"]),
|
||||
line: z.string(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
model: z.string().optional(),
|
||||
});
|
||||
16
packages/config-yaml/src/schemas/data/quickEdit/v0.1.0.ts
Normal file
16
packages/config-yaml/src/schemas/data/quickEdit/v0.1.0.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { quickEditEventAllSchema } from "./index.js";
|
||||
|
||||
export const quickEditEventSchema_0_1_0 = quickEditEventAllSchema.pick({
|
||||
prompt: true,
|
||||
path: true,
|
||||
label: true,
|
||||
diffs: true,
|
||||
model: true,
|
||||
});
|
||||
|
||||
export const quickEditEventSchema_0_1_0_noCode =
|
||||
quickEditEventSchema_0_1_0.omit({
|
||||
prompt: true,
|
||||
path: true,
|
||||
diffs: true,
|
||||
});
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { baseDevDataAllSchema } from "../base.js";
|
||||
|
||||
export const tokensGeneratedEventAllSchema = baseDevDataAllSchema.extend({
|
||||
model: z.string(),
|
||||
provider: z.string(),
|
||||
promptTokens: z.number(),
|
||||
generatedTokens: z.number(),
|
||||
});
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import { tokensGeneratedEventAllSchema } from "./index.js";
|
||||
|
||||
export const tokensGeneratedEventSchema_0_1_0 =
|
||||
tokensGeneratedEventAllSchema.pick({
|
||||
model: true,
|
||||
provider: true,
|
||||
promptTokens: true,
|
||||
generatedTokens: true,
|
||||
});
|
||||
|
||||
export const tokensGeneratedEventSchema_0_1_0_noCode =
|
||||
tokensGeneratedEventSchema_0_1_0;
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import { tokensGeneratedEventAllSchema } from "./index.js";
|
||||
|
||||
export const tokensGeneratedEventSchema_0_2_0 =
|
||||
tokensGeneratedEventAllSchema.pick({
|
||||
// base
|
||||
timestamp: true,
|
||||
userId: true,
|
||||
userAgent: true,
|
||||
selectedProfileId: true,
|
||||
eventName: true,
|
||||
schema: true,
|
||||
|
||||
// tokens generated specific
|
||||
model: true,
|
||||
provider: true,
|
||||
promptTokens: true,
|
||||
generatedTokens: true,
|
||||
});
|
||||
|
||||
export const tokensGeneratedEventSchema_0_2_0_noCode =
|
||||
tokensGeneratedEventSchema_0_2_0;
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
import * as z from "zod";
|
||||
import { modelSchema, partialModelSchema } from "./models.js";
|
||||
|
||||
export const dataSchema = z.object({
|
||||
destination: z.string(),
|
||||
levels: z.string().optional(),
|
||||
});
|
||||
import { dataSchema } from "./data/index.js";
|
||||
|
||||
export const contextSchema = z.object({
|
||||
provider: z.string(),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"dependencies": {
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"@continuedev/config-yaml": "^1.0.31",
|
||||
"@continuedev/config-yaml": "^1.0.32",
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue