@jamesaphoenix/tx-types 0.4.2 → 0.4.3

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 (62) hide show
  1. package/README.md +480 -0
  2. package/dist/anchor.d.ts +93 -96
  3. package/dist/anchor.d.ts.map +1 -1
  4. package/dist/anchor.js +74 -1
  5. package/dist/anchor.js.map +1 -1
  6. package/dist/attempt.d.ts +36 -28
  7. package/dist/attempt.d.ts.map +1 -1
  8. package/dist/attempt.js +59 -1
  9. package/dist/attempt.js.map +1 -1
  10. package/dist/candidate.d.ts +117 -145
  11. package/dist/candidate.d.ts.map +1 -1
  12. package/dist/candidate.js +109 -0
  13. package/dist/candidate.js.map +1 -1
  14. package/dist/cycle.d.ts +130 -0
  15. package/dist/cycle.d.ts.map +1 -0
  16. package/dist/cycle.js +89 -0
  17. package/dist/cycle.js.map +1 -0
  18. package/dist/deduplication.d.ts +76 -92
  19. package/dist/deduplication.d.ts.map +1 -1
  20. package/dist/deduplication.js +63 -2
  21. package/dist/deduplication.js.map +1 -1
  22. package/dist/doc.d.ts +269 -0
  23. package/dist/doc.d.ts.map +1 -0
  24. package/dist/doc.js +232 -0
  25. package/dist/doc.js.map +1 -0
  26. package/dist/edge.d.ts +53 -56
  27. package/dist/edge.d.ts.map +1 -1
  28. package/dist/edge.js +51 -1
  29. package/dist/edge.js.map +1 -1
  30. package/dist/file-learning.d.ts +23 -28
  31. package/dist/file-learning.d.ts.map +1 -1
  32. package/dist/file-learning.js +22 -2
  33. package/dist/file-learning.js.map +1 -1
  34. package/dist/index.d.ts +14 -14
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +38 -21
  37. package/dist/index.js.map +1 -1
  38. package/dist/learning.d.ts +167 -172
  39. package/dist/learning.d.ts.map +1 -1
  40. package/dist/learning.js +109 -1
  41. package/dist/learning.js.map +1 -1
  42. package/dist/response.d.ts +636 -0
  43. package/dist/response.d.ts.map +1 -0
  44. package/dist/response.js +354 -0
  45. package/dist/response.js.map +1 -0
  46. package/dist/run.d.ts +73 -40
  47. package/dist/run.d.ts.map +1 -1
  48. package/dist/run.js +108 -1
  49. package/dist/run.js.map +1 -1
  50. package/dist/symbol.d.ts +42 -43
  51. package/dist/symbol.d.ts.map +1 -1
  52. package/dist/symbol.js +55 -1
  53. package/dist/symbol.js.map +1 -1
  54. package/dist/task.d.ts +114 -78
  55. package/dist/task.d.ts.map +1 -1
  56. package/dist/task.js +149 -2
  57. package/dist/task.js.map +1 -1
  58. package/dist/tracked-project.d.ts +24 -34
  59. package/dist/tracked-project.d.ts.map +1 -1
  60. package/dist/tracked-project.js +34 -0
  61. package/dist/tracked-project.js.map +1 -1
  62. package/package.json +7 -3
package/dist/symbol.d.ts CHANGED
@@ -3,70 +3,69 @@
3
3
  *
4
4
  * Type definitions for code intelligence and symbol extraction.
5
5
  * Used by ast-grep integration for structural code analysis.
6
- * Zero runtime dependencies - pure TypeScript types only.
6
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
7
+ * Schema definitions provide both compile-time types and runtime validation.
7
8
  */
9
+ import { Schema } from "effect";
8
10
  /**
9
11
  * All valid symbol kinds for code extraction.
10
12
  * Covers common constructs across TypeScript, Rust, Go, Python, etc.
11
13
  */
12
14
  export declare const SYMBOL_KINDS: readonly ["function", "class", "interface", "type", "const", "variable", "method", "struct", "enum", "trait", "module"];
