Skip to content

Commit e6c33a2

Browse files
committed
feat(config): add quick and interactive model configuration
1 parent 28ff2ce commit e6c33a2

6 files changed

Lines changed: 124 additions & 24 deletions

File tree

.taskmaster/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"fallback": {
1616
"provider": "gemini-cli",
17-
"modelId": "gemini-2.5-pro",
17+
"modelId": "gemini-2.5-flash",
1818
"maxTokens": 65536,
1919
"temperature": 0.2
2020
}

src/constants/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const TASKMASTER_INIT_MSG = "TaskMaster AI Core initialized";
6161
export const TASKS_FILE_WARN: (path: string) => string = (path: string) =>
6262
`tasks.json not found at "${path}". Please generate tasks from PRD first.`;
6363

64-
// Supported languages for TMAI responses
64+
// supported languages for TMAI responses
6565
export const LANG = [
6666
"English",
6767
"French",
@@ -72,3 +72,9 @@ export const LANG = [
7272
"Chinese",
7373
"Japanese",
7474
] as const;
75+
76+
// ai models configuration
77+
export const AI_MODELS = [
78+
{ name: "Gemini 2.5 Pro", value: "gemini-2.5-pro" },
79+
{ name: "Gemini 2.5 Flash", value: "gemini-2.5-flash" },
80+
];

src/core/taskmaster/TaskMaster.ts

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ import {
2727
readJsonFileAsync,
2828
} from "@/utils/extras";
2929

30-
/* asks */
31-
import { askLangAsync } from "@/core/taskmaster/asks";
32-
3330
/* types */
3431
import type { T_PackageManager } from "@/@types/index";
3532
import type { I_Tasks, Status, Priority } from "@/@types/tasks";
@@ -326,21 +323,6 @@ export class TaskMaster {
326323
}, oraOptions);
327324
}
328325

329-
// TODO: done
330-
/**
331-
* @description Sets the response language for TMAI
332-
* @param lang Language to set for TMAI responses
333-
*/
334-
public async setLangAsync(lang: string): Promise<void> {
335-
await this.executeCommandAsync(
336-
`Setting TMAI response language to ${chalk.bold(lang)}...`,
337-
`Language set to ${lang} successfully!`,
338-
`Failed to set language to ${lang}`,
339-
this._mainCommand,
340-
["lang", `--response=${lang}`],
341-
);
342-
}
343-
344326
// TODO: done
345327
/**
346328
* @description Initializes the task-master AI by creating a PRD file
@@ -370,7 +352,7 @@ export class TaskMaster {
370352
/**
371353
* @description Configures AI models for task-master by running the interactive setup
372354
*/
373-
public async configAsync(): Promise<void> {
355+
public async interactiveConfigModelAsync(): Promise<void> {
374356
await this.executeCommandAsync(
375357
"Configuring AI models...",
376358
"AI models configured successfully!",
@@ -380,6 +362,61 @@ export class TaskMaster {
380362
);
381363
}
382364

365+
// TODO: done
366+
/**
367+
* @description Configures AI models with specified models
368+
* @param mainModel The main AI model to use
369+
* @param researchModel The research AI model to use
370+
* @param fallbackModel The fallback AI model to use
371+
*/
372+
public async configModelsAsync(
373+
mainModel: string,
374+
researchModel: string,
375+
fallbackModel: string,
376+
): Promise<void> {
377+
const oraOptions = {
378+
text: "Configuring AI models...",
379+
successText: chalk.bgGreen("AI models configured successfully!"),
380+
failText: chalk.bgRed("AI model configuration failed"),
381+
};
382+
383+
await oraPromise(async () => {
384+
await runCommandAsync(
385+
this._mainCommand,
386+
["models", "--set-main", mainModel],
387+
false,
388+
false,
389+
);
390+
await runCommandAsync(
391+
this._mainCommand,
392+
["models", "--set-research", researchModel],
393+
false,
394+
false,
395+
);
396+
await runCommandAsync(
397+
this._mainCommand,
398+
["models", "--set-fallback", fallbackModel],
399+
false,
400+
false,
401+
);
402+
}, oraOptions);
403+
}
404+
405+
// TODO: done
406+
/**
407+
* @description Sets the response language for TMAI
408+
* @param lang Language to set for TMAI responses
409+
*/
410+
public async setLangAsync(lang: string): Promise<void> {
411+
await this.executeCommandAsync(
412+
`Setting TMAI response language to ${chalk.bold(lang)}...`,
413+
`Language set to ${lang} successfully!`,
414+
`Failed to set language to ${lang}`,
415+
this._mainCommand,
416+
["lang", `--response=${lang}`],
417+
);
418+
}
419+
383420
// ==============================================
384421
// Method for Generation and Decomposition
385422
// ==============================================

src/core/taskmaster/asks.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
PRD_PATH,
2222
TASKS_STATUSES,
2323
TASKS_BCK_DEST_PATH,
24+
AI_MODELS,
2425
} from "@/constants";
2526

2627
/* utils */
@@ -479,3 +480,47 @@ export async function askLangAsync(): Promise<string> {
479480
});
480481
return lang;
481482
}
483+
484+
/**
485+
* @description Prompts the user to select AI models for main, research, and fallback
486+
* Note: This list is designed for faster TMAI testing using free or generously quota'd models.
487+
* For a wider selection, use the standard interactive configuration mode.
488+
*/
489+
export async function askModelsAsync(): Promise<{
490+
mainModel: string;
491+
researchModel: string;
492+
fallbackModel: string;
493+
}> {
494+
console.log(
495+
chalk.blue(
496+
"Note: This list is optimized for quicker TMAI testing with free or high-quota models. These models are fully suitable for real projects too. For more options, use the standard interactive configuration mode.",
497+
),
498+
);
499+
500+
const { mainModel, researchModel, fallbackModel } = await inquirer.prompt<{
501+
mainModel: string;
502+
researchModel: string;
503+
fallbackModel: string;
504+
}>([
505+
{
506+
type: "list",
507+
name: "mainModel",
508+
message: "Select the main AI model:",
509+
choices: AI_MODELS,
510+
},
511+
{
512+
type: "list",
513+
name: "researchModel",
514+
message: "Select the research AI model:",
515+
choices: AI_MODELS,
516+
},
517+
{
518+
type: "list",
519+
name: "fallbackModel",
520+
message: "Select the fallback AI model:",
521+
choices: AI_MODELS,
522+
},
523+
]);
524+
525+
return { mainModel, researchModel, fallbackModel };
526+
}

