feat: Enhance testing, CLI flag validation, and AI capabilities

This commit introduces several significant improvements:

- **Enhanced Unit Testing:**  Vastly improved unit tests for the  module, covering core functions, edge cases, and error handling.  Simplified test functions and comprehensive mocking were implemented for better isolation and reliability. Added new section to tests.mdc detailing reliable testing techniques.

- **CLI Kebab-Case Flag Enforcement:**  The CLI now enforces kebab-case for flags, providing helpful error messages when camelCase is used. This improves consistency and user experience.

- **AI Enhancements:**
    - Enabled 128k token output for Claude 3.7 Sonnet by adding the  header.
    - Added a new task to  to document this change and its testing strategy.
    - Added unit tests to verify the Anthropic client configuration.
    - Added  and  utility functions.

- **Improved Test Coverage:** Added tests for the new CLI flag validation logic.
This commit is contained in:
Eyal Toledano
2025-03-25 17:20:09 -04:00
parent 002612bdf9
commit 9e19b54518
10 changed files with 444 additions and 24 deletions

View File

@@ -265,6 +265,57 @@ function findCycles(subtaskId, dependencyMap, visited = new Set(), recursionStac
return cyclesToBreak;
}
/**
* Convert a string from camelCase to kebab-case
* @param {string} str - The string to convert
* @returns {string} The kebab-case version of the string
*/
const toKebabCase = (str) => {
// Special handling for common acronyms
const withReplacedAcronyms = str
.replace(/ID/g, 'Id')
.replace(/API/g, 'Api')
.replace(/UI/g, 'Ui')
.replace(/URL/g, 'Url')
.replace(/URI/g, 'Uri')
.replace(/JSON/g, 'Json')
.replace(/XML/g, 'Xml')
.replace(/HTML/g, 'Html')
.replace(/CSS/g, 'Css');
// Insert hyphens before capital letters and convert to lowercase
return withReplacedAcronyms
.replace(/([A-Z])/g, '-$1')
.toLowerCase()
.replace(/^-/, ''); // Remove leading hyphen if present
};
/**
* Detect camelCase flags in command arguments
* @param {string[]} args - Command line arguments to check
* @returns {Array<{original: string, kebabCase: string}>} - List of flags that should be converted
*/
function detectCamelCaseFlags(args) {
const camelCaseFlags = [];
for (const arg of args) {
if (arg.startsWith('--')) {
const flagName = arg.split('=')[0].slice(2); // Remove -- and anything after =
// Only test for uppercase letters in the flag name
if (/[A-Z]/.test(flagName)) {
// Prevent adding duplicate flags or cases where kebab would be same as original
const kebabVersion = toKebabCase(flagName);
if (kebabVersion !== flagName) {
camelCaseFlags.push({
original: flagName,
kebabCase: kebabVersion
});
}
}
}
}
return camelCaseFlags;
}
// Export all utility functions and configuration
export {
CONFIG,
@@ -279,5 +330,7 @@ export {
formatTaskId,
findTaskById,
truncate,
findCycles
findCycles,
toKebabCase,
detectCamelCaseFlags
};