task-o-matic 0.0.14 → 0.0.15

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 (110) hide show
  1. package/dist/cli/display/progress.d.ts +15 -2
  2. package/dist/cli/display/progress.d.ts.map +1 -1
  3. package/dist/cli/display/progress.js +72 -4
  4. package/dist/commands/benchmark.d.ts.map +1 -1
  5. package/dist/commands/benchmark.js +11 -3
  6. package/dist/commands/init.d.ts.map +1 -1
  7. package/dist/commands/init.js +19 -4
  8. package/dist/commands/prd.js +7 -1
  9. package/dist/commands/tasks/delete.d.ts.map +1 -1
  10. package/dist/commands/tasks/delete.js +2 -1
  11. package/dist/commands/tasks/document/add.d.ts.map +1 -1
  12. package/dist/commands/tasks/document/add.js +2 -1
  13. package/dist/commands/tasks/document/get.d.ts.map +1 -1
  14. package/dist/commands/tasks/document/get.js +2 -1
  15. package/dist/commands/tasks/plan/set.d.ts.map +1 -1
  16. package/dist/commands/tasks/plan/set.js +11 -3
  17. package/dist/commands/tasks/show.d.ts.map +1 -1
  18. package/dist/commands/tasks/show.js +2 -1
  19. package/dist/commands/tasks/status.d.ts.map +1 -1
  20. package/dist/commands/tasks/status.js +2 -1
  21. package/dist/commands/tasks/update.d.ts.map +1 -1
  22. package/dist/commands/tasks/update.js +7 -1
  23. package/dist/lib/ai-service/model-provider.d.ts.map +1 -1
  24. package/dist/lib/ai-service/model-provider.js +37 -6
  25. package/dist/lib/ai-service/task-operations.d.ts +1 -0
  26. package/dist/lib/ai-service/task-operations.d.ts.map +1 -1
  27. package/dist/lib/ai-service/task-operations.js +135 -173
  28. package/dist/lib/benchmark/registry.d.ts.map +1 -1
  29. package/dist/lib/benchmark/registry.js +6 -10
  30. package/dist/lib/config-validation.d.ts +215 -0
  31. package/dist/lib/config-validation.d.ts.map +1 -0
  32. package/dist/lib/config-validation.js +246 -0
  33. package/dist/lib/config.d.ts.map +1 -1
  34. package/dist/lib/config.js +19 -5
  35. package/dist/lib/storage/file-system.d.ts.map +1 -1
  36. package/dist/lib/storage/file-system.js +81 -21
  37. package/dist/lib/task-execution-core.d.ts.map +1 -1
  38. package/dist/lib/task-execution-core.js +3 -2
  39. package/dist/services/prd.d.ts +17 -0
  40. package/dist/services/prd.d.ts.map +1 -1
  41. package/dist/services/prd.js +49 -15
  42. package/dist/services/tasks.d.ts +315 -1
  43. package/dist/services/tasks.d.ts.map +1 -1
  44. package/dist/services/tasks.js +483 -107
  45. package/dist/services/workflow-ai-assistant.d.ts.map +1 -1
  46. package/dist/services/workflow-ai-assistant.js +19 -6
  47. package/dist/test/lib/ai-service/task-operations.test.d.ts +2 -0
  48. package/dist/test/lib/ai-service/task-operations.test.d.ts.map +1 -0
  49. package/dist/test/lib/ai-service/task-operations.test.js +362 -0
  50. package/dist/test/mocks/mock-ai-operations.d.ts +15 -0
  51. package/dist/test/mocks/mock-ai-operations.d.ts.map +1 -0
  52. package/dist/test/mocks/mock-ai-operations.js +107 -0
  53. package/dist/test/mocks/mock-context-builder.d.ts +10 -0
  54. package/dist/test/mocks/mock-context-builder.d.ts.map +1 -0
  55. package/dist/test/mocks/mock-context-builder.js +81 -0
  56. package/dist/test/mocks/mock-model-provider.d.ts +7 -0
  57. package/dist/test/mocks/mock-model-provider.d.ts.map +1 -0
  58. package/dist/test/mocks/mock-model-provider.js +21 -0
  59. package/dist/test/mocks/mock-service-factory.d.ts +11 -0
  60. package/dist/test/mocks/mock-service-factory.d.ts.map +1 -0
  61. package/dist/test/mocks/mock-service-factory.js +61 -0
  62. package/dist/test/mocks/mock-storage.d.ts +50 -0
  63. package/dist/test/mocks/mock-storage.d.ts.map +1 -0
  64. package/dist/test/mocks/mock-storage.js +145 -0
  65. package/dist/test/services/task-service.test.d.ts +2 -0
  66. package/dist/test/services/task-service.test.d.ts.map +1 -0
  67. package/dist/test/services/task-service.test.js +352 -0
  68. package/dist/test/test-mock-setup.d.ts +26 -0
  69. package/dist/test/test-mock-setup.d.ts.map +1 -0
  70. package/dist/test/test-mock-setup.js +41 -0
  71. package/dist/test/test-setup.d.ts +9 -0
  72. package/dist/test/test-setup.d.ts.map +1 -0
  73. package/dist/test/test-setup.js +44 -0
  74. package/dist/test/test-utils.d.ts +22 -0
  75. package/dist/test/test-utils.d.ts.map +1 -0
  76. package/dist/test/test-utils.js +37 -0
  77. package/dist/test/utils/ai-operation-utility.test.d.ts +2 -0
  78. package/dist/test/utils/ai-operation-utility.test.d.ts.map +1 -0
  79. package/dist/test/utils/ai-operation-utility.test.js +290 -0
  80. package/dist/test/utils/error-handling.test.d.ts +2 -0
  81. package/dist/test/utils/error-handling.test.d.ts.map +1 -0
  82. package/dist/test/utils/error-handling.test.js +231 -0
  83. package/dist/utils/ai-operation-utility.d.ts +142 -0
  84. package/dist/utils/ai-operation-utility.d.ts.map +1 -0
  85. package/dist/utils/ai-operation-utility.js +288 -0
  86. package/dist/utils/ai-service-factory.d.ts +10 -0
  87. package/dist/utils/ai-service-factory.d.ts.map +1 -1
  88. package/dist/utils/ai-service-factory.js +19 -1
  89. package/dist/utils/cli-validators.d.ts +2 -2
  90. package/dist/utils/cli-validators.d.ts.map +1 -1
  91. package/dist/utils/cli-validators.js +7 -6
  92. package/dist/utils/error-utils.d.ts +3 -3
  93. package/dist/utils/error-utils.d.ts.map +1 -1
  94. package/dist/utils/error-utils.js +5 -4
  95. package/dist/utils/file-utils.d.ts +4 -4
  96. package/dist/utils/file-utils.d.ts.map +1 -1
  97. package/dist/utils/file-utils.js +11 -6
  98. package/dist/utils/id-generator.d.ts +1 -1
  99. package/dist/utils/id-generator.d.ts.map +1 -1
  100. package/dist/utils/id-generator.js +8 -2
  101. package/dist/utils/model-executor-parser.d.ts +1 -1
  102. package/dist/utils/model-executor-parser.d.ts.map +1 -1
  103. package/dist/utils/model-executor-parser.js +3 -2
  104. package/dist/utils/storage-utils.d.ts +3 -3
  105. package/dist/utils/storage-utils.d.ts.map +1 -1
  106. package/dist/utils/storage-utils.js +7 -6
  107. package/dist/utils/task-o-matic-error.d.ts +206 -0
  108. package/dist/utils/task-o-matic-error.d.ts.map +1 -0
  109. package/dist/utils/task-o-matic-error.js +304 -0
  110. package/package.json +2 -2
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigSchema = exports.AIConfigSchema = exports.AIProviderSchema = void 0;
4
+ exports.validateAIConfig = validateAIConfig;
5
+ exports.validateConfig = validateConfig;
6
+ exports.safeValidateConfig = safeValidateConfig;
7
+ exports.safeValidateAIConfig = safeValidateAIConfig;
8
+ exports.validatePartialAIConfig = validatePartialAIConfig;
9
+ const zod_1 = require("zod");
10
+ const task_o_matic_error_1 = require("../utils/task-o-matic-error");
11
+ /**
12
+ * Zod schema for AI Provider
13
+ */
14
+ exports.AIProviderSchema = zod_1.z.enum(["openai", "anthropic", "openrouter", "custom"], {
15
+ errorMap: () => ({
16
+ message: "Provider must be one of: openai, anthropic, openrouter, custom",
17
+ }),
18
+ });
19
+ /**
20
+ * Zod schema for AI Configuration
21
+ */
22
+ exports.AIConfigSchema = zod_1.z.object({
23
+ provider: exports.AIProviderSchema,
24
+ model: zod_1.z.string().min(1, "Model name cannot be empty"),
25
+ apiKey: zod_1.z.string().optional(),
26
+ baseURL: zod_1.z.string().url("Base URL must be a valid URL").optional().or(zod_1.z.literal("")),
27
+ maxTokens: zod_1.z
28
+ .number()
29
+ .int("Max tokens must be an integer")
30
+ .positive("Max tokens must be positive")
31
+ .max(1000000, "Max tokens cannot exceed 1,000,000")
32
+ .optional(),
33
+ temperature: zod_1.z
34
+ .number()
35
+ .min(0, "Temperature must be between 0 and 2")
36
+ .max(2, "Temperature must be between 0 and 2")
37
+ .optional(),
38
+ context7Enabled: zod_1.z.boolean().optional(),
39
+ reasoning: zod_1.z
40
+ .object({
41
+ maxTokens: zod_1.z
42
+ .number()
43
+ .int("Reasoning max tokens must be an integer")
44
+ .positive("Reasoning max tokens must be positive")
45
+ .max(100000, "Reasoning max tokens cannot exceed 100,000")
46
+ .optional(),
47
+ })
48
+ .optional(),
49
+ });
50
+ /**
51
+ * Zod schema for full Config object
52
+ */
53
+ exports.ConfigSchema = zod_1.z.object({
54
+ ai: exports.AIConfigSchema,
55
+ workingDirectory: zod_1.z.string().optional(),
56
+ });
57
+ /**
58
+ * Validate AI configuration
59
+ *
60
+ * @param config - AI configuration to validate
61
+ * @returns Validated and typed configuration
62
+ * @throws {TaskOMaticError} If validation fails
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const aiConfig = {
67
+ * provider: "openai",
68
+ * model: "gpt-4",
69
+ * temperature: 0.7,
70
+ * maxTokens: 4000
71
+ * };
72
+ *
73
+ * const validated = validateAIConfig(aiConfig);
74
+ * // validated is now type-safe and guaranteed valid
75
+ * ```
76
+ */
77
+ function validateAIConfig(config) {
78
+ try {
79
+ return exports.AIConfigSchema.parse(config);
80
+ }
81
+ catch (error) {
82
+ if (error instanceof zod_1.z.ZodError) {
83
+ const errors = error.errors.map((err) => ({
84
+ path: err.path.join("."),
85
+ message: err.message,
86
+ }));
87
+ throw new task_o_matic_error_1.TaskOMaticError("AI configuration validation failed", {
88
+ code: task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR,
89
+ context: JSON.stringify(config, null, 2),
90
+ suggestions: [
91
+ "Check that all required fields are present",
92
+ "Verify provider is one of: openai, anthropic, openrouter, custom",
93
+ "Ensure model name is not empty",
94
+ "Check temperature is between 0 and 2",
95
+ "Verify maxTokens is a positive integer",
96
+ ...errors.map((e) => `Fix ${e.path}: ${e.message}`),
97
+ ],
98
+ metadata: { errors },
99
+ });
100
+ }
101
+ throw error;
102
+ }
103
+ }
104
+ /**
105
+ * Validate full configuration object
106
+ *
107
+ * @param config - Configuration object to validate
108
+ * @returns Validated and typed configuration
109
+ * @throws {TaskOMaticError} If validation fails
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const config = {
114
+ * ai: {
115
+ * provider: "anthropic",
116
+ * model: "claude-sonnet-4.5",
117
+ * temperature: 0.5
118
+ * },
119
+ * workingDirectory: "/path/to/project"
120
+ * };
121
+ *
122
+ * const validated = validateConfig(config);
123
+ * ```
124
+ */
125
+ function validateConfig(config) {
126
+ try {
127
+ return exports.ConfigSchema.parse(config);
128
+ }
129
+ catch (error) {
130
+ if (error instanceof zod_1.z.ZodError) {
131
+ const errors = error.errors.map((err) => ({
132
+ path: err.path.join("."),
133
+ message: err.message,
134
+ }));
135
+ throw new task_o_matic_error_1.TaskOMaticError("Configuration validation failed", {
136
+ code: task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR,
137
+ context: JSON.stringify(config, null, 2),
138
+ suggestions: [
139
+ "Check that all required fields are present",
140
+ "Verify the configuration structure is correct",
141
+ ...errors.map((e) => `Fix ${e.path}: ${e.message}`),
142
+ ],
143
+ metadata: { errors },
144
+ });
145
+ }
146
+ throw error;
147
+ }
148
+ }
149
+ /**
150
+ * Safe validation that returns a result object instead of throwing
151
+ *
152
+ * @param config - Configuration to validate
153
+ * @returns Validation result with success flag and data or errors
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const result = safeValidateConfig(userInput);
158
+ * if (result.success) {
159
+ * console.log("Valid config:", result.data);
160
+ * } else {
161
+ * console.error("Validation errors:", result.errors);
162
+ * }
163
+ * ```
164
+ */
165
+ function safeValidateConfig(config) {
166
+ const result = exports.ConfigSchema.safeParse(config);
167
+ if (result.success) {
168
+ return {
169
+ success: true,
170
+ data: result.data,
171
+ };
172
+ }
173
+ else {
174
+ return {
175
+ success: false,
176
+ errors: result.error.errors.map((err) => ({
177
+ path: err.path.join("."),
178
+ message: err.message,
179
+ })),
180
+ };
181
+ }
182
+ }
183
+ /**
184
+ * Safe AI config validation
185
+ *
186
+ * @param config - AI configuration to validate
187
+ * @returns Validation result with success flag and data or errors
188
+ */
189
+ function safeValidateAIConfig(config) {
190
+ const result = exports.AIConfigSchema.safeParse(config);
191
+ if (result.success) {
192
+ return {
193
+ success: true,
194
+ data: result.data,
195
+ };
196
+ }
197
+ else {
198
+ return {
199
+ success: false,
200
+ errors: result.error.errors.map((err) => ({
201
+ path: err.path.join("."),
202
+ message: err.message,
203
+ })),
204
+ };
205
+ }
206
+ }
207
+ /**
208
+ * Validate partial AI config (for updates)
209
+ *
210
+ * @param config - Partial AI configuration to validate
211
+ * @returns Validated partial configuration
212
+ * @throws {TaskOMaticError} If validation fails
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * // Only validating fields that are present
217
+ * const updates = {
218
+ * temperature: 0.8
219
+ * };
220
+ *
221
+ * const validated = validatePartialAIConfig(updates);
222
+ * ```
223
+ */
224
+ function validatePartialAIConfig(config) {
225
+ try {
226
+ return exports.AIConfigSchema.partial().parse(config);
227
+ }
228
+ catch (error) {
229
+ if (error instanceof zod_1.z.ZodError) {
230
+ const errors = error.errors.map((err) => ({
231
+ path: err.path.join("."),
232
+ message: err.message,
233
+ }));
234
+ throw new task_o_matic_error_1.TaskOMaticError("AI configuration update validation failed", {
235
+ code: task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR,
236
+ context: JSON.stringify(config, null, 2),
237
+ suggestions: [
238
+ "Check that field values are valid",
239
+ ...errors.map((e) => `Fix ${e.path}: ${e.message}`),
240
+ ],
241
+ metadata: { errors },
242
+ });
243
+ }
244
+ throw error;
245
+ }
246
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAA6C,MAAM,UAAU,CAAC;AAI/E,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,QAAQ,CAAC;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9C,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,M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AGjB"}
@@ -7,6 +7,7 @@ const path_1 = require("path");
7
7
  const process_1 = require("process");
8
8
  const fs_1 = require("fs");
9
9
  const dotenv_1 = require("dotenv");
10
+ const config_validation_1 = require("./config-validation");
10
11
  // Provider-specific sensible defaults for 2025
11
12
  const PROVIDER_DEFAULTS = {
12
13
  openrouter: {
@@ -140,22 +141,27 @@ class ConfigManager {
140
141
  const configData = await this.callbacks.read("config.json");
141
142
  if (configData) {
142
143
  const fileConfig = JSON.parse(configData);
143
- this.config = {
144
+ const mergedConfig = {
144
145
  ...defaultConfig,
145
146
  ...fileConfig,
146
147
  ai: { ...defaultConfig.ai, ...fileConfig.ai, ...envConfig },
147
148
  };
149
+ // Validate the merged configuration
150
+ const validatedConfig = (0, config_validation_1.validateConfig)(mergedConfig);
151
+ this.config = validatedConfig;
148
152
  if (this.config && this.config.workingDirectory) {
149
153
  this.customWorkingDir = this.config.workingDirectory;
150
154
  }
151
155
  }
152
156
  else {
153
- this.config = defaultConfig;
157
+ // Validate default config too
158
+ this.config = (0, config_validation_1.validateConfig)(defaultConfig);
154
159
  }
155
160
  }
156
161
  catch (error) {
157
- console.warn("Failed to read config, using defaults:", error);
158
- this.config = defaultConfig;
162
+ console.warn("Failed to read or validate config, using defaults:", error);
163
+ // Even defaults should be validated
164
+ this.config = (0, config_validation_1.validateConfig)(defaultConfig);
159
165
  }
160
166
  return this.config;
161
167
  }
@@ -188,7 +194,15 @@ class ConfigManager {
188
194
  if (!this.config) {
189
195
  await this.load();
190
196
  }
191
- this.config.ai = { ...this.config.ai, ...aiConfig };
197
+ // Validate the partial config before merging
198
+ const validatedPartial = (0, config_validation_1.validatePartialAIConfig)(aiConfig);
199
+ // Merge and validate the full config
200
+ const mergedAIConfig = { ...this.config.ai, ...validatedPartial };
201
+ const validatedConfig = (0, config_validation_1.validateConfig)({
202
+ ...this.config,
203
+ ai: mergedAIConfig,
204
+ });
205
+ this.config = validatedConfig;
192
206
  await this.save();
193
207
  }
194
208
  setConfig(config) {
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,CAAC,MAAM,CAAC;IAsCzC,wBAAwB,IAAI,OAAO,CAAC;QACxC,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IA6CI,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBrD,OAAO,CACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAiBnE,SAAS,IAAI,OAAO,CACxB,KAAK,CAAC;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CACH;IAoCK,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW5C,qBAAqB,CACzB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC;IA0BZ,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAYnE"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileSystemStorage = void 0;
4
4
  const config_1 = require("../config");
5
5
  const storage_callbacks_1 = require("./storage-callbacks");
6
+ const task_o_matic_error_1 = require("../../utils/task-o-matic-error");
6
7
  class FileSystemStorage {
7
8
  callbacks;
8
9
  constructor(callbacks) {
@@ -16,30 +17,54 @@ class FileSystemStorage {
16
17
  }
17
18
  validateTaskId(taskId) {
18
19
  if (!taskId || typeof taskId !== "string" || taskId.trim() === "") {
19
- throw new Error("Task ID must be a non-empty string");
20
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Task ID must be a non-empty string", {
21
+ context: "validateTaskId",
22
+ suggestions: ["Provide a valid task ID string"],
23
+ metadata: { taskId },
24
+ });
20
25
  }
21
26
  }
22
27
  validateTaskRequest(task) {
23
28
  if (!task || typeof task !== "object") {
24
- throw new Error("Task request must be a valid object");
29
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Task request must be a valid object", {
30
+ context: "validateTaskRequest",
31
+ suggestions: ["Provide a valid task request object"],
32
+ });
25
33
  }
26
34
  if (!task.title ||
27
35
  typeof task.title !== "string" ||
28
36
  task.title.trim() === "") {
29
- throw new Error("Task title is required and must be a non-empty string");
37
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Task title is required and must be a non-empty string", {
38
+ context: "validateTaskRequest - title validation",
39
+ suggestions: ["Provide a non-empty title for the task"],
40
+ });
30
41
  }
31
42
  if (task.parentId && typeof task.parentId !== "string") {
32
- throw new Error("Parent ID must be a string if provided");
43
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Parent ID must be a string if provided", {
44
+ context: "validateTaskRequest - parentId validation",
45
+ suggestions: ["Provide a valid parent ID string or omit the field"],
46
+ metadata: { parentId: task.parentId },
47
+ });
33
48
  }