13
15
  /**
14
- * Symbol kind - one of the valid code construct types.
15
- */
16
- export type SymbolKind = (typeof SYMBOL_KINDS)[number];
17
- /**
18
- * Information about an extracted symbol.
16
+ * Import kind - static (import/require) or dynamic (import()).
19
17
  */
20
- export interface SymbolInfo {
18
+ export declare const IMPORT_KINDS: readonly ["static", "dynamic"];
19
+ /** Symbol kind - one of the valid code construct types. */
20
+ export declare const SymbolKindSchema: Schema.Literal<["function", "class", "interface", "type", "const", "variable", "method", "struct", "enum", "trait", "module"]>;
21
+ export type SymbolKind = typeof SymbolKindSchema.Type;
22
+ /** Import kind schema. */
23
+ export declare const ImportKindSchema: Schema.Literal<["static", "dynamic"]>;
24
+ export type ImportKind = typeof ImportKindSchema.Type;
25
+ /** Information about an extracted symbol. */
26
+ export declare const SymbolInfoSchema: Schema.Struct<{
21
27
  /** Symbol name (e.g., function name, class name) */
22
- readonly name: string;
28
+ name: typeof Schema.String;
23
29
  /** Kind of symbol */
24
- readonly kind: SymbolKind;
30
+ kind: Schema.Literal<["function", "class", "interface", "type", "const", "variable", "method", "struct", "enum", "trait", "module"]>;
25
31
  /** Line number where the symbol is defined (1-indexed) */
26
- readonly line: number;
32
+ line: Schema.filter<typeof Schema.Number>;
27
33
  /** Whether the symbol is exported */
28
- readonly exported: boolean;
29
- }
30
- /**
31
- * Import kind - static (import/require) or dynamic (import()).
32
- */
33
- export declare const IMPORT_KINDS: readonly ["static", "dynamic"];
34
- export type ImportKind = (typeof IMPORT_KINDS)[number];
35
- /**
36
- * Information about an import statement.
37
- */
38
- export interface ImportInfo {
34
+ exported: typeof Schema.Boolean;
35
+ }>;
36
+ export type SymbolInfo = typeof SymbolInfoSchema.Type;
37
+ /** Information about an import statement. */
38
+ export declare const ImportInfoSchema: Schema.Struct<{
39
39
  /** Source module path or package name */
40
- readonly source: string;
40
+ source: typeof Schema.String;
41
41
  /** Imported specifiers (names) */
42
- readonly specifiers: readonly string[];
42
+ specifiers: Schema.Array$<typeof Schema.String>;
43
43
  /** Kind of import */
44
- readonly kind: ImportKind;
45
- }
46
- /**
47
- * Pattern for matching symbols with ast-grep.
48
- */
49
- export interface SymbolPattern {
44
+ kind: Schema.Literal<["static", "dynamic"]>;
45
+ }>;
46
+ export type ImportInfo = typeof ImportInfoSchema.Type;
47
+ /** Pattern for matching symbols with ast-grep. */
48
+ export declare const SymbolPatternSchema: Schema.Struct<{
50
49
  /** ast-grep pattern string */
51
- readonly pattern: string;
50
+ pattern: typeof Schema.String;
52
51
  /** Kind of symbol this pattern matches */
53
- readonly kind: SymbolKind;
52
+ kind: Schema.Literal<["function", "class", "interface", "type", "const", "variable", "method", "struct", "enum", "trait", "module"]>;
54
53
  /** If specified, only match exported/non-exported symbols */
55
- readonly exported?: boolean;
56
- }
57
- /**
58
- * A match result from ast-grep pattern matching.
59
- */
60
- export interface Match {
54
+ exported: Schema.optional<typeof Schema.Boolean>;
55
+ }>;
56
+ export type SymbolPattern = typeof SymbolPatternSchema.Type;
57
+ /** A match result from ast-grep pattern matching. */
58
+ export declare const MatchSchema: Schema.Struct<{
61
59
  /** File path where the match was found */
62
- readonly file: string;
60
+ file: typeof Schema.String;
63
61
  /** Line number (1-indexed) */
64
- readonly line: number;
62
+ line: Schema.filter<typeof Schema.Number>;
65
63
  /** Column number (1-indexed) */
66
- readonly column: number;
64
+ column: Schema.filter<typeof Schema.Number>;
67
65
  /** Matched text */
68
- readonly text: string;
66
+ text: typeof Schema.String;
69
67
  /** Named captures from the pattern (e.g., $NAME -> value) */
70
- readonly captures: Readonly<Record<string, string>>;
71
- }
68
+ captures: Schema.Record$<typeof Schema.String, typeof Schema.String>;
69
+ }>;
70
+ export type Match = typeof MatchSchema.Type;
72
71
  //# sourceMappingURL=symbol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,YAAY,yHAYf,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAA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AgB,gIAAkC,CAAA;AAC/D,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAErD,0BAA0B;AAC1B,eAAO,MAAM,gBAAgB,uCAAkC,CAAA;AAC/D,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAErD,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;IAC3B,oDAAoD;;IAEpD,qBAAqB;;IAErB,0DAA0D;;IAE1D,qCAAqC;;EAErC,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAErD,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;IAC3B,yCAAyC;;IAEzC,kCAAkC;;IAElC,qBAAqB;;EAErB,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAErD,kDAAkD;AAClD,eAAO,MAAM,mBAAmB;IAC9B,8BAA8B;;IAE9B,0CAA0C;;IAE1C,6DAA6D;;EAE7D,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAE3D,qDAAqD;AACrD,eAAO,MAAM,WAAW;IACtB,0CAA0C;;IAE1C,8BAA8B;;IAE9B,gCAAgC;;IAEhC,mBAAmB;;IAEnB,6DAA6D;;EAE7D,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA"}
