task-o-matic 0.0.14 → 0.0.16

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 (125) 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/commands/workflow.d.ts.map +1 -1
  24. package/dist/commands/workflow.js +15 -2
  25. package/dist/lib/ai-service/base-operations.d.ts +8 -0
  26. package/dist/lib/ai-service/base-operations.d.ts.map +1 -1
  27. package/dist/lib/ai-service/base-operations.js +23 -10
  28. package/dist/lib/ai-service/model-provider.d.ts.map +1 -1
  29. package/dist/lib/ai-service/model-provider.js +37 -6
  30. package/dist/lib/ai-service/prd-operations.d.ts.map +1 -1
  31. package/dist/lib/ai-service/prd-operations.js +50 -7
  32. package/dist/lib/ai-service/task-operations.d.ts +1 -0
  33. package/dist/lib/ai-service/task-operations.d.ts.map +1 -1
  34. package/dist/lib/ai-service/task-operations.js +158 -171
  35. package/dist/lib/benchmark/registry.d.ts.map +1 -1
  36. package/dist/lib/benchmark/registry.js +6 -10
  37. package/dist/lib/config-validation.d.ts +215 -0
  38. package/dist/lib/config-validation.d.ts.map +1 -0
  39. package/dist/lib/config-validation.js +246 -0
  40. package/dist/lib/config.d.ts.map +1 -1
  41. package/dist/lib/config.js +30 -7
  42. package/dist/lib/index.d.ts +1 -1
  43. package/dist/lib/index.d.ts.map +1 -1
  44. package/dist/lib/index.js +2 -1
  45. package/dist/lib/storage/file-system.d.ts.map +1 -1
  46. package/dist/lib/storage/file-system.js +81 -21
  47. package/dist/lib/task-execution-core.d.ts.map +1 -1
  48. package/dist/lib/task-execution-core.js +3 -2
  49. package/dist/services/prd.d.ts +17 -0
  50. package/dist/services/prd.d.ts.map +1 -1
  51. package/dist/services/prd.js +69 -84
  52. package/dist/services/tasks.d.ts +315 -1
  53. package/dist/services/tasks.d.ts.map +1 -1
  54. package/dist/services/tasks.js +486 -121
  55. package/dist/services/workflow-ai-assistant.d.ts.map +1 -1
  56. package/dist/services/workflow-ai-assistant.js +19 -6
  57. package/dist/services/workflow.d.ts.map +1 -1
  58. package/dist/services/workflow.js +7 -1
  59. package/dist/test/lib/ai-service/task-operations.test.d.ts +2 -0
  60. package/dist/test/lib/ai-service/task-operations.test.d.ts.map +1 -0
  61. package/dist/test/lib/ai-service/task-operations.test.js +362 -0
  62. package/dist/test/mocks/mock-ai-operations.d.ts +15 -0
  63. package/dist/test/mocks/mock-ai-operations.d.ts.map +1 -0
  64. package/dist/test/mocks/mock-ai-operations.js +107 -0
  65. package/dist/test/mocks/mock-context-builder.d.ts +10 -0
  66. package/dist/test/mocks/mock-context-builder.d.ts.map +1 -0
  67. package/dist/test/mocks/mock-context-builder.js +81 -0
  68. package/dist/test/mocks/mock-model-provider.d.ts +7 -0
  69. package/dist/test/mocks/mock-model-provider.d.ts.map +1 -0
  70. package/dist/test/mocks/mock-model-provider.js +21 -0
  71. package/dist/test/mocks/mock-service-factory.d.ts +11 -0
  72. package/dist/test/mocks/mock-service-factory.d.ts.map +1 -0
  73. package/dist/test/mocks/mock-service-factory.js +61 -0
  74. package/dist/test/mocks/mock-storage.d.ts +50 -0
  75. package/dist/test/mocks/mock-storage.d.ts.map +1 -0
  76. package/dist/test/mocks/mock-storage.js +145 -0
  77. package/dist/test/services/task-service.test.d.ts +2 -0
  78. package/dist/test/services/task-service.test.d.ts.map +1 -0
  79. package/dist/test/services/task-service.test.js +459 -0
  80. package/dist/test/test-mock-setup.d.ts +26 -0
  81. package/dist/test/test-mock-setup.d.ts.map +1 -0
  82. package/dist/test/test-mock-setup.js +41 -0
  83. package/dist/test/test-setup.d.ts +9 -0
  84. package/dist/test/test-setup.d.ts.map +1 -0
  85. package/dist/test/test-setup.js +44 -0
  86. package/dist/test/test-utils.d.ts +22 -0
  87. package/dist/test/test-utils.d.ts.map +1 -0
  88. package/dist/test/test-utils.js +37 -0
  89. package/dist/test/utils/ai-operation-utility.test.d.ts +2 -0
  90. package/dist/test/utils/ai-operation-utility.test.d.ts.map +1 -0
  91. package/dist/test/utils/ai-operation-utility.test.js +290 -0
  92. package/dist/test/utils/error-handling.test.d.ts +2 -0
  93. package/dist/test/utils/error-handling.test.d.ts.map +1 -0
  94. package/dist/test/utils/error-handling.test.js +231 -0
  95. package/dist/utils/ai-operation-utility.d.ts +142 -0
  96. package/dist/utils/ai-operation-utility.d.ts.map +1 -0
  97. package/dist/utils/ai-operation-utility.js +279 -0
  98. package/dist/utils/ai-service-factory.d.ts +10 -0
  99. package/dist/utils/ai-service-factory.d.ts.map +1 -1
  100. package/dist/utils/ai-service-factory.js +19 -1
  101. package/dist/utils/cli-validators.d.ts +2 -2
  102. package/dist/utils/cli-validators.d.ts.map +1 -1
  103. package/dist/utils/cli-validators.js +7 -6
  104. package/dist/utils/error-utils.d.ts +3 -3
  105. package/dist/utils/error-utils.d.ts.map +1 -1
  106. package/dist/utils/error-utils.js +5 -4
  107. package/dist/utils/file-utils.d.ts +27 -4
  108. package/dist/utils/file-utils.d.ts.map +1 -1
  109. package/dist/utils/file-utils.js +46 -6
  110. package/dist/utils/id-generator.d.ts +1 -1
  111. package/dist/utils/id-generator.d.ts.map +1 -1
  112. package/dist/utils/id-generator.js +8 -2
  113. package/dist/utils/metadata-utils.d.ts +40 -0
  114. package/dist/utils/metadata-utils.d.ts.map +1 -0
  115. package/dist/utils/metadata-utils.js +43 -0
  116. package/dist/utils/model-executor-parser.d.ts +1 -1
  117. package/dist/utils/model-executor-parser.d.ts.map +1 -1
  118. package/dist/utils/model-executor-parser.js +3 -2
  119. package/dist/utils/storage-utils.d.ts +3 -3
  120. package/dist/utils/storage-utils.d.ts.map +1 -1
  121. package/dist/utils/storage-utils.js +7 -6
  122. package/dist/utils/task-o-matic-error.d.ts +206 -0
  123. package/dist/utils/task-o-matic-error.d.ts.map +1 -0
  124. package/dist/utils/task-o-matic-error.js +304 -0
  125. package/package.json +7 -2
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskIDGenerator = void 0;
4
4
  const crypto_1 = require("crypto");