34
49
  if (task.estimatedEffort &&
35
50
  !["small", "medium", "large"].includes(task.estimatedEffort)) {
36
- throw new Error("Estimated effort must be 'small', 'medium', or 'large'");
51
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Estimated effort must be 'small', 'medium', or 'large'", {
52
+ context: "validateTaskRequest - estimatedEffort validation",
53
+ suggestions: ["Use 'small', 'medium', or 'large' for estimatedEffort"],
54
+ metadata: { estimatedEffort: task.estimatedEffort },
55
+ });
37
56
  }
38
57
  if (task.dependencies && !Array.isArray(task.dependencies)) {
39
- throw new Error("Dependencies must be an array if provided");
58
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Dependencies must be an array if provided", {
59
+ context: "validateTaskRequest - dependencies validation",
60
+ suggestions: ["Provide dependencies as an array of task IDs"],
61
+ });
40
62
  }
41
63
  if (task.tags && !Array.isArray(task.tags)) {
42
- throw new Error("Tags must be an array if provided");
64
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Tags must be an array if provided", {
65
+ context: "validateTaskRequest - tags validation",
66
+ suggestions: ["Provide tags as an array of strings"],
67
+ });
43
68
  }
44
69
  }
45
70
  async loadTasksData() {
@@ -60,7 +85,7 @@ class FileSystemStorage {
60
85
  await this.callbacks.write("tasks.json", JSON.stringify(data, null, 2));
61
86
  }
62
87
  catch (error) {
63
- throw new Error(`Failed to save tasks data: ${error instanceof Error ? error.message : "Unknown error"}`);
88
+ throw (0, task_o_matic_error_1.formatStorageError)("write tasks.json", error instanceof Error ? error : undefined);
64
89
  }
65
90
  }
