Run prettier on everything (#104)
This commit is contained in:
@@ -35,7 +35,7 @@ export function getFilesRecursively(dir: string, baseDir: string): string[] {
|
||||
|
||||
export async function copyDirectoryRecursive(
|
||||
source: string,
|
||||
destination: string
|
||||
destination: string,
|
||||
) {
|
||||
await fsPromises.mkdir(destination, { recursive: true });
|
||||
const entries = await fsPromises.readdir(source, { withFileTypes: true });
|
||||
|
||||
@@ -17,7 +17,7 @@ import log from "electron-log";
|
||||
const logger = log.scope("getModelClient");
|
||||
export function getModelClient(
|
||||
model: LargeLanguageModel,
|
||||
settings: UserSettings
|
||||
settings: UserSettings,
|
||||
) {
|
||||
const dyadApiKey = settings.providerSettings?.auto?.apiKey?.value;
|
||||
// Handle 'auto' provider by trying each model in AUTO_MODELS until one works
|
||||
@@ -31,7 +31,7 @@ export function getModelClient(
|
||||
|
||||
if (apiKey) {
|
||||
logger.log(
|
||||
`Using provider: ${autoModel.provider} model: ${autoModel.name}`
|
||||
`Using provider: ${autoModel.provider} model: ${autoModel.name}`,
|
||||
);
|
||||
// Use the first model that has an API key
|
||||
return getModelClient(
|
||||
@@ -39,7 +39,7 @@ export function getModelClient(
|
||||
provider: autoModel.provider,
|
||||
name: autoModel.name,
|
||||
} as LargeLanguageModel,
|
||||
settings
|
||||
settings,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ const DEFAULT_MAX_TOKENS = 8_000;
|
||||
export function getMaxTokens(model: LargeLanguageModel) {
|
||||
if (!MODEL_OPTIONS[model.provider as keyof typeof MODEL_OPTIONS]) {
|
||||
logger.warn(
|
||||
`Model provider ${model.provider} not found in MODEL_OPTIONS. Using default max tokens.`
|
||||
`Model provider ${model.provider} not found in MODEL_OPTIONS. Using default max tokens.`,
|
||||
);
|
||||
return DEFAULT_MAX_TOKENS;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export function acquireLock(lockId: number | string): {
|
||||
*/
|
||||
export async function withLock<T>(
|
||||
lockId: number | string,
|
||||
fn: () => Promise<T>
|
||||
fn: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
// Wait for any existing operation to complete
|
||||
const existingLock = locks.get(lockId);
|
||||
|
||||
@@ -36,7 +36,7 @@ export function killProcess(process: ChildProcess): Promise<void> {
|
||||
// Add timeout to prevent hanging
|
||||
const timeout = setTimeout(() => {
|
||||
console.warn(
|
||||
`Timeout waiting for process (PID: ${process.pid}) to close. Force killing may be needed.`
|
||||
`Timeout waiting for process (PID: ${process.pid}) to close. Force killing may be needed.`,
|
||||
);
|
||||
resolve();
|
||||
}, 5000); // 5-second timeout
|
||||
@@ -44,7 +44,7 @@ export function killProcess(process: ChildProcess): Promise<void> {
|
||||
process.on("close", (code, signal) => {
|
||||
clearTimeout(timeout);
|
||||
console.log(
|
||||
`Received 'close' event for process (PID: ${process.pid}) with code ${code}, signal ${signal}.`
|
||||
`Received 'close' event for process (PID: ${process.pid}) with code ${code}, signal ${signal}.`,
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
@@ -53,7 +53,7 @@ export function killProcess(process: ChildProcess): Promise<void> {
|
||||
process.on("error", (err) => {
|
||||
clearTimeout(timeout);
|
||||
console.error(
|
||||
`Error during stop sequence for process (PID: ${process.pid}): ${err.message}`
|
||||
`Error during stop sequence for process (PID: ${process.pid}): ${err.message}`,
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
@@ -62,16 +62,16 @@ export function killProcess(process: ChildProcess): Promise<void> {
|
||||
if (process.pid) {
|
||||
// Use tree-kill to terminate the entire process tree
|
||||
console.log(
|
||||
`Attempting to tree-kill process tree starting at PID ${process.pid}.`
|
||||
`Attempting to tree-kill process tree starting at PID ${process.pid}.`,
|
||||
);
|
||||
treeKill(process.pid, "SIGTERM", (err: Error | undefined) => {
|
||||
if (err) {
|
||||
console.warn(
|
||||
`tree-kill error for PID ${process.pid}: ${err.message}`
|
||||
`tree-kill error for PID ${process.pid}: ${err.message}`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`tree-kill signal sent successfully to PID ${process.pid}.`
|
||||
`tree-kill signal sent successfully to PID ${process.pid}.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -88,17 +88,17 @@ export function killProcess(process: ChildProcess): Promise<void> {
|
||||
*/
|
||||
export function removeAppIfCurrentProcess(
|
||||
appId: number,
|
||||
process: ChildProcess
|
||||
process: ChildProcess,
|
||||
): void {
|
||||
const currentAppInfo = runningApps.get(appId);
|
||||
if (currentAppInfo && currentAppInfo.process === process) {
|
||||
runningApps.delete(appId);
|
||||
console.log(
|
||||
`Removed app ${appId} (processId ${currentAppInfo.processId}) from running map. Current size: ${runningApps.size}`
|
||||
`Removed app ${appId} (processId ${currentAppInfo.processId}) from running map. Current size: ${runningApps.size}`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`App ${appId} process was already removed or replaced in running map. Ignoring.`
|
||||
`App ${appId} process was already removed or replaced in running map. Ignoring.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function runShellCommand(command: string): Promise<string | null> {
|
||||
process.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
logger.debug(
|
||||
`Command "${command}" succeeded with code ${code}: ${output.trim()}`
|
||||
`Command "${command}" succeeded with code ${code}: ${output.trim()}`,
|
||||
);
|
||||
resolve(output.trim()); // Command succeeded, return trimmed output
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const estimateTokens = (text: string): number => {
|
||||
export const estimateMessagesTokens = (messages: Message[]): number => {
|
||||
return messages.reduce(
|
||||
(acc, message) => acc + estimateTokens(message.content),
|
||||
0
|
||||
0,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ export function getContextWindow() {
|
||||
const model = settings.selectedModel;
|
||||
if (!MODEL_OPTIONS[model.provider as keyof typeof MODEL_OPTIONS]) {
|
||||
logger.warn(
|
||||
`Model provider ${model.provider} not found in MODEL_OPTIONS. Using default max tokens.`
|
||||
`Model provider ${model.provider} not found in MODEL_OPTIONS. Using default max tokens.`,
|
||||
);
|
||||
return DEFAULT_CONTEXT_WINDOW;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user