5
+ const task_o_matic_error_1 = require("./task-o-matic-error");
5
6
  /**
6
7
  * Generates unique task IDs with consistent format.
7
8
  * Uses timestamp + random hex for uniqueness.
@@ -84,7 +85,7 @@ class TaskIDGenerator {
84
85
  * @param prefix - Prefix for the ID
85
86
  * @param maxAttempts - Maximum number of generation attempts
86
87
  * @returns Unique task ID
87
- * @throws Error if unable to generate unique ID after maxAttempts
88
+ * @throws TaskOMaticError if unable to generate unique ID after maxAttempts
88
89
  */
89
90
  static generateUnique(existingIds, prefix = "task", maxAttempts = 10) {
90
91
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
@@ -93,7 +94,12 @@ class TaskIDGenerator {
93
94
  return id;
94
95
  }
95
96
  }
96
- throw new Error(`Failed to generate unique ID after ${maxAttempts} attempts`);
97
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.UNEXPECTED_ERROR, `Failed to generate unique ID after ${maxAttempts} attempts`, {
98
+ context: `Could not find a unique ID with prefix '${prefix}' after ${maxAttempts} attempts.`,
99
+ suggestions: [
100
+ "Increase maxAttempts if you have a very large number of tasks.",
101
+ ],
102
+ });
97
103
  }