src/core/taskmaster/exec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
askHybridTaskIdAsync,
3232
askMultipleTaskIdAsync,
3333
askLangAsync,
34+
askModelsAsync,
3435
} from "@/core/taskmaster/asks";
3536

3637
import chalk from "chalk";
@@ -65,8 +66,11 @@ export async function tmaiInitAsync() {
6566
await tmai.installAsync();
6667
} else if (choice.tmaiInitMenu === "tmai-init") {
6768
await tmai.initAsync();
69+
} else if (choice.tmaiInitMenu === "tmai-interactive-config") {
70+
await tmai.interactiveConfigModelAsync();
6871
} else if (choice.tmaiInitMenu === "tmai-config") {
69-
await tmai.configAsync();
72+
const { mainModel, researchModel, fallbackModel } = await askModelsAsync();
73+
await tmai.configModelsAsync(mainModel, researchModel, fallbackModel);
7074
} else if (choice.tmaiInitMenu === "tmai-lang") {
7175
const lang = await askLangAsync();
7276
await tmai.setLangAsync(lang);

src/prompt.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ export const tmaiInitMenu_prompt = [
8888
value: "tmai-init",
8989
},
9090
{
91-
name: `${emoji.get("wrench")} 3 - Configure AI models`,
91+
name: `${emoji.get(
92+
"wrench",
93+
)} 3 - Configure AI models (interactive mode)`,
94+
value: "tmai-interactive-config",
95+
},
96+
{
97+
name: `${emoji.get("fast_forward")} 4 - Configure AI models (quickly)`,
9298
value: "tmai-config",
9399
},
94100
{
95-
name: `${emoji.get("globe_with_meridians")} 4 - Set the response language for AI-generated content in TMAI`,
101+
name: `${emoji.get(
102+
"globe_with_meridians",
103+
)} 5 - Set the response language for AI-generated content in TMAI`,
96104
value: "tmai-lang",
97105
},
98106
],

0 commit comments

Comments
 (0)