@task-mcp/shared 1.0.6 → 1.0.8

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.
Files changed (41) hide show
  1. package/dist/schemas/inbox.d.ts +49 -18
  2. package/dist/schemas/inbox.d.ts.map +1 -1
  3. package/dist/schemas/inbox.js +16 -16
  4. package/dist/schemas/inbox.js.map +1 -1
  5. package/dist/schemas/index.d.ts +2 -1
  6. package/dist/schemas/index.d.ts.map +1 -1
  7. package/dist/schemas/index.js +2 -0
  8. package/dist/schemas/index.js.map +1 -1
  9. package/dist/schemas/project.d.ts +164 -42
  10. package/dist/schemas/project.d.ts.map +1 -1
  11. package/dist/schemas/project.js +41 -33
  12. package/dist/schemas/project.js.map +1 -1
  13. package/dist/schemas/response-format.d.ts +76 -2
  14. package/dist/schemas/response-format.d.ts.map +1 -1
  15. package/dist/schemas/response-format.js +3 -2
  16. package/dist/schemas/response-format.js.map +1 -1
  17. package/dist/schemas/response-schema.d.ts +307 -0
  18. package/dist/schemas/response-schema.d.ts.map +1 -0
  19. package/dist/schemas/response-schema.js +75 -0
  20. package/dist/schemas/response-schema.js.map +1 -0
  21. package/dist/schemas/response-schema.test.d.ts +2 -0
  22. package/dist/schemas/response-schema.test.d.ts.map +1 -0
  23. package/dist/schemas/response-schema.test.js +256 -0
  24. package/dist/schemas/response-schema.test.js.map +1 -0
  25. package/dist/schemas/task.d.ts +588 -147
  26. package/dist/schemas/task.d.ts.map +1 -1
  27. package/dist/schemas/task.js +114 -88
  28. package/dist/schemas/task.js.map +1 -1
  29. package/dist/schemas/view.d.ts +128 -37
  30. package/dist/schemas/view.d.ts.map +1 -1
  31. package/dist/schemas/view.js +38 -24
  32. package/dist/schemas/view.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/schemas/inbox.ts +20 -20
  35. package/src/schemas/index.ts +23 -0
  36. package/src/schemas/project.ts +46 -40
  37. package/src/schemas/response-format.ts +99 -3
  38. package/src/schemas/response-schema.test.ts +314 -0
  39. package/src/schemas/response-schema.ts +92 -0
  40. package/src/schemas/task.ts +128 -110
  41. package/src/schemas/view.ts +43 -33
