@juanhuttemann/pi-deep-research 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/result.ts +35 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juanhuttemann/pi-deep-research",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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,6 +16,16 @@ 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;
21
31
  depth: string;
@@ -28,6 +38,7 @@ export interface Digest {
28
38
  verdicts: Record<string, number>;
29
39
  unconfirmed: Unconfirmed[];
30
40
  blocked: Blocked[];
41
+ figures: Figure[];
31
42
  gaps: string[];
32
43
  sources: number;
33
44
  cited: number;
@@ -40,7 +51,8 @@ interface RunJSON {
40
51
  confidence?: string;
41
52
  error?: string;
42
53
  analysis?: {
43
- claims?: { id: string; claim: string; status?: string }[];
54
+ claims?: { id: string; claim: string; status?: string; note?: string; computed?: string }[];
55
+ computations?: { id: string; label?: string; result?: string; unit?: string; formula?: string; valid?: boolean; reason?: string }[];
44
56
  recommendations?: Rec[];
45
57
  conclusions?: Rec[];
46
58
  gaps?: string[] | null;
@@ -75,6 +87,18 @@ export function digest(raw: unknown): Digest {
75
87
  const unconfirmed = verdicts
76
88
  .filter((v) => v.status !== "supported")
77
89
  .map((v) => ({ id: v.id, claim: v.claim || claims.get(v.id) || "", status: v.status, reason: v.reason }));
90
+ // A computed claim has no verdict: the program decided it against its
91
+ // computation, and its status and note say how.
92
+ for (const c of j.analysis?.claims ?? []) {
93
+ if (c.computed && c.status && c.status !== "supported") {
94
+ unconfirmed.push({ id: c.id, claim: c.claim, status: c.status, reason: c.note });
95
+ }
96
+ }
97
+ const figures = (j.analysis?.computations ?? []).map((m) =>
98
+ m.valid
99
+ ? { id: m.id, label: m.label ?? "", value: [m.result, m.unit].filter(Boolean).join(" "), formula: m.formula }
100
+ : { id: m.id, label: m.label ?? "", reason: m.reason || "not computed" },
101
+ );
78
102
  const blocked: Blocked[] = [];
79
103
  for (const [kind, list] of [
80
104
  ["recommendation", j.analysis?.recommendations],
@@ -94,6 +118,7 @@ export function digest(raw: unknown): Digest {
94
118
  verdicts: counts,
95
119
  unconfirmed,
96
120
  blocked,
121
+ figures,
97
122
  gaps: j.analysis?.gaps ?? [],
98
123
  sources: citations.length,
99
124
  cited: citations.filter((c) => c.cited).length,
@@ -120,6 +145,7 @@ const rules = [
120
145
  "Answer from this report and keep its citations.",
121
146
  "Say the confidence it gives.",
122
147
  "Say which claims the fact-check did not confirm, and do not present an unconfirmed claim or a blocked recommendation or conclusion as fact.",
148
+ "State a figure only as the report or a COMPUTED line gives it; do no arithmetic of your own.",
123
149
  "Do not add facts the run did not establish; offer research_ask for a question its pages may answer, or a new run.",
124
150
  "Give the user the artifact paths.",
125
151
  ];
@@ -143,6 +169,14 @@ function digestLines(d: Digest): string[] {
143
169
  for (const b of d.blocked) {
144
170
  out.push(`- BLOCKED ${b.kind}, not established${b.failed.length ? ` (failed: ${b.failed.join(", ")})` : ""}: ${b.text}`);
145
171
  }
172
+ for (const f of d.figures) {
173
+ const name = f.label ? `${f.id} (${f.label})` : f.id;
174
+ out.push(
175
+ f.value
176
+ ? `- COMPUTED by the program: ${name} = ${f.value}, from ${f.formula}`
177
+ : `- NOT COMPUTED, not established: ${name}: ${f.reason}`,
178
+ );
179
+ }
146
180
  if (d.gaps.length) {
147
181
  out.push(`Gaps the run could not close: ${d.gaps.join("; ")}`);
148
182
  }