@task-mcp/shared 1.0.19 → 1.0.21

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 (163) hide show
  1. package/package.json +1 -6
  2. package/src/schemas/task.ts +60 -14
  3. package/src/utils/date.ts +40 -0
  4. package/src/utils/hierarchy.ts +63 -1
  5. package/src/utils/index.ts +2 -0
  6. package/src/utils/natural-language.ts +12 -0
  7. package/src/utils/projection.ts +14 -3
  8. package/dist/algorithms/critical-path.d.ts +0 -46
  9. package/dist/algorithms/critical-path.d.ts.map +0 -1
  10. package/dist/algorithms/critical-path.js +0 -320
  11. package/dist/algorithms/critical-path.js.map +0 -1
  12. package/dist/algorithms/critical-path.test.d.ts +0 -2
  13. package/dist/algorithms/critical-path.test.d.ts.map +0 -1
  14. package/dist/algorithms/critical-path.test.js +0 -194
  15. package/dist/algorithms/critical-path.test.js.map +0 -1
  16. package/dist/algorithms/dependency-integrity.d.ts +0 -81
  17. package/dist/algorithms/dependency-integrity.d.ts.map +0 -1
  18. package/dist/algorithms/dependency-integrity.js +0 -207
  19. package/dist/algorithms/dependency-integrity.js.map +0 -1
  20. package/dist/algorithms/dependency-integrity.test.d.ts +0 -2
  21. package/dist/algorithms/dependency-integrity.test.d.ts.map +0 -1
  22. package/dist/algorithms/dependency-integrity.test.js +0 -309
  23. package/dist/algorithms/dependency-integrity.test.js.map +0 -1
  24. package/dist/algorithms/index.d.ts +0 -5
  25. package/dist/algorithms/index.d.ts.map +0 -1
  26. package/dist/algorithms/index.js +0 -5
  27. package/dist/algorithms/index.js.map +0 -1
  28. package/dist/algorithms/tech-analysis.d.ts +0 -106
  29. package/dist/algorithms/tech-analysis.d.ts.map +0 -1
  30. package/dist/algorithms/tech-analysis.js +0 -344
  31. package/dist/algorithms/tech-analysis.js.map +0 -1
  32. package/dist/algorithms/tech-analysis.test.d.ts +0 -2
  33. package/dist/algorithms/tech-analysis.test.d.ts.map +0 -1
  34. package/dist/algorithms/tech-analysis.test.js +0 -338
  35. package/dist/algorithms/tech-analysis.test.js.map +0 -1
  36. package/dist/algorithms/topological-sort.d.ts +0 -41
  37. package/dist/algorithms/topological-sort.d.ts.map +0 -1
  38. package/dist/algorithms/topological-sort.js +0 -165
  39. package/dist/algorithms/topological-sort.js.map +0 -1
  40. package/dist/algorithms/topological-sort.test.d.ts +0 -2
  41. package/dist/algorithms/topological-sort.test.d.ts.map +0 -1
  42. package/dist/algorithms/topological-sort.test.js +0 -162
  43. package/dist/algorithms/topological-sort.test.js.map +0 -1
  44. package/dist/index.d.ts +0 -4
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/index.js +0 -7
  47. package/dist/index.js.map +0 -1
  48. package/dist/schemas/inbox.d.ts +0 -55
  49. package/dist/schemas/inbox.d.ts.map +0 -1
  50. package/dist/schemas/inbox.js +0 -25
  51. package/dist/schemas/inbox.js.map +0 -1
  52. package/dist/schemas/index.d.ts +0 -7
  53. package/dist/schemas/index.d.ts.map +0 -1
  54. package/dist/schemas/index.js +0 -17
  55. package/dist/schemas/index.js.map +0 -1
  56. package/dist/schemas/project.d.ts +0 -177
  57. package/dist/schemas/project.d.ts.map +0 -1
  58. package/dist/schemas/project.js +0 -56
  59. package/dist/schemas/project.js.map +0 -1
  60. package/dist/schemas/response-format.d.ts +0 -148
  61. package/dist/schemas/response-format.d.ts.map +0 -1
  62. package/dist/schemas/response-format.js +0 -18
  63. package/dist/schemas/response-format.js.map +0 -1
  64. package/dist/schemas/response-schema.d.ts +0 -307
  65. package/dist/schemas/response-schema.d.ts.map +0 -1
  66. package/dist/schemas/response-schema.js +0 -75
  67. package/dist/schemas/response-schema.js.map +0 -1
  68. package/dist/schemas/response-schema.test.d.ts +0 -2
  69. package/dist/schemas/response-schema.test.d.ts.map +0 -1
  70. package/dist/schemas/response-schema.test.js +0 -256
  71. package/dist/schemas/response-schema.test.js.map +0 -1
  72. package/dist/schemas/state.d.ts +0 -17
  73. package/dist/schemas/state.d.ts.map +0 -1
  74. package/dist/schemas/state.js +0 -17
  75. package/dist/schemas/state.js.map +0 -1
  76. package/dist/schemas/task.d.ts +0 -625
  77. package/dist/schemas/task.d.ts.map +0 -1
  78. package/dist/schemas/task.js +0 -152
  79. package/dist/schemas/task.js.map +0 -1
  80. package/dist/schemas/view.d.ts +0 -143
  81. package/dist/schemas/view.d.ts.map +0 -1
  82. package/dist/schemas/view.js +0 -48
  83. package/dist/schemas/view.js.map +0 -1
  84. package/dist/utils/dashboard-renderer.d.ts +0 -93
  85. package/dist/utils/dashboard-renderer.d.ts.map +0 -1
  86. package/dist/utils/dashboard-renderer.js +0 -424
  87. package/dist/utils/dashboard-renderer.js.map +0 -1
  88. package/dist/utils/dashboard-renderer.test.d.ts +0 -2
  89. package/dist/utils/dashboard-renderer.test.d.ts.map +0 -1
  90. package/dist/utils/dashboard-renderer.test.js +0 -774
  91. package/dist/utils/dashboard-renderer.test.js.map +0 -1
  92. package/dist/utils/date.d.ts +0 -81
  93. package/dist/utils/date.d.ts.map +0 -1
  94. package/dist/utils/date.js +0 -294
  95. package/dist/utils/date.js.map +0 -1
  96. package/dist/utils/date.test.d.ts +0 -2
  97. package/dist/utils/date.test.d.ts.map +0 -1
  98. package/dist/utils/date.test.js +0 -276
  99. package/dist/utils/date.test.js.map +0 -1
  100. package/dist/utils/hierarchy.d.ts +0 -75
  101. package/dist/utils/hierarchy.d.ts.map +0 -1
  102. package/dist/utils/hierarchy.js +0 -189
  103. package/dist/utils/hierarchy.js.map +0 -1
  104. package/dist/utils/hierarchy.test.d.ts +0 -2
  105. package/dist/utils/hierarchy.test.d.ts.map +0 -1
  106. package/dist/utils/hierarchy.test.js +0 -351
  107. package/dist/utils/hierarchy.test.js.map +0 -1
  108. package/dist/utils/id.d.ts +0 -60
  109. package/dist/utils/id.d.ts.map +0 -1
  110. package/dist/utils/id.js +0 -118
  111. package/dist/utils/id.js.map +0 -1
  112. package/dist/utils/id.test.d.ts +0 -2
  113. package/dist/utils/id.test.d.ts.map +0 -1
  114. package/dist/utils/id.test.js +0 -193
  115. package/dist/utils/id.test.js.map +0 -1
  116. package/dist/utils/index.d.ts +0 -12
  117. package/dist/utils/index.d.ts.map +0 -1
  118. package/dist/utils/index.js +0 -34
  119. package/dist/utils/index.js.map +0 -1
  120. package/dist/utils/natural-language.d.ts +0 -57
  121. package/dist/utils/natural-language.d.ts.map +0 -1
  122. package/dist/utils/natural-language.js +0 -205
  123. package/dist/utils/natural-language.js.map +0 -1
  124. package/dist/utils/natural-language.test.d.ts +0 -2
  125. package/dist/utils/natural-language.test.d.ts.map +0 -1
  126. package/dist/utils/natural-language.test.js +0 -156
  127. package/dist/utils/natural-language.test.js.map +0 -1
  128. package/dist/utils/priority-queue.d.ts +0 -17
  129. package/dist/utils/priority-queue.d.ts.map +0 -1
  130. package/dist/utils/priority-queue.js +0 -62
  131. package/dist/utils/priority-queue.js.map +0 -1
  132. package/dist/utils/projection.d.ts +0 -65
  133. package/dist/utils/projection.d.ts.map +0 -1
  134. package/dist/utils/projection.js +0 -170
  135. package/dist/utils/projection.js.map +0 -1
  136. package/dist/utils/projection.test.d.ts +0 -2
  137. package/dist/utils/projection.test.d.ts.map +0 -1
  138. package/dist/utils/projection.test.js +0 -336
  139. package/dist/utils/projection.test.js.map +0 -1
  140. package/dist/utils/terminal-ui.d.ts +0 -208
  141. package/dist/utils/terminal-ui.d.ts.map +0 -1
  142. package/dist/utils/terminal-ui.js +0 -611
  143. package/dist/utils/terminal-ui.js.map +0 -1
  144. package/dist/utils/terminal-ui.test.d.ts +0 -2
  145. package/dist/utils/terminal-ui.test.d.ts.map +0 -1
  146. package/dist/utils/terminal-ui.test.js +0 -683
  147. package/dist/utils/terminal-ui.test.js.map +0 -1
  148. package/dist/utils/workspace.d.ts +0 -100
  149. package/dist/utils/workspace.d.ts.map +0 -1
  150. package/dist/utils/workspace.js +0 -173
  151. package/dist/utils/workspace.js.map +0 -1
  152. package/src/algorithms/critical-path.test.ts +0 -241
  153. package/src/algorithms/dependency-integrity.test.ts +0 -348
  154. package/src/algorithms/tech-analysis.test.ts +0 -413
  155. package/src/algorithms/topological-sort.test.ts +0 -190
  156. package/src/schemas/response-schema.test.ts +0 -314
  157. package/src/utils/dashboard-renderer.test.ts +0 -983
  158. package/src/utils/date.test.ts +0 -329
  159. package/src/utils/hierarchy.test.ts +0 -411
  160. package/src/utils/id.test.ts +0 -235
  161. package/src/utils/natural-language.test.ts +0 -182
  162. package/src/utils/projection.test.ts +0 -425
  163. package/src/utils/terminal-ui.test.ts +0 -831
