packages/tm-core/docs/listTasks-architecture.md
┌─────────────────────────────────────────────────────────────┐
│ CLI Layer │
│ scripts/modules/task-manager/list-tasks.js │
│ - Complex UI rendering (tables, progress bars) │
│ - Multiple output formats (json, text, markdown, compact) │
│ - Status filtering and statistics │
└─────────────────────────────────────────────────────────────┘
│
│ Currently reads directly
│ from files (needs integration)
▼
┌─────────────────────────────────────────────────────────────┐
│ tm-core Package │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ TaskMasterCore (Facade) │ │
│ │ src/task-master-core.ts │ │
│ │ │ │
│ │ - listTasks(options) │ │
│ │ • tag filtering │ │
│ │ • status filtering │ │
│ │ • include/exclude subtasks │ │
│ │ - getTask(id) │ │
│ │ - getTasksByStatus(status) │ │
│ │ - getTaskStats() │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Storage Layer (IStorage) │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ FileStorage │ │ ApiStorage │ │ │
│ │ │ │ │ (Hamster) │ │ │
│ │ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ │ StorageFactory.create() selects based on config │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Domain Layer (Entities) │ │
│ │ │ │
│ │ TaskEntity │ │
│ │ - Business logic │ │
│ │ - Validation │ │
│ │ - Status transitions │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
// Current CLI (needs update to use tm-core)
listTasks(tasksPath, statusFilter, reportPath, withSubtasks, outputFormat, context)
// Our new implementation
const tmCore = createTaskMasterCore(projectPath, {
storage: {
type: 'api', // or 'file'
apiEndpoint: 'https://tryhamster.com',
apiAccessToken: 'xxx'
}
});
const result = await tmCore.listTasks({
tag: 'feature-branch',
filter: {
status: ['pending', 'in-progress'],
priority: 'high',
search: 'authentication'
},
includeSubtasks: true
});
// StorageFactory automatically selects storage
const storage = StorageFactory.create(config, projectPath);
// Returns either FileStorage or ApiStorage based on config
// FileStorage
- Reads from .taskmaster/tasks/tasks.json (or tag-specific file)
- Local file system operations
// ApiStorage (Hamster)
- Makes HTTP requests to Hamster API
- Uses access token from config
- Handles retries and rate limiting
// Convert raw data to TaskEntity for business logic
const taskEntities = TaskEntity.fromArray(rawTasks);
// Apply filters
const filtered = applyFilters(taskEntities, filter);
// Convert back to plain objects
const tasks = filtered.map(entity => entity.toJSON());
interface ListTasksResult {
tasks: Task[]; // Filtered tasks
total: number; // Total task count
filtered: number; // Filtered task count
tag?: string; // Tag context if applicable
}
scripts/modules/task-manager/list-tasks.js to use tm-core.taskmaster/config.json for storage settings