Skip to content

Commit 51db2f6

Browse files
fix: auto-detect installed CLI when aiTools config is missing
When config.json has no aiTools (setup predates tool selection or was skipped), sync now scans for installed CLIs and prompts the user to pick one instead of immediately falling back to prompts mode.
1 parent 7a67312 commit 51db2f6

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/sync/index.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,32 @@ function runToolInteractive(tool: AiTool, brief: string, cwd: string): boolean {
4141
/** Pick which AI tool to use for interactive sync */
4242
async function pickSyncTool(configuredTools: AiTool[]): Promise<AiTool | null> {
4343
// Filter to tools that have a CLI and are installed
44-
const available = configuredTools.filter((t) => {
44+
let available = configuredTools.filter((t) => {
4545
const meta = AI_TOOLS[t];
4646
return meta.cli && hasCliTool(meta.cli);
4747
});
4848

49-
if (available.length === 0) return null;
49+
// If no configured tools matched, scan for any installed CLI and ask user
50+
if (available.length === 0) {
51+
const detected = (Object.keys(AI_TOOLS) as AiTool[]).filter((t) => {
52+
const meta = AI_TOOLS[t];
53+
return meta.cli && hasCliTool(meta.cli);
54+
});
55+
56+
if (detected.length === 0) return null;
57+
58+
console.log(chalk.yellow("\nNo AI tool configured — but found installed CLI(s):"));
59+
console.log();
60+
detected.forEach((t, i) => {
61+
console.log(` ${i + 1}) ${AI_TOOLS[t].name}`);
62+
});
63+
console.log();
64+
65+
const choice = await askUser(`Which one should we use? [1-${detected.length}] (default: 1): `);
66+
const idx = parseInt(choice || "1", 10) - 1;
67+
return detected[idx] ?? detected[0];
68+
}
69+
5070
if (available.length === 1) return available[0];
5171

5272
// Multiple CLI tools available — ask user

0 commit comments

Comments
 (0)