@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.
- package/README.md +480 -0
- package/dist/anchor.d.ts +93 -96
- package/dist/anchor.d.ts.map +1 -1
- package/dist/anchor.js +74 -1
- package/dist/anchor.js.map +1 -1
- package/dist/attempt.d.ts +36 -28
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +59 -1
- package/dist/attempt.js.map +1 -1
- package/dist/candidate.d.ts +117 -145
- package/dist/candidate.d.ts.map +1 -1
- package/dist/candidate.js +109 -0
- package/dist/candidate.js.map +1 -1
- package/dist/cycle.d.ts +130 -0
- package/dist/cycle.d.ts.map +1 -0
- package/dist/cycle.js +89 -0
- package/dist/cycle.js.map +1 -0
- package/dist/deduplication.d.ts +76 -92
- package/dist/deduplication.d.ts.map +1 -1
- package/dist/deduplication.js +63 -2
- package/dist/deduplication.js.map +1 -1
- package/dist/doc.d.ts +269 -0
- package/dist/doc.d.ts.map +1 -0
- package/dist/doc.js +232 -0
- package/dist/doc.js.map +1 -0
- package/dist/edge.d.ts +53 -56
- package/dist/edge.d.ts.map +1 -1
- package/dist/edge.js +51 -1
- package/dist/edge.js.map +1 -1
- package/dist/file-learning.d.ts +23 -28
- package/dist/file-learning.d.ts.map +1 -1
- package/dist/file-learning.js +22 -2
- package/dist/file-learning.js.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -21
- package/dist/index.js.map +1 -1
- package/dist/learning.d.ts +167 -172
- package/dist/learning.d.ts.map +1 -1
- package/dist/learning.js +109 -1
- package/dist/learning.js.map +1 -1
- package/dist/response.d.ts +636 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +354 -0
- package/dist/response.js.map +1 -0
- package/dist/run.d.ts +73 -40
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +108 -1
- package/dist/run.js.map +1 -1
- package/dist/symbol.d.ts +42 -43
- package/dist/symbol.d.ts.map +1 -1
- package/dist/symbol.js +55 -1
- package/dist/symbol.js.map +1 -1
- package/dist/task.d.ts +114 -78
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +149 -2
- package/dist/task.js.map +1 -1
- package/dist/tracked-project.d.ts +24 -34
- package/dist/tracked-project.d.ts.map +1 -1
- package/dist/tracked-project.js +34 -0
- package/dist/tracked-project.js.map +1 -1
- 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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
28
|
+
name: typeof Schema.String;
|
|
23
29
|
/** Kind of symbol */
|
|
24
|
-
|
|
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
|
-
|
|
32
|
+
line: Schema.filter<typeof Schema.Number>;
|
|
27
33
|
/** Whether the symbol is exported */
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
40
|
+
source: typeof Schema.String;
|
|
41
41
|
/** Imported specifiers (names) */
|
|
42
|
-
|
|
42
|
+
specifiers: Schema.Array$<typeof Schema.String>;
|
|
43
43
|
/** Kind of import */
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
+
pattern: typeof Schema.String;
|
|
52
51
|
/** Kind of symbol this pattern matches */
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
60
|
+
file: typeof Schema.String;
|
|
63
61
|
/** Line number (1-indexed) */
|
|
64
|
-
|
|
62
|
+
line: Schema.filter<typeof Schema.Number>;
|
|
65
63
|
/** Column number (1-indexed) */
|
|
66
|
-
|
|
64
|
+
column: Schema.filter<typeof Schema.Number>;
|
|
67
65
|
/** Matched text */
|
|
68
|
-
|
|
66
|
+
text: typeof Schema.String;
|
|
69
67
|
/** Named captures from the pattern (e.g., $NAME -> value) */
|
|
70
|
-
|
|
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
|
package/dist/symbol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"symbol.d.ts","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"A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* Used by ast-grep integration for structural code analysis.
|
|
6
|
-
*
|
|
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
|
package/dist/symbol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":"AAAA
|
|
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,QA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,CAAA;AAGF,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACtC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACxC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC,MAAM,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
|
|
5
|
-
*
|
|
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
|
-
*
|
|
14
|
+
* Regex pattern for valid task IDs.
|
|
14
15
|
*/
|
|
15
|
-
export
|
|
16
|
+
export declare const TASK_ID_PATTERN: RegExp;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* Valid status transitions map.
|
|
19
|
+
* Used to validate status changes follow the lifecycle.
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
50
|
+
export declare const TaskWithDepsSchema: Schema.Struct<{
|
|
45
51
|
/** Task IDs that block this task */
|
|
46
|
-
|
|
52
|
+
blockedBy: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
|
|
47
53
|
/** Task IDs this task blocks */
|
|
48
|
-
|
|
54
|
+
blocks: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "TaskId">>;
|
|
49
55
|
/** Direct child task IDs */
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
*
|
|
126
|
+
* Check if a string is a valid task status.
|
|
63
127
|
*/
|
|
64
|
-
export
|
|
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
|
-
*
|
|
130
|
+
* Error thrown when a task status is invalid.
|
|
71
131
|
*/
|
|
72
|
-
export
|
|
73
|
-
readonly
|
|
74
|
-
|
|
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
|
-
*
|
|
137
|
+
* Validate and return a TaskStatus, or throw if invalid.
|
|
81
138
|
*/
|
|
82
|
-
export
|
|
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
|
-
*
|
|
141
|
+
* Check if a string is a valid task ID format.
|
|
92
142
|
*/
|
|
93
|
-
export
|
|
94
|
-
readonly score: number;
|
|
95
|
-
readonly id: string;
|
|
96
|
-
}
|
|
143
|
+
export declare const isValidTaskId: (id: string) => id is TaskId;
|
|
97
144
|
/**
|
|
98
|
-
*
|
|
145
|
+
* Error thrown when a task ID is invalid.
|
|
99
146
|
*/
|
|
100
|
-
export
|
|
101
|
-
readonly
|
|
102
|
-
|
|
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
|
-
*
|
|
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;
|
package/dist/task.d.ts.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAM/B;;;GAGG;AACH,eAAO,MAAM,aAAa,2GAShB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe,QAAwB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,UAAU,EAAE,CAS9D,CAAC;AAMX,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,kHAAmC,CAAA;AAChE,MAAM,MAAM,UAAU,GAA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|
2
2
|
* Task types for tx
|
|
3
3
|
*
|
|
4
|
-
* Core type definitions
|
|
5
|
-
*
|
|
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
|