66
91
  findTaskInHierarchy(tasks, id) {
@@ -111,7 +136,15 @@ class FileSystemStorage {
111
136
  if (task.parentId) {
112
137
  const parentResult = this.findTaskInHierarchy(data.tasks, task.parentId);
113
138
  if (!parentResult.task) {
114
- throw new Error(`Parent task with ID ${task.parentId} not found`);
139
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.TASK_NOT_FOUND, `Parent task with ID ${task.parentId} not found`, {
140
+ context: "createTask - parent validation",
141
+ suggestions: [
142
+ "Create the parent task first",
143
+ "Check that the parent ID is correct",
144
+ "List all tasks to see available parent IDs",
145
+ ],
146
+ metadata: { parentId: task.parentId },
147
+ });
115
148
  }
116
149
  const siblingCount = (parentResult.task.subtasks?.length || 0) + 1;
117
150
  id = `${task.parentId}.${siblingCount}`;
@@ -129,11 +162,26 @@ class FileSystemStorage {
129
162
  for (const depId of task.dependencies) {
130
163
  const depExists = this.taskExists(data.tasks, depId);
131
164
  if (!depExists) {
132
- throw new Error(`Dependency task not found: ${depId}`);
165
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.TASK_NOT_FOUND, `Dependency task not found: ${depId}`, {
166
+ context: "createTask - dependency validation",
167
+ suggestions: [
168
+ "Create the dependency task first",
169
+ "Check that the dependency ID is correct",
170
+ "Remove the dependency from the task",
171
+ ],
172
+ metadata: { dependencyId: depId, taskDependencies: task.dependencies },
173
+ });
133
174
  }
134
175
  }
135
176
  if (this.wouldCreateCircularDependency(data.tasks, id, task.dependencies)) {
136
- throw new Error(`Circular dependency detected for task ${id}`);
177
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.STORAGE_INTEGRITY_ERROR, `Circular dependency detected for task ${id}`, {
178
+ context: "createTask - circular dependency check",
179
+ suggestions: [
180
+ "Remove circular dependencies from the task",
181
+ "Review the dependency chain",
182
+ ],
183
+ metadata: { taskId: id, dependencies: task.dependencies },
184
+ });
137
185
  }
138
186
  }
