2025-06-07 22:07:35 -04:00
|
|
|
import fs from 'fs';
|
|
|
|
|
import path from 'path';
|
|
|
|
|
import chalk from 'chalk';
|
|
|
|
|
import { log, findProjectRoot } from './utils.js';
|
|
|
|
|
import { getProjectName } from './config-manager.js';
|
|
|
|
|
import listTasks from './task-manager/list-tasks.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a basic README structure if one doesn't exist
|
|
|
|
|
* @param {string} projectName - Name of the project
|
|
|
|
|
* @returns {string} - Basic README content
|
|
|
|
|
*/
|
|
|
|
|
function createBasicReadme(projectName) {
|
|
|
|
|
return `# ${projectName}
|
|
|
|
|
|
|
|
|
|
This project is managed using Task Master.
|
|
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create UTM tracking URL for task-master.dev
|
|
|
|
|
* @param {string} projectRoot - The project root path
|
|
|
|
|
* @returns {string} - UTM tracked URL
|
|
|
|
|
*/
|
|
|
|
|
function createTaskMasterUrl(projectRoot) {
|
|
|
|
|
// Get the actual folder name from the project root path
|
|
|
|
|
const folderName = path.basename(projectRoot);
|
|
|
|
|
|
|
|
|
|
// Clean folder name for UTM (replace spaces/special chars with hyphens)
|
|
|
|
|
const cleanFolderName = folderName
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/[^a-z0-9]/g, '-')
|
|
|
|
|
.replace(/-+/g, '-')
|
|
|
|
|
.replace(/^-|-$/g, '');
|
|
|
|
|
|
|
|
|
|
const utmParams = new URLSearchParams({
|
|
|
|
|
utm_source: 'github-readme',
|
|
|
|
|
utm_medium: 'readme-export',
|
|
|
|
|
utm_campaign: cleanFolderName || 'task-sync',
|
|
|
|
|
utm_content: 'task-export-link'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return `https://task-master.dev?${utmParams.toString()}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the start marker with metadata
|
|
|
|
|
* @param {Object} options - Export options
|
|
|
|
|
* @returns {string} - Formatted start marker
|
|
|
|
|
*/
|
|
|
|
|
function createStartMarker(options) {
|
|
|
|
|
const { timestamp, withSubtasks, status, projectRoot } = options;
|
|
|
|
|
|
|
|
|
|
// Format status filter text
|
|
|
|
|
const statusText = status
|
|
|
|
|
? `Status filter: ${status}`
|
|
|
|
|
: 'Status filter: none';
|
|
|
|
|
const subtasksText = withSubtasks ? 'with subtasks' : 'without subtasks';
|
|
|
|
|
|
|
|
|
|
// Create the export info content
|
|
|
|
|
const exportInfo =
|
|
|
|
|
`🎯 **Taskmaster Export** - ${timestamp}\n` +
|
|
|
|
|
`📋 Export: ${subtasksText} • ${statusText}\n` +
|
|
|
|
|
`🔗 Powered by [Task Master](${createTaskMasterUrl(projectRoot)})`;
|
|
|
|
|
|
|
|
|
|
// Create a markdown box using code blocks and emojis to mimic our UI style
|
|
|
|
|
const boxContent =
|
|
|
|
|
`<!-- TASKMASTER_EXPORT_START -->\n` +
|
|
|
|
|
`> ${exportInfo.split('\n').join('\n> ')}\n\n`;
|
|
|
|
|
|
|
|
|
|
return boxContent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the end marker
|
|
|
|
|
* @returns {string} - Formatted end marker
|
|
|
|
|
*/
|
|
|
|
|
function createEndMarker() {
|
|
|
|
|
return (
|
|
|
|
|
`\n> 📋 **End of Taskmaster Export** - Tasks are synced from your project using the \`sync-readme\` command.\n` +
|
|
|
|
|
`<!-- TASKMASTER_EXPORT_END -->\n`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Syncs the current task list to README.md at the project root
|
|
|
|
|
* @param {string} projectRoot - Path to the project root directory
|
|
|
|
|
* @param {Object} options - Options for syncing
|
|
|
|
|
* @param {boolean} options.withSubtasks - Include subtasks in the output (default: false)
|
|
|
|
|
* @param {string} options.status - Filter by status (e.g., 'pending', 'done')
|
|
|
|
|
* @param {string} options.tasksPath - Custom path to tasks.json
|
|
|
|
|
* @returns {boolean} - True if sync was successful, false otherwise
|
fix(core): Implement Boundary-First Tag Resolution (#943)
* refactor(context): Standardize tag and projectRoot handling across all task tools
This commit unifies context management by adopting a boundary-first resolution strategy. All task-scoped tools now resolve `tag` and `projectRoot` at their entry point and forward these values to the underlying direct functions.
This approach centralizes context logic, ensuring consistent behavior and enhanced flexibility in multi-tag environments.
* fix(tag): Clean up tag handling in task functions and sync process
This commit refines the handling of the `tag` parameter across multiple functions, ensuring consistent context management. The `tag` is now passed more efficiently in `listTasksDirect`, `setTaskStatusDirect`, and `syncTasksToReadme`, improving clarity and reducing redundancy. Additionally, a TODO comment has been added in `sync-readme.js` to address future tag support enhancements.
* feat(tag): Implement Boundary-First Tag Resolution for consistent tag handling
This commit introduces Boundary-First Tag Resolution in the task manager, ensuring consistent and deterministic tag handling across CLI and MCP. This change resolves potential race conditions and improves the reliability of tag-specific operations.
Additionally, the `expandTask` function has been updated to use the resolved tag when writing JSON, enhancing data integrity during task updates.
* chore(biome): formatting
* fix(expand-task): Update writeJSON call to use tag instead of resolvedTag
* fix(commands): Enhance complexity report path resolution and task initialization
`resolveComplexityReportPath` function to streamline output path generation based on tag context and user-defined output.
- Improved clarity and maintainability of command handling by centralizing path resolution logic.
* Fix: unknown currentTag
* fix(task-manager): Update generateTaskFiles calls to include tag and projectRoot parameters
This commit modifies the `moveTask` and `updateSubtaskById` functions to pass the `tag` and `projectRoot` parameters to the `generateTaskFiles` function. This ensures that task files are generated with the correct context when requested, enhancing consistency in task management operations.
* fix(commands): Refactor tag handling and complexity report path resolution
This commit updates the `registerCommands` function to utilize `taskMaster.getCurrentTag()` for consistent tag retrieval across command actions. It also enhances the initialization of `TaskMaster` by passing the tag directly, improving clarity and maintainability. The complexity report path resolution is streamlined to ensure correct file naming based on the current tag context.
* fix(task-master): Update complexity report path expectations in tests
This commit modifies the `initTaskMaster` test to expect a valid string for the complexity report path, ensuring it matches the expected file naming convention. This change enhances test reliability by verifying the correct output format when the path is generated.
* fix(set-task-status): Enhance logging and tag resolution in task status updates
This commit improves the logging output in the `registerSetTaskStatusTool` function to include the tag context when setting task statuses. It also updates the tag handling by resolving the tag using the `resolveTag` utility, ensuring that the correct tag is used when updating task statuses. Additionally, the `setTaskStatus` function is modified to remove the tag parameter from the `readJSON` and `writeJSON` calls, streamlining the data handling process.
* fix(commands, expand-task, task-manager): Add complexity report option and enhance path handling
This commit introduces a new `--complexity-report` option in the `registerCommands` function, allowing users to specify a custom path for the complexity report. The `expandTask` function is updated to accept the `complexityReportPath` from the context, ensuring it is utilized correctly during task expansion. Additionally, the `setTaskStatus` function now includes the `tag` parameter in the `readJSON` and `writeJSON` calls, improving task status updates with proper context. The `initTaskMaster` function is also modified to create parent directories for output paths, enhancing file handling robustness.
* fix(expand-task): Add complexityReportPath to context for task expansion tests
This commit updates the test for the `expandTask` function by adding the `complexityReportPath` to the context object. This change ensures that the complexity report path is correctly utilized in the test, aligning with recent enhancements to complexity report handling in the task manager.
* chore: implement suggested changes
* fix(parse-prd): Clarify tag parameter description for task organization
Updated the documentation for the `tag` parameter in the `parse-prd.js` file to provide a clearer context on its purpose for organizing tasks into separate task lists.
* Fix Inconsistent tag resolution pattern.
* fix: Enhance complexity report path handling with tag support
This commit updates various functions to incorporate the `tag` parameter when resolving complexity report paths. The `expandTaskDirect`, `resolveComplexityReportPath`, and related tools now utilize the current tag context, improving consistency in task management. Additionally, the complexity report path is now correctly passed through the context in the `expand-task` and `set-task-status` tools, ensuring accurate report retrieval based on the active tag.
* Updated the JSDoc for the `tag` parameter in the `show-task.js` file.
* Remove redundant comment on tag parameter in readJSON call
* Remove unused import for getTagAwareFilePath
* Add missed complexityReportPath to args for task expansion
* fix(tests): Enhance research tests with tag-aware functionality
This commit updates the `research.test.js` file to improve the testing of the `performResearch` function by incorporating tag-aware functionality. Key changes include mocking the `findProjectRoot` to return a valid path, enhancing the `ContextGatherer` and `FuzzyTaskSearch` mocks, and adding comprehensive tests for tag parameter handling in various scenarios. The tests now cover passing different tag values, ensuring correct behavior when tags are provided, undefined, or null, and validating the integration of tags in task discovery and context gathering processes.
* Remove unused import for
* fix: Refactor complexity report path handling and improve argument destructuring
This commit enhances the `expandTaskDirect` function by improving the destructuring of arguments for better readability. It also updates the `analyze.js` and `analyze-task-complexity.js` files to utilize the new `resolveComplexityReportOutputPath` function, ensuring tag-aware resolution of output paths. Additionally, logging has been added to provide clarity on the report path being used.
* test: Add complexity report tag isolation tests and improve path handling
This commit introduces a new test file for complexity report tag isolation, ensuring that different tags maintain separate complexity reports. It enhances the existing tests in `analyze-task-complexity.test.js` by updating expectations to use `expect.stringContaining` for file paths, improving robustness against path changes. The new tests cover various scenarios, including path resolution and report generation for both master and feature tags, ensuring no cross-tag contamination occurs.
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test(complexity-report): Fix tag slugification in filename expectations
- Update mocks to use slugifyTagForFilePath for cross-platform compatibility
- Replace raw tag values with slugified versions in expected filenames
- Fix test expecting 'feature/user-auth-v2' to expect 'feature-user-auth-v2'
- Align test with actual filename generation logic that sanitizes special chars
---------
Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-18 19:05:04 +02:00
|
|
|
* TODO: Add tag support - this is not currently supported how we want to handle this - Parthy
|
2025-06-07 22:07:35 -04:00
|
|
|
*/
|
|
|
|
|
export async function syncTasksToReadme(projectRoot = null, options = {}) {
|
|
|
|
|
try {
|
|
|
|
|
const actualProjectRoot = projectRoot || findProjectRoot() || '.';
|
fix(core): Implement Boundary-First Tag Resolution (#943)
* refactor(context): Standardize tag and projectRoot handling across all task tools
This commit unifies context management by adopting a boundary-first resolution strategy. All task-scoped tools now resolve `tag` and `projectRoot` at their entry point and forward these values to the underlying direct functions.
This approach centralizes context logic, ensuring consistent behavior and enhanced flexibility in multi-tag environments.
* fix(tag): Clean up tag handling in task functions and sync process
This commit refines the handling of the `tag` parameter across multiple functions, ensuring consistent context management. The `tag` is now passed more efficiently in `listTasksDirect`, `setTaskStatusDirect`, and `syncTasksToReadme`, improving clarity and reducing redundancy. Additionally, a TODO comment has been added in `sync-readme.js` to address future tag support enhancements.
* feat(tag): Implement Boundary-First Tag Resolution for consistent tag handling
This commit introduces Boundary-First Tag Resolution in the task manager, ensuring consistent and deterministic tag handling across CLI and MCP. This change resolves potential race conditions and improves the reliability of tag-specific operations.
Additionally, the `expandTask` function has been updated to use the resolved tag when writing JSON, enhancing data integrity during task updates.
* chore(biome): formatting
* fix(expand-task): Update writeJSON call to use tag instead of resolvedTag
* fix(commands): Enhance complexity report path resolution and task initialization
`resolveComplexityReportPath` function to streamline output path generation based on tag context and user-defined output.
- Improved clarity and maintainability of command handling by centralizing path resolution logic.
* Fix: unknown currentTag
* fix(task-manager): Update generateTaskFiles calls to include tag and projectRoot parameters
This commit modifies the `moveTask` and `updateSubtaskById` functions to pass the `tag` and `projectRoot` parameters to the `generateTaskFiles` function. This ensures that task files are generated with the correct context when requested, enhancing consistency in task management operations.
* fix(commands): Refactor tag handling and complexity report path resolution
This commit updates the `registerCommands` function to utilize `taskMaster.getCurrentTag()` for consistent tag retrieval across command actions. It also enhances the initialization of `TaskMaster` by passing the tag directly, improving clarity and maintainability. The complexity report path resolution is streamlined to ensure correct file naming based on the current tag context.
* fix(task-master): Update complexity report path expectations in tests
This commit modifies the `initTaskMaster` test to expect a valid string for the complexity report path, ensuring it matches the expected file naming convention. This change enhances test reliability by verifying the correct output format when the path is generated.
* fix(set-task-status): Enhance logging and tag resolution in task status updates
This commit improves the logging output in the `registerSetTaskStatusTool` function to include the tag context when setting task statuses. It also updates the tag handling by resolving the tag using the `resolveTag` utility, ensuring that the correct tag is used when updating task statuses. Additionally, the `setTaskStatus` function is modified to remove the tag parameter from the `readJSON` and `writeJSON` calls, streamlining the data handling process.
* fix(commands, expand-task, task-manager): Add complexity report option and enhance path handling
This commit introduces a new `--complexity-report` option in the `registerCommands` function, allowing users to specify a custom path for the complexity report. The `expandTask` function is updated to accept the `complexityReportPath` from the context, ensuring it is utilized correctly during task expansion. Additionally, the `setTaskStatus` function now includes the `tag` parameter in the `readJSON` and `writeJSON` calls, improving task status updates with proper context. The `initTaskMaster` function is also modified to create parent directories for output paths, enhancing file handling robustness.
* fix(expand-task): Add complexityReportPath to context for task expansion tests
This commit updates the test for the `expandTask` function by adding the `complexityReportPath` to the context object. This change ensures that the complexity report path is correctly utilized in the test, aligning with recent enhancements to complexity report handling in the task manager.
* chore: implement suggested changes
* fix(parse-prd): Clarify tag parameter description for task organization
Updated the documentation for the `tag` parameter in the `parse-prd.js` file to provide a clearer context on its purpose for organizing tasks into separate task lists.
* Fix Inconsistent tag resolution pattern.
* fix: Enhance complexity report path handling with tag support
This commit updates various functions to incorporate the `tag` parameter when resolving complexity report paths. The `expandTaskDirect`, `resolveComplexityReportPath`, and related tools now utilize the current tag context, improving consistency in task management. Additionally, the complexity report path is now correctly passed through the context in the `expand-task` and `set-task-status` tools, ensuring accurate report retrieval based on the active tag.
* Updated the JSDoc for the `tag` parameter in the `show-task.js` file.
* Remove redundant comment on tag parameter in readJSON call
* Remove unused import for getTagAwareFilePath
* Add missed complexityReportPath to args for task expansion
* fix(tests): Enhance research tests with tag-aware functionality
This commit updates the `research.test.js` file to improve the testing of the `performResearch` function by incorporating tag-aware functionality. Key changes include mocking the `findProjectRoot` to return a valid path, enhancing the `ContextGatherer` and `FuzzyTaskSearch` mocks, and adding comprehensive tests for tag parameter handling in various scenarios. The tests now cover passing different tag values, ensuring correct behavior when tags are provided, undefined, or null, and validating the integration of tags in task discovery and context gathering processes.
* Remove unused import for
* fix: Refactor complexity report path handling and improve argument destructuring
This commit enhances the `expandTaskDirect` function by improving the destructuring of arguments for better readability. It also updates the `analyze.js` and `analyze-task-complexity.js` files to utilize the new `resolveComplexityReportOutputPath` function, ensuring tag-aware resolution of output paths. Additionally, logging has been added to provide clarity on the report path being used.
* test: Add complexity report tag isolation tests and improve path handling
This commit introduces a new test file for complexity report tag isolation, ensuring that different tags maintain separate complexity reports. It enhances the existing tests in `analyze-task-complexity.test.js` by updating expectations to use `expect.stringContaining` for file paths, improving robustness against path changes. The new tests cover various scenarios, including path resolution and report generation for both master and feature tags, ensuring no cross-tag contamination occurs.
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test(complexity-report): Fix tag slugification in filename expectations
- Update mocks to use slugifyTagForFilePath for cross-platform compatibility
- Replace raw tag values with slugified versions in expected filenames
- Fix test expecting 'feature/user-auth-v2' to expect 'feature-user-auth-v2'
- Align test with actual filename generation logic that sanitizes special chars
---------
Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-18 19:05:04 +02:00
|
|
|
const { withSubtasks = false, status, tasksPath, tag } = options;
|
2025-06-07 22:07:35 -04:00
|
|
|
|
|
|
|
|
// Get current tasks using the list-tasks functionality with markdown-readme format
|
|
|
|
|
const tasksOutput = await listTasks(
|
|
|
|
|
tasksPath ||
|
|
|
|
|
path.join(actualProjectRoot, '.taskmaster', 'tasks', 'tasks.json'),
|
|
|
|
|
status,
|
|
|
|
|
null,
|
|
|
|
|
withSubtasks,
|
fix(core): Implement Boundary-First Tag Resolution (#943)
* refactor(context): Standardize tag and projectRoot handling across all task tools
This commit unifies context management by adopting a boundary-first resolution strategy. All task-scoped tools now resolve `tag` and `projectRoot` at their entry point and forward these values to the underlying direct functions.
This approach centralizes context logic, ensuring consistent behavior and enhanced flexibility in multi-tag environments.
* fix(tag): Clean up tag handling in task functions and sync process
This commit refines the handling of the `tag` parameter across multiple functions, ensuring consistent context management. The `tag` is now passed more efficiently in `listTasksDirect`, `setTaskStatusDirect`, and `syncTasksToReadme`, improving clarity and reducing redundancy. Additionally, a TODO comment has been added in `sync-readme.js` to address future tag support enhancements.
* feat(tag): Implement Boundary-First Tag Resolution for consistent tag handling
This commit introduces Boundary-First Tag Resolution in the task manager, ensuring consistent and deterministic tag handling across CLI and MCP. This change resolves potential race conditions and improves the reliability of tag-specific operations.
Additionally, the `expandTask` function has been updated to use the resolved tag when writing JSON, enhancing data integrity during task updates.
* chore(biome): formatting
* fix(expand-task): Update writeJSON call to use tag instead of resolvedTag
* fix(commands): Enhance complexity report path resolution and task initialization
`resolveComplexityReportPath` function to streamline output path generation based on tag context and user-defined output.
- Improved clarity and maintainability of command handling by centralizing path resolution logic.
* Fix: unknown currentTag
* fix(task-manager): Update generateTaskFiles calls to include tag and projectRoot parameters
This commit modifies the `moveTask` and `updateSubtaskById` functions to pass the `tag` and `projectRoot` parameters to the `generateTaskFiles` function. This ensures that task files are generated with the correct context when requested, enhancing consistency in task management operations.
* fix(commands): Refactor tag handling and complexity report path resolution
This commit updates the `registerCommands` function to utilize `taskMaster.getCurrentTag()` for consistent tag retrieval across command actions. It also enhances the initialization of `TaskMaster` by passing the tag directly, improving clarity and maintainability. The complexity report path resolution is streamlined to ensure correct file naming based on the current tag context.
* fix(task-master): Update complexity report path expectations in tests
This commit modifies the `initTaskMaster` test to expect a valid string for the complexity report path, ensuring it matches the expected file naming convention. This change enhances test reliability by verifying the correct output format when the path is generated.
* fix(set-task-status): Enhance logging and tag resolution in task status updates
This commit improves the logging output in the `registerSetTaskStatusTool` function to include the tag context when setting task statuses. It also updates the tag handling by resolving the tag using the `resolveTag` utility, ensuring that the correct tag is used when updating task statuses. Additionally, the `setTaskStatus` function is modified to remove the tag parameter from the `readJSON` and `writeJSON` calls, streamlining the data handling process.
* fix(commands, expand-task, task-manager): Add complexity report option and enhance path handling
This commit introduces a new `--complexity-report` option in the `registerCommands` function, allowing users to specify a custom path for the complexity report. The `expandTask` function is updated to accept the `complexityReportPath` from the context, ensuring it is utilized correctly during task expansion. Additionally, the `setTaskStatus` function now includes the `tag` parameter in the `readJSON` and `writeJSON` calls, improving task status updates with proper context. The `initTaskMaster` function is also modified to create parent directories for output paths, enhancing file handling robustness.
* fix(expand-task): Add complexityReportPath to context for task expansion tests
This commit updates the test for the `expandTask` function by adding the `complexityReportPath` to the context object. This change ensures that the complexity report path is correctly utilized in the test, aligning with recent enhancements to complexity report handling in the task manager.
* chore: implement suggested changes
* fix(parse-prd): Clarify tag parameter description for task organization
Updated the documentation for the `tag` parameter in the `parse-prd.js` file to provide a clearer context on its purpose for organizing tasks into separate task lists.
* Fix Inconsistent tag resolution pattern.
* fix: Enhance complexity report path handling with tag support
This commit updates various functions to incorporate the `tag` parameter when resolving complexity report paths. The `expandTaskDirect`, `resolveComplexityReportPath`, and related tools now utilize the current tag context, improving consistency in task management. Additionally, the complexity report path is now correctly passed through the context in the `expand-task` and `set-task-status` tools, ensuring accurate report retrieval based on the active tag.
* Updated the JSDoc for the `tag` parameter in the `show-task.js` file.
* Remove redundant comment on tag parameter in readJSON call
* Remove unused import for getTagAwareFilePath
* Add missed complexityReportPath to args for task expansion
* fix(tests): Enhance research tests with tag-aware functionality
This commit updates the `research.test.js` file to improve the testing of the `performResearch` function by incorporating tag-aware functionality. Key changes include mocking the `findProjectRoot` to return a valid path, enhancing the `ContextGatherer` and `FuzzyTaskSearch` mocks, and adding comprehensive tests for tag parameter handling in various scenarios. The tests now cover passing different tag values, ensuring correct behavior when tags are provided, undefined, or null, and validating the integration of tags in task discovery and context gathering processes.
* Remove unused import for
* fix: Refactor complexity report path handling and improve argument destructuring
This commit enhances the `expandTaskDirect` function by improving the destructuring of arguments for better readability. It also updates the `analyze.js` and `analyze-task-complexity.js` files to utilize the new `resolveComplexityReportOutputPath` function, ensuring tag-aware resolution of output paths. Additionally, logging has been added to provide clarity on the report path being used.
* test: Add complexity report tag isolation tests and improve path handling
This commit introduces a new test file for complexity report tag isolation, ensuring that different tags maintain separate complexity reports. It enhances the existing tests in `analyze-task-complexity.test.js` by updating expectations to use `expect.stringContaining` for file paths, improving robustness against path changes. The new tests cover various scenarios, including path resolution and report generation for both master and feature tags, ensuring no cross-tag contamination occurs.
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update scripts/modules/task-manager/list-tasks.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test(complexity-report): Fix tag slugification in filename expectations
- Update mocks to use slugifyTagForFilePath for cross-platform compatibility
- Replace raw tag values with slugified versions in expected filenames
- Fix test expecting 'feature/user-auth-v2' to expect 'feature-user-auth-v2'
- Align test with actual filename generation logic that sanitizes special chars
---------
Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-18 19:05:04 +02:00
|
|
|
'markdown-readme',
|
|
|
|
|
{ projectRoot, tag }
|
2025-06-07 22:07:35 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!tasksOutput) {
|
|
|
|
|
console.log(chalk.red('❌ Failed to generate task output'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate timestamp and metadata
|
|
|
|
|
const timestamp =
|
|
|
|
|
new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC';
|
|
|
|
|
const projectName = getProjectName(actualProjectRoot);
|
|
|
|
|
|
|
|
|
|
// Create the export markers with metadata
|
|
|
|
|
const startMarker = createStartMarker({
|
|
|
|
|
timestamp,
|
|
|
|
|
withSubtasks,
|
|
|
|
|
status,
|
|
|
|
|
projectRoot: actualProjectRoot
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const endMarker = createEndMarker();
|
|
|
|
|
|
|
|
|
|
// Create the complete task section
|
|
|
|
|
const taskSection = startMarker + tasksOutput + endMarker;
|
|
|
|
|
|
|
|
|
|
// Read current README content
|
|
|
|
|
const readmePath = path.join(actualProjectRoot, 'README.md');
|
|
|
|
|
let readmeContent = '';
|
|
|
|
|
try {
|
|
|
|
|
readmeContent = fs.readFileSync(readmePath, 'utf8');
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (err.code === 'ENOENT') {
|
|
|
|
|
// Create basic README if it doesn't exist
|
|
|
|
|
readmeContent = createBasicReadme(projectName);
|
|
|
|
|
} else {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if export markers exist and replace content between them
|
|
|
|
|
const startComment = '<!-- TASKMASTER_EXPORT_START -->';
|
|
|
|
|
const endComment = '<!-- TASKMASTER_EXPORT_END -->';
|
|
|
|
|
|
|
|
|
|
let updatedContent;
|
|
|
|
|
const startIndex = readmeContent.indexOf(startComment);
|
|
|
|
|
const endIndex = readmeContent.indexOf(endComment);
|
|
|
|
|
|
|
|
|
|
if (startIndex !== -1 && endIndex !== -1) {
|
|
|
|
|
// Replace existing task section
|
|
|
|
|
const beforeTasks = readmeContent.substring(0, startIndex);
|
|
|
|
|
const afterTasks = readmeContent.substring(endIndex + endComment.length);
|
|
|
|
|
updatedContent = beforeTasks + taskSection + afterTasks;
|
|
|
|
|
} else {
|
|
|
|
|
// Append to end of README
|
|
|
|
|
updatedContent = readmeContent + '\n' + taskSection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write updated content to README
|
|
|
|
|
fs.writeFileSync(readmePath, updatedContent, 'utf8');
|
|
|
|
|
|
|
|
|
|
console.log(chalk.green('✅ Successfully synced tasks to README.md'));
|
|
|
|
|
console.log(
|
|
|
|
|
chalk.cyan(
|
|
|
|
|
`📋 Export details: ${withSubtasks ? 'with' : 'without'} subtasks${status ? `, status: ${status}` : ''}`
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
console.log(chalk.gray(`📍 Location: ${readmePath}`));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(chalk.red('❌ Failed to sync tasks to README:'), error.message);
|
|
|
|
|
log('error', `README sync error: ${error.message}`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default syncTasksToReadme;
|