@ftrdotdev/pi-tracker 0.7.0 → 0.9.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.
- package/CHANGELOG.md +369 -0
- package/README.md +88 -9
- package/package.json +27 -16
- package/src/compaction/candidate.test.ts +66 -125
- package/src/compaction/classifier.test.ts +22 -2
- package/src/compaction/classifier.ts +35 -22
- package/src/compaction/completion.test.ts +24 -16
- package/src/compaction/completion.ts +1 -1
- package/src/compaction/decision-record.test.ts +1 -1
- package/src/compaction/decision-record.ts +1 -1
- package/src/compaction/digest.test.ts +34 -34
- package/src/compaction/footprint.ts +2 -4
- package/src/compaction/settings.test.ts +5 -1
- package/src/compaction/settings.ts +1 -1
- package/src/compaction/settle.test.ts +50 -10
- package/src/compaction/settle.ts +5 -5
- package/src/core/deps.test.ts +128 -109
- package/src/core/deps.ts +3 -2
- package/src/core/domain.test.ts +99 -68
- package/src/core/domain.ts +16 -10
- package/src/core/persistence.test.ts +18 -19
- package/src/core/persistence.ts +4 -3
- package/src/core/store.test.ts +129 -167
- package/src/core/store.ts +77 -57
- package/src/harness-collection.test.ts +75 -0
- package/src/index.test.ts +59 -17
- package/src/index.ts +63 -64
- package/src/layers.test.ts +101 -0
- package/src/layers.ts +46 -0
- package/src/presentation/tool-metadata.test.ts +36 -38
- package/src/presentation/tool-metadata.ts +127 -130
- package/src/presentation/ui.test.ts +128 -67
- package/src/presentation/ui.ts +68 -20
- package/src/presentation/vim-settings.test.ts +101 -0
- package/src/presentation/vim-settings.ts +59 -0
|
@@ -3,9 +3,19 @@
|
|
|
3
3
|
* contract, and the prompt-facing strings. Everything here is free of runtime
|
|
4
4
|
* state; behavior (execute and rendering) lives in index.ts.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
arr,
|
|
8
|
+
bool,
|
|
9
|
+
lit,
|
|
10
|
+
num,
|
|
11
|
+
obj,
|
|
12
|
+
oneOf,
|
|
13
|
+
opt,
|
|
14
|
+
str,
|
|
15
|
+
union,
|
|
16
|
+
type Schema,
|
|
17
|
+
type Static,
|
|
18
|
+
} from "@earendil-works/pi-schema";
|
|
9
19
|
import { dependentsOf, formatItemRef, parseItemRef, unsatisfiedDeps } from "../core/deps.ts";
|
|
10
20
|
import type { TodoItem, TodoList, TrackerState } from "../core/domain.ts";
|
|
11
21
|
import type { EncodedState } from "../core/persistence.ts";
|
|
@@ -23,6 +33,15 @@ export const TOOL_ACTIONS = [
|
|
|
23
33
|
|
|
24
34
|
export type TrackerToolAction = (typeof TOOL_ACTIONS)[number];
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The action enum keeps an explicit `type: "string"`. Some providers reject an
|
|
38
|
+
* enum without a type, and TypeBox's `StringEnum` existed for that reason.
|
|
39
|
+
*/
|
|
40
|
+
const actionSchema: Schema<TrackerToolAction> = {
|
|
41
|
+
type: "string",
|
|
42
|
+
...oneOf(TOOL_ACTIONS, { description: "Tracker operation to perform" }),
|
|
43
|
+
};
|
|
44
|
+
|
|
26
45
|
export const TRACKER_TOOL_NAME = "tracker";
|
|
27
46
|
export const TRACKER_TOOL_LABEL = "Tracker";
|
|
28
47
|
|
|
@@ -30,96 +49,72 @@ export const TRACKER_TOOL_LABEL = "Tracker";
|
|
|
30
49
|
* How an item is declared when it is created: bare text, or an object that
|
|
31
50
|
* also carries the same-list items it must wait for.
|
|
32
51
|
*/
|
|
33
|
-
const depsSchema =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
52
|
+
const depsSchema = arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
53
|
+
description: "Same-list items that must be done before this one.",
|
|
54
|
+
});
|
|
37
55
|
|
|
38
56
|
/** The item-title cap. Enforced only at the tool input, never persisted. */
|
|
39
57
|
export const TITLE_LIMIT = 200;
|
|
40
58
|
|
|
41
|
-
const titleField =
|
|
59
|
+
const titleField = str({
|
|
42
60
|
description:
|
|
43
61
|
"Item title: one short action line (max 200 characters). Move longer detail into 'description'.",
|
|
44
62
|
});
|
|
45
63
|
|
|
46
|
-
const descriptionField =
|
|
64
|
+
const descriptionField = str({
|
|
47
65
|
description:
|
|
48
66
|
"Optional: the longer explanation of the item. Put the essential detail in the first paragraph.",
|
|
49
67
|
});
|
|
50
68
|
|
|
51
69
|
/** A declared reference: a path (optionally narrowed to a symbol or span) or a decision topic. */
|
|
52
|
-
const referenceSchema =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
kind: Type.Literal("decision"),
|
|
65
|
-
topic: Type.String({ description: "The decision the item depends on." }),
|
|
66
|
-
},
|
|
67
|
-
{ additionalProperties: false },
|
|
68
|
-
),
|
|
70
|
+
const referenceSchema = union([
|
|
71
|
+
obj({
|
|
72
|
+
kind: lit("path"),
|
|
73
|
+
path: str({ description: "The file path this item must read next." }),
|
|
74
|
+
symbol: opt(str({ description: "A symbol inside the path." })),
|
|
75
|
+
span: opt(str({ description: 'A line span, e.g. "12-14" or "12".' })),
|
|
76
|
+
}),
|
|
77
|
+
obj({
|
|
78
|
+
kind: lit("decision"),
|
|
79
|
+
topic: str({ description: "The decision the item depends on." }),
|
|
80
|
+
}),
|
|
69
81
|
]);
|
|
70
82
|
|
|
71
|
-
const refsSchema =
|
|
83
|
+
const refsSchema = arr(referenceSchema, {
|
|
72
84
|
description:
|
|
73
85
|
"Optional: the files, symbols, regions, or decisions this item must read after the completed item finishes.",
|
|
74
86
|
});
|
|
75
87
|
|
|
76
|
-
const producesSchema =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{ additionalProperties: false },
|
|
80
|
-
),
|
|
81
|
-
{ description: "Optional: every document this item will write." },
|
|
82
|
-
);
|
|
88
|
+
const producesSchema = arr(obj({ path: str({ description: "A document the item will write." }) }), {
|
|
89
|
+
description: "Optional: every document this item will write.",
|
|
90
|
+
});
|
|
83
91
|
|
|
84
92
|
/** One new item, as the strict item object both add paths accept. */
|
|
85
|
-
const ItemObjectSchema =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
// Item objects are strict: a typo inside one fails here.
|
|
94
|
-
{ additionalProperties: false },
|
|
95
|
-
);
|
|
93
|
+
const ItemObjectSchema = obj({
|
|
94
|
+
title: titleField,
|
|
95
|
+
description: opt(descriptionField),
|
|
96
|
+
refs: opt(refsSchema),
|
|
97
|
+
produces: opt(producesSchema),
|
|
98
|
+
deps: opt(depsSchema),
|
|
99
|
+
});
|
|
96
100
|
|
|
97
101
|
/** One `update_items` patch: the item id plus the fields to replace. */
|
|
98
|
-
const UpdatePatchSchema =
|
|
99
|
-
{
|
|
100
|
-
|
|
102
|
+
const UpdatePatchSchema = obj({
|
|
103
|
+
item_id: str({
|
|
104
|
+
description: 'The id of the item within list_id, as shown by the list action (e.g. "Work:2").',
|
|
105
|
+
}),
|
|
106
|
+
title: opt(str({ description: "Replacement title for the item." })),
|
|
107
|
+
description: opt(str({ description: "Replacement description for the item." })),
|
|
108
|
+
refs: opt(refsSchema),
|
|
109
|
+
produces: opt(producesSchema),
|
|
110
|
+
done: opt(bool({ description: "true marks the item done, false reopens it." })),
|
|
111
|
+
deps: opt(
|
|
112
|
+
arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
101
113
|
description:
|
|
102
|
-
|
|
114
|
+
"Replacement dependency set for this item. Pass [] to clear. Must not form a cycle.",
|
|
103
115
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Type.String({ description: "Replacement description for the item." }),
|
|
107
|
-
),
|
|
108
|
-
refs: Type.Optional(refsSchema),
|
|
109
|
-
produces: Type.Optional(producesSchema),
|
|
110
|
-
done: Type.Optional(
|
|
111
|
-
Type.Boolean({ description: "true marks the item done, false reopens it." }),
|
|
112
|
-
),
|
|
113
|
-
deps: Type.Optional(
|
|
114
|
-
Type.Array(Type.String({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
115
|
-
description:
|
|
116
|
-
"Replacement dependency set for this item. Pass [] to clear. Must not form a cycle.",
|
|
117
|
-
}),
|
|
118
|
-
),
|
|
119
|
-
},
|
|
120
|
-
// Patch objects are strict: a typo inside an item update fails here.
|
|
121
|
-
{ additionalProperties: false },
|
|
122
|
-
);
|
|
116
|
+
),
|
|
117
|
+
});
|
|
123
118
|
|
|
124
119
|
/** One item to add, as the tool accepts it. */
|
|
125
120
|
export type TrackerItemSpec = Static<typeof ItemObjectSchema>;
|
|
@@ -135,61 +130,63 @@ export type TrackerUpdatePatch = Static<typeof UpdatePatchSchema>;
|
|
|
135
130
|
* receives a precise, actionable error message instead of a generic schema
|
|
136
131
|
* rejection.
|
|
137
132
|
*/
|
|
138
|
-
export const TrackerToolParams =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
133
|
+
export const TrackerToolParams = obj(
|
|
134
|
+
{
|
|
135
|
+
action: actionSchema,
|
|
136
|
+
list_id: opt(
|
|
137
|
+
num({
|
|
138
|
+
description:
|
|
139
|
+
"List id, as shown by the list action. Required for delete_list, add_items, and for update_items' items={...} batch; optional for set_active (omit to deselect).",
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
item_id: opt(
|
|
143
|
+
str({
|
|
144
|
+
description:
|
|
145
|
+
'Item id, as shown by the list action: listName:id (e.g. "Work:2"). Ids are permanent: removing an item does not change the other ids. Required for update_items (scalar form) and remove_item.',
|
|
146
|
+
}),
|
|
147
|
+
),
|
|
148
|
+
name: opt(str({ description: "Name for the new list. Required for create_list." })),
|
|
149
|
+
initial_items: opt(
|
|
150
|
+
arr(ItemObjectSchema, {
|
|
151
|
+
description:
|
|
152
|
+
"For create_list: initial items, each {title, description?, refs?, produces?, deps?}, added when the list is created.",
|
|
153
|
+
minItems: 1,
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
activate: opt(
|
|
157
|
+
bool({
|
|
158
|
+
description:
|
|
159
|
+
"For create_list: switch the active list to the new list (defaults to true; pass false to keep the current active list).",
|
|
160
|
+
}),
|
|
161
|
+
),
|
|
162
|
+
title: opt(
|
|
163
|
+
str({
|
|
164
|
+
description: "For update_items: the replacement title for the item (max 200 characters).",
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
description: opt(descriptionField),
|
|
168
|
+
refs: opt(refsSchema),
|
|
169
|
+
produces: opt(producesSchema),
|
|
170
|
+
done: opt(
|
|
171
|
+
bool({ description: "For update_items: true marks the item done, false reopens it." }),
|
|
172
|
+
),
|
|
173
|
+
deps: opt(
|
|
174
|
+
arr(str({ description: 'A dependency as listName:id, e.g. "Work:1".' }), {
|
|
175
|
+
description:
|
|
176
|
+
"For update_items: the replacement dependency set (same-list items that must be done first). Pass [] to clear. Must not form a cycle.",
|
|
177
|
+
}),
|
|
178
|
+
),
|
|
179
|
+
items: opt(
|
|
180
|
+
arr(union([ItemObjectSchema, UpdatePatchSchema]), {
|
|
181
|
+
description:
|
|
182
|
+
"For add_items: the item objects to add, each {title, description?, refs?, produces?, deps?}. For update_items: the item patches, each with an item_id.",
|
|
183
|
+
minItems: 1,
|
|
184
|
+
}),
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
// Unknown top-level fields are tolerated and reported by `validateTrackerCall`.
|
|
188
|
+
{ open: true },
|
|
189
|
+
);
|
|
193
190
|
|
|
194
191
|
export type TrackerToolParams = Static<typeof TrackerToolParams>;
|
|
195
192
|
|
|
@@ -484,15 +481,15 @@ export function validateTrackerCall(args: unknown): TrackerCallValidation {
|
|
|
484
481
|
/** Structured result payload attached to tool calls, consumed by the renderers. */
|
|
485
482
|
export interface TrackerToolDetails {
|
|
486
483
|
action: TrackerToolAction;
|
|
487
|
-
error?: string;
|
|
488
|
-
listId?: number;
|
|
484
|
+
error?: string | undefined;
|
|
485
|
+
listId?: number | undefined;
|
|
489
486
|
/** `listName:id`, as shown by the list action. */
|
|
490
|
-
itemId?: string;
|
|
491
|
-
list?: TodoList;
|
|
487
|
+
itemId?: string | undefined;
|
|
488
|
+
list?: TodoList | undefined;
|
|
492
489
|
/** Items affected by an add_items/update_items call, in creation/patch order. */
|
|
493
|
-
items?: TodoItem[];
|
|
490
|
+
items?: TodoItem[] | undefined;
|
|
494
491
|
/** Full state snapshot, only for the `list` action (for rendering). */
|
|
495
|
-
snapshot?: EncodedState;
|
|
492
|
+
snapshot?: EncodedState | undefined;
|
|
496
493
|
}
|
|
497
494
|
|
|
498
495
|
/**
|
|
@@ -586,7 +583,7 @@ export const doneMarkReminder = (
|
|
|
586
583
|
patches: readonly { readonly done?: boolean }[],
|
|
587
584
|
openRemaining?: number,
|
|
588
585
|
): string | null => {
|
|
589
|
-
const doneCount = patches.filter((patch) => patch.done
|
|
586
|
+
const doneCount = patches.filter((patch) => patch.done ?? false).length;
|
|
590
587
|
// Only the terminal batch — two or more done marks with nothing left open —
|
|
591
588
|
// is flagged. Batches that finish several items while other work remains are
|
|
592
589
|
// normal mid-turn progress and stay quiet. When the post-call open count is
|