@task-mcp/shared 1.0.7 → 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.
- package/dist/schemas/index.d.ts +2 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/project.d.ts +37 -28
- package/dist/schemas/project.d.ts.map +1 -1
- package/dist/schemas/project.js +3 -0
- package/dist/schemas/project.js.map +1 -1
- package/dist/schemas/response-format.d.ts +73 -0
- package/dist/schemas/response-format.d.ts.map +1 -1
- package/dist/schemas/response-format.js +1 -0
- package/dist/schemas/response-format.js.map +1 -1
- package/dist/schemas/response-schema.d.ts +307 -0
- package/dist/schemas/response-schema.d.ts.map +1 -0
- package/dist/schemas/response-schema.js +75 -0
- package/dist/schemas/response-schema.js.map +1 -0
- package/dist/schemas/response-schema.test.d.ts +2 -0
- package/dist/schemas/response-schema.test.d.ts.map +1 -0
- package/dist/schemas/response-schema.test.js +256 -0
- package/dist/schemas/response-schema.test.js.map +1 -0
- package/package.json +1 -1
- package/src/schemas/index.ts +23 -0
- package/src/schemas/project.ts +3 -0
- package/src/schemas/response-format.ts +96 -0
- package/src/schemas/response-schema.test.ts +314 -0
- package/src/schemas/response-schema.ts +92 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Response Schema
|
|
4
|
+
*
|
|
5
|
+
* Standardized formats for AI agents to ask questions, make suggestions,
|
|
6
|
+
* or request confirmation from users.
|
|
7
|
+
*/
|
|
8
|
+
// Response types
|
|
9
|
+
export const ResponseType = z.enum(["question", "suggestion", "confirmation"]);
|
|
10
|
+
// Priority level for responses
|
|
11
|
+
export const ResponsePriority = z.enum(["low", "medium", "high", "critical"]);
|
|
12
|
+
// Option for multiple choice responses
|
|
13
|
+
export const ResponseOption = z.object({
|
|
14
|
+
label: z.string().describe("Display text for the option"),
|
|
15
|
+
value: z.string().describe("Value to return when selected"),
|
|
16
|
+
description: z.string().optional().describe("Additional explanation"),
|
|
17
|
+
});
|
|
18
|
+
// Base response schema
|
|
19
|
+
const BaseResponse = z.object({
|
|
20
|
+
type: ResponseType.describe("Type of response: question, suggestion, or confirmation"),
|
|
21
|
+
message: z.string().describe("Main message to display to user"),
|
|
22
|
+
context: z.string().optional().describe("Additional context or explanation"),
|
|
23
|
+
priority: ResponsePriority.optional().describe("Urgency/importance of response (default: medium)"),
|
|
24
|
+
});
|
|
25
|
+
// Question response - for clarification
|
|
26
|
+
export const QuestionResponse = BaseResponse.extend({
|
|
27
|
+
type: z.literal("question"),
|
|
28
|
+
options: z.array(ResponseOption).optional()
|
|
29
|
+
.describe("Multiple choice options (omit for free-form answer)"),
|
|
30
|
+
defaultOption: z.string().optional()
|
|
31
|
+
.describe("Default option value if user provides no input"),
|
|
32
|
+
});
|
|
33
|
+
// Suggestion response - for recommendations
|
|
34
|
+
export const SuggestionResponse = BaseResponse.extend({
|
|
35
|
+
type: z.literal("suggestion"),
|
|
36
|
+
options: z.array(ResponseOption).min(1)
|
|
37
|
+
.describe("Suggested options for user to choose from"),
|
|
38
|
+
reasoning: z.string().optional()
|
|
39
|
+
.describe("Explanation of why these suggestions were made"),
|
|
40
|
+
});
|
|
41
|
+
// Confirmation response - for explicit approval
|
|
42
|
+
export const ConfirmationResponse = BaseResponse.extend({
|
|
43
|
+
type: z.literal("confirmation"),
|
|
44
|
+
action: z.string().describe("Action that will be taken if confirmed"),
|
|
45
|
+
consequences: z.array(z.string()).optional()
|
|
46
|
+
.describe("List of effects or changes that will occur"),
|
|
47
|
+
defaultConfirm: z.boolean().optional()
|
|
48
|
+
.describe("Default choice if user provides no input (default: false)"),
|
|
49
|
+
});
|
|
50
|
+
// Union type for all response types
|
|
51
|
+
export const AgentResponse = z.discriminatedUnion("type", [
|
|
52
|
+
QuestionResponse,
|
|
53
|
+
SuggestionResponse,
|
|
54
|
+
ConfirmationResponse,
|
|
55
|
+
]);
|
|
56
|
+
// Input schema for generating responses
|
|
57
|
+
export const GenerateResponseInput = z.object({
|
|
58
|
+
type: ResponseType.describe("Type of response to generate"),
|
|
59
|
+
message: z.string().describe("Main message"),
|
|
60
|
+
options: z.array(ResponseOption).optional()
|
|
61
|
+
.describe("Options for question/suggestion types"),
|
|
62
|
+
context: z.string().optional(),
|
|
63
|
+
priority: ResponsePriority.optional().default("medium"),
|
|
64
|
+
action: z.string().optional()
|
|
65
|
+
.describe("Action description (for confirmation type)"),
|
|
66
|
+
consequences: z.array(z.string()).optional()
|
|
67
|
+
.describe("Consequences list (for confirmation type)"),
|
|
68
|
+
reasoning: z.string().optional()
|
|
69
|
+
.describe("Reasoning explanation (for suggestion type)"),
|
|
70
|
+
defaultOption: z.string().optional()
|
|
71
|
+
.describe("Default option value (for question type)"),
|
|
72
|
+
defaultConfirm: z.boolean().optional()
|
|
73
|
+
.describe("Default confirmation choice (for confirmation type)"),
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=response-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-schema.js","sourceRoot":"","sources":["../../src/schemas/response-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AAEH,iBAAiB;AACjB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAG/E,+BAA+B;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAG9E,uCAAuC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BA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AC;IACzD,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;SACzC,QAAQ,CAAC,2CAA2C,CAAC;IACxD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC7B,QAAQ,CAAC,6CAA6C,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACjC,QAAQ,CAAC,0CAA0C,CAAC;IACvD,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SACnC,QAAQ,CAAC,qDAAqD,CAAC;CACnE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-schema.test.d.ts","sourceRoot":"","sources":["../../src/schemas/response-schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { ResponseType, ResponsePriority, ResponseOption, QuestionResponse, SuggestionResponse, ConfirmationResponse, GenerateResponseInput, } from "./response-schema.js";
|
|
3
|
+
describe("Response Schema", () => {
|
|
4
|
+
describe("ResponseType", () => {
|
|
5
|
+
it("should accept valid response types", () => {
|
|
6
|
+
expect(() => ResponseType.parse("question")).not.toThrow();
|
|
7
|
+
expect(() => ResponseType.parse("suggestion")).not.toThrow();
|
|
8
|
+
expect(() => ResponseType.parse("confirmation")).not.toThrow();
|
|
9
|
+
});
|
|
10
|
+
it("should reject invalid response types", () => {
|
|
11
|
+
expect(() => ResponseType.parse("invalid")).toThrow();
|
|
12
|
+
expect(() => ResponseType.parse("ask")).toThrow();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe("ResponsePriority", () => {
|
|
16
|
+
it("should accept valid priority levels", () => {
|
|
17
|
+
expect(() => ResponsePriority.parse("low")).not.toThrow();
|
|
18
|
+
expect(() => ResponsePriority.parse("medium")).not.toThrow();
|
|
19
|
+
expect(() => ResponsePriority.parse("high")).not.toThrow();
|
|
20
|
+
expect(() => ResponsePriority.parse("critical")).not.toThrow();
|
|
21
|
+
});
|
|
22
|
+
it("should reject invalid priority levels", () => {
|
|
23
|
+
expect(() => ResponsePriority.parse("urgent")).toThrow();
|
|
24
|
+
expect(() => ResponsePriority.parse("normal")).toThrow();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe("ResponseOption", () => {
|
|
28
|
+
it("should validate option with all fields", () => {
|
|
29
|
+
const option = {
|
|
30
|
+
label: "High Priority",
|
|
31
|
+
value: "high",
|
|
32
|
+
description: "For urgent tasks",
|
|
33
|
+
};
|
|
34
|
+
expect(() => ResponseOption.parse(option)).not.toThrow();
|
|
35
|
+
const parsed = ResponseOption.parse(option);
|
|
36
|
+
expect(parsed.label).toBe("High Priority");
|
|
37
|
+
expect(parsed.value).toBe("high");
|
|
38
|
+
expect(parsed.description).toBe("For urgent tasks");
|
|
39
|
+
});
|
|
40
|
+
it("should validate option without description", () => {
|
|
41
|
+
const option = {
|
|
42
|
+
label: "Low Priority",
|
|
43
|
+
value: "low",
|
|
44
|
+
};
|
|
45
|
+
expect(() => ResponseOption.parse(option)).not.toThrow();
|
|
46
|
+
const parsed = ResponseOption.parse(option);
|
|
47
|
+
expect(parsed.label).toBe("Low Priority");
|
|
48
|
+
expect(parsed.value).toBe("low");
|
|
49
|
+
expect(parsed.description).toBeUndefined();
|
|
50
|
+
});
|
|
51
|
+
it("should reject option without required fields", () => {
|
|
52
|
+
expect(() => ResponseOption.parse({ label: "Test" })).toThrow();
|
|
53
|
+
expect(() => ResponseOption.parse({ value: "test" })).toThrow();
|
|
54
|
+
expect(() => ResponseOption.parse({})).toThrow();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("QuestionResponse", () => {
|
|
58
|
+
it("should validate question with all fields", () => {
|
|
59
|
+
const question = {
|
|
60
|
+
type: "question",
|
|
61
|
+
message: "What should we do?",
|
|
62
|
+
context: "Need clarification on approach",
|
|
63
|
+
priority: "high",
|
|
64
|
+
options: [
|
|
65
|
+
{ label: "Option A", value: "a" },
|
|
66
|
+
{ label: "Option B", value: "b" },
|
|
67
|
+
],
|
|
68
|
+
defaultOption: "a",
|
|
69
|
+
};
|
|
70
|
+
expect(() => QuestionResponse.parse(question)).not.toThrow();
|
|
71
|
+
const parsed = QuestionResponse.parse(question);
|
|
72
|
+
expect(parsed.type).toBe("question");
|
|
73
|
+
expect(parsed.message).toBe("What should we do?");
|
|
74
|
+
expect(parsed.options).toHaveLength(2);
|
|
75
|
+
expect(parsed.defaultOption).toBe("a");
|
|
76
|
+
});
|
|
77
|
+
it("should validate question with minimal fields", () => {
|
|
78
|
+
const question = {
|
|
79
|
+
type: "question",
|
|
80
|
+
message: "Proceed?",
|
|
81
|
+
};
|
|
82
|
+
expect(() => QuestionResponse.parse(question)).not.toThrow();
|
|
83
|
+
const parsed = QuestionResponse.parse(question);
|
|
84
|
+
expect(parsed.type).toBe("question");
|
|
85
|
+
expect(parsed.message).toBe("Proceed?");
|
|
86
|
+
expect(parsed.context).toBeUndefined();
|
|
87
|
+
expect(parsed.options).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
it("should reject question without message", () => {
|
|
90
|
+
expect(() => QuestionResponse.parse({ type: "question" })).toThrow();
|
|
91
|
+
});
|
|
92
|
+
it("should reject question with wrong type", () => {
|
|
93
|
+
expect(() => QuestionResponse.parse({
|
|
94
|
+
type: "suggestion",
|
|
95
|
+
message: "Test",
|
|
96
|
+
})).toThrow();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe("SuggestionResponse", () => {
|
|
100
|
+
it("should validate suggestion with all fields", () => {
|
|
101
|
+
const suggestion = {
|
|
102
|
+
type: "suggestion",
|
|
103
|
+
message: "Consider breaking down this task",
|
|
104
|
+
context: "Task is complex",
|
|
105
|
+
priority: "medium",
|
|
106
|
+
options: [
|
|
107
|
+
{ label: "3 subtasks", value: "sub_3" },
|
|
108
|
+
{ label: "5 subtasks", value: "sub_5" },
|
|
109
|
+
],
|
|
110
|
+
reasoning: "Based on complexity analysis",
|
|
111
|
+
};
|
|
112
|
+
expect(() => SuggestionResponse.parse(suggestion)).not.toThrow();
|
|
113
|
+
const parsed = SuggestionResponse.parse(suggestion);
|
|
114
|
+
expect(parsed.type).toBe("suggestion");
|
|
115
|
+
expect(parsed.options).toHaveLength(2);
|
|
116
|
+
expect(parsed.reasoning).toBe("Based on complexity analysis");
|
|
117
|
+
});
|
|
118
|
+
it("should validate suggestion with minimal fields", () => {
|
|
119
|
+
const suggestion = {
|
|
120
|
+
type: "suggestion",
|
|
121
|
+
message: "Try this",
|
|
122
|
+
options: [{ label: "Do it", value: "yes" }],
|
|
123
|
+
};
|
|
124
|
+
expect(() => SuggestionResponse.parse(suggestion)).not.toThrow();
|
|
125
|
+
const parsed = SuggestionResponse.parse(suggestion);
|
|
126
|
+
expect(parsed.options).toHaveLength(1);
|
|
127
|
+
});
|
|
128
|
+
it("should reject suggestion without options", () => {
|
|
129
|
+
expect(() => SuggestionResponse.parse({
|
|
130
|
+
type: "suggestion",
|
|
131
|
+
message: "Test",
|
|
132
|
+
})).toThrow();
|
|
133
|
+
});
|
|
134
|
+
it("should reject suggestion with empty options array", () => {
|
|
135
|
+
expect(() => SuggestionResponse.parse({
|
|
136
|
+
type: "suggestion",
|
|
137
|
+
message: "Test",
|
|
138
|
+
options: [],
|
|
139
|
+
})).toThrow();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe("ConfirmationResponse", () => {
|
|
143
|
+
it("should validate confirmation with all fields", () => {
|
|
144
|
+
const confirmation = {
|
|
145
|
+
type: "confirmation",
|
|
146
|
+
message: "Are you sure?",
|
|
147
|
+
action: "Delete all completed tasks",
|
|
148
|
+
context: "This operation is irreversible",
|
|
149
|
+
priority: "critical",
|
|
150
|
+
consequences: ["10 tasks will be removed", "Cannot be undone"],
|
|
151
|
+
defaultConfirm: false,
|
|
152
|
+
};
|
|
153
|
+
expect(() => ConfirmationResponse.parse(confirmation)).not.toThrow();
|
|
154
|
+
const parsed = ConfirmationResponse.parse(confirmation);
|
|
155
|
+
expect(parsed.type).toBe("confirmation");
|
|
156
|
+
expect(parsed.action).toBe("Delete all completed tasks");
|
|
157
|
+
expect(parsed.consequences).toHaveLength(2);
|
|
158
|
+
expect(parsed.defaultConfirm).toBe(false);
|
|
159
|
+
});
|
|
160
|
+
it("should validate confirmation with minimal fields", () => {
|
|
161
|
+
const confirmation = {
|
|
162
|
+
type: "confirmation",
|
|
163
|
+
message: "Delete this?",
|
|
164
|
+
action: "Delete task",
|
|
165
|
+
};
|
|
166
|
+
expect(() => ConfirmationResponse.parse(confirmation)).not.toThrow();
|
|
167
|
+
const parsed = ConfirmationResponse.parse(confirmation);
|
|
168
|
+
expect(parsed.action).toBe("Delete task");
|
|
169
|
+
expect(parsed.consequences).toBeUndefined();
|
|
170
|
+
});
|
|
171
|
+
it("should reject confirmation without action", () => {
|
|
172
|
+
expect(() => ConfirmationResponse.parse({
|
|
173
|
+
type: "confirmation",
|
|
174
|
+
message: "Confirm?",
|
|
175
|
+
})).toThrow();
|
|
176
|
+
});
|
|
177
|
+
it("should reject confirmation without message", () => {
|
|
178
|
+
expect(() => ConfirmationResponse.parse({
|
|
179
|
+
type: "confirmation",
|
|
180
|
+
action: "Do something",
|
|
181
|
+
})).toThrow();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe("GenerateResponseInput", () => {
|
|
185
|
+
it("should validate input for question type", () => {
|
|
186
|
+
const input = {
|
|
187
|
+
type: "question",
|
|
188
|
+
message: "What to do?",
|
|
189
|
+
options: [{ label: "Yes", value: "yes" }],
|
|
190
|
+
defaultOption: "yes",
|
|
191
|
+
};
|
|
192
|
+
expect(() => GenerateResponseInput.parse(input)).not.toThrow();
|
|
193
|
+
const parsed = GenerateResponseInput.parse(input);
|
|
194
|
+
expect(parsed.type).toBe("question");
|
|
195
|
+
});
|
|
196
|
+
it("should validate input for suggestion type", () => {
|
|
197
|
+
const input = {
|
|
198
|
+
type: "suggestion",
|
|
199
|
+
message: "Try this",
|
|
200
|
+
options: [{ label: "Option", value: "opt" }],
|
|
201
|
+
reasoning: "Because reasons",
|
|
202
|
+
};
|
|
203
|
+
expect(() => GenerateResponseInput.parse(input)).not.toThrow();
|
|
204
|
+
});
|
|
205
|
+
it("should validate input for confirmation type", () => {
|
|
206
|
+
const input = {
|
|
207
|
+
type: "confirmation",
|
|
208
|
+
message: "Sure?",
|
|
209
|
+
action: "Delete",
|
|
210
|
+
consequences: ["Gone forever"],
|
|
211
|
+
defaultConfirm: false,
|
|
212
|
+
};
|
|
213
|
+
expect(() => GenerateResponseInput.parse(input)).not.toThrow();
|
|
214
|
+
});
|
|
215
|
+
it("should use default priority of medium", () => {
|
|
216
|
+
const input = {
|
|
217
|
+
type: "question",
|
|
218
|
+
message: "Test?",
|
|
219
|
+
};
|
|
220
|
+
const parsed = GenerateResponseInput.parse(input);
|
|
221
|
+
expect(parsed.priority).toBe("medium");
|
|
222
|
+
});
|
|
223
|
+
it("should allow custom priority", () => {
|
|
224
|
+
const input = {
|
|
225
|
+
type: "question",
|
|
226
|
+
message: "Test?",
|
|
227
|
+
priority: "critical",
|
|
228
|
+
};
|
|
229
|
+
const parsed = GenerateResponseInput.parse(input);
|
|
230
|
+
expect(parsed.priority).toBe("critical");
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
describe("Type discrimination", () => {
|
|
234
|
+
it("should differentiate response types at compile time", () => {
|
|
235
|
+
const question = {
|
|
236
|
+
type: "question",
|
|
237
|
+
message: "Test",
|
|
238
|
+
};
|
|
239
|
+
const suggestion = {
|
|
240
|
+
type: "suggestion",
|
|
241
|
+
message: "Test",
|
|
242
|
+
options: [{ label: "A", value: "a" }],
|
|
243
|
+
};
|
|
244
|
+
const confirmation = {
|
|
245
|
+
type: "confirmation",
|
|
246
|
+
message: "Test",
|
|
247
|
+
action: "Do it",
|
|
248
|
+
};
|
|
249
|
+
// TypeScript should allow this
|
|
250
|
+
expect(question.type).toBe("question");
|
|
251
|
+
expect(suggestion.type).toBe("suggestion");
|
|
252
|
+
expect(confirmation.type).toBe("confirmation");
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=response-schema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-schema.test.js","sourceRoot":"","sources":["../../src/schemas/response-schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YAC7D,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACtD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,C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AC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/schemas/index.ts
CHANGED
|
@@ -58,4 +58,27 @@ export {
|
|
|
58
58
|
type InboxPreview,
|
|
59
59
|
type CriticalPathSummary,
|
|
60
60
|
type BottleneckSummary,
|
|
61
|
+
// Dashboard types
|
|
62
|
+
type DashboardProgress,
|
|
63
|
+
type DashboardPriorityBreakdown,
|
|
64
|
+
type DashboardDependencyMetrics,
|
|
65
|
+
type DashboardNextTask,
|
|
66
|
+
type DashboardCriticalPath,
|
|
67
|
+
type DashboardStatusBreakdown,
|
|
68
|
+
type DashboardSubtaskProgress,
|
|
69
|
+
type DashboardDependencyStats,
|
|
70
|
+
type DashboardConcise,
|
|
71
|
+
type DashboardStandard,
|
|
61
72
|
} from "./response-format.js";
|
|
73
|
+
|
|
74
|
+
// Response schema (agent interaction)
|
|
75
|
+
export {
|
|
76
|
+
ResponseType,
|
|
77
|
+
ResponsePriority,
|
|
78
|
+
ResponseOption,
|
|
79
|
+
QuestionResponse,
|
|
80
|
+
SuggestionResponse,
|
|
81
|
+
ConfirmationResponse,
|
|
82
|
+
AgentResponse,
|
|
83
|
+
GenerateResponseInput,
|
|
84
|
+
} from "./response-schema.js";
|
package/src/schemas/project.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const Project = z.object({
|
|
|
33
33
|
createdAt: z.string(),
|
|
34
34
|
updatedAt: z.string(),
|
|
35
35
|
targetDate: z.string().optional(),
|
|
36
|
+
sortOrder: z.number().optional(), // User-defined display order (auto-assigned if not specified)
|
|
36
37
|
|
|
37
38
|
// Computed stats
|
|
38
39
|
completionPercentage: z.number().optional(),
|
|
@@ -50,6 +51,7 @@ export const ProjectCreateInput = z.object({
|
|
|
50
51
|
defaultPriority: Priority.optional(),
|
|
51
52
|
contexts: z.array(Context).optional(),
|
|
52
53
|
targetDate: z.string().optional(),
|
|
54
|
+
sortOrder: z.number().optional(), // Auto-assigned if not specified
|
|
53
55
|
});
|
|
54
56
|
export type ProjectCreateInput = z.infer<typeof ProjectCreateInput>;
|
|
55
57
|
|
|
@@ -61,5 +63,6 @@ export const ProjectUpdateInput = z.object({
|
|
|
61
63
|
defaultPriority: Priority.optional(),
|
|
62
64
|
contexts: z.array(Context).optional(),
|
|
63
65
|
targetDate: z.string().optional(),
|
|
66
|
+
sortOrder: z.number().optional(),
|
|
64
67
|
});
|
|
65
68
|
export type ProjectUpdateInput = z.infer<typeof ProjectUpdateInput>;
|
|
@@ -106,3 +106,99 @@ export interface BottleneckSummary {
|
|
|
106
106
|
title: string;
|
|
107
107
|
blockedCount: number;
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Dashboard response types - project_dashboard tool
|
|
112
|
+
*
|
|
113
|
+
* Provides unified project overview with progress, priority breakdown,
|
|
114
|
+
* dependency metrics, and next task recommendation.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
// Progress metrics
|
|
118
|
+
export interface DashboardProgress {
|
|
119
|
+
completed: number;
|
|
120
|
+
total: number;
|
|
121
|
+
pct: number; // 0-100
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Priority breakdown
|
|
125
|
+
export interface DashboardPriorityBreakdown {
|
|
126
|
+
critical: number;
|
|
127
|
+
high: number;
|
|
128
|
+
medium: number;
|
|
129
|
+
low: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Dependency metrics
|
|
133
|
+
export interface DashboardDependencyMetrics {
|
|
134
|
+
ready: number; // No dependencies or all satisfied
|
|
135
|
+
blocked: number; // Has unsatisfied dependencies
|
|
136
|
+
noDeps: number; // Tasks with no dependencies
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Next task recommendation
|
|
140
|
+
export interface DashboardNextTask {
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
priority: string;
|
|
144
|
+
reason: string; // Why this task is recommended
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Critical path info
|
|
148
|
+
export interface DashboardCriticalPath {
|
|
149
|
+
length: number; // Total duration in minutes
|
|
150
|
+
taskCount: number; // Number of tasks on critical path
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Status breakdown (TaskMaster-style)
|
|
154
|
+
export interface DashboardStatusBreakdown {
|
|
155
|
+
done: number;
|
|
156
|
+
inProgress: number;
|
|
157
|
+
pending: number;
|
|
158
|
+
blocked: number;
|
|
159
|
+
deferred: number;
|
|
160
|
+
cancelled: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Subtask progress metrics (TaskMaster-style)
|
|
164
|
+
export interface DashboardSubtaskProgress {
|
|
165
|
+
completed: number;
|
|
166
|
+
total: number;
|
|
167
|
+
pct: number; // 0-100
|
|
168
|
+
inProgress: number;
|
|
169
|
+
pending: number;
|
|
170
|
+
blocked: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Dependency statistics (TaskMaster-style)
|
|
174
|
+
export interface DashboardDependencyStats {
|
|
175
|
+
mostDependedOn?: {
|
|
176
|
+
taskId: string;
|
|
177
|
+
title: string;
|
|
178
|
+
dependentCount: number; // How many tasks depend on this
|
|
179
|
+
};
|
|
180
|
+
avgDepsPerTask: number; // Average number of dependencies per task
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Concise format (~100 tokens) - essential metrics only
|
|
184
|
+
export interface DashboardConcise {
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
progress: DashboardProgress;
|
|
188
|
+
statusBreakdown: DashboardStatusBreakdown;
|
|
189
|
+
subtaskProgress?: DashboardSubtaskProgress;
|
|
190
|
+
priority: DashboardPriorityBreakdown;
|
|
191
|
+
dependency: DashboardDependencyMetrics;
|
|
192
|
+
dependencyStats: DashboardDependencyStats;
|
|
193
|
+
nextTask?: DashboardNextTask;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Standard format (~300 tokens) - includes tasks and critical path
|
|
197
|
+
export interface DashboardStandard extends DashboardConcise {
|
|
198
|
+
projectStatus: string;
|
|
199
|
+
targetDate?: string;
|
|
200
|
+
criticalPath?: DashboardCriticalPath;
|
|
201
|
+
tasks: TaskSummary[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Detailed format - human-readable markdown (use string output)
|