fix formatting
This commit is contained in:
@@ -218,6 +218,7 @@ task-master init --rules cursor,windsurf
|
||||
- You can use multiple comma-separated brands in a single command.
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
task-master init --rules cursor,roo
|
||||
```
|
||||
@@ -238,6 +239,7 @@ task-master rules remove <brand1,brand2,...>
|
||||
- You can use multiple comma-separated brands in a single command.
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
task-master rules add windsurf,roo
|
||||
task-master rules remove windsurf
|
||||
|
||||
@@ -80,9 +80,9 @@ export async function initializeProjectDirect(args, log, context = {}) {
|
||||
// Handle rules option just like CLI
|
||||
if (Array.isArray(args.rules) && args.rules.length > 0) {
|
||||
options.rules = args.rules;
|
||||
log.info(`Including brand rules: ${args.rules.join(", ")}`);
|
||||
log.info(`Including brand rules: ${args.rules.join(', ')}`);
|
||||
} else {
|
||||
options.rules = ["cursor"];
|
||||
options.rules = ['cursor'];
|
||||
log.info(`No rules specified, defaulting to: cursor`);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,12 @@ export async function rulesDirect(args, log, context = {}) {
|
||||
enableSilentMode();
|
||||
try {
|
||||
const { action, rules, projectRoot, yes } = args;
|
||||
if (!action || !Array.isArray(rules) || rules.length === 0 || !projectRoot) {
|
||||
if (
|
||||
!action ||
|
||||
!Array.isArray(rules) ||
|
||||
rules.length === 0 ||
|
||||
!projectRoot
|
||||
) {
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
@@ -35,7 +40,8 @@ export async function rulesDirect(args, log, context = {}) {
|
||||
}
|
||||
const rulesList = rules.join(',');
|
||||
const yesFlag = yes !== false ? '--yes' : '';
|
||||
const cmd = `npx task-master rules ${action} ${rulesList} ${yesFlag}`.trim();
|
||||
const cmd =
|
||||
`npx task-master rules ${action} ${rulesList} ${yesFlag}`.trim();
|
||||
log.info(`[rulesDirect] Running: ${cmd} in ${projectRoot}`);
|
||||
const output = execSync(cmd, { cwd: projectRoot, encoding: 'utf8' });
|
||||
log.info(`[rulesDirect] Output: ${output}`);
|
||||
|
||||
@@ -39,7 +39,9 @@ export function registerInitializeProjectTool(server) {
|
||||
rules: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe('List of brand rules to include at initialization (e.g., ["cursor", "roo"]). If omitted, defaults to ["cursor"].')
|
||||
.describe(
|
||||
'List of brand rules to include at initialization (e.g., ["cursor", "roo"]). If omitted, defaults to ["cursor"].'
|
||||
)
|
||||
}),
|
||||
execute: withNormalizedProjectRoot(async (args, context) => {
|
||||
const { log } = context;
|
||||
|
||||
@@ -18,16 +18,34 @@ import { rulesDirect } from '../core/direct-functions/rules.js';
|
||||
export function registerRulesTool(server) {
|
||||
server.addTool({
|
||||
name: 'rules',
|
||||
description: 'Add or remove brand rules and MCP config from the project (mirrors CLI rules add/remove).',
|
||||
description:
|
||||
'Add or remove brand rules and MCP config from the project (mirrors CLI rules add/remove).',
|
||||
parameters: z.object({
|
||||
action: z.enum(['add', 'remove']).describe('Whether to add or remove brand rules.'),
|
||||
rules: z.array(z.string()).min(1).describe('List of brand rules to add or remove (e.g., ["roo", "windsurf"]).'),
|
||||
projectRoot: z.string().describe('The root directory of the project. Must be an absolute path.'),
|
||||
yes: z.boolean().optional().default(true).describe('Run non-interactively (default: true).')
|
||||
action: z
|
||||
.enum(['add', 'remove'])
|
||||
.describe('Whether to add or remove brand rules.'),
|
||||
rules: z
|
||||
.array(z.string())
|
||||
.min(1)
|
||||
.describe(
|
||||
'List of brand rules to add or remove (e.g., ["roo", "windsurf"]).'
|
||||
),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe(
|
||||
'The root directory of the project. Must be an absolute path.'
|
||||
),
|
||||
yes: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.default(true)
|
||||
.describe('Run non-interactively (default: true).')
|
||||
}),
|
||||
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
|
||||
try {
|
||||
log.info(`[rules tool] Executing action: ${args.action} for rules: ${args.rules.join(', ')} in ${args.projectRoot}`);
|
||||
log.info(
|
||||
`[rules tool] Executing action: ${args.action} for rules: ${args.rules.join(', ')} in ${args.projectRoot}`
|
||||
);
|
||||
const result = await rulesDirect(args, log, { session });
|
||||
return handleApiResult(result, log);
|
||||
} catch (error) {
|
||||
|
||||
@@ -319,7 +319,8 @@ async function initializeProject(options = {}) {
|
||||
// }
|
||||
|
||||
const skipPrompts = options.yes || (options.name && options.description);
|
||||
let selectedBrandRules = options.rules && Array.isArray(options.rules) && options.rules.length > 0
|
||||
let selectedBrandRules =
|
||||
options.rules && Array.isArray(options.rules) && options.rules.length > 0
|
||||
? options.rules
|
||||
: ['cursor'];
|
||||
|
||||
@@ -383,8 +384,8 @@ let selectedBrandRules = options.rules && Array.isArray(options.rules) && option
|
||||
console.log('\nTask Master Project settings:');
|
||||
console.log(
|
||||
chalk.blue(
|
||||
'Add shell aliases (so you can use "tm" instead of "task-master"):')
|
||||
,
|
||||
'Add shell aliases (so you can use "tm" instead of "task-master"):'
|
||||
),
|
||||
chalk.white(addAliasesPrompted ? 'Yes' : 'No')
|
||||
);
|
||||
|
||||
@@ -401,10 +402,11 @@ let selectedBrandRules = options.rules && Array.isArray(options.rules) && option
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// === Brand Rules Selection (Inquirer) ===
|
||||
console.log(
|
||||
chalk.cyan('\nRules help enforce best practices and conventions for Task Master.')
|
||||
chalk.cyan(
|
||||
'\nRules help enforce best practices and conventions for Task Master.'
|
||||
)
|
||||
);
|
||||
const brandRulesQuestion = {
|
||||
type: 'checkbox',
|
||||
@@ -417,7 +419,6 @@ let selectedBrandRules = options.rules && Array.isArray(options.rules) && option
|
||||
const { brandRules } = await inquirer.prompt([brandRulesQuestion]);
|
||||
selectedBrandRules = brandRules;
|
||||
|
||||
|
||||
const dryRun = options.dryRun || false;
|
||||
|
||||
if (dryRun) {
|
||||
@@ -468,7 +469,11 @@ function promptQuestion(rl, question) {
|
||||
}
|
||||
|
||||
// Function to create the project structure
|
||||
function createProjectStructure(addAliases, dryRun, selectedBrandRules = ['cursor']) {
|
||||
function createProjectStructure(
|
||||
addAliases,
|
||||
dryRun,
|
||||
selectedBrandRules = ['cursor']
|
||||
) {
|
||||
const targetDir = process.cwd();
|
||||
log('info', `Initializing project in ${targetDir}`);
|
||||
|
||||
|
||||
@@ -15,14 +15,19 @@ const mockLogger = {
|
||||
};
|
||||
|
||||
// Use a temp directory for testing (simulate a project root)
|
||||
const tempProjectRoot = path.join(__dirname, '../../fixtures/temp-rules-project');
|
||||
const tempProjectRoot = path.join(
|
||||
__dirname,
|
||||
'../../fixtures/temp-rules-project'
|
||||
);
|
||||
|
||||
beforeAll(() => {
|
||||
if (!fs.existsSync(tempProjectRoot)) fs.mkdirSync(tempProjectRoot, { recursive: true });
|
||||
if (!fs.existsSync(tempProjectRoot))
|
||||
fs.mkdirSync(tempProjectRoot, { recursive: true });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
if (fs.existsSync(tempProjectRoot)) fs.rmSync(tempProjectRoot, { recursive: true, force: true });
|
||||
if (fs.existsSync(tempProjectRoot))
|
||||
fs.rmSync(tempProjectRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe('rulesDirect (integration)', () => {
|
||||
|
||||
Reference in New Issue
Block a user