@@ -0,0 +1,92 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * Response Schema
5
+ *
6
+ * Standardized formats for AI agents to ask questions, make suggestions,
7
+ * or request confirmation from users.
8
+ */
9
+
10
+ // Response types
11
+ export const ResponseType = z.enum(["question", "suggestion", "confirmation"]);
12
+ export type ResponseType = z.infer<typeof ResponseType>;
13
+
14
+ // Priority level for responses
15
+ export const ResponsePriority = z.enum(["low", "medium", "high", "critical"]);
16
+ export type ResponsePriority = z.infer<typeof ResponsePriority>;
17
+
18
+ // Option for multiple choice responses
19
+ export const ResponseOption = z.object({
20
+ label: z.string().describe("Display text for the option"),
21
+ value: z.string().describe("Value to return when selected"),
22
+ description: z.string().optional().describe("Additional explanation"),
23
+ });
24
+ export type ResponseOption = z.infer<typeof ResponseOption>;
25
+
26
+ // Base response schema
27
+ const BaseResponse = z.object({
28
+ type: ResponseType.describe("Type of response: question, suggestion, or confirmation"),
29
+ message: z.string().describe("Main message to display to user"),
30
+ context: z.string().optional().describe("Additional context or explanation"),
31
+ priority: ResponsePriority.optional().describe("Urgency/importance of response (default: medium)"),
32
+ });
33
+
34
+ // Question response - for clarification
35
+ export const QuestionResponse = BaseResponse.extend({
36
+ type: z.literal("question"),
37
+ options: z.array(ResponseOption).optional()
38
+ .describe("Multiple choice options (omit for free-form answer)"),
39
+ defaultOption: z.string().optional()
40
+ .describe("Default option value if user provides no input"),
41
+ });
42
+ export type QuestionResponse = z.infer<typeof QuestionResponse>;
43
+
44
+ // Suggestion response - for recommendations
45
+ export const SuggestionResponse = BaseResponse.extend({
46
+ type: z.literal("suggestion"),
47
+ options: z.array(ResponseOption).min(1)
48
+ .describe("Suggested options for user to choose from"),
49
+ reasoning: z.string().optional()
50
+ .describe("Explanation of why these suggestions were made"),
51
+ });
52
+ export type SuggestionResponse = z.infer<typeof SuggestionResponse>;
53
+
54
+ // Confirmation response - for explicit approval
55
+ export const ConfirmationResponse = BaseResponse.extend({
56
+ type: z.literal("confirmation"),
57
+ action: z.string().describe("Action that will be taken if confirmed"),
58
+ consequences: z.array(z.string()).optional()
59
+ .describe("List of effects or changes that will occur"),
60
+ defaultConfirm: z.boolean().optional()
61
+ .describe("Default choice if user provides no input (default: false)"),
62
+ });
63
+ export type ConfirmationResponse = z.infer<typeof ConfirmationResponse>;
64
+
65
+ // Union type for all response types
66
+ export const AgentResponse = z.discriminatedUnion("type", [
67
+ QuestionResponse,
68
+ SuggestionResponse,
69
+ ConfirmationResponse,
70
+ ]);
71
+ export type AgentResponse = z.infer<typeof AgentResponse>;
72
+
73
+ // Input schema for generating responses
74
+ export const GenerateResponseInput = z.object({
75
+ type: ResponseType.describe("Type of response to generate"),
76
+ message: z.string().describe("Main message"),
77
+ options: z.array(ResponseOption).optional()
78
+ .describe("Options for question/suggestion types"),
79
+ context: z.string().optional(),
80
+ priority: ResponsePriority.optional().default("medium"),
81
+ action: z.string().optional()
82
+ .describe("Action description (for confirmation type)"),
83
+ consequences: z.array(z.string()).optional()
84
+ .describe("Consequences list (for confirmation type)"),
85
+ reasoning: z.string().optional()
86
+ .describe("Reasoning explanation (for suggestion type)"),
87
+ defaultOption: z.string().optional()
88
+ .describe("Default option value (for question type)"),
89
+ defaultConfirm: z.boolean().optional()
90
+ .describe("Default confirmation choice (for confirmation type)"),
91
+ });
92
+ export type GenerateResponseInput = z.infer<typeof GenerateResponseInput>;
@@ -1,166 +1,184 @@
1
- import { type } from "arktype";
1
+ import { z } from "zod";
2
2
 
3
3
  // Priority levels
4
- export const Priority = type("'critical' | 'high' | 'medium' | 'low'");
5
- export type Priority = typeof Priority.infer;
4
+ export const Priority = z.enum(["critical", "high", "medium", "low"]);
5
+ export type Priority = z.infer<typeof Priority>;
6
6
 
7
7
  // Task status with clear state machine
8
- export const TaskStatus = type(
9
- "'pending' | 'in_progress' | 'blocked' | 'completed' | 'cancelled'"
10
- );
11
- export type TaskStatus = typeof TaskStatus.infer;
8
+ export const TaskStatus = z.enum([
9
+ "pending",
10
+ "in_progress",
11
+ "blocked",
12
+ "completed",
13
+ "cancelled",
14
+ ]);
15
+ export type TaskStatus = z.infer<typeof TaskStatus>;
12
16
 
13
17
  // Dependency relationship types
14
- export const DependencyType = type(
15
- "'blocks' | 'blocked_by' | 'related'"
16
- );
17
- export type DependencyType = typeof DependencyType.infer;
18
+ export const DependencyType = z.enum(["blocks", "blocked_by", "related"]);
19
+ export type DependencyType = z.infer<typeof DependencyType>;
18
20
 
