@bumpyclock/pi-tasque 0.2.0 → 0.2.1

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.
@@ -0,0 +1,193 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { type Static, Type } from "typebox";
3
+ import { BULK_ITEM_ACTIONS } from "./bulk-contract.js";
4
+
5
+ export const TASK_TOOL_NAME = "task";
6
+
7
+ export const TASK_ACTIONS = [
8
+ "doctor",
9
+ "find",
10
+ "show",
11
+ "deps",
12
+ "notes",
13
+ "similar",
14
+ "create",
15
+ "note",
16
+ "finish",
17
+ "reopen",
18
+ "defer",
19
+ "start",
20
+ "claim",
21
+ "block",
22
+ "unblock",
23
+ "order",
24
+ "unorder",
25
+ "spec",
26
+ "mark_planned",
27
+ "bulk",
28
+ "create_tree",
29
+ "handoff_check",
30
+ "link",
31
+ "list_links",
32
+ "promote",
33
+ "import",
34
+ ] as const;
35
+
36
+ export const FIND_TARGETS = ["ready", "open"] as const;
37
+ export const VIEW_MODES = ["list", "tree"] as const;
38
+ export const SPEC_MODES = ["show", "check", "set", "update"] as const;
39
+ export const BRIDGE_DESTINATIONS = ["todo"] as const;
40
+
41
+ export type TaskAction = (typeof TASK_ACTIONS)[number];
42
+
43
+ const BulkItemParamsSchema = Type.Object({
44
+ action: StringEnum(BULK_ITEM_ACTIONS, {
45
+ description:
46
+ "Bulk item action: start, finish, reopen, defer, note, or mark_planned.",
47
+ }),
48
+ task: Type.String({ description: "Durable task id for this bulk item." }),
49
+ because: Type.Optional(
50
+ Type.String({
51
+ description:
52
+ "Note/reason text. Required for note; optional for finish/defer.",
53
+ }),
54
+ ),
55
+ });
56
+
57
+ const CreateTreeNodeParamsSchema = Type.Object({
58
+ title: Type.String({ description: "Durable task title for this node." }),
59
+ kind: Type.String({ description: "Durable task kind for this node." }),
60
+ priority: Type.Integer({
61
+ description: "Durable task priority for this node.",
62
+ }),
63
+ description: Type.Optional(
64
+ Type.String({ description: "Task description for this node." }),
65
+ ),
66
+ planned: Type.Optional(
67
+ Type.Boolean({ description: "Mark this node planned." }),
68
+ ),
69
+ needsPlan: Type.Optional(
70
+ Type.Boolean({ description: "Mark this node as needing planning." }),
71
+ ),
72
+ children: Type.Optional(
73
+ Type.Array(
74
+ Type.Unknown({
75
+ description:
76
+ "Child create-tree nodes with the same shape: { title, kind, priority, description?, planned?, needsPlan?, children? }.",
77
+ }),
78
+ { description: "Nested child task nodes." },
79
+ ),
80
+ ),
81
+ });
82
+
83
+ export const TaskParamsSchema = Type.Object(
84
+ {
85
+ action: StringEnum(TASK_ACTIONS, {
86
+ description: "Durable task action to run.",
87
+ }),
88
+ task: Type.Optional(
89
+ Type.String({
90
+ description: "Durable task id for existing tasks, or title for create.",
91
+ }),
92
+ ),
93
+ tasks: Type.Optional(
94
+ StringEnum(FIND_TARGETS, {
95
+ description: "Task set for find actions.",
96
+ }),
97
+ ),
98
+ view: Type.Optional(
99
+ StringEnum(VIEW_MODES, {
100
+ description: "Find output view.",
101
+ }),
102
+ ),
103
+ lane: Type.Optional(
104
+ Type.String({ description: "Ready-task lane, e.g. planning or coding." }),
105
+ ),
106
+ for: Type.Optional(
107
+ Type.String({ description: "Assignee or owner for claim/find/import." }),
108
+ ),
109
+ query: Type.Optional(
110
+ Type.String({ description: "Search text for similar task lookup." }),
111
+ ),
112
+ with: Type.Optional(
113
+ Type.Array(
114
+ Type.String({ description: "Extra context to include, e.g. spec." }),
115
+ ),
116
+ ),
117
+ kind: Type.Optional(Type.String({ description: "Durable task kind." })),
118
+ priority: Type.Optional(
119
+ Type.Integer({ description: "Durable task priority." }),
120
+ ),
121
+ description: Type.Optional(
122
+ Type.String({ description: "Task description for create/promote." }),
123
+ ),
124
+ under: Type.Optional(
125
+ Type.String({
126
+ description: "Parent durable task id for create/promote.",
127
+ }),
128
+ ),
129
+ planned: Type.Optional(
130
+ Type.Boolean({ description: "Mark created/promoted task planned." }),
131
+ ),
132
+ needsPlan: Type.Optional(
133
+ Type.Boolean({
134
+ description: "Mark created/promoted task as needing planning.",
135
+ }),
136
+ ),
137
+ because: Type.Optional(
138
+ Type.String({
139
+ description: "Note or reason text for lifecycle actions.",
140
+ }),
141
+ ),
142
+ by: Type.Optional(
143
+ Type.String({
144
+ description: "Blocking durable task id for block/unblock.",
145
+ }),
146
+ ),
147
+ after: Type.Optional(
148
+ Type.String({
149
+ description: "Earlier durable task id for order/unorder.",
150
+ }),
151
+ ),
152
+ start: Type.Optional(
153
+ Type.Boolean({
154
+ description: "Start task while claiming. Defaults true.",
155
+ }),
156
+ ),
157
+ requireSpec: Type.Optional(
158
+ Type.Boolean({ description: "Require an attached spec before claim." }),
159
+ ),
160
+ todo: Type.Optional(
161
+ Type.Union([
162
+ Type.Boolean({ description: "Create a linked todo for claim." }),
163
+ Type.Integer({ description: "Session todo id for link/promote." }),
164
+ ]),
165
+ ),
166
+ mode: Type.Optional(
167
+ StringEnum(SPEC_MODES, {
168
+ description: "Spec operation mode for spec action.",
169
+ }),
170
+ ),
171
+ text: Type.Optional(
172
+ Type.String({
173
+ description: "Spec text content for spec set/update.",
174
+ }),
175
+ ),
176
+ to: Type.Optional(
177
+ StringEnum(BRIDGE_DESTINATIONS, {
178
+ description: "Bridge destination for import.",
179
+ }),
180
+ ),
181
+ items: Type.Optional(
182
+ Type.Array(BulkItemParamsSchema, {
183
+ description:
184
+ "Bulk lifecycle items. Each item has { action, task, because? }.",
185
+ minItems: 1,
186
+ }),
187
+ ),
188
+ root: Type.Optional(CreateTreeNodeParamsSchema),
189
+ },
190
+ { additionalProperties: false },
191
+ );
192
+
193
+ export type TaskParams = Static<typeof TaskParamsSchema>;