139
187
  let contentFile;
@@ -184,7 +232,10 @@ class FileSystemStorage {
184
232
  async updateTask(id, updates) {
185
233
  this.validateTaskId(id);
186
234
  if (!updates || typeof updates !== "object") {
187
- throw new Error("Updates must be a valid object");
235
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Updates must be a valid object", {
236
+ context: "updateTask - updates validation",
237
+ suggestions: ["Provide a valid updates object with task properties"],
238
+ });
188
239
  }
189
240
  const data = await this.loadTasksData();
190
241
  const result = this.findTaskInHierarchy(data.tasks, id);
@@ -314,28 +365,34 @@ class FileSystemStorage {
314
365
  async saveTaskContent(taskId, content) {
315
366
  this.validateTaskId(taskId);
316
367
  if (typeof content !== "string") {
317
- throw new Error("Content must be a string");
368
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Content must be a string", {
369
+ context: "Content validation",
370
+ suggestions: ["Provide content as a string"],
371
+ });
318
372
  }
319
373
  const contentFileName = `tasks/${taskId}.md`;
320
374
  try {
321
375
  await this.callbacks.write(contentFileName, content);
322
376
  }
323
377
  catch (error) {
324
- throw new Error(`Failed to save task content: ${error instanceof Error ? error.message : "Unknown error"}`);
378
+ throw (0, task_o_matic_error_1.formatStorageError)("write task content", error instanceof Error ? error : undefined);
325
379
  }