package/dist/symbol.js CHANGED
@@ -3,8 +3,13 @@
3
3
  *
4
4
  * Type definitions for code intelligence and symbol extraction.
5
5
  * Used by ast-grep integration for structural code analysis.
6
- * Zero runtime dependencies - pure TypeScript types only.
6
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
7
+ * Schema definitions provide both compile-time types and runtime validation.
7
8
  */
9
+ import { Schema } from "effect";
10
+ // =============================================================================
11
+ // CONSTANTS
12
+ // =============================================================================
8
13
  /**
9
14
  * All valid symbol kinds for code extraction.
10
15
  * Covers common constructs across TypeScript, Rust, Go, Python, etc.
@@ -26,4 +31,53 @@ export const SYMBOL_KINDS = [
26
31
  * Import kind - static (import/require) or dynamic (import()).
27
32
  */
28
33
  export const IMPORT_KINDS = ["static", "dynamic"];
34
+ // =============================================================================
35
+ // SCHEMAS & TYPES
36
+ // =============================================================================
37
+ /** Symbol kind - one of the valid code construct types. */
38
+ export const SymbolKindSchema = Schema.Literal(...SYMBOL_KINDS);
39
+ /** Import kind schema. */
40
+ export const ImportKindSchema = Schema.Literal(...IMPORT_KINDS);
41
+ /** Information about an extracted symbol. */
42
+ export const SymbolInfoSchema = Schema.Struct({
43
+ /** Symbol name (e.g., function name, class name) */
44
+ name: Schema.String,
45
+ /** Kind of symbol */
46
+ kind: SymbolKindSchema,
47
+ /** Line number where the symbol is defined (1-indexed) */
48
+ line: Schema.Number.pipe(Schema.int()),
49
+ /** Whether the symbol is exported */
50
+ exported: Schema.Boolean,
51
+ });
52
+ /** Information about an import statement. */
53
+ export const ImportInfoSchema = Schema.Struct({
54
+ /** Source module path or package name */
55
+ source: Schema.String,
56
+ /** Imported specifiers (names) */
57
+ specifiers: Schema.Array(Schema.String),
58
+ /** Kind of import */
59
+ kind: ImportKindSchema,
60
+ });
61
+ /** Pattern for matching symbols with ast-grep. */
62
+ export const SymbolPatternSchema = Schema.Struct({
63
+ /** ast-grep pattern string */
64
+ pattern: Schema.String,
65
+ /** Kind of symbol this pattern matches */
66
+ kind: SymbolKindSchema,
67
+ /** If specified, only match exported/non-exported symbols */
68
+ exported: Schema.optional(Schema.Boolean),
69
+ });
70
+ /** A match result from ast-grep pattern matching. */
71
+ export const MatchSchema = Schema.Struct({
72
+ /** File path where the match was found */
73
+ file: Schema.String,
74
+ /** Line number (1-indexed) */
75
+ line: Schema.Number.pipe(Schema.int()),
76
+ /** Column number (1-indexed) */
77
+ column: Schema.Number.pipe(Schema.int()),
78
+ /** Matched text */
79
+ text: Schema.String,
80
+ /** Named captures from the pattern (e.g., $NAME -> value) */
81
+ captures: Schema.Record({ key: Schema.String, value: Schema.String }),
82
+ });
29
83
  //# sourceMappingURL=symbol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU;IACV,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;CACA,CAAC;AAqBX;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU,CAAC"}
