chore: cleanup and apply requested changes

This commit is contained in:
Ralph Khreish
2025-08-27 23:32:35 +02:00
parent 86d9c4b194
commit 5ed3f2f16b
18 changed files with 165 additions and 231 deletions

View File

@@ -1,37 +1,37 @@
{
"models": {
"main": {
"provider": "anthropic",
"modelId": "claude-3-7-sonnet-20250219",
"maxTokens": 120000,
"temperature": 0.2
},
"research": {
"provider": "perplexity",
"modelId": "sonar",
"maxTokens": 8700,
"temperature": 0.1
},
"fallback": {
"provider": "anthropic",
"modelId": "claude-3-5-sonnet-20241022",
"maxTokens": 8192,
"temperature": 0.2
}
},
"global": {
"logLevel": "info",
"debug": false,
"defaultNumTasks": 10,
"defaultSubtasks": 5,
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com",
"responseLanguage": "English",
"userId": "1234567890",
"azureBaseURL": "https://your-endpoint.azure.com/",
"defaultTag": "master"
},
"claudeCode": {}
"models": {
"main": {
"provider": "anthropic",
"modelId": "claude-3-7-sonnet-20250219",
"maxTokens": 120000,
"temperature": 0.2
},
"research": {
"provider": "perplexity",
"modelId": "sonar",
"maxTokens": 8700,
"temperature": 0.1
},
"fallback": {
"provider": "anthropic",
"modelId": "claude-3-5-sonnet-20241022",
"maxTokens": 8192,
"temperature": 0.2
}
},
"global": {
"logLevel": "info",
"debug": false,
"defaultNumTasks": 10,
"defaultSubtasks": 5,
"defaultPriority": "medium",
"projectName": "Taskmaster",
"ollamaBaseURL": "http://localhost:11434/api",
"bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com",
"responseLanguage": "English",
"userId": "1234567890",
"azureBaseURL": "https://your-endpoint.azure.com/",
"defaultTag": "master"
},
"claudeCode": {}
}

View File

@@ -1,9 +1,9 @@
{
"currentTag": "master",
"lastSwitched": "2025-08-27T21:03:20.550Z",
"branchTagMapping": {
"v017-adds": "v017-adds",
"next": "next"
},
"migrationNoticeShown": true
"currentTag": "master",
"lastSwitched": "2025-08-27T21:03:20.550Z",
"branchTagMapping": {
"v017-adds": "v017-adds",
"next": "next"
},
"migrationNoticeShown": true
}

View File

@@ -1,7 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["../../biome.json"],
"files": {
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
}

View File

@@ -93,7 +93,10 @@ export class ListTasksCommand extends Command {
this.displayResults(result, options);
}
} catch (error: any) {
console.error(chalk.red(`Error: ${error.message}`));
const msg = error?.getSanitizedDetails?.() ?? {
message: error?.message ?? String(error)
};
console.error(chalk.red(`Error: ${msg.message || 'Unexpected error'}`));
if (error.stack && process.env.DEBUG) {
console.error(chalk.gray(error.stack));
}

7
package-lock.json generated
View File

@@ -77,7 +77,8 @@
"prettier": "^3.5.3",
"supertest": "^7.1.0",
"tsup": "^8.5.0",
"tsx": "^4.16.2"
"tsx": "^4.16.2",
"typescript": "^5.9.2"
},
"engines": {
"node": ">=18.0.0"
@@ -24783,7 +24784,9 @@
}
},
"node_modules/typescript": {
"version": "5.8.3",
"version": "5.9.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
"dev": true,
"license": "Apache-2.0",
"bin": {

View File

@@ -136,6 +136,7 @@
"prettier": "^3.5.3",
"supertest": "^7.1.0",
"tsup": "^8.5.0",
"tsx": "^4.16.2"
"tsx": "^4.16.2",
"typescript": "^5.9.2"
}
}

View File