98
104
  /**
99
105
  * Generates a hierarchical child ID from a parent ID.
@@ -0,0 +1,40 @@
1
+ import { AIConfig } from "../types";
2
+ /**
3
+ * Creates base AI metadata object with common fields.
4
+ * Caller can extend with operation-specific fields.
5
+ *
6
+ * @param taskId - The ID of the task
7
+ * @param aiConfig - AI configuration used for the operation
8
+ * @param promptOverride - Optional custom prompt override
9
+ * @param defaultPrompt - Default prompt if no override provided
10
+ * @param confidence - Confidence score (0-1) for the AI operation
11
+ * @returns Base metadata object
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const baseMetadata = createBaseAIMetadata(
16
+ * "task-123",
17
+ * { provider: "anthropic", model: "claude-sonnet-4.5" },
18
+ * undefined,
19
+ * "Split task into subtasks",
20
+ * 0.9
21
+ * );
22
+ *
23
+ * // Extend with operation-specific fields
24
+ * const subtaskMetadata = {
25
+ * ...baseMetadata,
26
+ * parentTaskId: "parent-123",
27
+ * subtaskIndex: 1
28
+ * };
29
+ * ```
30
+ */
31
+ export declare function createBaseAIMetadata(taskId: string, aiConfig: Partial<AIConfig>, promptOverride?: string, defaultPrompt?: string, confidence?: number): {
32
+ taskId: string;
33
+ aiGenerated: boolean;
34
+ aiPrompt: string;
35
+ confidence: number;
36
+ aiProvider: import("../types").AIProvider | undefined;
37
+ aiModel: string | undefined;
38
+ generatedAt: number;
39
+ };
40
+ //# sourceMappingURL=metadata-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-utils.d.ts","sourceRoot":"","sources":["../../src/utils/metadata-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,aAAa,GAAE,MAA4B,EAC3C,UAAU,GAAE,MAAY;;;;;;;;EAWzB"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBaseAIMetadata = createBaseAIMetadata;
4
+ /**
5
+ * Creates base AI metadata object with common fields.
6
+ * Caller can extend with operation-specific fields.
7
+ *
8
+ * @param taskId - The ID of the task
9
+ * @param aiConfig - AI configuration used for the operation
10
+ * @param promptOverride - Optional custom prompt override
11
+ * @param defaultPrompt - Default prompt if no override provided
12
+ * @param confidence - Confidence score (0-1) for the AI operation
13
+ * @returns Base metadata object
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const baseMetadata = createBaseAIMetadata(
18
+ * "task-123",
19
+ * { provider: "anthropic", model: "claude-sonnet-4.5" },
20
+ * undefined,
21
+ * "Split task into subtasks",
22
+ * 0.9
23
+ * );
24
+ *
25
+ * // Extend with operation-specific fields
26
+ * const subtaskMetadata = {
27
+ * ...baseMetadata,
28
+ * parentTaskId: "parent-123",
29
+ * subtaskIndex: 1
30
+ * };
31
+ * ```
32
+ */
33
+ function createBaseAIMetadata(taskId, aiConfig, promptOverride, defaultPrompt = "AI-generated task", confidence = 0.9) {
34
+ return {
35
+ taskId,
36
+ aiGenerated: true,
37
+ aiPrompt: promptOverride || defaultPrompt,
38
+ confidence,
39
+ aiProvider: aiConfig.provider,
40
+ aiModel: aiConfig.model,
41
+ generatedAt: Date.now(),
42
+ };
43
+ }
@@ -12,7 +12,7 @@ export declare const VALID_EXECUTORS: ExecutorTool[];
12
12
  *