@@ -1,314 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import {
3
- ResponseType,
4
- ResponsePriority,
5
- ResponseOption,
6
- QuestionResponse,
7
- SuggestionResponse,
8
- ConfirmationResponse,
9
- GenerateResponseInput,
10
- } from "./response-schema.js";
11
-
12
- describe("Response Schema", () => {
13
- describe("ResponseType", () => {
14
- it("should accept valid response types", () => {
15
- expect(() => ResponseType.parse("question")).not.toThrow();
16
- expect(() => ResponseType.parse("suggestion")).not.toThrow();
17
- expect(() => ResponseType.parse("confirmation")).not.toThrow();
18
- });
19
-
20
- it("should reject invalid response types", () => {
21
- expect(() => ResponseType.parse("invalid")).toThrow();
22
- expect(() => ResponseType.parse("ask")).toThrow();
23
- });
24
- });
25
-
26
- describe("ResponsePriority", () => {
27
- it("should accept valid priority levels", () => {
28
- expect(() => ResponsePriority.parse("low")).not.toThrow();
29
- expect(() => ResponsePriority.parse("medium")).not.toThrow();
30
- expect(() => ResponsePriority.parse("high")).not.toThrow();
31
- expect(() => ResponsePriority.parse("critical")).not.toThrow();
32
- });
33
-
34
- it("should reject invalid priority levels", () => {
35
- expect(() => ResponsePriority.parse("urgent")).toThrow();
36
- expect(() => ResponsePriority.parse("normal")).toThrow();
37
- });
38
- });
39
-
40
- describe("ResponseOption", () => {
41
- it("should validate option with all fields", () => {
42
- const option = {
43
- label: "High Priority",
44
- value: "high",
45
- description: "For urgent tasks",
46
- };
47
-
48
- expect(() => ResponseOption.parse(option)).not.toThrow();
49
- const parsed = ResponseOption.parse(option);
50
- expect(parsed.label).toBe("High Priority");
51
- expect(parsed.value).toBe("high");
52
- expect(parsed.description).toBe("For urgent tasks");
53
- });
54
-
55
- it("should validate option without description", () => {
56
- const option = {
57
- label: "Low Priority",
58
- value: "low",
59
- };
60
-
61
- expect(() => ResponseOption.parse(option)).not.toThrow();
62
- const parsed = ResponseOption.parse(option);
63
- expect(parsed.label).toBe("Low Priority");
64
- expect(parsed.value).toBe("low");
65
- expect(parsed.description).toBeUndefined();
66
- });
67
-
68
- it("should reject option without required fields", () => {
69
- expect(() => ResponseOption.parse({ label: "Test" })).toThrow();
70
- expect(() => ResponseOption.parse({ value: "test" })).toThrow();
71
- expect(() => ResponseOption.parse({})).toThrow();
72
- });
73
- });
74
-
75
- describe("QuestionResponse", () => {
76
- it("should validate question with all fields", () => {
77
- const question = {
78
- type: "question" as const,
79
- message: "What should we do?",
80
- context: "Need clarification on approach",
81
- priority: "high" as const,
82
- options: [
83
- { label: "Option A", value: "a" },
84
- { label: "Option B", value: "b" },
85
- ],
86
- defaultOption: "a",
87
- };
88
-
89
- expect(() => QuestionResponse.parse(question)).not.toThrow();
90
- const parsed = QuestionResponse.parse(question);
91
- expect(parsed.type).toBe("question");
92
- expect(parsed.message).toBe("What should we do?");
93
- expect(parsed.options).toHaveLength(2);
94
- expect(parsed.defaultOption).toBe("a");
95
- });
96
-
97
- it("should validate question with minimal fields", () => {
98
- const question = {
99
- type: "question" as const,
100
- message: "Proceed?",
101
- };
102
-
103
- expect(() => QuestionResponse.parse(question)).not.toThrow();
104
- const parsed = QuestionResponse.parse(question);
105
- expect(parsed.type).toBe("question");
106
- expect(parsed.message).toBe("Proceed?");
107
- expect(parsed.context).toBeUndefined();
108
- expect(parsed.options).toBeUndefined();
109
- });
110
-
111
- it("should reject question without message", () => {
112
- expect(() => QuestionResponse.parse({ type: "question" })).toThrow();
113
- });
114
-
115
- it("should reject question with wrong type", () => {
116
- expect(() =>
117
- QuestionResponse.parse({
118
- type: "suggestion",
119
- message: "Test",
120
- })
121
- ).toThrow();
122
- });
123
- });
124
-
125
- describe("SuggestionResponse", () => {
126
- it("should validate suggestion with all fields", () => {
127
- const suggestion = {
128
- type: "suggestion" as const,
129
- message: "Consider breaking down this task",
130
- context: "Task is complex",
131
- priority: "medium" as const,
132
- options: [
133
- { label: "3 subtasks", value: "sub_3" },
134
- { label: "5 subtasks", value: "sub_5" },
135
- ],
136
- reasoning: "Based on complexity analysis",
137
- };
138
-
139
- expect(() => SuggestionResponse.parse(suggestion)).not.toThrow();
140
- const parsed = SuggestionResponse.parse(suggestion);
141
- expect(parsed.type).toBe("suggestion");
142
- expect(parsed.options).toHaveLength(2);
143
- expect(parsed.reasoning).toBe("Based on complexity analysis");
144
- });
145
-
146
- it("should validate suggestion with minimal fields", () => {
147
- const suggestion = {
148
- type: "suggestion" as const,
149
- message: "Try this",
150
- options: [{ label: "Do it", value: "yes" }],
151
- };
152
-
153
- expect(() => SuggestionResponse.parse(suggestion)).not.toThrow();
154
- const parsed = SuggestionResponse.parse(suggestion);
155
- expect(parsed.options).toHaveLength(1);
156
- });
157
-
158
- it("should reject suggestion without options", () => {
159
- expect(() =>
160
- SuggestionResponse.parse({
161
- type: "suggestion",
162
- message: "Test",
163
- })
164
- ).toThrow();
165
- });
166
-
167
- it("should reject suggestion with empty options array", () => {
168
- expect(() =>
169
- SuggestionResponse.parse({
170
- type: "suggestion",
171
- message: "Test",
172
- options: [],
173
- })
174
- ).toThrow();
175
- });
176
- });
177
-
178
- describe("ConfirmationResponse", () => {
179
- it("should validate confirmation with all fields", () => {
180
- const confirmation = {
181
- type: "confirmation" as const,
182
- message: "Are you sure?",
183
- action: "Delete all completed tasks",
184
- context: "This operation is irreversible",
185
- priority: "critical" as const,
186
- consequences: ["10 tasks will be removed", "Cannot be undone"],
187
- defaultConfirm: false,
188
- };
189
-
190
- expect(() => ConfirmationResponse.parse(confirmation)).not.toThrow();
191
- const parsed = ConfirmationResponse.parse(confirmation);
192
- expect(parsed.type).toBe("confirmation");
193
- expect(parsed.action).toBe("Delete all completed tasks");
194
- expect(parsed.consequences).toHaveLength(2);
195
- expect(parsed.defaultConfirm).toBe(false);
196
- });
197
-
198
- it("should validate confirmation with minimal fields", () => {
199
- const confirmation = {
200
- type: "confirmation" as const,
201
- message: "Delete this?",
202
- action: "Delete task",
203
- };
204
-
205
- expect(() => ConfirmationResponse.parse(confirmation)).not.toThrow();
206
- const parsed = ConfirmationResponse.parse(confirmation);
207
- expect(parsed.action).toBe("Delete task");
208
- expect(parsed.consequences).toBeUndefined();
209
- });
210
-
211
- it("should reject confirmation without action", () => {
212
- expect(() =>
213
- ConfirmationResponse.parse({
214
- type: "confirmation",
215
- message: "Confirm?",
216
- })
217
- ).toThrow();
218
- });
219
-
220
- it("should reject confirmation without message", () => {
221
- expect(() =>
222
- ConfirmationResponse.parse({
223
- type: "confirmation",
224
- action: "Do something",
225
- })
226
- ).toThrow();
227
- });
228
- });
229
-
230
- describe("GenerateResponseInput", () => {
231
- it("should validate input for question type", () => {
232
- const input = {
233
- type: "question" as const,
234
- message: "What to do?",
235
- options: [{ label: "Yes", value: "yes" }],
236
- defaultOption: "yes",
237
- };
238
-
239
- expect(() => GenerateResponseInput.parse(input)).not.toThrow();
240
- const parsed = GenerateResponseInput.parse(input);
241
- expect(parsed.type).toBe("question");
242
- });
243
-
244
- it("should validate input for suggestion type", () => {
245
- const input = {
246
- type: "suggestion" as const,
247
- message: "Try this",
248
- options: [{ label: "Option", value: "opt" }],
249
- reasoning: "Because reasons",
250
- };
251
-
252
- expect(() => GenerateResponseInput.parse(input)).not.toThrow();
253
- });
254
-
255
- it("should validate input for confirmation type", () => {
256
- const input = {
257
- type: "confirmation" as const,
258
- message: "Sure?",
259
- action: "Delete",
260
- consequences: ["Gone forever"],
261
- defaultConfirm: false,
262
- };
263
-
264
- expect(() => GenerateResponseInput.parse(input)).not.toThrow();
265
- });
266
-
267
- it("should use default priority of medium", () => {
268
- const input = {
269
- type: "question" as const,
270
- message: "Test?",
271
- };
272
-
273
- const parsed = GenerateResponseInput.parse(input);
274
- expect(parsed.priority).toBe("medium");
275
- });
276
-
277
- it("should allow custom priority", () => {
278
- const input = {
279
- type: "question" as const,
280
- message: "Test?",
281
- priority: "critical" as const,
282
- };
283
-
284
- const parsed = GenerateResponseInput.parse(input);
285
- expect(parsed.priority).toBe("critical");
286
- });
287
- });
288
-
289
- describe("Type discrimination", () => {
290
- it("should differentiate response types at compile time", () => {
291
- const question: QuestionResponse = {
292
- type: "question",
293
- message: "Test",
294
- };
295
-
296
- const suggestion: SuggestionResponse = {
297
- type: "suggestion",
298
- message: "Test",
299
- options: [{ label: "A", value: "a" }],
300
- };
301
-
302
- const confirmation: ConfirmationResponse = {
303
- type: "confirmation",
304
- message: "Test",
305
- action: "Do it",
306
- };
307
-
308
- // TypeScript should allow this
309
- expect(question.type).toBe("question");
310
- expect(suggestion.type).toBe("suggestion");
311
- expect(confirmation.type).toBe("confirmation");
312
- });
313
- });
314
- });