@@ -1,104 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"include": ["src/**/*.ts", "tests/**/*.ts", "*.ts", "*.js", "*.json"],
"ignore": [
"**/node_modules",
"**/dist",
"**/.git",
"**/coverage",
"**/*.d.ts"
]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off",
"useConst": "error",
"useImportType": "warn",
"useTemplate": "warn",
"noUselessElse": "warn",
"noVar": "error"
},
"correctness": {
"noUnusedVariables": "warn",
"noUnusedImports": "error",
"useExhaustiveDependencies": "warn"
},
"complexity": {
"noBannedTypes": "error",
"noForEach": "off",
"noStaticOnlyClass": "warn",
"noUselessConstructor": "error",
"noUselessTypeConstraint": "error",
"useArrowFunction": "off"
},
"suspicious": {
"noExplicitAny": "warn",
"noImplicitAnyLet": "error",
"noArrayIndexKey": "warn",
"noAsyncPromiseExecutor": "error",
"noDoubleEquals": "warn",
"noRedundantUseStrict": "error"
},
"security": {
"noGlobalEval": "error"
},
"performance": {
"noAccumulatingSpread": "warn",
"noDelete": "warn"
},
"a11y": {
"recommended": false
}
}
},
"javascript": {
"formatter": {
"enabled": true,
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "none",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false
},
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
},
"json": {
"formatter": {
"enabled": true,
"indentStyle": "tab",
"lineWidth": 100,
"trailingCommas": "none"
},
"parser": {
"allowComments": true,
"allowTrailingCommas": false
}
}
}

View File

@@ -3,6 +3,15 @@
* This file exports all custom error types and error handling utilities
*/
// Export the main TaskMasterError class
export {
TaskMasterError,
ERROR_CODES,
type ErrorCode,
type ErrorContext,
type SerializableError
} from './task-master-error.js';
// Error implementations will be defined here
// export * from './task-errors.js';
// export * from './storage-errors.js';

View File

