@jwilger/pi-development-system 0.37.0 → 0.38.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 +23 -6
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type { Phase } from "../core/types.ts";
|
|
3
|
+
import { exitCodeOf, summarizeOutput } from "../core/test-runner.ts";
|
|
4
|
+
import type { DevsysState, Phase } from "../core/types.ts";
|
|
6
5
|
import type { Jev } from "../jev/client.ts";
|
|
7
6
|
import { judgeTurn, type ToolEvidence } from "../jev/questions/turn.ts";
|
|
8
7
|
import type { SessionState } from "../state/session-state.ts";
|
|
@@ -44,6 +43,14 @@ export function asksUser(text: string): boolean {
|
|
|
44
43
|
return last !== undefined && /\?(?:\s*\([^()]{0,40}\))?[\s)"'*_`]*$/.test(last);
|
|
45
44
|
}
|
|
46
45
|
|
|
46
|
+
/** True when a scope.expansion departure already covers the slice: the remedy the note asks for exists. */
|
|
47
|
+
const expansionRecorded = (state: DevsysState, slice: string): boolean =>
|
|
48
|
+
state.openDepartures.some(
|
|
49
|
+
(d) =>
|
|
50
|
+
d.gate === "scope.expansion" &&
|
|
51
|
+
(d.scope.kind === "session" || (d.scope.kind === "slice" && d.scope.slice === slice)),
|
|
52
|
+
);
|
|
53
|
+
|
|
47
54
|
const claimMessage = (): string =>
|
|
48
55
|
"Development system: your last message claims something was run, passed or done, but no tool evidence in this run shows it. Run the verification now, or restate without the claim.";
|
|
49
56
|
|
|
@@ -79,10 +86,18 @@ export function registerTurnVerifier(deps: TurnVerifierDeps): void {
|
|
|
79
86
|
});
|
|
80
87
|
deps.pi.on("tool_result", (event) => {
|
|
81
88
|
const text = event.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("\n");
|
|
82
|
-
const summary =
|
|
89
|
+
const summary = summarizeOutput(text);
|
|
90
|
+
const command = typeof event.input.command === "string" ? event.input.command : undefined;
|
|
91
|
+
// exitCodeOf sees through `npm test | tail`, which would otherwise show a failing run as exit 0.
|
|
92
|
+
const exitCode = exitCodeOf({
|
|
93
|
+
isError: event.isError,
|
|
94
|
+
text,
|
|
95
|
+
structured: event.structuredContent,
|
|
96
|
+
...(command === undefined ? {} : { command }),
|
|
97
|
+
});
|
|
83
98
|
const item: ToolEvidence =
|
|
84
99
|
event.toolName === "bash"
|
|
85
|
-
? { tool: "bash", summary, exitCode
|
|
100
|
+
? { tool: "bash", summary, exitCode }
|
|
86
101
|
: { tool: event.toolName, summary };
|
|
87
102
|
evidence = [...evidence, item].slice(-MAX_EVIDENCE);
|
|
88
103
|
});
|
|
@@ -109,7 +124,9 @@ export function registerTurnVerifier(deps: TurnVerifierDeps): void {
|
|
|
109
124
|
if (!judged.ok) return undefined;
|
|
110
125
|
const entries = [
|
|
111
126
|
...(judged.value.unverifiedClaim >= VERIFIER_THRESHOLD ? [note(claimMessage())] : []),
|
|
112
|
-
...(judged.value.driftFromSlice >= VERIFIER_THRESHOLD &&
|
|
127
|
+
...(judged.value.driftFromSlice >= VERIFIER_THRESHOLD &&
|
|
128
|
+
state.activeSlice !== undefined &&
|
|
129
|
+
!expansionRecorded(state, state.activeSlice)
|
|
113
130
|
? [note(driftMessage(state.activeSlice))]
|
|
114
131
|
: []),
|
|
115
132
|
];
|