@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,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact types for the orchestration workflow
|
|
3
|
+
*
|
|
4
|
+
* Artifacts are phase-specific knowledge files stored alongside .task.json
|
|
5
|
+
* Each phase (explore, search, plan, build, test) produces an artifact
|
|
6
|
+
* that subsequent phases can read and build upon.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Valid artifact phases in the orchestration workflow
|
|
10
|
+
*/
|
|
11
|
+
export declare const ARTIFACT_PHASES: readonly ["explore", "search", "plan", "build", "test"];
|
|
12
|
+
export type ArtifactPhase = typeof ARTIFACT_PHASES[number];
|
|
13
|
+
/**
|
|
14
|
+
* Required phases that must be present in every workflow
|
|
15
|
+
*/
|
|
16
|
+
export declare const REQUIRED_PHASES: readonly ArtifactPhase[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional phases that may be skipped
|
|
19
|
+
*/
|
|
20
|
+
export declare const OPTIONAL_PHASES: readonly ArtifactPhase[];
|
|
21
|
+
/**
|
|
22
|
+
* Valid artifact status values
|
|
23
|
+
*/
|
|
24
|
+
export declare const ARTIFACT_STATUSES: readonly ["pending", "in-progress", "completed", "failed", "skipped"];
|
|
25
|
+
export type ArtifactStatus = typeof ARTIFACT_STATUSES[number];
|
|
26
|
+
/**
|
|
27
|
+
* Status display information
|
|
28
|
+
*/
|
|
29
|
+
export declare const ARTIFACT_STATUS_INFO: Record<ArtifactStatus, {
|
|
30
|
+
label: string;
|
|
31
|
+
icon: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Phase display information
|
|
35
|
+
*/
|
|
36
|
+
export declare const PHASE_INFO: Record<ArtifactPhase, {
|
|
37
|
+
label: string;
|
|
38
|
+
icon: string;
|
|
39
|
+
order: number;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Artifact metadata stored in YAML frontmatter
|
|
43
|
+
*/
|
|
44
|
+
export interface ArtifactMetadata {
|
|
45
|
+
/** Phase this artifact belongs to */
|
|
46
|
+
readonly phase: ArtifactPhase;
|
|
47
|
+
/** Status of this phase */
|
|
48
|
+
status: ArtifactStatus;
|
|
49
|
+
/** Timestamp when the artifact was created */
|
|
50
|
+
readonly createdAt: string;
|
|
51
|
+
/** Timestamp when the artifact was last updated */
|
|
52
|
+
updatedAt: string;
|
|
53
|
+
/** Number of retry attempts for this phase */
|
|
54
|
+
retries?: number;
|
|
55
|
+
/** Optional error message if status is 'failed' */
|
|
56
|
+
error?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Complete artifact including metadata and content
|
|
60
|
+
*/
|
|
61
|
+
export interface Artifact {
|
|
62
|
+
/** Artifact metadata */
|
|
63
|
+
readonly metadata: ArtifactMetadata;
|
|
64
|
+
/** Markdown content of the artifact */
|
|
65
|
+
content: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Map of all artifacts for a task
|
|
69
|
+
*/
|
|
70
|
+
export type TaskArtifacts = {
|
|
71
|
+
readonly [K in ArtifactPhase]?: Artifact;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Input for creating an artifact
|
|
75
|
+
*/
|
|
76
|
+
export interface CreateArtifactInput {
|
|
77
|
+
/** Markdown content for the artifact body */
|
|
78
|
+
content: string;
|
|
79
|
+
/** Status of the phase (defaults to 'completed') */
|
|
80
|
+
status?: ArtifactStatus;
|
|
81
|
+
/** Number of retry attempts */
|
|
82
|
+
retries?: number;
|
|
83
|
+
/** Error message if status is 'failed' */
|
|
84
|
+
error?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Input for updating an artifact
|
|
88
|
+
*/
|
|
89
|
+
export interface UpdateArtifactInput {
|
|
90
|
+
/** Markdown content for the artifact body */
|
|
91
|
+
content?: string;
|
|
92
|
+
/** Status of the phase */
|
|
93
|
+
status?: ArtifactStatus;
|
|
94
|
+
/** Number of retry attempts */
|
|
95
|
+
retries?: number;
|
|
96
|
+
/** Error message if status is 'failed' */
|
|
97
|
+
error?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the filename for an artifact phase
|
|
101
|
+
*/
|
|
102
|
+
export declare function getArtifactFilename(phase: ArtifactPhase): string;
|
|
103
|
+
/**
|
|
104
|
+
* Check if a phase is valid
|
|
105
|
+
*/
|
|
106
|
+
export declare function isValidPhase(phase: unknown): phase is ArtifactPhase;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a status is valid
|
|
109
|
+
*/
|
|
110
|
+
export declare function isValidArtifactStatus(status: unknown): status is ArtifactStatus;
|
|
111
|
+
/**
|
|
112
|
+
* Get phase label
|
|
113
|
+
*/
|
|
114
|
+
export declare function getPhaseLabel(phase: ArtifactPhase): string;
|
|
115
|
+
/**
|
|
116
|
+
* Get phase icon
|
|
117
|
+
*/
|
|
118
|
+
export declare function getPhaseIcon(phase: ArtifactPhase): string;
|
|
119
|
+
/**
|
|
120
|
+
* Get status icon
|
|
121
|
+
*/
|
|
122
|
+
export declare function getArtifactStatusIcon(status: ArtifactStatus): string;
|
|
123
|
+
/**
|
|
124
|
+
* Human-readable descriptions for each phase
|
|
125
|
+
*/
|
|
126
|
+
export declare const PHASE_DESCRIPTIONS: Record<ArtifactPhase, string>;
|
|
127
|
+
/**
|
|
128
|
+
* Tool descriptions for each operation type
|
|
129
|
+
*/
|
|
130
|
+
export declare const OPERATION_DESCRIPTIONS: {
|
|
131
|
+
readonly create: {
|
|
132
|
+
readonly explore: "Create the explore artifact with codebase analysis findings. Use after analyzing the repository to document relevant files, logic entry points, and unknowns.";
|
|
133
|
+
readonly search: "Create the search artifact with external research findings. Use after web research to document patterns, best practices, and solutions found.";
|
|
134
|
+
readonly plan: "Create the plan artifact with the implementation approach. Use after designing the solution to document step-by-step implementation plan.";
|
|
135
|
+
readonly build: "Create the build artifact documenting implementation changes. Use after making code changes to document what was modified and why.";
|
|
136
|
+
readonly test: "Create the test artifact with verification results. Use after running tests to document results, pass/fail status, and any issues found.";
|
|
137
|
+
};
|
|
138
|
+
readonly update: {
|
|
139
|
+
readonly explore: "Update the explore artifact with additional analysis findings or corrections.";
|
|
140
|
+
readonly search: "Update the search artifact with additional research findings or corrections.";
|
|
141
|
+
readonly plan: "Update the plan artifact with revised approach or additional implementation steps.";
|
|
142
|
+
readonly build: "Update the build artifact with additional changes or corrections to the implementation record.";
|
|
143
|
+
readonly test: "Update the test artifact with additional test results or corrections.";
|
|
144
|
+
};
|
|
145
|
+
readonly delete: {
|
|
146
|
+
readonly explore: "Delete the explore artifact. Use to reset the exploration phase for re-analysis.";
|
|
147
|
+
readonly search: "Delete the search artifact. Use to reset the research phase for new research.";
|
|
148
|
+
readonly plan: "Delete the plan artifact. Use to reset the planning phase for a new approach.";
|
|
149
|
+
readonly build: "Delete the build artifact. Use to reset the build phase record.";
|
|
150
|
+
readonly test: "Delete the test artifact. Use to reset the testing phase for re-verification.";
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Get workflow progress based on artifact statuses
|
|
155
|
+
*/
|
|
156
|
+
export declare function getWorkflowProgress(artifacts: TaskArtifacts): {
|
|
157
|
+
completed: number;
|
|
158
|
+
total: number;
|
|
159
|
+
percentage: number;
|
|
160
|
+
nextPhase?: ArtifactPhase;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Check if workflow is complete
|
|
164
|
+
*/
|
|
165
|
+
export declare function isWorkflowComplete(artifacts: TaskArtifacts): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Get missing required phases
|
|
168
|
+
*/
|
|
169
|
+
export declare function getMissingRequiredPhases(artifacts: TaskArtifacts): ArtifactPhase[];
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact types for the orchestration workflow
|
|
3
|
+
*
|
|
4
|
+
* Artifacts are phase-specific knowledge files stored alongside .task.json
|
|
5
|
+
* Each phase (explore, search, plan, build, test) produces an artifact
|
|
6
|
+
* that subsequent phases can read and build upon.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Valid artifact phases in the orchestration workflow
|
|
10
|
+
*/
|
|
11
|
+
export const ARTIFACT_PHASES = ['explore', 'search', 'plan', 'build', 'test'];
|
|
12
|
+
/**
|
|
13
|
+
* Required phases that must be present in every workflow
|
|
14
|
+
*/
|
|
15
|
+
export const REQUIRED_PHASES = ['explore', 'plan', 'build'];
|
|
16
|
+
/**
|
|
17
|
+
* Optional phases that may be skipped
|
|
18
|
+
*/
|
|
19
|
+
export const OPTIONAL_PHASES = ['search', 'test'];
|
|
20
|
+
/**
|
|
21
|
+
* Valid artifact status values
|
|
22
|
+
*/
|
|
23
|
+
export const ARTIFACT_STATUSES = ['pending', 'in-progress', 'completed', 'failed', 'skipped'];
|
|
24
|
+
/**
|
|
25
|
+
* Status display information
|
|
26
|
+
*/
|
|
27
|
+
export const ARTIFACT_STATUS_INFO = {
|
|
28
|
+
'pending': { label: 'Pending', icon: '⏳' },
|
|
29
|
+
'in-progress': { label: 'In Progress', icon: '🔄' },
|
|
30
|
+
'completed': { label: 'Completed', icon: '✅' },
|
|
31
|
+
'failed': { label: 'Failed', icon: '❌' },
|
|
32
|
+
'skipped': { label: 'Skipped', icon: '⏭️' },
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Phase display information
|
|
36
|
+
*/
|
|
37
|
+
export const PHASE_INFO = {
|
|
38
|
+
explore: { label: 'Explore', icon: '🔍', order: 1 },
|
|
39
|
+
search: { label: 'Search', icon: '🌐', order: 2 },
|
|
40
|
+
plan: { label: 'Plan', icon: '📋', order: 3 },
|
|
41
|
+
build: { label: 'Build', icon: '🔨', order: 4 },
|
|
42
|
+
test: { label: 'Test', icon: '🧪', order: 5 },
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Get the filename for an artifact phase
|
|
46
|
+
*/
|
|
47
|
+
export function getArtifactFilename(phase) {
|
|
48
|
+
return `${phase}.md`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if a phase is valid
|
|
52
|
+
*/
|
|
53
|
+
export function isValidPhase(phase) {
|
|
54
|
+
return typeof phase === 'string' && ARTIFACT_PHASES.includes(phase);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if a status is valid
|
|
58
|
+
*/
|
|
59
|
+
export function isValidArtifactStatus(status) {
|
|
60
|
+
return typeof status === 'string' && ARTIFACT_STATUSES.includes(status);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get phase label
|
|
64
|
+
*/
|
|
65
|
+
export function getPhaseLabel(phase) {
|
|
66
|
+
return PHASE_INFO[phase].label;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get phase icon
|
|
70
|
+
*/
|
|
71
|
+
export function getPhaseIcon(phase) {
|
|
72
|
+
return PHASE_INFO[phase].icon;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get status icon
|
|
76
|
+
*/
|
|
77
|
+
export function getArtifactStatusIcon(status) {
|
|
78
|
+
return ARTIFACT_STATUS_INFO[status].icon;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Human-readable descriptions for each phase
|
|
82
|
+
*/
|
|
83
|
+
export const PHASE_DESCRIPTIONS = {
|
|
84
|
+
explore: 'Codebase analysis and discovery findings',
|
|
85
|
+
search: 'External research and documentation findings',
|
|
86
|
+
plan: 'Implementation approach and step-by-step plan',
|
|
87
|
+
build: 'Implementation changes and modifications made',
|
|
88
|
+
test: 'Test execution results and verification status'
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Tool descriptions for each operation type
|
|
92
|
+
*/
|
|
93
|
+
export const OPERATION_DESCRIPTIONS = {
|
|
94
|
+
create: {
|
|
95
|
+
explore: 'Create the explore artifact with codebase analysis findings. Use after analyzing the repository to document relevant files, logic entry points, and unknowns.',
|
|
96
|
+
search: 'Create the search artifact with external research findings. Use after web research to document patterns, best practices, and solutions found.',
|
|
97
|
+
plan: 'Create the plan artifact with the implementation approach. Use after designing the solution to document step-by-step implementation plan.',
|
|
98
|
+
build: 'Create the build artifact documenting implementation changes. Use after making code changes to document what was modified and why.',
|
|
99
|
+
test: 'Create the test artifact with verification results. Use after running tests to document results, pass/fail status, and any issues found.'
|
|
100
|
+
},
|
|
101
|
+
update: {
|
|
102
|
+
explore: 'Update the explore artifact with additional analysis findings or corrections.',
|
|
103
|
+
search: 'Update the search artifact with additional research findings or corrections.',
|
|
104
|
+
plan: 'Update the plan artifact with revised approach or additional implementation steps.',
|
|
105
|
+
build: 'Update the build artifact with additional changes or corrections to the implementation record.',
|
|
106
|
+
test: 'Update the test artifact with additional test results or corrections.'
|
|
107
|
+
},
|
|
108
|
+
delete: {
|
|
109
|
+
explore: 'Delete the explore artifact. Use to reset the exploration phase for re-analysis.',
|
|
110
|
+
search: 'Delete the search artifact. Use to reset the research phase for new research.',
|
|
111
|
+
plan: 'Delete the plan artifact. Use to reset the planning phase for a new approach.',
|
|
112
|
+
build: 'Delete the build artifact. Use to reset the build phase record.',
|
|
113
|
+
test: 'Delete the test artifact. Use to reset the testing phase for re-verification.'
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get workflow progress based on artifact statuses
|
|
118
|
+
*/
|
|
119
|
+
export function getWorkflowProgress(artifacts) {
|
|
120
|
+
let completed = 0;
|
|
121
|
+
let nextPhase;
|
|
122
|
+
for (const phase of ARTIFACT_PHASES) {
|
|
123
|
+
const artifact = artifacts[phase];
|
|
124
|
+
if (artifact?.metadata.status === 'completed') {
|
|
125
|
+
completed++;
|
|
126
|
+
}
|
|
127
|
+
else if (!nextPhase && artifact?.metadata.status !== 'skipped') {
|
|
128
|
+
nextPhase = phase;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
completed,
|
|
133
|
+
total: ARTIFACT_PHASES.length,
|
|
134
|
+
percentage: (completed / ARTIFACT_PHASES.length) * 100,
|
|
135
|
+
nextPhase,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if workflow is complete
|
|
140
|
+
*/
|
|
141
|
+
export function isWorkflowComplete(artifacts) {
|
|
142
|
+
return REQUIRED_PHASES.every(phase => {
|
|
143
|
+
const artifact = artifacts[phase];
|
|
144
|
+
return artifact?.metadata.status === 'completed';
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get missing required phases
|
|
149
|
+
*/
|
|
150
|
+
export function getMissingRequiredPhases(artifacts) {
|
|
151
|
+
return REQUIRED_PHASES.filter(phase => {
|
|
152
|
+
const artifact = artifacts[phase];
|
|
153
|
+
return !artifact || artifact.metadata.status !== 'completed';
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration constants for the task management system
|
|
3
|
+
*
|
|
4
|
+
* Task ID = folder name (e.g., '001-implement-auth') - serves as the task title
|
|
5
|
+
* ID generated from details field using intelligent slug extraction
|
|
6
|
+
* Details can be comprehensive, ID is auto-generated from key parts
|
|
7
|
+
* No index.json - tasks are discovered by scanning folders
|
|
8
|
+
*
|
|
9
|
+
* Artifacts stored in task folders as {phase}.md files
|
|
10
|
+
* Each phase (explore, search, plan, build, test) has its own artifact
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Current schema version for the task storage format
|
|
14
|
+
* v9.0.0 - Simplified model: subtasks inline, no dependsOn, no parentId
|
|
15
|
+
*/
|
|
16
|
+
export declare const CURRENT_STORAGE_VERSION = "9.0.0";
|
|
17
|
+
/**
|
|
18
|
+
* Storage paths configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare const STORAGE_PATHS: {
|
|
21
|
+
/** Root directory for cortex data */
|
|
22
|
+
readonly ROOT_DIR: ".cortex";
|
|
23
|
+
/** Tasks directory name */
|
|
24
|
+
readonly TASKS_DIR: "tasks";
|
|
25
|
+
/** Task metadata filename */
|
|
26
|
+
readonly TASK_FILE: ".task.json";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Task numbering configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare const TASK_NUMBERING: {
|
|
32
|
+
/** Number of digits for task numbers */
|
|
33
|
+
readonly DIGITS: 3;
|
|
34
|
+
/** Pattern for matching task folders */
|
|
35
|
+
readonly PATTERN: RegExp;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* File naming constraints
|
|
39
|
+
*/
|
|
40
|
+
export declare const FILE_NAMING: {
|
|
41
|
+
/** Maximum length for task slug */
|
|
42
|
+
readonly MAX_SLUG_LENGTH: 50;
|
|
43
|
+
/** Maximum length for full task ID */
|
|
44
|
+
readonly MAX_ID_LENGTH: 100;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Cache configuration defaults
|
|
48
|
+
*/
|
|
49
|
+
export declare const CACHE_CONFIG: {
|
|
50
|
+
/** Default TTL in milliseconds */
|
|
51
|
+
readonly DEFAULT_TTL: number;
|
|
52
|
+
/** Maximum cache entries */
|
|
53
|
+
readonly MAX_SIZE: 1000;
|
|
54
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration constants for the task management system
|
|
3
|
+
*
|
|
4
|
+
* Task ID = folder name (e.g., '001-implement-auth') - serves as the task title
|
|
5
|
+
* ID generated from details field using intelligent slug extraction
|
|
6
|
+
* Details can be comprehensive, ID is auto-generated from key parts
|
|
7
|
+
* No index.json - tasks are discovered by scanning folders
|
|
8
|
+
*
|
|
9
|
+
* Artifacts stored in task folders as {phase}.md files
|
|
10
|
+
* Each phase (explore, search, plan, build, test) has its own artifact
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Current schema version for the task storage format
|
|
14
|
+
* v9.0.0 - Simplified model: subtasks inline, no dependsOn, no parentId
|
|
15
|
+
*/
|
|
16
|
+
export const CURRENT_STORAGE_VERSION = '9.0.0';
|
|
17
|
+
/**
|
|
18
|
+
* Storage paths configuration
|
|
19
|
+
*/
|
|
20
|
+
export const STORAGE_PATHS = {
|
|
21
|
+
/** Root directory for cortex data */
|
|
22
|
+
ROOT_DIR: '.cortex',
|
|
23
|
+
/** Tasks directory name */
|
|
24
|
+
TASKS_DIR: 'tasks',
|
|
25
|
+
/** Task metadata filename */
|
|
26
|
+
TASK_FILE: '.task.json',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Task numbering configuration
|
|
30
|
+
*/
|
|
31
|
+
export const TASK_NUMBERING = {
|
|
32
|
+
/** Number of digits for task numbers */
|
|
33
|
+
DIGITS: 3,
|
|
34
|
+
/** Pattern for matching task folders */
|
|
35
|
+
PATTERN: /^\d{3}-/,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* File naming constraints
|
|
39
|
+
*/
|
|
40
|
+
export const FILE_NAMING = {
|
|
41
|
+
/** Maximum length for task slug */
|
|
42
|
+
MAX_SLUG_LENGTH: 50,
|
|
43
|
+
/** Maximum length for full task ID */
|
|
44
|
+
MAX_ID_LENGTH: 100,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Cache configuration defaults
|
|
48
|
+
*/
|
|
49
|
+
export const CACHE_CONFIG = {
|
|
50
|
+
/** Default TTL in milliseconds */
|
|
51
|
+
DEFAULT_TTL: 5 * 60 * 1000, // 5 minutes
|
|
52
|
+
/** Maximum cache entries */
|
|
53
|
+
MAX_SIZE: 1000,
|
|
54
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
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 declare const TASK_STATUSES: readonly ["pending", "in_progress", "done"];
|
|
16
|
+
export type TaskStatus = typeof TASK_STATUSES[number];
|
|
17
|
+
/**
|
|
18
|
+
* Status display information
|
|
19
|
+
*/
|
|
20
|
+
export declare const TASK_STATUS_INFO: Record<TaskStatus, {
|
|
21
|
+
label: string;
|
|
22
|
+
icon: string;
|
|
23
|
+
description: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Subtask - simplified task for organizational purposes
|
|
27
|
+
* Stored inside parent task's subtasks array
|
|
28
|
+
* Single level only - subtasks cannot have their own subtasks
|
|
29
|
+
*/
|
|
30
|
+
export interface Subtask {
|
|
31
|
+
/** Subtask ID (simple incremental number: "1", "2", etc.) */
|
|
32
|
+
readonly id: string;
|
|
33
|
+
/** Subtask description */
|
|
34
|
+
details: string;
|
|
35
|
+
/** Subtask status */
|
|
36
|
+
status: TaskStatus;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Base task interface - parent task with all fields
|
|
40
|
+
* Each parent task has its own folder with .task.json
|
|
41
|
+
*/
|
|
42
|
+
export interface Task {
|
|
43
|
+
/** Unique identifier for the task (same as folder name, e.g., '001-implement-auth') */
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/** Comprehensive task description with full context and requirements */
|
|
46
|
+
details: string;
|
|
47
|
+
/** Timestamp when the task was created */
|
|
48
|
+
readonly createdAt: string;
|
|
49
|
+
/** Timestamp when the task was last updated */
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
/** Task status (pending, in_progress, done) */
|
|
52
|
+
status: TaskStatus;
|
|
53
|
+
/** Tags for categorization and filtering */
|
|
54
|
+
tags?: string[];
|
|
55
|
+
/** Actual time spent in hours */
|
|
56
|
+
actualHours?: number;
|
|
57
|
+
/** Subtasks for organizational purposes */
|
|
58
|
+
subtasks: Subtask[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Task without readonly fields (for internal updates)
|
|
62
|
+
*/
|
|
63
|
+
export type MutableTask = Omit<Task, 'id' | 'createdAt'> & {
|
|
64
|
+
id: string;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Input data for creating a new parent task
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateTaskInput {
|
|
71
|
+
/** Task description - used to generate folder name/ID */
|
|
72
|
+
details: string;
|
|
73
|
+
/** Task status (defaults to 'pending') */
|
|
74
|
+
status?: TaskStatus;
|
|
75
|
+
/** Tags for categorization and filtering */
|
|
76
|
+
tags?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Input for adding a new subtask
|
|
80
|
+
*/
|
|
81
|
+
export interface AddSubtaskInput {
|
|
82
|
+
/** Subtask description */
|
|
83
|
+
details: string;
|
|
84
|
+
/** Subtask status (defaults to 'pending') */
|
|
85
|
+
status?: TaskStatus;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Input for updating an existing subtask
|
|
89
|
+
*/
|
|
90
|
+
export interface UpdateSubtaskInput {
|
|
91
|
+
/** Subtask ID to update */
|
|
92
|
+
id: string;
|
|
93
|
+
/** Updated description (optional) */
|
|
94
|
+
details?: string;
|
|
95
|
+
/** Updated status (optional) */
|
|
96
|
+
status?: TaskStatus;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Input data for updating an existing parent task
|
|
100
|
+
* Supports updating parent fields and subtask operations
|
|
101
|
+
*/
|
|
102
|
+
export interface UpdateTaskInput {
|
|
103
|
+
/** Task description (optional) */
|
|
104
|
+
details?: string;
|
|
105
|
+
/** Task status */
|
|
106
|
+
status?: TaskStatus;
|
|
107
|
+
/** Tags for categorization and filtering */
|
|
108
|
+
tags?: string[];
|
|
109
|
+
/** Actual time spent in hours */
|
|
110
|
+
actualHours?: number;
|
|
111
|
+
/** Add a new subtask */
|
|
112
|
+
addSubtask?: AddSubtaskInput;
|
|
113
|
+
/** Update an existing subtask */
|
|
114
|
+
updateSubtask?: UpdateSubtaskInput;
|
|
115
|
+
/** Remove subtask by ID */
|
|
116
|
+
removeSubtaskId?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Task hierarchy helper types
|
|
120
|
+
*/
|
|
121
|
+
export interface TaskHierarchy {
|
|
122
|
+
readonly task: Task;
|
|
123
|
+
readonly depth: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Task summary for list views
|
|
127
|
+
*/
|
|
128
|
+
export interface TaskSummary {
|
|
129
|
+
readonly id: string;
|
|
130
|
+
readonly status: TaskStatus;
|
|
131
|
+
readonly subtaskCount: number;
|
|
132
|
+
readonly doneSubtaskCount: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Task filters for querying
|
|
136
|
+
*/
|
|
137
|
+
export interface TaskFilters {
|
|
138
|
+
readonly status?: TaskStatus | TaskStatus[];
|
|
139
|
+
readonly tags?: string[];
|
|
140
|
+
readonly includeDone?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if a status is valid
|
|
144
|
+
*/
|
|
145
|
+
export declare function isValidTaskStatus(status: unknown): status is TaskStatus;
|
|
146
|
+
/**
|
|
147
|
+
* Get status icon
|
|
148
|
+
*/
|
|
149
|
+
export declare function getStatusIcon(status: TaskStatus): string;
|
|
150
|
+
/**
|
|
151
|
+
* Get status label
|
|
152
|
+
*/
|
|
153
|
+
export declare function getStatusLabel(status: TaskStatus): string;
|
|
154
|
+
/**
|
|
155
|
+
* Check if task is done (including all subtasks)
|
|
156
|
+
*/
|
|
157
|
+
export declare function isTaskDone(task: Task): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Calculate task progress (ratio of done subtasks)
|
|
160
|
+
*/
|
|
161
|
+
export declare function calculateTaskProgress(task: Task): number;
|
|
162
|
+
/**
|
|
163
|
+
* Generate next subtask ID
|
|
164
|
+
*/
|
|
165
|
+
export declare function generateNextSubtaskId(subtasks: readonly Subtask[]): string;
|
|
166
|
+
/**
|
|
167
|
+
* Find subtask by ID
|
|
168
|
+
*/
|
|
169
|
+
export declare function findSubtask(task: Task, subtaskId: string): Subtask | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Check if all subtasks are done
|
|
172
|
+
*/
|
|
173
|
+
export declare function areAllSubtasksDone(task: Task): boolean;
|