@@ -32,7 +32,10 @@ export class FileOperations {
/**
* Write JSON file with atomic operation and locking
*/
async writeJson(filePath: string, data: FileStorageData | any): Promise<void> {
async writeJson(
filePath: string,
data: FileStorageData | any
): Promise<void> {
// Use file locking to prevent concurrent writes
const lockKey = filePath;
const existingLock = this.fileLocks.get(lockKey);
@@ -109,7 +112,9 @@ export class FileOperations {
try {
await fs.mkdir(dirPath, { recursive: true });
} catch (error: any) {
throw new Error(`Failed to create directory ${dirPath}: ${error.message}`);
throw new Error(
`Failed to create directory ${dirPath}: ${error.message}`
);
}
}
@@ -133,7 +138,9 @@ export class FileOperations {
try {
await fs.rename(oldPath, newPath);
} catch (error: any) {
throw new Error(`Failed to move file from ${oldPath} to ${newPath}: ${error.message}`);
throw new Error(
`Failed to move file from ${oldPath} to ${newPath}: ${error.message}`
);
}
}
@@ -144,7 +151,9 @@ export class FileOperations {
try {
await fs.copyFile(srcPath, destPath);
} catch (error: any) {
throw new Error(`Failed to copy file from ${srcPath} to ${destPath}: ${error.message}`);
throw new Error(
`Failed to copy file from ${srcPath} to ${destPath}: ${error.message}`
);
}
}

View File

@@ -136,7 +136,12 @@ export class FileStorage implements IStorage {
const normalizedTasks = this.normalizeTaskIds(tasks);
// Update the specific tag in the existing data structure
if (this.formatHandler.detectFormat(existingData) === 'legacy' || Object.keys(existingData).some(key => key !== 'tasks' && key !== 'metadata')) {
if (
this.formatHandler.detectFormat(existingData) === 'legacy' ||
Object.keys(existingData).some(
(key) => key !== 'tasks' && key !== 'metadata'
)
) {
// Legacy format - update/add the tag
existingData[resolvedTag] = {
tasks: normalizedTasks,
@@ -177,11 +182,12 @@ export class FileStorage implements IStorage {
...task,
id: String(task.id), // Task IDs are strings
dependencies: task.dependencies?.map((dep) => String(dep)) || [],
subtasks: task.subtasks?.map((subtask) => ({
...subtask,
id: Number(subtask.id), // Subtask IDs are numbers
parentId: String(subtask.parentId) // Parent ID is string (Task ID)
})) || []
subtasks:
task.subtasks?.map((subtask) => ({
...subtask,
id: Number(subtask.id), // Subtask IDs are numbers
parentId: String(subtask.parentId) // Parent ID is string (Task ID)
})) || []
}));
}

View File

@@ -27,7 +27,9 @@ export class FormatHandler {
// Check if this uses the legacy format with tag keys
// Legacy format has keys that are not 'tasks' or 'metadata'
const hasLegacyFormat = keys.some(key => key !== 'tasks' && key !== 'metadata');
const hasLegacyFormat = keys.some(
(key) => key !== 'tasks' && key !== 'metadata'
);
return hasLegacyFormat ? 'legacy' : 'standard';
}
@@ -60,7 +62,9 @@ export class FormatHandler {
}
// If we're looking for 'master' tag but it doesn't exist, try the first available tag
const availableKeys = Object.keys(data).filter(key => key !== 'tasks' && key !== 'metadata');
const availableKeys = Object.keys(data).filter(
(key) => key !== 'tasks' && key !== 'metadata'
);
if (tag === 'master' && availableKeys.length > 0) {
const firstTag = availableKeys[0];
const tagData = data[firstTag];
@@ -97,7 +101,10 @@ export class FormatHandler {
/**
* Extract metadata from legacy format
*/
private extractMetadataFromLegacy(data: any, tag: string): TaskMetadata | null {
private extractMetadataFromLegacy(
data: any,
tag: string
): TaskMetadata | null {
if (tag in data) {
const tagData = data[tag];
// Generate metadata if not present in legacy format
@@ -108,7 +115,9 @@ export class FormatHandler {
}
// If we're looking for 'master' tag but it doesn't exist, try the first available tag
const availableKeys = Object.keys(data).filter(key => key !== 'tasks' && key !== 'metadata');
const availableKeys = Object.keys(data).filter(
(key) => key !== 'tasks' && key !== 'metadata'
);
if (tag === 'master' && availableKeys.length > 0) {
const firstTag = availableKeys[0];
const tagData = data[firstTag];
@@ -141,7 +150,7 @@ export class FormatHandler {
if (format === 'legacy') {
// Return all tag keys from legacy format
const keys = Object.keys(data);
return keys.filter(key => key !== 'tasks' && key !== 'metadata');
return keys.filter((key) => key !== 'tasks' && key !== 'metadata');
}
// Standard format - just has 'master' tag
@@ -215,11 +224,12 @@ export class FormatHandler {
...task,
id: String(task.id), // Task IDs are strings
dependencies: task.dependencies?.map((dep) => String(dep)) || [],
subtasks: task.subtasks?.map((subtask) => ({
...subtask,
id: Number(subtask.id), // Subtask IDs are numbers
parentId: String(subtask.parentId) // Parent ID is string (Task ID)
})) || []
subtasks:
task.subtasks?.map((subtask) => ({
...subtask,
id: Number(subtask.id), // Subtask IDs are numbers
parentId: String(subtask.parentId) // Parent ID is string (Task ID)
})) || []
}));
}

View File

@@ -2,7 +2,11 @@
* @fileoverview Exports for file storage components
*/
export { FormatHandler, type FileStorageData, type FileFormat } from './format-handler.js';
export {
FormatHandler,
type FileStorageData,
type FileFormat
} from './format-handler.js';
export { FileOperations } from './file-operations.js';
export { PathResolver } from './path-resolver.js';

View File

@@ -28,12 +28,12 @@
"isolatedModules": true,
"paths": {
"@/*": ["./src/*"],
"@/types": ["./src/types/index"],
"@/providers": ["./src/providers/index"],
"@/storage": ["./src/storage/index"],
"@/parser": ["./src/parser/index"],
"@/utils": ["./src/utils/index"],
"@/errors": ["./src/errors/index"]
"@/types": ["./src/types"],
"@/providers": ["./src/providers"],
"@/storage": ["./src/storage"],
"@/parser": ["./src/parser"],
"@/utils": ["./src/utils"],
"@/errors": ["./src/errors"]
}
},
"include": ["src/**/*"],

View File

@@ -1,6 +1,11 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
// __dirname in ESM
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default defineConfig({
test: {
globals: true,
@@ -8,6 +13,7 @@ export default defineConfig({
include: [
'tests/**/*.test.ts',
'tests/**/*.spec.ts',
'tests/{unit,integration,e2e}/**/*.{test,spec}.ts',
'src/**/*.test.ts',
'src/**/*.spec.ts'
],
@@ -22,7 +28,7 @@ export default defineConfig({
'**/*.test.ts',
'**/*.spec.ts',
'**/*.d.ts',
'**/index.ts'
'src/index.ts'
],
thresholds: {
branches: 80,

View File

@@ -3,6 +3,8 @@
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2022"],
"types": ["node"],
"allowJs": true,
"resolveJsonModule": true,
"esModuleInterop": true,
@@ -10,13 +12,7 @@
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"@tm/core": ["packages/tm-core/src/index.ts"],
"@tm/core/*": ["packages/tm-core/src/*"],
"@tm/cli": ["apps/cli/src/index.ts"],
"@tm/cli/*": ["apps/cli/src/*"]
}
"baseUrl": "."
},
"tsx": {
"tsconfig": {

View File

@@ -10,8 +10,6 @@ export default defineConfig({
splitting: false,
sourcemap: true,
clean: true,
shims: true,
dts: true,
bundle: true, // Bundle everything into one file
outDir: 'dist',
// Handle TypeScript imports transparently