1
+ {"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU;IACV,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;CACA,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU,CAAC;AAE3D,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAA;AAG/D,0BAA0B;AAC1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAA;AAG/D,6CAA6C;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;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AM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;CACtE,CAAC,CAAA"}
package/dist/task.d.ts CHANGED
@@ -1,120 +1,158 @@
1
1
  /**
2
2
  * Task types for tx
3
3
  *
4
- * Core type definitions for the task management system.
5
- * Zero runtime dependencies - pure TypeScript types only.
4
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
5
+ * Schema definitions provide both compile-time types and runtime validation.
6
6
  */
7
+ import { Schema } from "effect";
7
8
  /**
8
9
  * All valid task statuses in lifecycle order.
9
10
  * backlog → ready → planning → active → blocked → review → human_needs_to_review → done
10
11
  */
11
12
  export declare const TASK_STATUSES: readonly ["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"];
12
13
  /**
13
- * Task status - one of the valid lifecycle states.
14
+ * Regex pattern for valid task IDs.
14
15
  */
15
- export type TaskStatus = (typeof TASK_STATUSES)[number];
16
+ export declare const TASK_ID_PATTERN: RegExp;
16
17
  /**
17
- * Branded type for task IDs.
18
- * Format: tx-[a-z0-9]{6,8} (e.g., "tx-abc123")
18
+ * Valid status transitions map.
19
+ * Used to validate status changes follow the lifecycle.
19
20
  */
20
- export type TaskId = string & {
21
- readonly _brand: unique symbol;
22
- };
21
+ export declare const VALID_TRANSITIONS: Record<TaskStatus, readonly TaskStatus[]>;
22
+ /** Task status - one of the valid lifecycle states. */
23
+ export declare const TaskStatusSchema: Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>;
24
+ export type TaskStatus = typeof TaskStatusSchema.Type;
25
+ /** Task ID - branded string matching tx-[a-z0-9]{6,12}. */
26
+ export declare const TaskIdSchema: Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">;
27
+ export type TaskId = typeof TaskIdSchema.Type;
23
28
  /**
24
29
  * Core task entity without dependency information.
25
30
  * IMPORTANT: Per doctrine Rule 1, never return bare Task to external consumers.
26
31
  * Always use TaskWithDeps for API responses.
27
32
  */
28
- export interface Task {
29
- readonly id: TaskId;
30
- readonly title: string;
31
- readonly description: string;
32
- readonly status: TaskStatus;
33
- readonly parentId: TaskId | null;
34
- readonly score: number;
35
- readonly createdAt: Date;
36
- readonly updatedAt: Date;
37
- readonly completedAt: Date | null;
38
- readonly metadata: Record<string, unknown>;
39
- }
33
+ export declare const TaskSchema: Schema.Struct<{
34
+ id: Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">;
35
+ title: typeof Schema.String;
36
+ description: typeof Schema.String;
37
+ status: Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>;
38
+ parentId: Schema.NullOr<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
39
+ score: Schema.filter<typeof Schema.Number>;
40
+ createdAt: typeof Schema.DateFromSelf;
41
+ updatedAt: typeof Schema.DateFromSelf;
42
+ completedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
43
+ metadata: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
44
+ }>;
45
+ export type Task = typeof TaskSchema.Type;
40
46
  /**
41
47
  * Task with full dependency information.
42
48
  * This is the REQUIRED return type for all external APIs (Rule 1).
43
49
  */