326
380
  return contentFileName;
327
381
  }
328
382
  async saveEnhancedTaskContent(taskId, content) {
329
383
  this.validateTaskId(taskId);
330
384
  if (typeof content !== "string") {
331
- throw new Error("Content must be a string");
385
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Content must be a string", {
386
+ context: "Content validation",
387
+ suggestions: ["Provide content as a string"],
388
+ });
332
389
  }
333
390
  const contentFileName = `tasks/enhanced/${taskId}.md`;
334
391
  try {
335
392
  await this.callbacks.write(contentFileName, content);
336
393
  }
337
394
  catch (error) {
338
- throw new Error(`Failed to save enhanced task content: ${error instanceof Error ? error.message : "Unknown error"}`);
395
+ throw (0, task_o_matic_error_1.formatStorageError)("write enhanced task content", error instanceof Error ? error : undefined);
339
396
  }
340
397
  return contentFileName;
341
398
  }
@@ -496,7 +553,7 @@ class FileSystemStorage {
496
553
  await this.callbacks.write(planFile, JSON.stringify(planData, null, 2));
497
554
  }
498
555
  catch (error) {
499
- throw new Error(`Failed to save plan for task ${taskId}: ${error instanceof Error ? error.message : "Unknown error"}`);
556
+ throw (0, task_o_matic_error_1.formatStorageError)(`write plan for task ${taskId}`, error instanceof Error ? error : undefined);
500
557
  }