13
13
  * @param value - Comma-separated model/executor specifications
14
14
  * @returns Array of model attempt configurations
15
- * @throws Error if an invalid executor is specified
15
+ * @throws TaskOMaticError if an invalid executor is specified
16
16
  *
17
17
  * @example
18
18
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"model-executor-parser.d.ts","sourceRoot":"","sources":["../../src/utils/model-executor-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,EAKzC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAAE,CA2BlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,YAAY,CAE3E"}
1
+ {"version":3,"file":"model-executor-parser.d.ts","sourceRoot":"","sources":["../../src/utils/model-executor-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAM5D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,EAKzC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAAE,CA4BlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,YAAY,CAE3E"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VALID_EXECUTORS = void 0;
4
4
  exports.parseTryModels = parseTryModels;
5
5
  exports.validateExecutor = validateExecutor;
6
+ const task_o_matic_error_1 = require("./task-o-matic-error");
6
7
  /**
7
8
  * Valid executor tools
8
9
  */
@@ -21,7 +22,7 @@ exports.VALID_EXECUTORS = [
21
22
  *
22
23
  * @param value - Comma-separated model/executor specifications
23
24
  * @returns Array of model attempt configurations
24
- * @throws Error if an invalid executor is specified
25
+ * @throws TaskOMaticError if an invalid executor is specified
25
26
  *
26
27
  * @example
27
28
  * ```typescript
@@ -36,7 +37,7 @@ function parseTryModels(value) {
36
37
  if (trimmed.includes(":")) {
37
38
  const [executor, model] = trimmed.split(":");
38
39
  if (!exports.VALID_EXECUTORS.includes(executor)) {
39
- throw new Error(`Invalid executor "${executor}" in --try-models. Must be one of: ${exports.VALID_EXECUTORS.join(", ")}`);
40
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, `Invalid executor "${executor}" in --try-models. Must be one of: ${exports.VALID_EXECUTORS.join(", ")}`);
40
41
  }
41
42
  return {
42
43
  executor: executor,
@@ -6,7 +6,7 @@ import { Task } from "../types/index.js";
6
6
  * @param task - Task that may be null
7
7
  * @param taskId - ID of the task for error message
8
8
  * @returns The task if not null
9
- * @throws Error if task is null
9
+ * @throws TaskOMaticError if task is null
10
10
  *
11
11
  * @example
12
12
  * ```typescript
@@ -22,7 +22,7 @@ export declare function requireTask(task: Task | null, taskId: string): Task;
22
22
  * @param tasks - Array of tasks that may contain nulls
23
23
  * @param context - Context for error message (e.g., "subtasks", "dependencies")
24
24
  * @returns Array of tasks with nulls filtered out
25
- * @throws Error if any task is null
25
+ * @throws TaskOMaticError if any task is null
26
26
  */
27
27
  export declare function requireTasks(tasks: (Task | null)[], context?: string): Task[];
28
28
  /**
@@ -43,7 +43,7 @@ export declare function filterNullTasks(tasks: (Task | null)[]): Task[];
43
43
  * Validates that a task ID is a non-empty string.
44
44
  *
45
45
  * @param taskId - Task ID to validate
46
- * @throws Error if task ID is invalid
46
+ * @throws TaskOMaticError if task ID is invalid
47
47
  */
48
48
  export declare function validateTaskId(taskId: string): void;
49
49
  //# sourceMappingURL=storage-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-utils.d.ts","sourceRoot":"","sources":["../../src/utils/storage-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKnE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EACtB,OAAO,GAAE,MAAgB,GACxB,IAAI,EAAE,CAiBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAInD"}
1
+ {"version":3,"file":"storage-utils.d.ts","sourceRoot":"","sources":["../../src/utils/storage-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKnE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EACtB,OAAO,GAAE,MAAgB,GACxB,IAAI,EAAE,CAoBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAOnD"}
@@ -4,6 +4,7 @@ exports.requireTask = requireTask;
4
4
  exports.requireTasks = requireTasks;
5
5
  exports.filterNullTasks = filterNullTasks;
6
6
  exports.validateTaskId = validateTaskId;
7
+ const task_o_matic_error_1 = require("./task-o-matic-error");
7
8
  /**
8
9
  * Ensures a task is not null, throwing an error if it is.
9
10
  * Useful for enforcing null checks after storage operations.
@@ -11,7 +12,7 @@ exports.validateTaskId = validateTaskId;
11
12
  * @param task - Task that may be null
12
13
  * @param taskId - ID of the task for error message
13
14
  * @returns The task if not null
14
- * @throws Error if task is null
15
+ * @throws TaskOMaticError if task is null
15
16
  *
16
17
  * @example
17
18
  * ```typescript
@@ -22,7 +23,7 @@ exports.validateTaskId = validateTaskId;
22
23
  */
23
24
  function requireTask(task, taskId) {
24
25
  if (!task) {
25
- throw new Error(`Task not found: ${taskId}`);
26
+ throw (0, task_o_matic_error_1.formatTaskNotFoundError)(taskId);
26
27
  }
27
28
  return task;
28
29
  }
@@ -32,7 +33,7 @@ function requireTask(task, taskId) {
32
33
  * @param tasks - Array of tasks that may contain nulls
33
34
  * @param context - Context for error message (e.g., "subtasks", "dependencies")
34
35
  * @returns Array of tasks with nulls filtered out
35
- * @throws Error if any task is null
36
+ * @throws TaskOMaticError if any task is null
36
37
  */
37
38
  function requireTasks(tasks, context = "tasks") {
38
39
  const validTasks = [];
@@ -46,7 +47,7 @@ function requireTasks(tasks, context = "tasks") {
46
47
  }
47
48
  });
48
49
  if (missingIds.length > 0) {
49
- throw new Error(`Missing ${context}: ${missingIds.join(", ")}`);
50
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.STORAGE_INTEGRITY_ERROR, `Missing ${context}: ${missingIds.join(", ")}`);
50
51
  }
51
52
  return validTasks;
52
53
  }
@@ -70,10 +71,10 @@ function filterNullTasks(tasks) {
70
71
  * Validates that a task ID is a non-empty string.
71
72
  *
72
73
  * @param taskId - Task ID to validate
73
- * @throws Error if task ID is invalid
74
+ * @throws TaskOMaticError if task ID is invalid
74
75
  */
75
76
  function validateTaskId(taskId) {
76
77
  if (!taskId || typeof taskId !== "string" || !taskId.trim()) {
77
- throw new Error("Invalid task ID: must be a non-empty string");
78
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, "Invalid task ID: must be a non-empty string");
78
79
  }
79
80
  }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * TaskOMaticError - Standardized error class for TaskOMatic
3
+ *
4
+ * Provides consistent error handling with context, suggestions, and typing.
5
+ * All errors in the system should use this class or one of the helper functions
6
+ * to ensure consistent error reporting and debugging experience.
7
+ *
8
+ * @example Basic usage
9
+ * ```typescript
10
+ * throw new TaskOMaticError("Task not found", {
11
+ * code: "TASK_NOT_FOUND",
12
+ * context: "Attempted to retrieve task ID: 123",
13
+ * suggestions: [
14
+ * "Verify the task ID is correct",
15
+ * "Check if the task was deleted"
16
+ * ]
17
+ * });
18
+ * ```
19
+ *
20
+ * @example With cause chain
21
+ * ```typescript
22
+ * try {
23
+ * await storage.getTask(id);
24
+ * } catch (error) {
25
+ * throw new TaskOMaticError("Failed to retrieve task", {
26
+ * code: "STORAGE_ERROR",
27
+ * cause: error instanceof Error ? error : new Error(String(error)),
28
+ * context: `Task ID: ${id}`,
29
+ * suggestions: ["Check storage permissions", "Verify storage is initialized"]
30
+ * });
31
+ * }
32
+ * ```
33
+ *
34
+ * @example With metadata
35
+ * ```typescript
36
+ * throw new TaskOMaticError("AI operation timed out", {
37
+ * code: "AI_OPERATION_FAILED",
38
+ * metadata: {
39
+ * operation: "task-breakdown",
40
+ * duration: 30000,
41
+ * retryAttempts: 3
42
+ * },
43
+ * suggestions: ["Increase timeout", "Check AI service status"]
44
+ * });
45
+ * ```
46
+ */
47
+ export declare class TaskOMaticError extends Error {
48
+ /**
49
+ * Error code for categorization
50
+ */
51
+ code: string;
52
+ /**
53
+ * Additional context information
54
+ */
55
+ context?: string;
56
+ /**
57
+ * Actionable suggestions for resolving the error
58
+ */
59
+ suggestions?: string[];
60
+ /**
61
+ * Original error that caused this error (if applicable)
62
+ */
63
+ cause?: Error;
64
+ /**
65
+ * Timestamp when the error occurred
66
+ */
67
+ timestamp: number;
68
+ /**
69
+ * Additional metadata for debugging
70
+ */
71
+ metadata?: Record<string, unknown>;
72
+ /**
73
+ * Create a new TaskOMaticError
74
+ *
75
+ * @param message - Error message
76
+ * @param options - Additional error options
77
+ */
78
+ constructor(message: string, options: {
79
+ code: string;
80
+ context?: string;
81
+ suggestions?: string[];
82
+ cause?: Error;
83
+ metadata?: Record<string, unknown>;
84
+ });
85
+ /**
86
+ * Get full error details as a formatted string
87
+ */
88
+ getDetails(): string;
89
+ /**
90
+ * Get error details as a structured object
91
+ */
92
+ toJSON(): {
93
+ name: string;
94
+ code: string;
95
+ message: string;
96
+ context?: string;
97
+ suggestions?: string[];
98
+ cause?: string;
99
+ timestamp: number;
100
+ metadata?: Record<string, unknown>;
101
+ stack?: string;
102
+ };
103
+ }
104
+ /**
105
+ * Standard error codes for TaskOMatic
106
+ */
107
+ export declare const TaskOMaticErrorCodes: {
108
+ readonly UNEXPECTED_ERROR: "TASK_O_MATIC_001";
109
+ readonly INVALID_INPUT: "TASK_O_MATIC_002";
110
+ readonly CONFIGURATION_ERROR: "TASK_O_MATIC_003";
111
+ readonly TASK_NOT_FOUND: "TASK_O_MATIC_101";
112
+ readonly TASK_ALREADY_EXISTS: "TASK_O_MATIC_102";
113
+ readonly INVALID_TASK_STATUS: "TASK_O_MATIC_103";
114
+ readonly TASK_OPERATION_FAILED: "TASK_O_MATIC_104";
115
+ readonly STORAGE_ERROR: "TASK_O_MATIC_201";
116
+ readonly STORAGE_NOT_INITIALIZED: "TASK_O_MATIC_202";
117
+ readonly STORAGE_INTEGRITY_ERROR: "TASK_O_MATIC_203";
118
+ readonly AI_OPERATION_FAILED: "TASK_O_MATIC_301";
119
+ readonly AI_CONFIGURATION_ERROR: "TASK_O_MATIC_302";
120
+ readonly AI_RATE_LIMIT: "TASK_O_MATIC_303";
121
+ readonly WORKFLOW_VALIDATION_ERROR: "TASK_O_MATIC_401";
122
+ readonly WORKFLOW_EXECUTION_ERROR: "TASK_O_MATIC_402";
123
+ readonly PRD_PARSING_ERROR: "TASK_O_MATIC_501";
124
+ readonly PRD_GENERATION_ERROR: "TASK_O_MATIC_502";
125
+ readonly PRD_VALIDATION_ERROR: "TASK_O_MATIC_503";
126
+ };
127
+ type TaskOMaticErrorCode = (typeof TaskOMaticErrorCodes)[keyof typeof TaskOMaticErrorCodes];
128
+ /**
129
+ * Create a standardized error with context and suggestions
130
+ *
131
+ * Helper function to create TaskOMaticError instances with proper error codes
132
+ * from the TaskOMaticErrorCodes constants.
133
+ *
134
+ * @param code - Error code from TaskOMaticErrorCodes
135
+ * @param message - Human-readable error message
136
+ * @param options - Additional error options
137
+ * @returns Configured TaskOMaticError instance
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * throw createStandardError(
142
+ * TaskOMaticErrorCodes.TASK_NOT_FOUND,
143
+ * "Task with ID '123' not found",
144
+ * {
145
+ * context: "User attempted to retrieve non-existent task",
146
+ * suggestions: ["Verify task ID", "List all tasks to see available IDs"]
147
+ * }
148
+ * );
149
+ * ```
150
+ */
151
+ export declare function createStandardError(code: TaskOMaticErrorCode, message: string, options?: {
152
+ context?: string;
153
+ suggestions?: string[];
154
+ cause?: Error;
155
+ metadata?: Record<string, unknown>;
156
+ }): TaskOMaticError;
157
+ /**
158
+ * Format an existing error into a TaskOMaticError with context and suggestions
159
+ *
160
+ * Useful for wrapping caught errors with additional context while preserving
161
+ * the original error as the cause.
162
+ *
163
+ * @param error - Original error to wrap
164
+ * @param code - Error code from TaskOMaticErrorCodes
165
+ * @param options - Additional error options
166
+ * @returns TaskOMaticError wrapping the original error
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * try {
171
+ * await dangerousOperation();
172
+ * } catch (error) {
173
+ * throw formatStandardError(
174
+ * error,
175
+ * TaskOMaticErrorCodes.STORAGE_ERROR,
176
+ * {
177
+ * context: "Failed during task persistence",
178
+ * suggestions: ["Check disk space", "Verify write permissions"]
179
+ * }
180
+ * );
181
+ * }
182
+ * ```
183
+ */
184
+ export declare function formatStandardError(error: unknown, code: TaskOMaticErrorCode, options?: {
185
+ context?: string;
186
+ suggestions?: string[];
187
+ metadata?: Record<string, unknown>;
188
+ }): TaskOMaticError;
189
+ /**
190
+ * Type guard for TaskOMaticError
191
+ */
192
+ export declare function isTaskOMaticError(error: unknown): error is TaskOMaticError;
193
+ /**
194
+ * Common error formatting functions
195
+ */
196
+ export declare function formatTaskNotFoundError(taskId: string): TaskOMaticError;
197
+ export declare function formatInvalidStatusTransitionError(fromStatus: string, toStatus: string): TaskOMaticError;
198
+ export declare function formatStorageError(operation: string, cause?: Error): TaskOMaticError;
199
+ export declare function formatAIOperationError(operation: string, cause?: Error): TaskOMaticError;
200
+ /**
201
+ * Backward compatibility wrapper
202
+ * Maintains existing error handling patterns while using new error system
203
+ */
204
+ export declare function wrapErrorForBackwardCompatibility(error: unknown, context?: string): Error;
205
+ export {};
206
+ //# sourceMappingURL=task-o-matic-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-o-matic-error.d.ts","sourceRoot":"","sources":["../../src/utils/task-o-matic-error.ts"],"names":[],"mappings":"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"}