@geanatz/cortex-mcp 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/dist/errors/errors.d.ts +109 -0
- package/dist/errors/errors.js +199 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/features/task-management/models/artifact.d.ts +169 -0
- package/dist/features/task-management/models/artifact.js +155 -0
- package/dist/features/task-management/models/config.d.ts +54 -0
- package/dist/features/task-management/models/config.js +54 -0
- package/dist/features/task-management/models/index.d.ts +6 -0
- package/dist/features/task-management/models/index.js +6 -0
- package/dist/features/task-management/models/task.d.ts +173 -0
- package/dist/features/task-management/models/task.js +84 -0
- package/dist/features/task-management/storage/file-storage.d.ts +130 -0
- package/dist/features/task-management/storage/file-storage.js +575 -0
- package/dist/features/task-management/storage/index.d.ts +5 -0
- package/dist/features/task-management/storage/index.js +5 -0
- package/dist/features/task-management/storage/storage.d.ts +159 -0
- package/dist/features/task-management/storage/storage.js +37 -0
- package/dist/features/task-management/tools/artifacts/index.d.ts +6 -0
- package/dist/features/task-management/tools/artifacts/index.js +174 -0
- package/dist/features/task-management/tools/base/handlers.d.ts +7 -0
- package/dist/features/task-management/tools/base/handlers.js +15 -0
- package/dist/features/task-management/tools/base/index.d.ts +3 -0
- package/dist/features/task-management/tools/base/index.js +3 -0
- package/dist/features/task-management/tools/base/schemas.d.ts +3 -0
- package/dist/features/task-management/tools/base/schemas.js +6 -0
- package/dist/features/task-management/tools/base/types.d.ts +13 -0
- package/dist/features/task-management/tools/base/types.js +1 -0
- package/dist/features/task-management/tools/tasks/index.d.ts +10 -0
- package/dist/features/task-management/tools/tasks/index.js +500 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +57 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +61 -0
- package/dist/types/common.d.ts +10 -0
- package/dist/types/common.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/utils/cache.d.ts +104 -0
- package/dist/utils/cache.js +196 -0
- package/dist/utils/file-utils.d.ts +101 -0
- package/dist/utils/file-utils.js +270 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/logger.d.ts +77 -0
- package/dist/utils/logger.js +173 -0
- package/dist/utils/response-builder.d.ts +4 -0
- package/dist/utils/response-builder.js +19 -0
- package/dist/utils/storage-config.d.ts +29 -0
- package/dist/utils/storage-config.js +51 -0
- package/dist/utils/string-utils.d.ts +2 -0
- package/dist/utils/string-utils.js +16 -0
- package/dist/utils/validation.d.ts +9 -0
- package/dist/utils/validation.js +9 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.js +41 -0
- package/package.json +60 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task data model for the task management system
|
|
3
|
+
* ID = folder name (e.g., '001-implement-auth') - acts as the task title
|
|
4
|
+
* Details = comprehensive description
|
|
5
|
+
*
|
|
6
|
+
* New Structure:
|
|
7
|
+
* - Each parent task has its own folder
|
|
8
|
+
* - Subtasks are stored INSIDE the parent .task.json file
|
|
9
|
+
* - No separate folders for subtasks
|
|
10
|
+
* - No dependsOn field - simplified dependency model
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Valid task status values
|
|
14
|
+
*/
|
|
15
|
+
export const TASK_STATUSES = ['pending', 'in_progress', 'done'];
|
|
16
|
+
/**
|
|
17
|
+
* Status display information
|
|
18
|
+
*/
|
|
19
|
+
export const TASK_STATUS_INFO = {
|
|
20
|
+
pending: { label: 'Pending', icon: '⏳', description: 'Task has not been started' },
|
|
21
|
+
in_progress: { label: 'In Progress', icon: '🔄', description: 'Task is currently being worked on' },
|
|
22
|
+
done: { label: 'Done', icon: '✅', description: 'Task has been completed' },
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Check if a status is valid
|
|
26
|
+
*/
|
|
27
|
+
export function isValidTaskStatus(status) {
|
|
28
|
+
return typeof status === 'string' && TASK_STATUSES.includes(status);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get status icon
|
|
32
|
+
*/
|
|
33
|
+
export function getStatusIcon(status) {
|
|
34
|
+
return TASK_STATUS_INFO[status].icon;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get status label
|
|
38
|
+
*/
|
|
39
|
+
export function getStatusLabel(status) {
|
|
40
|
+
return TASK_STATUS_INFO[status].label;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if task is done (including all subtasks)
|
|
44
|
+
*/
|
|
45
|
+
export function isTaskDone(task) {
|
|
46
|
+
if (task.status !== 'done')
|
|
47
|
+
return false;
|
|
48
|
+
if (task.subtasks.length === 0)
|
|
49
|
+
return true;
|
|
50
|
+
return task.subtasks.every(subtask => subtask.status === 'done');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Calculate task progress (ratio of done subtasks)
|
|
54
|
+
*/
|
|
55
|
+
export function calculateTaskProgress(task) {
|
|
56
|
+
if (task.subtasks.length === 0) {
|
|
57
|
+
return task.status === 'done' ? 1 : 0;
|
|
58
|
+
}
|
|
59
|
+
const doneCount = task.subtasks.filter(s => s.status === 'done').length;
|
|
60
|
+
return doneCount / task.subtasks.length;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate next subtask ID
|
|
64
|
+
*/
|
|
65
|
+
export function generateNextSubtaskId(subtasks) {
|
|
66
|
+
if (subtasks.length === 0)
|
|
67
|
+
return '1';
|
|
68
|
+
const maxId = Math.max(...subtasks.map(s => parseInt(s.id, 10)).filter(n => !isNaN(n)));
|
|
69
|
+
return String(maxId + 1);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Find subtask by ID
|
|
73
|
+
*/
|
|
74
|
+
export function findSubtask(task, subtaskId) {
|
|
75
|
+
return task.subtasks.find(s => s.id === subtaskId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if all subtasks are done
|
|
79
|
+
*/
|
|
80
|
+
export function areAllSubtasksDone(task) {
|
|
81
|
+
if (task.subtasks.length === 0)
|
|
82
|
+
return true;
|
|
83
|
+
return task.subtasks.every(s => s.status === 'done');
|
|
84
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BaseStorage, StorageStats } from './storage.js';
|
|
2
|
+
import { Task, TaskHierarchy, CreateTaskInput, UpdateTaskInput, Subtask, AddSubtaskInput, UpdateSubtaskInput } from '../models/task.js';
|
|
3
|
+
import { Artifact, CreateArtifactInput, UpdateArtifactInput, ArtifactPhase, TaskArtifacts } from '../models/artifact.js';
|
|
4
|
+
/**
|
|
5
|
+
* File-based storage implementation - Simplified Model
|
|
6
|
+
*
|
|
7
|
+
* Storage Structure:
|
|
8
|
+
* - .cortex/tasks/{number}-{slug}/.task.json - Contains parent task + subtasks array
|
|
9
|
+
* - .cortex/tasks/{number}-{slug}/{phase}.md - Artifact files (for entire hierarchy)
|
|
10
|
+
*
|
|
11
|
+
* Key Changes:
|
|
12
|
+
* - Subtasks are stored INSIDE the parent .task.json file
|
|
13
|
+
* - No separate folders for subtasks
|
|
14
|
+
* - No dependsOn field - simplified model
|
|
15
|
+
* - Single level nesting only (subtasks cannot have subtasks)
|
|
16
|
+
* - Artifacts belong to the entire task hierarchy
|
|
17
|
+
*
|
|
18
|
+
* Features:
|
|
19
|
+
* - Each parent task has its own folder with sequential numbering
|
|
20
|
+
* - Task ID = folder name (e.g., '001-implement-auth')
|
|
21
|
+
* - Atomic file writes using temp files
|
|
22
|
+
* - In-memory caching with TTL
|
|
23
|
+
*/
|
|
24
|
+
export declare class FileStorage extends BaseStorage {
|
|
25
|
+
private readonly workingDirectory;
|
|
26
|
+
private readonly cortexDir;
|
|
27
|
+
private readonly tasksDir;
|
|
28
|
+
private readonly taskCache;
|
|
29
|
+
private readonly artifactCache;
|
|
30
|
+
private taskFoldersCache;
|
|
31
|
+
private taskFoldersCacheTime;
|
|
32
|
+
constructor(workingDirectory: string);
|
|
33
|
+
/**
|
|
34
|
+
* Initialize storage by validating working directory and ensuring directories exist
|
|
35
|
+
*/
|
|
36
|
+
initialize(): Promise<void>;
|
|
37
|
+
getWorkingDirectory(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Sanitize a string for safe filesystem usage
|
|
40
|
+
*/
|
|
41
|
+
private sanitizeName;
|
|
42
|
+
/**
|
|
43
|
+
* Get the next sequential number by scanning existing task folders
|
|
44
|
+
*/
|
|
45
|
+
private getNextNumber;
|
|
46
|
+
/**
|
|
47
|
+
* Generate task ID (folder name) from details
|
|
48
|
+
*/
|
|
49
|
+
private generateTaskId;
|
|
50
|
+
/**
|
|
51
|
+
* Get task folder path
|
|
52
|
+
*/
|
|
53
|
+
private getTaskFolderPath;
|
|
54
|
+
/**
|
|
55
|
+
* Get task file path
|
|
56
|
+
*/
|
|
57
|
+
private getTaskFilePath;
|
|
58
|
+
/**
|
|
59
|
+
* Get artifact file path
|
|
60
|
+
*/
|
|
61
|
+
private getArtifactFilePath;
|
|
62
|
+
/**
|
|
63
|
+
* Get all task folder names (parent tasks only, with caching)
|
|
64
|
+
*/
|
|
65
|
+
private getTaskFolders;
|
|
66
|
+
/**
|
|
67
|
+
* Invalidate task folders cache
|
|
68
|
+
*/
|
|
69
|
+
private invalidateTaskFoldersCache;
|
|
70
|
+
/**
|
|
71
|
+
* Load a task from disk (with caching)
|
|
72
|
+
*/
|
|
73
|
+
private loadTask;
|
|
74
|
+
/**
|
|
75
|
+
* Save a task to disk and update cache
|
|
76
|
+
*/
|
|
77
|
+
private saveTask;
|
|
78
|
+
/**
|
|
79
|
+
* Get all parent tasks (subtasks are inside each task)
|
|
80
|
+
*/
|
|
81
|
+
getTasks(): Promise<readonly Task[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get a single task by ID
|
|
84
|
+
*/
|
|
85
|
+
getTask(id: string): Promise<Task | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new parent task
|
|
88
|
+
*/
|
|
89
|
+
createTask(input: CreateTaskInput): Promise<Task>;
|
|
90
|
+
/**
|
|
91
|
+
* Update an existing task
|
|
92
|
+
* Supports updating parent fields and subtask operations
|
|
93
|
+
*/
|
|
94
|
+
updateTask(id: string, updates: UpdateTaskInput): Promise<Task | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete a task and all its subtasks
|
|
97
|
+
*/
|
|
98
|
+
deleteTask(id: string): Promise<boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* Add a subtask to a parent task
|
|
101
|
+
*/
|
|
102
|
+
addSubtask(taskId: string, input: AddSubtaskInput): Promise<Subtask | null>;
|
|
103
|
+
/**
|
|
104
|
+
* Update a subtask
|
|
105
|
+
*/
|
|
106
|
+
updateSubtask(taskId: string, input: UpdateSubtaskInput): Promise<Subtask | null>;
|
|
107
|
+
/**
|
|
108
|
+
* Remove a subtask by ID
|
|
109
|
+
*/
|
|
110
|
+
removeSubtask(taskId: string, subtaskId: string): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Get task hierarchy (all parent tasks with their subtasks)
|
|
113
|
+
*/
|
|
114
|
+
getTaskHierarchy(): Promise<readonly TaskHierarchy[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Parse artifact file content (YAML frontmatter + markdown body)
|
|
117
|
+
*/
|
|
118
|
+
private parseArtifactContent;
|
|
119
|
+
/**
|
|
120
|
+
* Serialize artifact to file content
|
|
121
|
+
*/
|
|
122
|
+
private serializeArtifact;
|
|
123
|
+
getArtifact(taskId: string, phase: ArtifactPhase): Promise<Artifact | null>;
|
|
124
|
+
getAllArtifacts(taskId: string): Promise<TaskArtifacts>;
|
|
125
|
+
createArtifact(taskId: string, phase: ArtifactPhase, input: CreateArtifactInput): Promise<Artifact>;
|
|
126
|
+
updateArtifact(taskId: string, phase: ArtifactPhase, input: UpdateArtifactInput): Promise<Artifact | null>;
|
|
127
|
+
deleteArtifact(taskId: string, phase: ArtifactPhase): Promise<boolean>;
|
|
128
|
+
getStats(): Promise<StorageStats>;
|
|
129
|
+
clearCache(): void;
|
|
130
|
+
}
|