44
- export interface TaskWithDeps extends Task {
50
+ export declare const TaskWithDepsSchema: Schema.Struct<{
45
51
  /** Task IDs that block this task */
46
- readonly blockedBy: TaskId[];
52
+ blockedBy: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
47
53
  /** Task IDs this task blocks */
48
- readonly blocks: TaskId[];
54
+ blocks: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
49
55
  /** Direct child task IDs */
50
- readonly children: TaskId[];
56
+ children: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
51
57
  /** Whether this task can be worked on (status is workable AND all blockers are done) */
52
- readonly isReady: boolean;
53
- }
54
- /**
55
- * Recursive tree structure for task hierarchy.
56
- */
57
- export interface TaskTree {
58
+ isReady: typeof Schema.Boolean;
59
+ id: Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">;
60
+ title: typeof Schema.String;
61
+ description: typeof Schema.String;
62
+ status: Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>;
63
+ parentId: Schema.NullOr<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
64
+ score: Schema.filter<typeof Schema.Number>;
65
+ createdAt: typeof Schema.DateFromSelf;
66
+ updatedAt: typeof Schema.DateFromSelf;
67
+ completedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
68
+ metadata: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
69
+ }>;
70
+ export type TaskWithDeps = typeof TaskWithDepsSchema.Type;
71
+ /** Recursive tree structure for task hierarchy. */
72
+ export declare const TaskTreeSchema: Schema.Schema<TaskTree, any>;
73
+ export type TaskTree = {
58
74
  readonly task: Task;
59
75
  readonly children: readonly TaskTree[];
60
- }
76
+ };
77
+ /** Task dependency relationship. */
78
+ export declare const TaskDependencySchema: Schema.Struct<{
79
+ blockerId: Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">;
80
+ blockedId: Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">;
81
+ createdAt: typeof Schema.DateFromSelf;
82
+ }>;
83
+ export type TaskDependency = typeof TaskDependencySchema.Type;
84
+ /** Input for creating a new task. */
85
+ export declare const CreateTaskInputSchema: Schema.Struct<{
86
+ title: typeof Schema.String;
87
+ description: Schema.optional<typeof Schema.String>;
88
+ parentId: Schema.optional<Schema.NullOr<typeof Schema.String>>;
89
+ score: Schema.optional<Schema.filter<typeof Schema.Number>>;
90
+ metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
91
+ }>;
92
+ export type CreateTaskInput = typeof CreateTaskInputSchema.Type;
93
+ /** Input for updating an existing task. */
94
+ export declare const UpdateTaskInputSchema: Schema.Struct<{
95
+ title: Schema.optional<typeof Schema.String>;
96
+ description: Schema.optional<typeof Schema.String>;
97
+ status: Schema.optional<Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>>;
98
+ parentId: Schema.optional<Schema.NullOr<typeof Schema.String>>;
99
+ score: Schema.optional<Schema.filter<typeof Schema.Number>>;
100
+ metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
101
+ }>;
102
+ export type UpdateTaskInput = typeof UpdateTaskInputSchema.Type;
103
+ /** Cursor for pagination (score + id based). */
104
+ export declare const TaskCursorSchema: Schema.Struct<{
105
+ score: typeof Schema.Number;
106
+ id: typeof Schema.String;
107
+ }>;
108
+ export type TaskCursor = typeof TaskCursorSchema.Type;
109
+ /** Filter options for task queries. */
110
+ export declare const TaskFilterSchema: Schema.Struct<{
111
+ status: Schema.optional<Schema.Union<[Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>, Schema.Array$<Schema.Literal<["backlog", "ready", "planning", "active", "blocked", "review", "human_needs_to_review", "done"]>>]>>;
112
+ parentId: Schema.optional<Schema.NullOr<typeof Schema.String>>;
113
+ limit: Schema.optional<Schema.filter<typeof Schema.Number>>;
114
+ /** Search in title and description (case-insensitive) */
115
+ search: Schema.optional<typeof Schema.String>;
116
+ /** Cursor for keyset pagination (returns tasks after this cursor) */
117
+ cursor: Schema.optional<Schema.Struct<{
118
+ score: typeof Schema.Number;
119
+ id: typeof Schema.String;
120
+ }>>;
121
+ /** Exclude tasks that have an active claim in task_claims (prevents thundering herd) */
122
+ excludeClaimed: Schema.optional<typeof Schema.Boolean>;
123
+ }>;
124
+ export type TaskFilter = typeof TaskFilterSchema.Type;
61
125
  /**
62
- * Task dependency relationship.
126
+ * Check if a string is a valid task status.
63
127
  */
