mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2025-07-06 08:31:04 +00:00

* feat: Support custom response language * fix: Add default values for response language in config-manager.js * chore: Update configuration file and add default response language settings * feat: Support MCP/CLI custom response language * chore: Update test comments to English for consistency * docs: Auto-update and format models.md * chore: fix format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
95 lines
2.0 KiB
JavaScript
95 lines
2.0 KiB
JavaScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import {
|
|
getConfig,
|
|
isConfigFilePresent,
|
|
writeConfig
|
|
} from '../config-manager.js';
|
|
|
|
function setResponseLanguage(lang, options = {}) {
|
|
const { mcpLog, projectRoot } = options;
|
|
|
|
const report = (level, ...args) => {
|
|
if (mcpLog && typeof mcpLog[level] === 'function') {
|
|
mcpLog[level](...args);
|
|
}
|
|
};
|
|
|
|
let configPath;
|
|
let configExists = false;
|
|
|
|
if (projectRoot) {
|
|
configPath = path.join(projectRoot, '.taskmasterconfig');
|
|
configExists = fs.existsSync(configPath);
|
|
report(
|
|
'info',
|
|
`Checking for .taskmasterconfig at: ${configPath}, exists: ${configExists}`
|
|
);
|
|
} else {
|
|
configExists = isConfigFilePresent();
|
|
report(
|
|
'info',
|
|
`Checking for .taskmasterconfig using isConfigFilePresent(), exists: ${configExists}`
|
|
);
|
|
}
|
|
|
|
if (!configExists) {
|
|
return {
|
|
success: false,
|
|
error: {
|
|
code: 'CONFIG_MISSING',
|
|
message:
|
|
'The .taskmasterconfig file is missing. Run "task-master models --setup" to create it.'
|
|
}
|
|
};
|
|
}
|
|
|
|
// Validate response language
|
|
if (typeof lang !== 'string' || lang.trim() === '') {
|
|
return {
|
|
success: false,
|
|
error: {
|
|
code: 'INVALID_RESPONSE_LANGUAGE',
|
|
message: `Invalid response language: ${lang}. Must be a non-empty string.`
|
|
}
|
|
};
|
|
}
|
|
|
|
try {
|
|
const currentConfig = getConfig(projectRoot);
|
|
currentConfig.global.responseLanguage = lang;
|
|
const writeResult = writeConfig(currentConfig, projectRoot);
|
|
|
|
if (!writeResult) {
|
|
return {
|
|
success: false,
|
|
error: {
|
|
code: 'WRITE_ERROR',
|
|
message: 'Error writing updated configuration to .taskmasterconfig'
|
|
}
|
|
};
|
|
}
|
|
|
|
const successMessage = `Successfully set response language to: ${lang}`;
|
|
report('info', successMessage);
|
|
return {
|
|
success: true,
|
|
data: {
|
|
responseLanguage: lang,
|
|
message: successMessage
|
|
}
|
|
};
|
|
} catch (error) {
|
|
report('error', `Error setting response language: ${error.message}`);
|
|
return {
|
|
success: false,
|
|
error: {
|
|
code: 'SET_RESPONSE_LANGUAGE_ERROR',
|
|
message: error.message
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
export default setResponseLanguage;
|