Skip to content

Commit 8ca7e3e

Browse files
committed
Improve sync command
1 parent cc3d69b commit 8ca7e3e

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/config/migrations.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
*/
44

55
import * as p from "@clack/prompts";
6-
import { getAgentMetadata } from "../agents/metadata";
6+
import type { Platform } from "../adapters/types";
7+
import { detectInstalledAgents, getAgentMetadata } from "../agents/metadata";
78
import { getConfig, setConfig } from "./manager";
89
import type { GlobalConfig } from "./types";
9-
import { SUPPORTED_AGENTS } from "./types";
1010

1111
export async function checkAndMigrateConfig(
1212
silent: boolean = false,
1313
): Promise<void> {
1414
try {
1515
const config = getConfig();
16-
const missing = findMissingConfigs(config);
16+
const platform = getPlatform();
17+
const missing = findMissingConfigs(config, platform);
1718

1819
if (missing.length === 0) {
1920
return;
@@ -46,22 +47,18 @@ export async function checkAndMigrateConfig(
4647
}
4748
}
4849

49-
function findMissingConfigs(config: GlobalConfig): string[] {
50-
const missing: string[] = [];
51-
52-
for (const id of SUPPORTED_AGENTS) {
53-
if (!config.agents.includes(id)) {
54-
missing.push(id);
55-
}
56-
}
57-
58-
return missing;
50+
function findMissingConfigs(
51+
config: GlobalConfig,
52+
platform: Platform,
53+
): string[] {
54+
const installedAgents = detectInstalledAgents(platform);
55+
return installedAgents.filter((id) => !config.agents.includes(id));
5956
}
6057

6158
export function hasNewConfigsAvailable(): boolean {
6259
try {
6360
const config = getConfig();
64-
const missing = findMissingConfigs(config);
61+
const missing = findMissingConfigs(config, getPlatform());
6562
return missing.length > 0;
6663
} catch {
6764
return false;
@@ -71,8 +68,18 @@ export function hasNewConfigsAvailable(): boolean {
7168
export function getNewConfigsAvailable(): string[] {
7269
try {
7370
const config = getConfig();
74-
return findMissingConfigs(config);
71+
return findMissingConfigs(config, getPlatform());
7572
} catch {
7673
return [];
7774
}
7875
}
76+
77+
function getPlatform(): Platform {
78+
if (process.platform === "darwin") {
79+
return "macos";
80+
}
81+
if (process.platform === "win32") {
82+
return "windows";
83+
}
84+
return "linux";
85+
}

0 commit comments

Comments
 (0)