64
- export interface TaskDependency {
65
- readonly blockerId: TaskId;
66
- readonly blockedId: TaskId;
67
- readonly createdAt: Date;
68
- }
128
+ export declare const isValidTaskStatus: (status: string) => status is TaskStatus;
69
129
  /**
70
- * Input for creating a new task.
130
+ * Error thrown when a task status is invalid.
71
131
  */
72
- export interface CreateTaskInput {
73
- readonly title: string;
74
- readonly description?: string;
75
- readonly parentId?: string | null;
76
- readonly score?: number;
77
- readonly metadata?: Record<string, unknown>;
132
+ export declare class InvalidTaskStatusError extends Error {
133
+ readonly status: string;
134
+ constructor(status: string);
78
135
  }
79
136
  /**
80
- * Input for updating an existing task.
137
+ * Validate and return a TaskStatus, or throw if invalid.
81
138
  */
82
- export interface UpdateTaskInput {
83
- readonly title?: string;
84
- readonly description?: string;
85
- readonly status?: TaskStatus;
86
- readonly parentId?: string | null;
87
- readonly score?: number;
88
- readonly metadata?: Record<string, unknown>;
89
- }
139
+ export declare const assertTaskStatus: (status: string) => TaskStatus;
90
140
  /**
91
- * Cursor for pagination (score + id based).
141
+ * Check if a string is a valid task ID format.
92
142
  */
93
- export interface TaskCursor {
94
- readonly score: number;
95
- readonly id: string;
96
- }
143
+ export declare const isValidTaskId: (id: string) => id is TaskId;
97
144
  /**
98
- * Filter options for task queries.
145
+ * Error thrown when a task ID is invalid.
99
146
  */
100
- export interface TaskFilter {
101
- readonly status?: TaskStatus | TaskStatus[];
102
- readonly parentId?: string | null;
103
- readonly limit?: number;
104
- /** Search in title and description (case-insensitive) */
105
- readonly search?: string;
106
- /** Cursor for keyset pagination (returns tasks after this cursor) */
107
- readonly cursor?: TaskCursor;
147
+ export declare class InvalidTaskIdError extends Error {
148
+ readonly id: string;
149
+ constructor(id: string);
108
150
  }
109
151
  /**
110
- * Valid status transitions map.
111
- * Used to validate status changes follow the lifecycle.
112
- */
113
- export declare const VALID_TRANSITIONS: Record<TaskStatus, readonly TaskStatus[]>;
114
- /**
115
- * Database row type for tasks (snake_case from SQLite).
116
- * Used by repositories for mapping DB rows to Task objects.
152
+ * Validate and return a branded TaskId, or throw if invalid.
117
153
  */
154
+ export declare const assertTaskId: (id: string) => TaskId;
155
+ /** Database row type for tasks (snake_case from SQLite). */
118
156
  export interface TaskRow {
119
157
  id: string;
120
158
  title: string;
@@ -127,9 +165,7 @@ export interface TaskRow {
127
165
  completed_at: string | null;
128
166
  metadata: string;
129
167
  }
130
- /**
131
- * Database row type for dependencies (snake_case from SQLite).
132
- */
168
+ /** Database row type for dependencies (snake_case from SQLite). */
133
169
  export interface DependencyRow {
134
170
  blocker_id: string;
135
171
  blocked_id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,2GAShB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI;IACxC,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,gCAAgC;IACh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CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB"}
package/dist/task.js CHANGED
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * Task types for tx
3
3
  *
4
- * Core type definitions for the task management system.
5
- * Zero runtime dependencies - pure TypeScript types only.
4
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
5
+ * Schema definitions provide both compile-time types and runtime validation.
6
6
  */
7
+ import { Schema } from "effect";
8
+ // =============================================================================
9
+ // CONSTANTS
10
+ // =============================================================================
7
11
  /**
8
12
  * All valid task statuses in lifecycle order.
9
13
  * backlog → ready → planning → active → blocked → review → human_needs_to_review → done
@@ -18,6 +22,10 @@ export const TASK_STATUSES = [
18
22
  "human_needs_to_review",
19
23
  "done",
20
24
  ];
25
+ /**
26
+ * Regex pattern for valid task IDs.
27
+ */
28
+ export const TASK_ID_PATTERN = /^tx-[a-z0-9]{6,12}$/;
21
29
  /**
22
30
  * Valid status transitions map.
23
31
  * Used to validate status changes follow the lifecycle.
@@ -32,4 +40,143 @@ export const VALID_TRANSITIONS = {
32
40
  human_needs_to_review: ["active", "review", "done"],
33
41
  done: ["backlog"],
34
42
  };
43
+ // =============================================================================
44
+ // SCHEMAS & TYPES
45
+ // =============================================================================
46
+ /** Task status - one of the valid lifecycle states. */
47
+ export const TaskStatusSchema = Schema.Literal(...TASK_STATUSES);
48
+ /** Task ID - branded string matching tx-[a-z0-9]{6,12}. */
49
+ export const TaskIdSchema = Schema.String.pipe(Schema.pattern(TASK_ID_PATTERN), Schema.brand("TaskId"));
50
+ /**
51
+ * Core task entity without dependency information.
52
+ * IMPORTANT: Per doctrine Rule 1, never return bare Task to external consumers.
53
+ * Always use TaskWithDeps for API responses.
54
+ */
55
+ export const TaskSchema = Schema.Struct({
56
+ id: TaskIdSchema,
57
+ title: Schema.String,
58
+ description: Schema.String,
59
+ status: TaskStatusSchema,
60
+ parentId: Schema.NullOr(TaskIdSchema),
61
+ score: Schema.Number.pipe(Schema.int()),
62
+ createdAt: Schema.DateFromSelf,
63
+ updatedAt: Schema.DateFromSelf,
64
+ completedAt: Schema.NullOr(Schema.DateFromSelf),
65
+ metadata: Schema.Record({ key: Schema.String, value: Schema.Unknown }),
66
+ });
67
+ /**
68
+ * Task with full dependency information.
69
+ * This is the REQUIRED return type for all external APIs (Rule 1).
70
+ */
71
+ export const TaskWithDepsSchema = Schema.Struct({
72
+ ...TaskSchema.fields,
73
+ /** Task IDs that block this task */
74
+ blockedBy: Schema.Array(TaskIdSchema),
75
+ /** Task IDs this task blocks */
76
+ blocks: Schema.Array(TaskIdSchema),
77
+ /** Direct child task IDs */
78
+ children: Schema.Array(TaskIdSchema),
79
+ /** Whether this task can be worked on (status is workable AND all blockers are done) */
80
+ isReady: Schema.Boolean,
81
+ });
82
+ /** Recursive tree structure for task hierarchy. */
83
+ export const TaskTreeSchema = Schema.Struct({
84
+ task: TaskSchema,
85
+ children: Schema.Array(Schema.suspend(() => TaskTreeSchema)),
86
+ });
87
+ /** Task dependency relationship. */
88
+ export const TaskDependencySchema = Schema.Struct({
89
+ blockerId: TaskIdSchema,
90
+ blockedId: TaskIdSchema,
91
+ createdAt: Schema.DateFromSelf,
92
+ });
93
+ /** Input for creating a new task. */
94
+ export const CreateTaskInputSchema = Schema.Struct({
95
+ title: Schema.String,
96
+ description: Schema.optional(Schema.String),
97
+ parentId: Schema.optional(Schema.NullOr(Schema.String)),
98
+ score: Schema.optional(Schema.Number.pipe(Schema.int())),
99
+ metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
100
+ });
101
+ /** Input for updating an existing task. */
102
+ export const UpdateTaskInputSchema = Schema.Struct({
103
+ title: Schema.optional(Schema.String),
104
+ description: Schema.optional(Schema.String),
105
+ status: Schema.optional(TaskStatusSchema),
106
+ parentId: Schema.optional(Schema.NullOr(Schema.String)),
107
+ score: Schema.optional(Schema.Number.pipe(Schema.int())),
108
+ metadata: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
109
+ });
110
+ /** Cursor for pagination (score + id based). */
111
+ export const TaskCursorSchema = Schema.Struct({
112
+ score: Schema.Number,
113
+ id: Schema.String,
114
+ });
115
+ /** Filter options for task queries. */
116
+ export const TaskFilterSchema = Schema.Struct({
117
+ status: Schema.optional(Schema.Union(TaskStatusSchema, Schema.Array(TaskStatusSchema))),
118
+ parentId: Schema.optional(Schema.NullOr(Schema.String)),
119
+ limit: Schema.optional(Schema.Number.pipe(Schema.int())),
120
+ /** Search in title and description (case-insensitive) */
121
+ search: Schema.optional(Schema.String),
122
+ /** Cursor for keyset pagination (returns tasks after this cursor) */
123
+ cursor: Schema.optional(TaskCursorSchema),
124
+ /** Exclude tasks that have an active claim in task_claims (prevents thundering herd) */
125
+ excludeClaimed: Schema.optional(Schema.Boolean),
126
+ });
127
+ // =============================================================================
128
+ // VALIDATION FUNCTIONS
129
+ // =============================================================================
130
+ /**
131
+ * Check if a string is a valid task status.
132
+ */
133
+ export const isValidTaskStatus = (status) => {
134
+ return TASK_STATUSES.includes(status);
135
+ };
136
+ /**
137
+ * Error thrown when a task status is invalid.
138
+ */
139
+ export class InvalidTaskStatusError extends Error {
140
+ status;
141
+ constructor(status) {
142
+ super(`Invalid task status: "${status}". Valid statuses: ${TASK_STATUSES.join(", ")}`);
143
+ this.status = status;
144
+ this.name = "InvalidTaskStatusError";
145
+ }
146
+ }
147
+ /**
148
+ * Validate and return a TaskStatus, or throw if invalid.
149
+ */
150
+ export const assertTaskStatus = (status) => {
151
+ if (!isValidTaskStatus(status)) {
152
+ throw new InvalidTaskStatusError(status);
153
+ }
154
+ return status;
155
+ };
156
+ /**
157
+ * Check if a string is a valid task ID format.
158
+ */
159
+ export const isValidTaskId = (id) => {
160
+ return TASK_ID_PATTERN.test(id);
161
+ };
162
+ /**
163
+ * Error thrown when a task ID is invalid.
164
+ */
165
+ export class InvalidTaskIdError extends Error {
166
+ id;
167
+ constructor(id) {
168
+ super(`Invalid task ID: "${id}". Expected format: tx-[a-z0-9]{6,12}`);
169
+ this.id = id;
170
+ this.name = "InvalidTaskIdError";
171
+ }
172
+ }
173
+ /**
174
+ * Validate and return a branded TaskId, or throw if invalid.
175
+ */
176
+ export const assertTaskId = (id) => {
177
+ if (!isValidTaskId(id)) {
178
+ throw new InvalidTaskIdError(id);
179
+ }
180
+ return id;
181
+ };
35
182
  //# sourceMappingURL=task.js.map