@task-mcp/shared 0.1.0

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 (81) hide show
  1. package/dist/algorithms/critical-path.d.ts +46 -0
  2. package/dist/algorithms/critical-path.d.ts.map +1 -0
  3. package/dist/algorithms/critical-path.js +308 -0
  4. package/dist/algorithms/critical-path.js.map +1 -0
  5. package/dist/algorithms/critical-path.test.d.ts +2 -0
  6. package/dist/algorithms/critical-path.test.d.ts.map +1 -0
  7. package/dist/algorithms/critical-path.test.js +194 -0
  8. package/dist/algorithms/critical-path.test.js.map +1 -0
  9. package/dist/algorithms/index.d.ts +3 -0
  10. package/dist/algorithms/index.d.ts.map +1 -0
  11. package/dist/algorithms/index.js +3 -0
  12. package/dist/algorithms/index.js.map +1 -0
  13. package/dist/algorithms/topological-sort.d.ts +41 -0
  14. package/dist/algorithms/topological-sort.d.ts.map +1 -0
  15. package/dist/algorithms/topological-sort.js +168 -0
  16. package/dist/algorithms/topological-sort.js.map +1 -0
  17. package/dist/algorithms/topological-sort.test.d.ts +2 -0
  18. package/dist/algorithms/topological-sort.test.d.ts.map +1 -0
  19. package/dist/algorithms/topological-sort.test.js +162 -0
  20. package/dist/algorithms/topological-sort.test.js.map +1 -0
  21. package/dist/index.d.ts +4 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +7 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/schemas/index.d.ts +4 -0
  26. package/dist/schemas/index.d.ts.map +1 -0
  27. package/dist/schemas/index.js +7 -0
  28. package/dist/schemas/index.js.map +1 -0
  29. package/dist/schemas/project.d.ts +55 -0
  30. package/dist/schemas/project.d.ts.map +1 -0
  31. package/dist/schemas/project.js +48 -0
  32. package/dist/schemas/project.js.map +1 -0
  33. package/dist/schemas/task.d.ts +124 -0
  34. package/dist/schemas/task.d.ts.map +1 -0
  35. package/dist/schemas/task.js +89 -0
  36. package/dist/schemas/task.js.map +1 -0
  37. package/dist/schemas/view.d.ts +44 -0
  38. package/dist/schemas/view.d.ts.map +1 -0
  39. package/dist/schemas/view.js +33 -0
  40. package/dist/schemas/view.js.map +1 -0
  41. package/dist/utils/date.d.ts +25 -0
  42. package/dist/utils/date.d.ts.map +1 -0
  43. package/dist/utils/date.js +103 -0
  44. package/dist/utils/date.js.map +1 -0
  45. package/dist/utils/date.test.d.ts +2 -0
  46. package/dist/utils/date.test.d.ts.map +1 -0
  47. package/dist/utils/date.test.js +138 -0
  48. package/dist/utils/date.test.js.map +1 -0
  49. package/dist/utils/id.d.ts +27 -0
  50. package/dist/utils/id.d.ts.map +1 -0
  51. package/dist/utils/id.js +41 -0
  52. package/dist/utils/id.js.map +1 -0
  53. package/dist/utils/index.d.ts +4 -0
  54. package/dist/utils/index.d.ts.map +1 -0
  55. package/dist/utils/index.js +4 -0
  56. package/dist/utils/index.js.map +1 -0
  57. package/dist/utils/natural-language.d.ts +12 -0
  58. package/dist/utils/natural-language.d.ts.map +1 -0
  59. package/dist/utils/natural-language.js +112 -0
  60. package/dist/utils/natural-language.js.map +1 -0
  61. package/dist/utils/natural-language.test.d.ts +2 -0
  62. package/dist/utils/natural-language.test.d.ts.map +1 -0
  63. package/dist/utils/natural-language.test.js +132 -0
  64. package/dist/utils/natural-language.test.js.map +1 -0
  65. package/package.json +46 -0
  66. package/src/algorithms/critical-path.test.ts +241 -0
  67. package/src/algorithms/critical-path.ts +413 -0
  68. package/src/algorithms/index.ts +17 -0
  69. package/src/algorithms/topological-sort.test.ts +190 -0
  70. package/src/algorithms/topological-sort.ts +204 -0
  71. package/src/index.ts +8 -0
  72. package/src/schemas/index.ts +30 -0
  73. package/src/schemas/project.ts +62 -0
  74. package/src/schemas/task.ts +116 -0
  75. package/src/schemas/view.ts +46 -0
  76. package/src/utils/date.test.ts +160 -0
  77. package/src/utils/date.ts +119 -0
  78. package/src/utils/id.ts +45 -0
  79. package/src/utils/index.ts +3 -0
  80. package/src/utils/natural-language.test.ts +154 -0
  81. package/src/utils/natural-language.ts +125 -0
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Convert priority string to numeric value
3
+ */
4
+ export function priorityToNumber(priority) {
5
+ const map = {
6
+ critical: 4,
7
+ high: 3,
8
+ medium: 2,
9
+ low: 1,
10
+ };
11
+ return map[priority] ?? 2;
12
+ }
13
+ /**
14
+ * Convert Task to TaskNode
15
+ */
16
+ export function taskToNode(task) {
17
+ return {
18
+ id: task.id,
19
+ dependencies: (task.dependencies ?? [])
20
+ .filter((d) => d.type === "blocked_by")
21
+ .map((d) => d.taskId),
22
+ priority: priorityToNumber(task.priority),
23
+ estimate: task.estimate?.expected ?? 0,
24
+ };
25
+ }
26
+ /**
27
+ * Topological sort using Kahn's algorithm with priority tie-breaking
28
+ *
29
+ * Returns tasks in optimal execution order:
30
+ * 1. Respects dependencies (blocked_by relationships)
31
+ * 2. Higher priority tasks come first when dependencies allow
32
+ *
33
+ * @throws Error if circular dependency detected
34
+ */
35
+ export function topologicalSort(tasks) {
36
+ const nodes = tasks.map(taskToNode);
37
+ const nodeMap = new Map(nodes.map((n) => [n.id, n]));
38
+ const taskMap = new Map(tasks.map((t) => [t.id, t]));
39
+ // Calculate in-degree for each node
40
+ const inDegree = new Map();
41
+ const adjacency = new Map();
42
+ for (const node of nodes) {
43
+ inDegree.set(node.id, 0);
44
+ adjacency.set(node.id, []);
45
+ }
46
+ // Build graph: if A is blocked_by B, then B -> A (B must come before A)
47
+ for (const node of nodes) {
48
+ for (const depId of node.dependencies) {
49
+ if (nodeMap.has(depId)) {
50
+ const adj = adjacency.get(depId);
51
+ if (adj)
52
+ adj.push(node.id);
53
+ inDegree.set(node.id, (inDegree.get(node.id) ?? 0) + 1);
54
+ }
55
+ }
56
+ }
57
+ // Initialize queue with nodes that have no dependencies
58
+ const queue = [];
59
+ for (const node of nodes) {
60
+ if (inDegree.get(node.id) === 0) {
61
+ queue.push(node);
62
+ }
63
+ }
64
+ // Sort by priority (higher first)
65
+ queue.sort((a, b) => b.priority - a.priority);
66
+ const result = [];
67
+ while (queue.length > 0) {
68
+ const current = queue.shift();
69
+ const task = taskMap.get(current.id);
70
+ if (task) {
71
+ result.push(task);
72
+ }
73
+ // Update neighbors
74
+ for (const neighborId of adjacency.get(current.id)) {
75
+ const newDegree = inDegree.get(neighborId) - 1;
76
+ inDegree.set(neighborId, newDegree);
77
+ if (newDegree === 0) {
78
+ const neighborNode = nodeMap.get(neighborId);
79
+ queue.push(neighborNode);
80
+ // Re-sort to maintain priority order
81
+ queue.sort((a, b) => b.priority - a.priority);
82
+ }
83
+ }
84
+ }
85
+ // Check for cycles
86
+ if (result.length !== tasks.length) {
87
+ const remaining = tasks.filter((t) => !result.some((r) => r.id === t.id));
88
+ const cycleIds = remaining.map((t) => t.id).join(", ");
89
+ throw new Error(`Circular dependency detected among tasks: ${cycleIds}`);
90
+ }
91
+ return result;
92
+ }
93
+ /**
94
+ * Detect if adding a dependency would create a cycle
95
+ */
96
+ export function wouldCreateCycle(tasks, fromId, toId) {
97
+ // Create a temporary task list with the new dependency
98
+ const tempTasks = tasks.map((t) => {
99
+ if (t.id === fromId) {
100
+ return {
101
+ ...t,
102
+ dependencies: [
103
+ ...(t.dependencies ?? []),
104
+ { taskId: toId, type: "blocked_by" },
105
+ ],
106
+ };
107
+ }
108
+ return t;
109
+ });
110
+ try {
111
+ topologicalSort(tempTasks);
112
+ return false;
113
+ }
114
+ catch {
115
+ return true;
116
+ }
117
+ }
118
+ /**
119
+ * Find all tasks that depend on a given task (directly or transitively)
120
+ */
121
+ export function findDependents(tasks, taskId) {
122
+ const taskMap = new Map(tasks.map((t) => [t.id, t]));
123
+ const visited = new Set();
124
+ const result = [];
125
+ function dfs(id) {
126
+ for (const task of tasks) {
127
+ const deps = (task.dependencies ?? [])
128
+ .filter((d) => d.type === "blocked_by")
129
+ .map((d) => d.taskId);
130
+ if (deps.includes(id) && !visited.has(task.id)) {
131
+ visited.add(task.id);
132
+ result.push(task);
133
+ dfs(task.id);
134
+ }
135
+ }
136
+ }
137
+ dfs(taskId);
138
+ return result;
139
+ }
140
+ /**
141
+ * Find all tasks that a given task depends on (directly or transitively)
142
+ */
143
+ export function findDependencies(tasks, taskId) {
144
+ const taskMap = new Map(tasks.map((t) => [t.id, t]));
145
+ const visited = new Set();
146
+ const result = [];
147
+ function dfs(id) {
148
+ const task = taskMap.get(id);
149
+ if (!task)
150
+ return;
151
+ const deps = (task.dependencies ?? [])
152
+ .filter((d) => d.type === "blocked_by")
153
+ .map((d) => d.taskId);
154
+ for (const depId of deps) {
155
+ if (!visited.has(depId)) {
156
+ visited.add(depId);
157
+ const depTask = taskMap.get(depId);
158
+ if (depTask) {
159
+ result.push(depTask);
160
+ dfs(depId);
161
+ }
162
+ }
163
+ }
164
+ }
165
+ dfs(taskId);
166
+ return result;
167
+ }
168
+ //# sourceMappingURL=topological-sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topological-sort.js","sourceRoot":"","sources":["../../src/algorithms/topological-sort.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,GAAG,GAA2B;QAClC,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,GAAG,EAAE,CAAC;KACP,CAAC;IACF,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;aACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACvB,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CA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AAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,MAAM,GAAW,EAAE,CAAC;IAE1B,SAAS,GAAG,CAAC,EAAU;QACrB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;aACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAExB,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnC,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrB,GAAG,CAAC,KAAK,CAAC,CAAC;gBACb,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,CAAC;IACZ,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=topological-sort.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topological-sort.test.d.ts","sourceRoot":"","sources":["../../src/algorithms/topological-sort.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,162 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { priorityToNumber, topologicalSort, wouldCreateCycle, findDependents, findDependencies, } from "./topological-sort.js";
3
+ // Helper to create mock tasks
4
+ function createTask(id, priority = "medium", deps = []) {
5
+ return {
6
+ id,
7
+ title: `Task ${id}`,
8
+ status: "pending",
9
+ priority: priority,
10
+ projectId: "test-project",
11
+ createdAt: new Date().toISOString(),
12
+ updatedAt: new Date().toISOString(),
13
+ dependencies: deps.map((depId) => ({ taskId: depId, type: "blocked_by" })),
14
+ };
15
+ }
16
+ describe("priorityToNumber", () => {
17
+ test("converts critical to 4", () => {
18
+ expect(priorityToNumber("critical")).toBe(4);
19
+ });
20
+ test("converts high to 3", () => {
21
+ expect(priorityToNumber("high")).toBe(3);
22
+ });
23
+ test("converts medium to 2", () => {
24
+ expect(priorityToNumber("medium")).toBe(2);
25
+ });
26
+ test("converts low to 1", () => {
27
+ expect(priorityToNumber("low")).toBe(1);
28
+ });
29
+ test("defaults to 2 for unknown priority", () => {
30
+ expect(priorityToNumber("unknown")).toBe(2);
31
+ });
32
+ });
33
+ describe("topologicalSort", () => {
34
+ test("returns empty array for empty input", () => {
35
+ const result = topologicalSort([]);
36
+ expect(result).toEqual([]);
37
+ });
38
+ test("returns single task unchanged", () => {
39
+ const tasks = [createTask("A")];
40
+ const result = topologicalSort(tasks);
41
+ expect(result.length).toBe(1);
42
+ expect(result[0].id).toBe("A");
43
+ });
44
+ test("sorts by dependency order", () => {
45
+ // B depends on A, so A should come first
46
+ const tasks = [createTask("B", "high", ["A"]), createTask("A", "low")];
47
+ const result = topologicalSort(tasks);
48
+ expect(result[0].id).toBe("A");
49
+ expect(result[1].id).toBe("B");
50
+ });
51
+ test("respects priority when no dependencies", () => {
52
+ const tasks = [
53
+ createTask("A", "low"),
54
+ createTask("B", "critical"),
55
+ createTask("C", "high"),
56
+ ];
57
+ const result = topologicalSort(tasks);
58
+ expect(result[0].id).toBe("B"); // critical first
59
+ expect(result[1].id).toBe("C"); // then high
60
+ expect(result[2].id).toBe("A"); // then low
61
+ });
62
+ test("handles chain of dependencies", () => {
63
+ // C -> B -> A (C depends on B, B depends on A)
64
+ const tasks = [
65
+ createTask("C", "critical", ["B"]),
66
+ createTask("B", "high", ["A"]),
67
+ createTask("A", "low"),
68
+ ];
69
+ const result = topologicalSort(tasks);
70
+ expect(result.map((t) => t.id)).toEqual(["A", "B", "C"]);
71
+ });
72
+ test("throws on circular dependency", () => {
73
+ // A -> B -> A
74
+ const tasks = [createTask("A", "medium", ["B"]), createTask("B", "medium", ["A"])];
75
+ expect(() => topologicalSort(tasks)).toThrow(/Circular dependency/);
76
+ });
77
+ test("handles diamond dependency", () => {
78
+ // D depends on B and C, both depend on A
79
+ const tasks = [
80
+ createTask("D", "medium", ["B", "C"]),
81
+ createTask("B", "high", ["A"]),
82
+ createTask("C", "low", ["A"]),
83
+ createTask("A", "medium"),
84
+ ];
85
+ const result = topologicalSort(tasks);
86
+ // A must come first, D must come last
87
+ expect(result[0].id).toBe("A");
88
+ expect(result[3].id).toBe("D");
89
+ });
90
+ });
91
+ describe("wouldCreateCycle", () => {
92
+ test("returns false for valid dependency", () => {
93
+ const tasks = [createTask("A"), createTask("B")];
94
+ // Adding B blocked_by A should not create cycle
95
+ expect(wouldCreateCycle(tasks, "B", "A")).toBe(false);
96
+ });
97
+ test("returns true for direct cycle", () => {
98
+ const tasks = [createTask("A", "medium", ["B"]), createTask("B")];
99
+ // B is already blocking A, so A blocking B would create cycle
100
+ expect(wouldCreateCycle(tasks, "B", "A")).toBe(true);
101
+ });
102
+ test("returns true for indirect cycle", () => {
103
+ const tasks = [
104
+ createTask("A", "medium", ["B"]),
105
+ createTask("B", "medium", ["C"]),
106
+ createTask("C"),
107
+ ];
108
+ // A <- B <- C, adding C <- A would create cycle
109
+ expect(wouldCreateCycle(tasks, "C", "A")).toBe(true);
110
+ });
111
+ });
112
+ describe("findDependents", () => {
113
+ test("returns empty for task with no dependents", () => {
114
+ const tasks = [createTask("A"), createTask("B")];
115
+ const result = findDependents(tasks, "A");
116
+ expect(result).toEqual([]);
117
+ });
118
+ test("finds direct dependents", () => {
119
+ const tasks = [
120
+ createTask("A"),
121
+ createTask("B", "medium", ["A"]),
122
+ createTask("C", "medium", ["A"]),
123
+ ];
124
+ const result = findDependents(tasks, "A");
125
+ expect(result.map((t) => t.id).sort()).toEqual(["B", "C"]);
126
+ });
127
+ test("finds transitive dependents", () => {
128
+ const tasks = [
129
+ createTask("A"),
130
+ createTask("B", "medium", ["A"]),
131
+ createTask("C", "medium", ["B"]),
132
+ ];
133
+ const result = findDependents(tasks, "A");
134
+ expect(result.map((t) => t.id).sort()).toEqual(["B", "C"]);
135
+ });
136
+ });
137
+ describe("findDependencies", () => {
138
+ test("returns empty for task with no dependencies", () => {
139
+ const tasks = [createTask("A"), createTask("B")];
140
+ const result = findDependencies(tasks, "A");
141
+ expect(result).toEqual([]);
142
+ });
143
+ test("finds direct dependencies", () => {
144
+ const tasks = [
145
+ createTask("A"),
146
+ createTask("B"),
147
+ createTask("C", "medium", ["A", "B"]),
148
+ ];
149
+ const result = findDependencies(tasks, "C");
150
+ expect(result.map((t) => t.id).sort()).toEqual(["A", "B"]);
151
+ });
152
+ test("finds transitive dependencies", () => {
153
+ const tasks = [
154
+ createTask("A"),
155
+ createTask("B", "medium", ["A"]),
156
+ createTask("C", "medium", ["B"]),
157
+ ];
158
+ const result = findDependencies(tasks, "C");
159
+ expect(result.map((t) => t.id).sort()).toEqual(["A", "B"]);
160
+ });
161
+ });
162
+ //# sourceMappingURL=topological-sort.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topological-sort.test.js","sourceRoot":"","sources":["../../src/algorithms/topological-sort.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAG/B,8BAA8B;AAC9B,SA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IAEH,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACrC,MAAM,KAAK,GAAG;YACZ,UAAU,CAAC,GAAG,CAAC;YACf,UAAU,CAAC,GAAG,CAAC;YACf,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACtC,CAAC;QACF,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GAAG;YACZ,UAAU,CAAC,GAAG,CAAC;YACf,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;YAChC,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;SACjC,CAAC;QACF,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./schemas/index.js";
2
+ export * from "./algorithms/index.js";
3
+ export * from "./utils/index.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // Schemas
2
+ export * from "./schemas/index.js";
3
+ // Algorithms
4
+ export * from "./algorithms/index.js";
5
+ // Utilities
6
+ export * from "./utils/index.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,oBAAoB,CAAC;AAEnC,aAAa;AACb,cAAc,uBAAuB,CAAC;AAEtC,YAAY;AACZ,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Priority, TaskStatus, DependencyType, Dependency, TimeEstimate, Recurrence, Task, TaskCreateInput, TaskUpdateInput, } from "./task.js";
2
+ export { ProjectStatus, Context, Project, ProjectCreateInput, ProjectUpdateInput, } from "./project.js";
3
+ export { SmartViewFilter, SortField, SortOrder, SmartView, BuiltInView, } from "./view.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Task schemas
2
+ export { Priority, TaskStatus, DependencyType, Dependency, TimeEstimate, Recurrence, Task, TaskCreateInput, TaskUpdateInput, } from "./task.js";
3
+ // Project schemas
4
+ export { ProjectStatus, Context, Project, ProjectCreateInput, ProjectUpdateInput, } from "./project.js";
5
+ // View schemas
6
+ export { SmartViewFilter, SortField, SortOrder, SmartView, BuiltInView, } from "./view.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,kBAAkB;AAClB,OAAO,EACL,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,eAAe;AACf,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC"}
@@ -0,0 +1,55 @@
1
+ export declare const ProjectStatus: import("arktype/internal/methods/string.ts").StringType<"completed" | "active" | "on_hold" | "archived", {}>;
2
+ export type ProjectStatus = typeof ProjectStatus.infer;
3
+ export declare const Context: import("arktype/internal/methods/object.ts").ObjectType<{
4
+ name: string;
5
+ color?: string;
6
+ description?: string;
7
+ }, {}>;
8
+ export type Context = typeof Context.infer;
9
+ export declare const Project: import("arktype/internal/methods/object.ts").ObjectType<{
10
+ id: string;
11
+ name: string;
12
+ status: "completed" | "active" | "on_hold" | "archived";
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ description?: string;
16
+ defaultPriority?: "critical" | "high" | "medium" | "low";
17
+ contexts?: {
18
+ name: string;
19
+ color?: string;
20
+ description?: string;
21
+ }[];
22
+ targetDate?: string;
23
+ completionPercentage?: number;
24
+ criticalPathLength?: number;
25
+ blockedTaskCount?: number;
26
+ totalTasks?: number;
27
+ completedTasks?: number;
28
+ }, {}>;
29
+ export type Project = typeof Project.infer;
30
+ export declare const ProjectCreateInput: import("arktype/internal/methods/object.ts").ObjectType<{
31
+ name: string;
32
+ description?: string;
33
+ defaultPriority?: "critical" | "high" | "medium" | "low";
34
+ contexts?: {
35
+ name: string;
36
+ color?: string;
37
+ description?: string;
38
+ }[];
39
+ targetDate?: string;
40
+ }, {}>;
41
+ export type ProjectCreateInput = typeof ProjectCreateInput.infer;
42
+ export declare const ProjectUpdateInput: import("arktype/internal/methods/object.ts").ObjectType<{
43
+ name?: string;
44
+ description?: string;
45
+ status?: "completed" | "active" | "on_hold" | "archived";
46
+ defaultPriority?: "critical" | "high" | "medium" | "low";
47
+ contexts?: {
48
+ name: string;
49
+ color?: string;
50
+ description?: string;
51
+ }[];
52
+ targetDate?: string;
53
+ }, {}>;
54
+ export type ProjectUpdateInput = typeof ProjectUpdateInput.infer;
55
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/schemas/project.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,8GAEzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,KAAK,CAAC;AAGvD,eAAO,MAAM,OAAO;;;;MAIlB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,KAAK,CAAC;AAG3C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;MAqBlB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,KAAK,CAAC;AAG3C,eAAO,MAAM,kBAAkB;;;;;;;;;;MAM7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,KAAK,CAAC;AAGjE,eAAO,MAAM,kBAAkB;;;;;;;;;;;MAO7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,KAAK,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { type } from "arktype";
2
+ import { Priority } from "./task.js";
3
+ // Project status
4
+ export const ProjectStatus = type("'active' | 'on_hold' | 'completed' | 'archived'");
5
+ // Context definition
6
+ export const Context = type({
7
+ name: "string",
8
+ "color?": "string", // hex color
9
+ "description?": "string",
10
+ });
11
+ // Project schema
12
+ export const Project = type({
13
+ id: "string",
14
+ name: "string",
15
+ "description?": "string",
16
+ status: ProjectStatus,
17
+ // Project-level settings
18
+ "defaultPriority?": Priority,
19
+ "contexts?": Context.array(),
20
+ // Metadata
21
+ createdAt: "string",
22
+ updatedAt: "string",
23
+ "targetDate?": "string",
24
+ // Computed stats
25
+ "completionPercentage?": "number",
26
+ "criticalPathLength?": "number", // Total minutes on critical path
27
+ "blockedTaskCount?": "number",
28
+ "totalTasks?": "number",
29
+ "completedTasks?": "number",
30
+ });
31
+ // Project creation input
32
+ export const ProjectCreateInput = type({
33
+ name: "string",
34
+ "description?": "string",
35
+ "defaultPriority?": Priority,
36
+ "contexts?": Context.array(),
37
+ "targetDate?": "string",
38
+ });
39
+ // Project update input
40
+ export const ProjectUpdateInput = type({
41
+ "name?": "string",
42
+ "description?": "string",
43
+ "status?": ProjectStatus,
44
+ "defaultPriority?": Priority,
45
+ "contexts?": Context.array(),
46
+ "targetDate?": "string",
47
+ });
48
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/schemas/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,iBAAiB;AACjB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAC/B,iDAAiD,CAClD,CAAC;AAGF,qBAAqB;AACrB,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,QAAQ,EAAE,YAAY;IAChC,cAAc,EAAE,QAAQ;CACzB,CAAC,CAAC;AAGH,iBAAiB;AACjB,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,cAAc,EAAE,QAAQ;IACxB,MAAM,EAAE,aAAa;IAErB,yBAAyB;IACzB,kBAAkB,EAAE,QAAQ;IAC5B,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;IAE5B,WAAW;IACX,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ;IACnB,aAAa,EAAE,QAAQ;IAEvB,iBAAiB;IACjB,uBAAuB,EAAE,QAAQ;IACjC,qBAAqB,EAAE,QAAQ,EAAE,iCAAiC;IAClE,mBAAmB,EAAE,QAAQ;IAC7B,aAAa,EAAE,QAAQ;IACvB,iBAAiB,EAAE,QAAQ;CAC5B,CAAC,CAAC;AAGH,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;IACrC,IAAI,EAAE,QAAQ;IACd,cAAc,EAAE,QAAQ;IACxB,kBAAkB,EAAE,QAAQ;IAC5B,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;IAC5B,aAAa,EAAE,QAAQ;CACxB,CAAC,CAAC;AAGH,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;IACrC,OAAO,EAAE,QAAQ;IACjB,cAAc,EAAE,QAAQ;IACxB,SAAS,EAAE,aAAa;IACxB,kBAAkB,EAAE,QAAQ;IAC5B,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;IAC5B,aAAa,EAAE,QAAQ;CACxB,CAAC,CAAC"}
@@ -0,0 +1,124 @@
1
+ export declare const Priority: import("arktype/internal/methods/string.ts").StringType<"critical" | "high" | "medium" | "low", {}>;
2
+ export type Priority = typeof Priority.infer;
3
+ export declare const TaskStatus: import("arktype/internal/methods/string.ts").StringType<"pending" | "in_progress" | "blocked" | "completed" | "cancelled", {}>;
4
+ export type TaskStatus = typeof TaskStatus.infer;
5
+ export declare const DependencyType: import("arktype/internal/methods/string.ts").StringType<"blocks" | "blocked_by" | "related", {}>;
6
+ export type DependencyType = typeof DependencyType.infer;
7
+ export declare const Dependency: import("arktype/internal/methods/object.ts").ObjectType<{
8
+ taskId: string;
9
+ type: "blocks" | "blocked_by" | "related";
10
+ reason?: string;
11
+ }, {}>;
12
+ export type Dependency = typeof Dependency.infer;
13
+ export declare const TimeEstimate: import("arktype/internal/methods/object.ts").ObjectType<{
14
+ optimistic?: number;
15
+ expected?: number;
16
+ pessimistic?: number;
17
+ confidence?: "high" | "medium" | "low";
18
+ }, {}>;
19
+ export type TimeEstimate = typeof TimeEstimate.infer;
20
+ export declare const Recurrence: import("arktype/internal/methods/object.ts").ObjectType<{
21
+ pattern: "daily" | "weekly" | "monthly" | "after_completion";
22
+ interval?: number;
23
+ daysOfWeek?: number[];
24
+ endDate?: string;
25
+ }, {}>;
26
+ export type Recurrence = typeof Recurrence.infer;
27
+ export declare const Task: import("arktype/internal/methods/object.ts").ObjectType<{
28
+ id: string;
29
+ title: string;
30
+ status: "pending" | "in_progress" | "blocked" | "completed" | "cancelled";
31
+ priority: "critical" | "high" | "medium" | "low";
32
+ projectId: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ description?: string;
36
+ dependencies?: {
37
+ taskId: string;
38
+ type: "blocks" | "blocked_by" | "related";
39
+ reason?: string;
40
+ }[];
41
+ estimate?: {
42
+ optimistic?: number;
43
+ expected?: number;
44
+ pessimistic?: number;
45
+ confidence?: "high" | "medium" | "low";
46
+ };
47
+ actualMinutes?: number;
48
+ dueDate?: string;
49
+ startDate?: string;
50
+ startedAt?: string;
51
+ completedAt?: string;
52
+ contexts?: string[];
53
+ tags?: string[];
54
+ recurrence?: {
55
+ pattern: "daily" | "weekly" | "monthly" | "after_completion";
56
+ interval?: number;
57
+ daysOfWeek?: number[];
58
+ endDate?: string;
59
+ };
60
+ criticalPath?: boolean;
61
+ slack?: number;
62
+ earliestStart?: number;
63
+ latestStart?: number;
64
+ }, {}>;
65
+ export type Task = typeof Task.infer;
66
+ export declare const TaskCreateInput: import("arktype/internal/methods/object.ts").ObjectType<{
67
+ title: string;
68
+ description?: string;
69
+ projectId?: string;
70
+ priority?: "critical" | "high" | "medium" | "low";
71
+ dependencies?: {
72
+ taskId: string;
73
+ type: "blocks" | "blocked_by" | "related";
74
+ reason?: string;
75
+ }[];
76
+ estimate?: {
77
+ optimistic?: number;
78
+ expected?: number;
79
+ pessimistic?: number;
80
+ confidence?: "high" | "medium" | "low";
81
+ };
82
+ dueDate?: string;
83
+ startDate?: string;
84
+ contexts?: string[];
85
+ tags?: string[];
86
+ recurrence?: {
87
+ pattern: "daily" | "weekly" | "monthly" | "after_completion";
88
+ interval?: number;
89
+ daysOfWeek?: number[];
90
+ endDate?: string;
91
+ };
92
+ }, {}>;
93
+ export type TaskCreateInput = typeof TaskCreateInput.infer;
94
+ export declare const TaskUpdateInput: import("arktype/internal/methods/object.ts").ObjectType<{
95
+ title?: string;
96
+ description?: string;
97
+ status?: "pending" | "in_progress" | "blocked" | "completed" | "cancelled";
98
+ priority?: "critical" | "high" | "medium" | "low";
99
+ projectId?: string;
100
+ dependencies?: {
101
+ taskId: string;
102
+ type: "blocks" | "blocked_by" | "related";
103
+ reason?: string;
104
+ }[];
105
+ estimate?: {
106
+ optimistic?: number;
107
+ expected?: number;
108
+ pessimistic?: number;
109
+ confidence?: "high" | "medium" | "low";
110
+ };
111
+ actualMinutes?: number;
112
+ dueDate?: string;
113
+ startDate?: string;
114
+ contexts?: string[];
115
+ tags?: string[];
116
+ recurrence?: {
117
+ pattern: "daily" | "weekly" | "monthly" | "after_completion";
118
+ interval?: number;
119
+ daysOfWeek?: number[];
120
+ endDate?: string;
121
+ };
122
+ }, {}>;
123
+ export type TaskUpdateInput = typeof TaskUpdateInput.infer;
124
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/schemas/task.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,qGAAiD,CAAC;AACvE,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,KAAK,CAAC;AAG7C,eAAO,MAAM,UAAU,gIAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAGjD,eAAO,MAAM,cAAc,kGAE1B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,KAAK,CAAC;AAGzD,eAAO,MAAM,UAAU;;;;MAIrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAGjD,eAAO,MAAM,YAAY;;;;;MAKvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,KAAK,CAAC;AAGrD,eAAO,MAAM,UAAU;;;;;MAKrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAGjD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmCf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,KAAK,CAAC;AAGrC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;MAY1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,KAAK,CAAC;AAG3D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAc1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,KAAK,CAAC"}