@juanhuttemann/pi-deep-research 0.1.4 → 0.1.6
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/result.ts +40 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanhuttemann/pi-deep-research",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Fact-checked, cited web research inside Pi: runs the deep-research CLI (drsh) on Pi's own model, with live progress, clarifying questions and plan review",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/src/result.ts
CHANGED
|
@@ -16,8 +16,21 @@ export interface Blocked {
|
|
|
16
16
|
failed: string[];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
// Figure is a computation the program ran over the claims' values: its
|
|
20
|
+
// result when every input passed the fact-check, or why it did not.
|
|
21
|
+
export interface Figure {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
value?: string;
|
|
25
|
+
formula?: string;
|
|
26
|
+
reason?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
export interface Digest {
|
|
20
30
|
question: string;
|
|
31
|
+
// title is the report's headline, absent for a run with none (instant
|
|
32
|
+
// and older runs): the question titles it then.
|
|
33
|
+
title?: string;
|
|
21
34
|
depth: string;
|
|
22
35
|
confidence: string;
|
|
23
36
|
// instant is a run that answers in one call with no fact-check at all.
|
|
@@ -28,6 +41,7 @@ export interface Digest {
|
|
|
28
41
|
verdicts: Record<string, number>;
|
|
29
42
|
unconfirmed: Unconfirmed[];
|
|
30
43
|
blocked: Blocked[];
|
|
44
|
+
figures: Figure[];
|
|
31
45
|
gaps: string[];
|
|
32
46
|
sources: number;
|
|
33
47
|
cited: number;
|
|
@@ -36,11 +50,13 @@ export interface Digest {
|
|
|
36
50
|
|
|
37
51
|
interface RunJSON {
|
|
38
52
|
question?: string;
|
|
53
|
+
title?: string;
|
|
39
54
|
depth?: string;
|
|
40
55
|
confidence?: string;
|
|
41
56
|
error?: string;
|
|
42
57
|
analysis?: {
|
|
43
|
-
claims?: { id: string; claim: string; status?: string }[];
|
|
58
|
+
claims?: { id: string; claim: string; status?: string; note?: string; computed?: string }[];
|
|
59
|
+
computations?: { id: string; label?: string; result?: string; unit?: string; formula?: string; valid?: boolean; reason?: string }[];
|
|
44
60
|
recommendations?: Rec[];
|
|
45
61
|
conclusions?: Rec[];
|
|
46
62
|
gaps?: string[] | null;
|
|
@@ -75,6 +91,18 @@ export function digest(raw: unknown): Digest {
|
|
|
75
91
|
const unconfirmed = verdicts
|
|
76
92
|
.filter((v) => v.status !== "supported")
|
|
77
93
|
.map((v) => ({ id: v.id, claim: v.claim || claims.get(v.id) || "", status: v.status, reason: v.reason }));
|
|
94
|
+
// A computed claim has no verdict: the program decided it against its
|
|
95
|
+
// computation, and its status and note say how.
|
|
96
|
+
for (const c of j.analysis?.claims ?? []) {
|
|
97
|
+
if (c.computed && c.status && c.status !== "supported") {
|
|
98
|
+
unconfirmed.push({ id: c.id, claim: c.claim, status: c.status, reason: c.note });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const figures = (j.analysis?.computations ?? []).map((m) =>
|
|
102
|
+
m.valid
|
|
103
|
+
? { id: m.id, label: m.label ?? "", value: [m.result, m.unit].filter(Boolean).join(" "), formula: m.formula }
|
|
104
|
+
: { id: m.id, label: m.label ?? "", reason: m.reason || "not computed" },
|
|
105
|
+
);
|
|
78
106
|
const blocked: Blocked[] = [];
|
|
79
107
|
for (const [kind, list] of [
|
|
80
108
|
["recommendation", j.analysis?.recommendations],
|
|
@@ -87,6 +115,7 @@ export function digest(raw: unknown): Digest {
|
|
|
87
115
|
const citations = j.citations ?? [];
|
|
88
116
|
return {
|
|
89
117
|
question: j.question ?? "",
|
|
118
|
+
title: j.title || undefined,
|
|
90
119
|
depth: j.depth ?? "",
|
|
91
120
|
confidence: j.confidence ?? "",
|
|
92
121
|
instant: j.depth === "instant",
|
|
@@ -94,6 +123,7 @@ export function digest(raw: unknown): Digest {
|
|
|
94
123
|
verdicts: counts,
|
|
95
124
|
unconfirmed,
|
|
96
125
|
blocked,
|
|
126
|
+
figures,
|
|
97
127
|
gaps: j.analysis?.gaps ?? [],
|
|
98
128
|
sources: citations.length,
|
|
99
129
|
cited: citations.filter((c) => c.cited).length,
|
|
@@ -120,6 +150,7 @@ const rules = [
|
|
|
120
150
|
"Answer from this report and keep its citations.",
|
|
121
151
|
"Say the confidence it gives.",
|
|
122
152
|
"Say which claims the fact-check did not confirm, and do not present an unconfirmed claim or a blocked recommendation or conclusion as fact.",
|
|
153
|
+
"State a figure only as the report or a COMPUTED line gives it; do no arithmetic of your own.",
|
|
123
154
|
"Do not add facts the run did not establish; offer research_ask for a question its pages may answer, or a new run.",
|
|
124
155
|
"Give the user the artifact paths.",
|
|
125
156
|
];
|
|
@@ -143,6 +174,14 @@ function digestLines(d: Digest): string[] {
|
|
|
143
174
|
for (const b of d.blocked) {
|
|
144
175
|
out.push(`- BLOCKED ${b.kind}, not established${b.failed.length ? ` (failed: ${b.failed.join(", ")})` : ""}: ${b.text}`);
|
|
145
176
|
}
|
|
177
|
+
for (const f of d.figures) {
|
|
178
|
+
const name = f.label ? `${f.id} (${f.label})` : f.id;
|
|
179
|
+
out.push(
|
|
180
|
+
f.value
|
|
181
|
+
? `- COMPUTED by the program: ${name} = ${f.value}, from ${f.formula}`
|
|
182
|
+
: `- NOT COMPUTED, not established: ${name}: ${f.reason}`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
146
185
|
if (d.gaps.length) {
|
|
147
186
|
out.push(`Gaps the run could not close: ${d.gaps.join("; ")}`);
|
|
148
187
|
}
|