19
21
  // A single dependency link
20
- export const Dependency = type({
21
- taskId: "string",
22
+ export const Dependency = z.object({
23
+ taskId: z.string(),
22
24
  type: DependencyType,
23
- "reason?": "string",
25
+ reason: z.string().optional(),
24
26
  });
25
- export type Dependency = typeof Dependency.infer;
27
+ export type Dependency = z.infer<typeof Dependency>;
26
28
 
27
29
  // Time estimation
28
- export const TimeEstimate = type({
29
- "optimistic?": "number", // minutes
30
- "expected?": "number", // minutes
31
- "pessimistic?": "number", // minutes
32
- "confidence?": "'low' | 'medium' | 'high'",
30
+ export const TimeEstimate = z.object({
31
+ optimistic: z.number().optional(), // minutes
32
+ expected: z.number().optional(), // minutes
33
+ pessimistic: z.number().optional(), // minutes
34
+ confidence: z.enum(["low", "medium", "high"]).optional(),
33
35
  });
34
- export type TimeEstimate = typeof TimeEstimate.infer;
36
+ export type TimeEstimate = z.infer<typeof TimeEstimate>;
35
37
 
36
38
  // Recurrence pattern
37
- export const Recurrence = type({
38
- pattern: "'daily' | 'weekly' | 'monthly' | 'after_completion'",
39
- "interval?": "number", // every N days/weeks/months
40
- "daysOfWeek?": "number[]", // 0-6 for weekly
41
- "endDate?": "string",
39
+ export const Recurrence = z.object({
40
+ pattern: z.enum(["daily", "weekly", "monthly", "after_completion"]),
41
+ interval: z.number().optional(), // every N days/weeks/months
42
+ daysOfWeek: z.array(z.number()).optional(), // 0-6 for weekly
43
+ endDate: z.string().optional(),
42
44
  });
43
- export type Recurrence = typeof Recurrence.infer;
45
+ export type Recurrence = z.infer<typeof Recurrence>;
44
46
 
45
47
  // Complexity factors that contribute to task difficulty
46
- export const ComplexityFactor = type(
47
- "'cross_cutting' | 'state_management' | 'error_handling' | 'performance' | 'security' | 'external_dependency' | 'data_migration' | 'breaking_change' | 'unclear_requirements' | 'coordination'"
48
- );
49
- export type ComplexityFactor = typeof ComplexityFactor.infer;
48
+ export const ComplexityFactor = z.enum([
49
+ "cross_cutting",
50
+ "state_management",
51
+ "error_handling",
52
+ "performance",
53
+ "security",
54
+ "external_dependency",
55
+ "data_migration",
56
+ "breaking_change",
57
+ "unclear_requirements",
58
+ "coordination",
59
+ ]);
60
+ export type ComplexityFactor = z.infer<typeof ComplexityFactor>;
50
61
 
51
62
  // Complexity analysis result (populated by Claude)
52
- export const ComplexityAnalysis = type({
53
- "score?": "number", // 1-10 complexity score
54
- "factors?": ComplexityFactor.array(),
55
- "suggestedSubtasks?": "number", // 0-10 recommended subtask count
56
- "rationale?": "string",
57
- "analyzedAt?": "string",
63
+ export const ComplexityAnalysis = z.object({
64
+ score: z.number().optional(), // 1-10 complexity score
65
+ factors: z.array(ComplexityFactor).optional(),
66
+ suggestedSubtasks: z.number().optional(), // 0-10 recommended subtask count
67
+ rationale: z.string().optional(),
68
+ analyzedAt: z.string().optional(),
58
69
  });
59
- export type ComplexityAnalysis = typeof ComplexityAnalysis.infer;
70
+ export type ComplexityAnalysis = z.infer<typeof ComplexityAnalysis>;
60
71
 
61
72
  // Tech area categories for ordering
62
- export const TechArea = type(
63
- "'schema' | 'backend' | 'frontend' | 'infra' | 'devops' | 'test' | 'docs' | 'refactor'"
64
- );
65
- export type TechArea = typeof TechArea.infer;
73
+ export const TechArea = z.enum([
74
+ "schema",
75
+ "backend",
76
+ "frontend",
77
+ "infra",
78
+ "devops",
79
+ "test",
80
+ "docs",
81
+ "refactor",
82
+ ]);
83
+ export type TechArea = z.infer<typeof TechArea>;
66
84
 
67
85
  // Risk level for changes
68
- export const RiskLevel = type("'low' | 'medium' | 'high' | 'critical'");
69
- export type RiskLevel = typeof RiskLevel.infer;
86
+ export const RiskLevel = z.enum(["low", "medium", "high", "critical"]);
87
+ export type RiskLevel = z.infer<typeof RiskLevel>;
70
88
 
71
89
  // Tech stack analysis result (populated by Claude)
72
- export const TechStackAnalysis = type({
73
- "areas?": TechArea.array(),
74
- "hasBreakingChange?": "boolean",
75
- "riskLevel?": RiskLevel,
76
- "affectedComponents?": "string[]",
77
- "rationale?": "string",
78
- "analyzedAt?": "string",
90
+ export const TechStackAnalysis = z.object({
91
+ areas: z.array(TechArea).optional(),
92
+ hasBreakingChange: z.boolean().optional(),
93
+ riskLevel: RiskLevel.optional(),
94
+ affectedComponents: z.array(z.string()).optional(),
95
+ rationale: z.string().optional(),
96
+ analyzedAt: z.string().optional(),
79
97
  });
80
- export type TechStackAnalysis = typeof TechStackAnalysis.infer;
98
+ export type TechStackAnalysis = z.infer<typeof TechStackAnalysis>;
81
99
 
82
100
  // Core Task schema
83
- export const Task = type({
84
- id: "string",
85
- title: "string",
86
- "description?": "string",
101
+ export const Task = z.object({
102
+ id: z.string(),
103
+ title: z.string(),
104
+ description: z.string().optional(),
87
105
  status: TaskStatus,
88
106
  priority: Priority,
89
- projectId: "string",
107
+ projectId: z.string(),
90
108
 
91
109
  // Hierarchy (subtask support)
92
- "parentId?": "string", // Parent task ID for subtasks
93
- "level?": "number", // Hierarchy depth (0=root, 1=subtask, 2=sub-subtask, max 3)
110
+ parentId: z.string().nullable().optional(), // Parent task ID for subtasks (null to unlink)
111
+ level: z.number().optional(), // Hierarchy depth (0=root, 1=subtask, 2=sub-subtask, max 3)
94
112
 
95
113
  // Dependencies
96
- "dependencies?": Dependency.array(),
114
+ dependencies: z.array(Dependency).optional(),
97
115
 
98
116
  // Time tracking
99
- "estimate?": TimeEstimate,
100
- "actualMinutes?": "number",
101
- "dueDate?": "string", // ISO date string
102
- "startDate?": "string", // When task can start
103
- "startedAt?": "string",
104
- "completedAt?": "string",
117
+ estimate: TimeEstimate.optional(),
118
+ actualMinutes: z.number().optional(),
119
+ dueDate: z.string().optional(), // ISO date string
120
+ startDate: z.string().optional(), // When task can start
121
+ startedAt: z.string().optional(),
122
+ completedAt: z.string().optional(),
105
123
 
106
124
  // Organization
107
- "contexts?": "string[]", // e.g., ["focus", "review"]
108
- "tags?": "string[]",
125
+ contexts: z.array(z.string()).optional(), // e.g., ["focus", "review"]
126
+ tags: z.array(z.string()).optional(),
109
127
 
110
128
  // Recurrence
111
- "recurrence?": Recurrence,
129
+ recurrence: Recurrence.optional(),
112
130
 
113
131
  // Metadata
114
- createdAt: "string",
115
- updatedAt: "string",
132
+ createdAt: z.string(),
133
+ updatedAt: z.string(),
116
134
 
117
135
  // Computed fields (populated at runtime)
118
- "criticalPath?": "boolean",
119
- "slack?": "number", // Minutes of slack time
120
- "earliestStart?": "number", // Minutes from project start
121
- "latestStart?": "number",
136
+ criticalPath: z.boolean().optional(),
137
+ slack: z.number().optional(), // Minutes of slack time
138
+ earliestStart: z.number().optional(), // Minutes from project start
139
+ latestStart: z.number().optional(),
122
140
 
123
141
  // Analysis fields (populated by Claude)
124
- "complexity?": ComplexityAnalysis,
125
- "techStack?": TechStackAnalysis,
142
+ complexity: ComplexityAnalysis.optional(),
143
+ techStack: TechStackAnalysis.optional(),
126
144
  });
127
- export type Task = typeof Task.infer;
145
+ export type Task = z.infer<typeof Task>;
128
146
 
129
147
  // Task creation input (minimal required fields)
130
- export const TaskCreateInput = type({
131
- title: "string",
132
- "description?": "string",
133
- "projectId?": "string",
134
- "priority?": Priority,
135
- "parentId?": "string", // Parent task ID for creating subtasks
136
- "dependencies?": Dependency.array(),
137
- "estimate?": TimeEstimate,
138
- "dueDate?": "string",
139
- "startDate?": "string",
140
- "contexts?": "string[]",
141
- "tags?": "string[]",
142
- "recurrence?": Recurrence,
148
+ export const TaskCreateInput = z.object({
149
+ title: z.string(),
150
+ description: z.string().optional(),
151
+ projectId: z.string().optional(),
152
+ priority: Priority.optional(),
153
+ parentId: z.string().nullable().optional(), // Parent task ID for creating subtasks (null to unlink)
154
+ dependencies: z.array(Dependency).optional(),
155
+ estimate: TimeEstimate.optional(),
156
+ dueDate: z.string().optional(),
157
+ startDate: z.string().optional(),
158
+ contexts: z.array(z.string()).optional(),
159
+ tags: z.array(z.string()).optional(),
160
+ recurrence: Recurrence.optional(),
143
161
  });
144
- export type TaskCreateInput = typeof TaskCreateInput.infer;
162
+ export type TaskCreateInput = z.infer<typeof TaskCreateInput>;
145
163
 
146
164
  // Task update input
147
- export const TaskUpdateInput = type({
148
- "title?": "string",
149
- "description?": "string",
150
- "status?": TaskStatus,
151
- "priority?": Priority,
152
- "projectId?": "string",
153
- "parentId?": "string", // Parent task ID for moving task in hierarchy
154
- "dependencies?": Dependency.array(),
155
- "estimate?": TimeEstimate,
156
- "actualMinutes?": "number",
157
- "dueDate?": "string",
158
- "startDate?": "string",
159
- "contexts?": "string[]",
160
- "tags?": "string[]",
161
- "recurrence?": Recurrence,
165
+ export const TaskUpdateInput = z.object({
166
+ title: z.string().optional(),
167
+ description: z.string().optional(),
168
+ status: TaskStatus.optional(),
169
+ priority: Priority.optional(),
170
+ projectId: z.string().optional(),
171
+ parentId: z.string().nullable().optional(), // Parent task ID for moving task in hierarchy (null to unlink)
172
+ dependencies: z.array(Dependency).optional(),
173
+ estimate: TimeEstimate.optional(),
174
+ actualMinutes: z.number().optional(),
175
+ dueDate: z.string().optional(),
176
+ startDate: z.string().optional(),
177
+ contexts: z.array(z.string()).optional(),
178
+ tags: z.array(z.string()).optional(),
179
+ recurrence: Recurrence.optional(),
162
180
  // Analysis fields
163
- "complexity?": ComplexityAnalysis,
164
- "techStack?": TechStackAnalysis,
181
+ complexity: ComplexityAnalysis.optional(),
182
+ techStack: TechStackAnalysis.optional(),
165
183
  });
166
- export type TaskUpdateInput = typeof TaskUpdateInput.infer;
184
+ export type TaskUpdateInput = z.infer<typeof TaskUpdateInput>;
@@ -1,46 +1,56 @@
1
- import { type } from "arktype";
1
+ import { z } from "zod";
2
2
  import { Priority, TaskStatus } from "./task.js";
3
3
 
4
4
  // Smart View filter
5
- export const SmartViewFilter = type({
6
- "statuses?": TaskStatus.array(),
7
- "priorities?": Priority.array(),
8
- "contexts?": "string[]",
9
- "tags?": "string[]",
10
- "projectIds?": "string[]",
11
- "dueBefore?": "string",
12
- "dueAfter?": "string",
13
- "isBlocked?": "boolean",
14
- "isCriticalPath?": "boolean",
15
- "hasNoDependencies?": "boolean",
16
- "search?": "string", // Search in title/description
5
+ export const SmartViewFilter = z.object({
6
+ statuses: z.array(TaskStatus).optional(),
7
+ priorities: z.array(Priority).optional(),
8
+ contexts: z.array(z.string()).optional(),
9
+ tags: z.array(z.string()).optional(),
10
+ projectIds: z.array(z.string()).optional(),
11
+ dueBefore: z.string().optional(),
12
+ dueAfter: z.string().optional(),
13
+ isBlocked: z.boolean().optional(),
14
+ isCriticalPath: z.boolean().optional(),
15
+ hasNoDependencies: z.boolean().optional(),
16
+ search: z.string().optional(), // Search in title/description
17
17
  });
18
- export type SmartViewFilter = typeof SmartViewFilter.infer;
18
+ export type SmartViewFilter = z.infer<typeof SmartViewFilter>;
19
19
 
20
20
  // Sort options
21
- export const SortField = type(
22
- "'priority' | 'dueDate' | 'createdAt' | 'criticalPath' | 'slack' | 'title'"
23
- );
24
- export type SortField = typeof SortField.infer;
21
+ export const SortField = z.enum([
22
+ "priority",
23
+ "dueDate",
24
+ "createdAt",
25
+ "criticalPath",
26
+ "slack",
27
+ "title",
28
+ ]);
29
+ export type SortField = z.infer<typeof SortField>;
25
30
 
26
- export const SortOrder = type("'asc' | 'desc'");
27
- export type SortOrder = typeof SortOrder.infer;
31
+ export const SortOrder = z.enum(["asc", "desc"]);
32
+ export type SortOrder = z.infer<typeof SortOrder>;
28
33
 
29
34
  // Smart View definition
30
- export const SmartView = type({
31
- id: "string",
32
- name: "string",
33
- "description?": "string",
35
+ export const SmartView = z.object({
36
+ id: z.string(),
37
+ name: z.string(),
38
+ description: z.string().optional(),
34
39
  filter: SmartViewFilter,
35
- "sortBy?": SortField,
36
- "sortOrder?": SortOrder,
37
- createdAt: "string",
38
- updatedAt: "string",
40
+ sortBy: SortField.optional(),
41
+ sortOrder: SortOrder.optional(),
42
+ createdAt: z.string(),
43
+ updatedAt: z.string(),
39
44
  });
40
- export type SmartView = typeof SmartView.infer;
45
+ export type SmartView = z.infer<typeof SmartView>;
41
46
 
42
47
  // Built-in view names
43
- export const BuiltInView = type(
44
- "'today' | 'this_week' | 'blocked' | 'critical_path' | 'quick_wins' | 'all'"
45
- );
46
- export type BuiltInView = typeof BuiltInView.infer;
48
+ export const BuiltInView = z.enum([
49
+ "today",
50
+ "this_week",
51
+ "blocked",
52
+ "critical_path",
53
+ "quick_wins",
54
+ "all",
55
+ ]);
56
+ export type BuiltInView = z.infer<typeof BuiltInView>;