@jwilger/pi-development-system 0.38.1 → 0.39.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/package.json +1 -1
- package/src/context/turn-verifier.ts +15 -6
package/package.json
CHANGED
|
@@ -31,17 +31,26 @@ export function assistantParts(message: AgentMessage): Parts | undefined {
|
|
|
31
31
|
|
|
32
32
|
const LIST_ITEM = /^(?:\d+[.)]|[-*+])\s/;
|
|
33
33
|
|
|
34
|
+
const QUESTION_END = /\?(?:\s*\([^()]{0,40}\))?[\s)"'*_`]*$/;
|
|
35
|
+
/** A lead-in that introduces options ("Want me to:", "Which next:") before a bare list. */
|
|
36
|
+
const LEAD_IN = /:\s*$/;
|
|
37
|
+
|
|
34
38
|
/**
|
|
35
|
-
* True when the message ends by asking the user something: the last non-empty line
|
|
36
|
-
* option
|
|
39
|
+
* True when the message ends by asking the user something: the last non-empty line, or the last line
|
|
40
|
+
* before an option list, ends with a question mark (optionally followed by a short parenthetical
|
|
41
|
+
* like "(y/n)"), or a bare option list follows a colon lead-in.
|
|
37
42
|
*/
|
|
38
43
|
export function asksUser(text: string): boolean {
|
|
39
|
-
const
|
|
44
|
+
const lines = text
|
|
40
45
|
.split("\n")
|
|
41
46
|
.map((l) => l.trim())
|
|
42
|
-
.filter((l) => l !== ""
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
.filter((l) => l !== "");
|
|
48
|
+
const last = lines.at(-1);
|
|
49
|
+
if (last === undefined) return false;
|
|
50
|
+
if (QUESTION_END.test(last)) return true;
|
|
51
|
+
const lead = lines.filter((l) => !LIST_ITEM.test(l)).at(-1);
|
|
52
|
+
if (lead === undefined) return false;
|
|
53
|
+
return QUESTION_END.test(lead) || (LIST_ITEM.test(last) && LEAD_IN.test(lead));
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
/** True when a scope.expansion departure already covers the slice: the remedy the note asks for exists. */
|