501
558
  }
502
559
  async getPlan(taskId) {
@@ -509,7 +566,7 @@ class FileSystemStorage {
509
566
  return JSON.parse(content);
510
567
  }
511
568
  catch (error) {
512
- throw new Error(`Failed to read plan for task ${taskId}: ${error instanceof Error ? error.message : "Unknown error"}`);
569
+ throw (0, task_o_matic_error_1.formatStorageError)(`read plan for task ${taskId}`, error instanceof Error ? error : undefined);
513
570
  }
514
571
  }
515
572
  async listPlans() {
@@ -534,7 +591,7 @@ class FileSystemStorage {
534
591
  return plans.sort((a, b) => b.updatedAt - a.updatedAt);
535
592
  }
536
593
  catch (error) {
537
- throw new Error(`Failed to list plans: ${error instanceof Error ? error.message : "Unknown error"}`);
594
+ throw (0, task_o_matic_error_1.formatStorageError)("list plans", error instanceof Error ? error : undefined);
538
595
  }
539
596
  }
540
597
  async deletePlan(taskId) {
@@ -551,14 +608,17 @@ class FileSystemStorage {
551
608
  async saveTaskDocumentation(taskId, documentation) {
552
609
  this.validateTaskId(taskId);
553
610
  if (typeof documentation !== "string") {
554
- throw new Error("Documentation must be a string");
611
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Documentation must be a string", {
612
+ context: "Documentation validation",
613
+ suggestions: ["Provide documentation as a string"],
614
+ });
555
615
  }
556
616
  const documentationFileName = `docs/tasks/${taskId}.md`;
557
617
  try {
558
618
  await this.callbacks.write(documentationFileName, documentation);
559
619
  }
560
620
  catch (error) {
561
- throw new Error(`Failed to save task documentation: ${error instanceof Error ? error.message : "Unknown error"}`);
621
+ throw (0, task_o_matic_error_1.formatStorageError)("write task documentation", error instanceof Error ? error : undefined);
562
622
  }
563
623
  return documentationFileName;
564
624
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-execution-core.d.ts","sourceRoot":"","sources":["../../src/lib/task-execution-core.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EAKpB,MAAM,UAAU,CAAC;AAWlB;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA+D9B"}
1
+ {"version":3,"file":"task-execution-core.d.ts","sourceRoot":"","sources":["../../src/lib/task-execution-core.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EAKpB,MAAM,UAAU,CAAC;AAWlB;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA+D9B"}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.executeTaskCore = executeTaskCore;
7
+ const task_o_matic_error_1 = require("../utils/task-o-matic-error");
7
8
  const tasks_1 = require("../services/tasks");
8
9
  const executor_factory_1 = require("./executors/executor-factory");
9
10
  const validation_1 = require("./validation");
@@ -23,7 +24,7 @@ async function executeTaskCore(taskId, config) {
23
24
  // Load task
24
25
  const task = await tasks_1.taskService.getTask(taskId);
25
26
  if (!task) {
26
- throw new Error(`Task with ID ${taskId} not found`);
27
+ throw (0, task_o_matic_error_1.formatTaskNotFoundError)(taskId);
27
28
  }
28
29
  // Check if task has subtasks and should execute them recursively
29
30
  if (executeSubtasks && !customMessage) {
@@ -254,7 +255,7 @@ async function executeSingleAttempt(task, config, attempts, planContent, attempt
254
255
  retryContext,
255
256
  });
256
257
  if (!promptResult.success) {
257
- throw new Error(`Failed to build execution prompt: ${promptResult.error}`);
258
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR, `Failed to build execution prompt: ${promptResult.error}`);
258
259
  }
259
260
  executionMessage = promptResult.prompt;
260
261
  }
@@ -1,12 +1,28 @@
1
+ import { getAIOperations, getStorage } from "../utils/ai-service-factory";
1
2
  import { AIOptions } from "../utils/ai-config-builder";
2
3
  import { StreamingOptions } from "../types";
3
4
  import { PRDParseResult } from "../types/results";
4
5
  import { ProgressCallback } from "../types/callbacks";
6
+ /**
7
+ * Dependencies for PRDService
8
+ */
9
+ export interface PRDServiceDependencies {
10
+ storage?: ReturnType<typeof getStorage>;
11
+ aiOperations?: ReturnType<typeof getAIOperations>;
12
+ }
5
13
  /**
6
14
  * PRDService - Business logic for PRD operations
7
15
  * Handles PRD parsing, task extraction, and PRD improvement
8
16
  */
9
17
  export declare class PRDService {
18
+ private storage;
19
+ private aiOperations;
20
+ /**
21
+ * Create a new PRDService
22
+ *
23
+ * @param dependencies - Optional dependencies to inject (for testing)
24
+ */
25
+ constructor(dependencies?: PRDServiceDependencies);
10
26
  parsePRD(input: {
11
27
  file: string;
12
28
  workingDirectory?: string;
@@ -98,5 +114,6 @@ export declare class PRDService {
98
114
  };
99
115
  }>;
100
116
  }
117
+ export declare function getPRDService(): PRDService;
101
118
  export declare const prdService: PRDService;
102
119
  //# sourceMappingURL=prd.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prd.d.ts","sourceRoot":"","sources":["../../src/services/prd.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAY,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;GAGG;AACH,qBAAa,UAAU;IACf,QAAQ,CAAC,KAAK,EAAE;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAChC,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,SAAS,CAAC,EAAE,gBAAgB,CAAC;KAC9B,GAAG,OAAO,CAAC,cAAc,CAAC;IAoMrB,iBAAiB,CAAC,KAAK,EAAE;QAC7B,IAAI,EAAE,MAAM,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