@askalf/deepdive 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/README.md +76 -0
- package/dist/agent.d.ts +5 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +31 -2
- package/dist/agent.js.map +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +226 -9
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -3
- package/dist/config.js.map +1 -1
- package/dist/domain-filter.d.ts +10 -0
- package/dist/domain-filter.d.ts.map +1 -0
- package/dist/domain-filter.js +71 -0
- package/dist/domain-filter.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/llm-format.d.ts +81 -0
- package/dist/llm-format.d.ts.map +1 -0
- package/dist/llm-format.js +129 -0
- package/dist/llm-format.js.map +1 -0
- package/dist/llm-stream.d.ts.map +1 -1
- package/dist/llm-stream.js +19 -9
- package/dist/llm-stream.js.map +1 -1
- package/dist/llm.d.ts +2 -0
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +11 -8
- package/dist/llm.js.map +1 -1
- package/dist/plan.d.ts +5 -1
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +14 -1
- package/dist/plan.js.map +1 -1
- package/dist/sessions.d.ts +44 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/sessions.js +165 -0
- package/dist/sessions.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,6 +116,8 @@ The critic reads its own draft, flags gaps ("the draft didn't source the 429 hea
|
|
|
116
116
|
|
|
117
117
|
Bare `--deep` = 2 extra rounds. `--deep=5` = up to 5. `--deep=0` is explicit single-pass.
|
|
118
118
|
|
|
119
|
+
In a TTY, every round's draft streams as it's written — round 0 lands under the question's H1; subsequent rounds are separated by a `---` divider and a `## Round N (deep)` header so you can read along as the agent iterates. The final round is whichever one the critic declared `done` on, or the round you set as the ceiling. The `--out` file gets only the final markdown answer; the streamed intermediate drafts are visible in the terminal but not persisted there.
|
|
120
|
+
|
|
119
121
|
**Why this is the whole point.** The critic loop is the axis hosted tools cap on. Per-query unit economics force them to ship a fixed depth — if they let you run a 5-round loop, some users would and their margins would collapse. On your own subscription, the only cap is the one you set on the command line.
|
|
120
122
|
|
|
121
123
|
---
|
|
@@ -128,6 +130,8 @@ For each sentence with a citation, the verifier tokenizes the claim into content
|
|
|
128
130
|
|
|
129
131
|
When something fails, deepdive prints a small `## Citation health` footer at the end of the answer and surfaces the offending sentences in `--verbose`. Clean runs stay clean: no footer, no noise. Use `--strict-cites` in scripts to fail the run with a non-zero exit code.
|
|
130
132
|
|
|
133
|
+
In `--deep` mode the verifier runs once per round, not just at the end: when intermediate rounds produce sentences with weak citations, those sentences are forwarded to the critic as top-priority gaps to fill in the next round of search. The critic and verifier close the loop — instead of "find more sources, hope they help," the next round explicitly hunts for authoritative support for the exact sentences that lack it.
|
|
134
|
+
|
|
131
135
|
What this is not: a semantic judge. Lexical recall flags hallucinated names, numbers, and dates with high precision, but a paraphrased-but-truthful sentence can score below threshold and a topic-aligned-but-incorrect sentence can score above. Treat the report as a sanity check and a reading guide, not a proof of correctness. To dial the strictness, raise `--cite-min-recall` above the default `0.4`; to disable entirely, pass `--no-verify-cites`.
|
|
132
136
|
|
|
133
137
|
---
|
|
@@ -174,6 +178,50 @@ The "$0 on Claude Max via dario" hint only appears when `--base-url` matches dar
|
|
|
174
178
|
|
|
175
179
|
---
|
|
176
180
|
|
|
181
|
+
## OpenAI-compatible endpoints
|
|
182
|
+
|
|
183
|
+
deepdive's wire format is Anthropic Messages by default — that's what dario speaks natively, and it's the format every Claude provider exposes. But the same pipeline works against any OpenAI Chat Completions endpoint via a built-in request/response adapter. Auto-detected from `--base-url`:
|
|
184
|
+
|
|
185
|
+
| URL pattern | Detected as |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `api.openai.com/...` | `openai` |
|
|
188
|
+
| `localhost:11434` (Ollama default) | `openai` |
|
|
189
|
+
| `localhost:8000` (vLLM convention) | `openai` |
|
|
190
|
+
| anything else | `anthropic` |
|
|
191
|
+
|
|
192
|
+
Override with `--api-format=anthropic|openai` or `DEEPDIVE_API_FORMAT`. The adapter translates request shape, headers (Bearer for OpenAI, `x-api-key` + `anthropic-version` for Anthropic), the streaming SSE event format (`choices[].delta.content` ↔ `content_block_delta`), and the `usage` field (`prompt_tokens` / `completion_tokens` ↔ `input_tokens` / `output_tokens`).
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Run against an Ollama-served local model:
|
|
196
|
+
deepdive "explain how X works" --base-url=http://localhost:11434 --model=llama3.1
|
|
197
|
+
|
|
198
|
+
# Run against OpenAI directly (auto-detected):
|
|
199
|
+
OPENAI_API_KEY=sk-... deepdive "..." \
|
|
200
|
+
--base-url=https://api.openai.com --api-key=$OPENAI_API_KEY --model=gpt-4o
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Cost telemetry still works for OpenAI-shape endpoints — you'll need to plug in the pricing yourself via `DEEPDIVE_PRICE_INPUT_PER_MTOK` / `DEEPDIVE_PRICE_OUTPUT_PER_MTOK` since the built-in price table only covers the Claude models.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Domain allow / deny lists
|
|
208
|
+
|
|
209
|
+
When the planner picks URLs, you sometimes want to force-pin to authoritative sources or drop noisy ones. Two flags, hostname-suffix matching:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Drop low-signal sources:
|
|
213
|
+
deepdive "what's the difference between X and Y" \
|
|
214
|
+
--deny-domain=pinterest.com,quora.com,reddit.com
|
|
215
|
+
|
|
216
|
+
# Pin to authoritative sources for a sensitive question:
|
|
217
|
+
deepdive "what does Anthropic's TOS say about Y" \
|
|
218
|
+
--allow-domain=anthropic.com,docs.anthropic.com
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Patterns match exactly OR as a strict subdomain (`github.com` matches `github.com` and `api.github.com`, but not `githubcompany.com`). Filtered URLs surface as `fetch.skipped` events with reason `domain-deny` or `domain-not-allowed` in `--verbose`. Both flags can be combined: a URL must pass the allow list AND not match the deny list. Env equivalents: `DEEPDIVE_ALLOW_DOMAIN`, `DEEPDIVE_DENY_DOMAIN`.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
177
225
|
## Common flags
|
|
178
226
|
|
|
179
227
|
Run `deepdive --help` for the full list. The ones you'll reach for:
|
|
@@ -191,6 +239,10 @@ Run `deepdive --help` for the full list. The ones you'll reach for:
|
|
|
191
239
|
| `--no-cost` | off | Suppress the end-of-run cost summary on stderr. |
|
|
192
240
|
| `--include=<paths>` | — | Comma-separated local files / dirs to ingest as sources (`.pdf`, `.md`, `.txt`, `.html`). |
|
|
193
241
|
| `--pdf-max-pages=<n>` | `50` | Per-PDF page cap. Larger PDFs are truncated. |
|
|
242
|
+
| `--allow-domain=<list>` | — | Comma-separated hostname suffixes — keep only matching URLs. |
|
|
243
|
+
| `--deny-domain=<list>` | — | Comma-separated hostname suffixes — drop matching URLs. |
|
|
244
|
+
| `--api-format=<anthropic\|openai>` | auto | Wire format for the LLM endpoint. Auto-detected from `--base-url`. |
|
|
245
|
+
| `--no-sessions` | off | Don't persist this run to `~/.deepdive/sessions/`. |
|
|
194
246
|
| `--json` | markdown | Emit `{question, plan, rounds, sources, answer, verification, cost, usage}` for piping. |
|
|
195
247
|
| `--out=<path>` | — | Save to file. |
|
|
196
248
|
| `--verbose`, `-v` | — | Stream plan / search / fetch / critique / verify events to stderr. |
|
|
@@ -263,6 +315,30 @@ Disable with `--no-cache` or `DEEPDIVE_NO_CACHE=1`. Change the dir with `DEEPDIV
|
|
|
263
315
|
|
|
264
316
|
---
|
|
265
317
|
|
|
318
|
+
## Sessions
|
|
319
|
+
|
|
320
|
+
Every successful run is saved to `~/.deepdive/sessions/<id>.json` — the full plan, round trace, kept sources (with their extracted content), the answer, the verification report, and the cost estimate. After each run deepdive prints the session id on stderr:
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
session 2026-05-07_134509_5959f102 (deepdive resume 2026-05-07_134509_5959f102)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Three subcommands operate on saved sessions:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
deepdive sessions ls # newest first; id, age, source/round counts, question
|
|
330
|
+
deepdive show <id> # re-print the original markdown answer
|
|
331
|
+
deepdive resume <id> [<new-question>] # re-synthesize against the saved sources
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
`resume` is the headline: it re-runs the synthesizer (one LLM call) against the existing source corpus, optionally with a new question or refinement. No re-search, no re-fetch, no critic loop. This closes the iteration loop that the page cache opens — the cache stops re-fetching pages, but `resume` stops re-running the entire pipeline. Refining "what does X say about Y" into "what does X say about Y in the post-2024 era" costs one synthesis instead of an entire deep run.
|
|
335
|
+
|
|
336
|
+
IDs are timestamp-prefixed (`YYYY-MM-DD_HHMMSS_<8-hex>`), so they sort chronologically and you can pass a unique prefix instead of typing the full id (`deepdive resume 2026-05-07_134509`).
|
|
337
|
+
|
|
338
|
+
Disable with `--no-sessions` or `DEEPDIVE_NO_SESSIONS=1`. Change the dir with `DEEPDIVE_SESSIONS_DIR`.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
266
342
|
## Library mode
|
|
267
343
|
|
|
268
344
|
```ts
|
package/dist/agent.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { LLMConfig } from "./llm.js";
|
|
|
2
2
|
import type { SearchAdapter } from "./search.js";
|
|
3
3
|
import { type Plan, type Critique } from "./plan.js";
|
|
4
4
|
import { type BrowserOptions, type FetchedPage } from "./browser.js";
|
|
5
|
-
import { type
|
|
5
|
+
import { type SourceWithContent } from "./synthesize.js";
|
|
6
6
|
import { type VerificationReport } from "./verify.js";
|
|
7
7
|
import { type CostEstimate } from "./pricing.js";
|
|
8
|
+
import { type DomainFilter } from "./domain-filter.js";
|
|
8
9
|
import type { PageCache } from "./cache.js";
|
|
9
10
|
import { type RobotsCache } from "./robots.js";
|
|
10
11
|
export interface BrowserLike {
|
|
@@ -30,6 +31,7 @@ export interface AgentConfig {
|
|
|
30
31
|
citeMinRecall?: number;
|
|
31
32
|
pdfMaxPages?: number;
|
|
32
33
|
include?: string[];
|
|
34
|
+
domainFilter?: DomainFilter;
|
|
33
35
|
env?: Record<string, string | undefined>;
|
|
34
36
|
onEvent?: (event: AgentEvent) => void;
|
|
35
37
|
onSynthesizeToken?: (chunk: string, round: number) => void;
|
|
@@ -65,7 +67,7 @@ export type AgentEvent = {
|
|
|
65
67
|
} | {
|
|
66
68
|
type: "fetch.skipped";
|
|
67
69
|
url: string;
|
|
68
|
-
reason: "robots" | "pdf-no-extractor";
|
|
70
|
+
reason: "robots" | "pdf-no-extractor" | "domain-deny" | "domain-not-allowed";
|
|
69
71
|
} | {
|
|
70
72
|
type: "include.done";
|
|
71
73
|
ingested: number;
|
|
@@ -105,7 +107,7 @@ export interface RoundTrace {
|
|
|
105
107
|
export interface AgentResult {
|
|
106
108
|
question: string;
|
|
107
109
|
plan: Plan;
|
|
108
|
-
sources:
|
|
110
|
+
sources: SourceWithContent[];
|
|
109
111
|
answer: string;
|
|
110
112
|
markdown: string;
|
|
111
113
|
rounds: RoundTrace[];
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAyB,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,E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MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IAKX,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,GAAG,EAAE;YACH,WAAW,EAAE,MAAM,CAAC;YACpB,YAAY,EAAE,MAAM,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;QACF,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAID,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,CAwRtB"}
|
package/dist/agent.js
CHANGED
|
@@ -17,6 +17,7 @@ import { verifyCitations as runVerify, DEFAULT_CITE_MIN_RECALL, } from "./verify
|
|
|
17
17
|
import { estimateCost } from "./pricing.js";
|
|
18
18
|
import { extractPdfText, PdfExtractorMissingError, looksLikePdf, } from "./pdf.js";
|
|
19
19
|
import { ingestLocalPaths } from "./local.js";
|
|
20
|
+
import { classifyUrl } from "./domain-filter.js";
|
|
20
21
|
import { runConcurrent } from "./concurrency.js";
|
|
21
22
|
import { canFetch, DEFAULT_USER_AGENT, } from "./robots.js";
|
|
22
23
|
export async function runAgent(question, config, signal) {
|
|
@@ -88,16 +89,29 @@ export async function runAgent(question, config, signal) {
|
|
|
88
89
|
emit(config, { type: "search.start", query });
|
|
89
90
|
const results = await config.search.search(query, config.resultsPerQuery, signal);
|
|
90
91
|
const fresh = dedupeByUrl(results).filter((r) => !seenUrls.has(r.url));
|
|
92
|
+
let kept = 0;
|
|
91
93
|
for (const r of fresh) {
|
|
92
94
|
seenUrls.add(r.url);
|
|
95
|
+
if (config.domainFilter) {
|
|
96
|
+
const verdict = classifyUrl(r.url, config.domainFilter);
|
|
97
|
+
if (verdict !== "allow") {
|
|
98
|
+
emit(config, {
|
|
99
|
+
type: "fetch.skipped",
|
|
100
|
+
url: r.url,
|
|
101
|
+
reason: verdict === "deny-listed" ? "domain-deny" : "domain-not-allowed",
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
93
106
|
allCandidates.push({
|
|
94
107
|
url: r.url,
|
|
95
108
|
title: r.title,
|
|
96
109
|
snippet: r.snippet,
|
|
97
110
|
query,
|
|
98
111
|
});
|
|
112
|
+
kept++;
|
|
99
113
|
}
|
|
100
|
-
emit(config, { type: "search.done", query, count:
|
|
114
|
+
emit(config, { type: "search.done", query, count: kept });
|
|
101
115
|
}
|
|
102
116
|
const candidatesFoundThisRound = allCandidates.length - candidatesBefore;
|
|
103
117
|
const headroom = Math.max(0, config.maxSources - keptSources.length);
|
|
@@ -178,8 +192,23 @@ export async function runAgent(question, config, signal) {
|
|
|
178
192
|
};
|
|
179
193
|
const isLastPossibleRound = round === maxRoundsTotal - 1;
|
|
180
194
|
if (!isLastPossibleRound && keptSources.length < config.maxSources) {
|
|
195
|
+
// Mid-loop citation verification — when enabled, surface weak
|
|
196
|
+
// cites to the critic so the next round's queries can target the
|
|
197
|
+
// exact sentences that lack authoritative support. The final
|
|
198
|
+
// verifier pass still runs after the loop exits and produces the
|
|
199
|
+
// user-facing report; this in-loop pass is purely advisory.
|
|
200
|
+
let weakCites = [];
|
|
201
|
+
if (config.verifyCitations !== false && answer) {
|
|
202
|
+
const inLoop = runVerify(answer, keptSources, {
|
|
203
|
+
threshold: config.citeMinRecall ?? DEFAULT_CITE_MIN_RECALL,
|
|
204
|
+
});
|
|
205
|
+
weakCites = inLoop.unsupported.map((c) => ({
|
|
206
|
+
sentence: c.sentence,
|
|
207
|
+
citedIds: c.citedIds,
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
181
210
|
emit(config, { type: "critique.start", round });
|
|
182
|
-
const crit = await critique(question, answer, allQueries, config.llm, signal, usageSinkFor("critique", round));
|
|
211
|
+
const crit = await critique(question, answer, allQueries, config.llm, signal, usageSinkFor("critique", round), weakCites);
|
|
183
212
|
emit(config, { type: "critique.done", round, critique: crit });
|
|
184
213
|
roundTrace.critique = crit;
|
|
185
214
|
rounds.push(roundTrace);
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,4EAA4E;AAC5E,uDAAuD;AACvD,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAI/E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAA4B,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAyC,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAe,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,eAAe,IAAI,SAAS,EAC5B,uBAAuB,GAExB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAA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AAM,EAAE,KAAK,EAAE,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,EAAE,YAAY;YAClB,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,MAAmB,EAAE,KAAiB;IAClD,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type CLIFlags } from "./config.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type VerificationReport } from "./verify.js";
|
|
4
4
|
import { type CostEstimate } from "./pricing.js";
|
|
5
5
|
interface ParsedArgs {
|
|
6
6
|
question?: string;
|
|
7
|
+
extras: string[];
|
|
7
8
|
outPath?: string;
|
|
8
9
|
flags: CLIFlags;
|
|
9
10
|
help: boolean;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAcA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAcA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM3D,OAAO,EAAgC,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAyFtB,UAAU,UAAU;IAIlB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAkKpD;AA8ED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,MAAM,CAIR;AAKD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GACrC,MAAM,CASR;AAKD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAIrD"}
|
package/dist/cli.js
CHANGED
|
@@ -15,15 +15,22 @@ import { resolveConfig } from "./config.js";
|
|
|
15
15
|
import { resolveSearchAdapter } from "./search.js";
|
|
16
16
|
import { runAgent } from "./agent.js";
|
|
17
17
|
import { createCache } from "./cache.js";
|
|
18
|
-
import { renderSourcesMarkdown } from "./citations.js";
|
|
19
|
-
import {
|
|
18
|
+
import { renderSourcesMarkdown, renderAnswerMarkdown } from "./citations.js";
|
|
19
|
+
import { synthesize } from "./synthesize.js";
|
|
20
|
+
import { verifyCitations as runVerify } from "./verify.js";
|
|
21
|
+
import { formatCostLine, looksLikeDario, estimateCost, } from "./pricing.js";
|
|
22
|
+
import { generateSessionId, saveSession, loadSession, listSessions, resolveSessionId, renderSessionsList, } from "./sessions.js";
|
|
20
23
|
import { runDoctor, renderDoctorText, renderDoctorJson, exitCodeFor, scrubPath, } from "./doctor.js";
|
|
21
24
|
const USAGE = `deepdive — local research agent
|
|
22
25
|
|
|
23
26
|
Usage:
|
|
24
|
-
deepdive "<question>" [flags]
|
|
25
|
-
deepdive doctor [flags]
|
|
26
|
-
deepdive
|
|
27
|
+
deepdive "<question>" [flags] Run the research agent
|
|
28
|
+
deepdive doctor [flags] Health check — paste the output when filing issues
|
|
29
|
+
deepdive sessions ls List saved sessions, newest first
|
|
30
|
+
deepdive show <id> Print a saved session's markdown answer
|
|
31
|
+
deepdive resume <id> [<question>] Re-synthesize against a saved session's
|
|
32
|
+
sources (cheap iteration; no re-fetching)
|
|
33
|
+
deepdive --help Show this help
|
|
27
34
|
|
|
28
35
|
Flags:
|
|
29
36
|
--base-url=<url> LLM endpoint. Default: http://localhost:3456 (dario)
|
|
@@ -54,12 +61,22 @@ Flags:
|
|
|
54
61
|
ingest as sources (.pdf, .md, .txt, .html).
|
|
55
62
|
PDFs require pdfjs-dist installed.
|
|
56
63
|
--pdf-max-pages=<n> Cap pages parsed per PDF. Default: 50
|
|
64
|
+
--allow-domain=<list> Comma-separated hostname suffixes to keep
|
|
65
|
+
exclusively (e.g. github.com,docs.anthropic.com).
|
|
66
|
+
--deny-domain=<list> Comma-separated hostname suffixes to drop
|
|
67
|
+
(e.g. pinterest.com,quora.com).
|
|
68
|
+
--api-format=<anthropic|openai>
|
|
69
|
+
Wire format for the LLM endpoint. Default:
|
|
70
|
+
auto-detected from --base-url (api.openai.com,
|
|
71
|
+
:11434 (Ollama), :8000 default to openai;
|
|
72
|
+
everything else to anthropic).
|
|
57
73
|
--json Emit a JSON result to stdout instead of markdown
|
|
58
74
|
--out=<path> Write the output (markdown or json) to a file too
|
|
59
75
|
--verbose, -v Stream progress events to stderr
|
|
60
76
|
--no-stream Buffer the final answer instead of streaming
|
|
61
|
-
tokens to stdout (auto-off for --json
|
|
62
|
-
|
|
77
|
+
tokens to stdout (auto-off for --json and
|
|
78
|
+
non-TTY stdout)
|
|
79
|
+
--no-sessions Do not persist this run to ~/.deepdive/sessions/
|
|
63
80
|
--help, -h Show this help
|
|
64
81
|
|
|
65
82
|
Environment:
|
|
@@ -71,12 +88,19 @@ Environment:
|
|
|
71
88
|
DEEPDIVE_LLM_TIMEOUT_MS, DEEPDIVE_LLM_ATTEMPTS,
|
|
72
89
|
DEEPDIVE_NO_VERIFY_CITES, DEEPDIVE_STRICT_CITES, DEEPDIVE_CITE_MIN_RECALL,
|
|
73
90
|
DEEPDIVE_NO_COST, DEEPDIVE_PRICE_INPUT_PER_MTOK, DEEPDIVE_PRICE_OUTPUT_PER_MTOK,
|
|
74
|
-
DEEPDIVE_INCLUDE, DEEPDIVE_PDF_MAX_PAGES
|
|
91
|
+
DEEPDIVE_INCLUDE, DEEPDIVE_PDF_MAX_PAGES,
|
|
92
|
+
DEEPDIVE_ALLOW_DOMAIN, DEEPDIVE_DENY_DOMAIN, DEEPDIVE_API_FORMAT,
|
|
93
|
+
DEEPDIVE_NO_SESSIONS, DEEPDIVE_SESSIONS_DIR
|
|
75
94
|
`;
|
|
95
|
+
// Verbs that accept additional positional arguments. Anything else
|
|
96
|
+
// triggers the "wrap your question in quotes" error when more than one
|
|
97
|
+
// positional shows up.
|
|
98
|
+
const SUBCOMMAND_VERBS = new Set(["doctor", "sessions", "show", "resume"]);
|
|
76
99
|
// Exported for unit tests.
|
|
77
100
|
export function parseArgs(argv) {
|
|
78
101
|
const flags = {};
|
|
79
102
|
let question;
|
|
103
|
+
const extras = [];
|
|
80
104
|
let outPath;
|
|
81
105
|
let help = false;
|
|
82
106
|
for (const a of argv) {
|
|
@@ -108,6 +132,10 @@ export function parseArgs(argv) {
|
|
|
108
132
|
flags.noCost = true;
|
|
109
133
|
continue;
|
|
110
134
|
}
|
|
135
|
+
if (a === "--no-sessions") {
|
|
136
|
+
flags.noSessions = true;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
111
139
|
if (a === "--json") {
|
|
112
140
|
flags.json = true;
|
|
113
141
|
continue;
|
|
@@ -179,6 +207,24 @@ export function parseArgs(argv) {
|
|
|
179
207
|
.map((s) => s.trim())
|
|
180
208
|
.filter((s) => s.length > 0);
|
|
181
209
|
break;
|
|
210
|
+
case "allow-domain":
|
|
211
|
+
flags.allowDomain = value
|
|
212
|
+
.split(",")
|
|
213
|
+
.map((s) => s.trim())
|
|
214
|
+
.filter((s) => s.length > 0);
|
|
215
|
+
break;
|
|
216
|
+
case "deny-domain":
|
|
217
|
+
flags.denyDomain = value
|
|
218
|
+
.split(",")
|
|
219
|
+
.map((s) => s.trim())
|
|
220
|
+
.filter((s) => s.length > 0);
|
|
221
|
+
break;
|
|
222
|
+
case "api-format":
|
|
223
|
+
if (value !== "anthropic" && value !== "openai") {
|
|
224
|
+
throw new Error(`--api-format must be 'anthropic' or 'openai' (got: ${value})`);
|
|
225
|
+
}
|
|
226
|
+
flags.apiFormat = value;
|
|
227
|
+
break;
|
|
182
228
|
case "out":
|
|
183
229
|
outPath = value;
|
|
184
230
|
break;
|
|
@@ -194,9 +240,17 @@ export function parseArgs(argv) {
|
|
|
194
240
|
question = a;
|
|
195
241
|
continue;
|
|
196
242
|
}
|
|
243
|
+
// Subcommand verbs (doctor / sessions / show / resume) take extra
|
|
244
|
+
// positional arguments — capture them. Everything else gets the
|
|
245
|
+
// "wrap the question in quotes" error so users don't accidentally
|
|
246
|
+
// run an unquoted multi-word question.
|
|
247
|
+
if (question !== undefined && SUBCOMMAND_VERBS.has(question)) {
|
|
248
|
+
extras.push(a);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
197
251
|
throw new Error(`unexpected positional argument: ${JSON.stringify(a)}. Wrap the question in quotes.`);
|
|
198
252
|
}
|
|
199
|
-
return { question, outPath, flags, help };
|
|
253
|
+
return { question, extras, outPath, flags, help };
|
|
200
254
|
}
|
|
201
255
|
function parsePositiveInt(s) {
|
|
202
256
|
if (!/^\d+$/.test(s))
|
|
@@ -325,6 +379,15 @@ async function main(argv) {
|
|
|
325
379
|
process.stdout.write(out);
|
|
326
380
|
return exitCodeFor(report);
|
|
327
381
|
}
|
|
382
|
+
if (parsed.question === "sessions") {
|
|
383
|
+
return await sessionsCommand(parsed);
|
|
384
|
+
}
|
|
385
|
+
if (parsed.question === "show") {
|
|
386
|
+
return await showCommand(parsed);
|
|
387
|
+
}
|
|
388
|
+
if (parsed.question === "resume") {
|
|
389
|
+
return await resumeCommand(parsed);
|
|
390
|
+
}
|
|
328
391
|
if (!parsed.question) {
|
|
329
392
|
process.stderr.write(`deepdive: missing question.\n\n${USAGE}`);
|
|
330
393
|
return 2;
|
|
@@ -364,10 +427,20 @@ async function main(argv) {
|
|
|
364
427
|
citeMinRecall: config.citeMinRecall,
|
|
365
428
|
pdfMaxPages: config.pdfMaxPages,
|
|
366
429
|
include: config.include,
|
|
430
|
+
domainFilter: config.domainFilter,
|
|
367
431
|
env: process.env,
|
|
368
432
|
onEvent: (e) => {
|
|
369
433
|
if (config.verbose)
|
|
370
434
|
process.stderr.write(renderEvent(e) + "\n");
|
|
435
|
+
// In --deep streaming mode, prefix each round-after-the-first
|
|
436
|
+
// synth with a separator + header so users can tell where one
|
|
437
|
+
// draft ends and the next begins. Round 0's header is the
|
|
438
|
+
// question (already printed above).
|
|
439
|
+
if (streaming &&
|
|
440
|
+
e.type === "synthesize.start" &&
|
|
441
|
+
e.round > 0) {
|
|
442
|
+
process.stdout.write(`\n\n---\n\n## Round ${e.round} (deep)\n\n`);
|
|
443
|
+
}
|
|
371
444
|
},
|
|
372
445
|
onSynthesizeToken: streaming
|
|
373
446
|
? (chunk) => {
|
|
@@ -379,6 +452,20 @@ async function main(argv) {
|
|
|
379
452
|
const citeFooter = renderCitationHealthFooter(result.verification);
|
|
380
453
|
const strictFail = config.strictCitations &&
|
|
381
454
|
(result.verification?.unsupported.length ?? 0) > 0;
|
|
455
|
+
// Persist the session before printing output. We do this even when
|
|
456
|
+
// --strict-cites is going to make us exit 1 — the run happened, the
|
|
457
|
+
// sources are real, and the user might want to inspect via `show`.
|
|
458
|
+
let sessionId;
|
|
459
|
+
if (config.sessions.enabled) {
|
|
460
|
+
try {
|
|
461
|
+
sessionId = await persistSession(parsed.question, result, config);
|
|
462
|
+
}
|
|
463
|
+
catch (err) {
|
|
464
|
+
// Persistence failure is non-fatal — surface a warning to stderr
|
|
465
|
+
// but don't break the run.
|
|
466
|
+
process.stderr.write(`deepdive: warning: failed to save session (${safeErrorMessage(err)})\n`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
382
469
|
// Cost summary lands on stderr regardless of stdout mode (suppressed by
|
|
383
470
|
// --no-cost / DEEPDIVE_NO_COST=1, and skipped for --json since the data
|
|
384
471
|
// is in the JSON envelope already).
|
|
@@ -400,6 +487,8 @@ async function main(argv) {
|
|
|
400
487
|
}
|
|
401
488
|
if (costLine)
|
|
402
489
|
process.stderr.write(costLine + "\n");
|
|
490
|
+
if (sessionId)
|
|
491
|
+
writeSessionHint(sessionId);
|
|
403
492
|
return strictFail ? 1 : 0;
|
|
404
493
|
}
|
|
405
494
|
const output = config.jsonOutput
|
|
@@ -429,6 +518,134 @@ async function main(argv) {
|
|
|
429
518
|
}
|
|
430
519
|
if (costLine)
|
|
431
520
|
process.stderr.write(costLine + "\n");
|
|
521
|
+
if (sessionId)
|
|
522
|
+
writeSessionHint(sessionId);
|
|
523
|
+
return strictFail ? 1 : 0;
|
|
524
|
+
}
|
|
525
|
+
catch (err) {
|
|
526
|
+
process.stderr.write(`deepdive: ${safeErrorMessage(err)}\n`);
|
|
527
|
+
return 1;
|
|
528
|
+
}
|
|
529
|
+
finally {
|
|
530
|
+
process.off("SIGINT", sigint);
|
|
531
|
+
process.off("SIGTERM", sigint);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
// Persist a finished agent run as a session record. Returns the new id.
|
|
535
|
+
async function persistSession(question, result, config) {
|
|
536
|
+
const id = generateSessionId();
|
|
537
|
+
const record = {
|
|
538
|
+
schema: 1,
|
|
539
|
+
id,
|
|
540
|
+
createdAt: Date.now(),
|
|
541
|
+
question,
|
|
542
|
+
plan: result.plan,
|
|
543
|
+
rounds: result.rounds,
|
|
544
|
+
sources: result.sources,
|
|
545
|
+
answer: result.answer,
|
|
546
|
+
verification: result.verification,
|
|
547
|
+
cost: result.cost,
|
|
548
|
+
llm: { baseUrl: config.llm.baseUrl, model: config.llm.model },
|
|
549
|
+
};
|
|
550
|
+
await saveSession(record, { dir: config.sessions.dir });
|
|
551
|
+
return id;
|
|
552
|
+
}
|
|
553
|
+
function writeSessionHint(id) {
|
|
554
|
+
process.stderr.write(`session ${id} (deepdive resume ${id})\n`);
|
|
555
|
+
}
|
|
556
|
+
async function sessionsCommand(parsed) {
|
|
557
|
+
const config = resolveConfig(parsed.flags, process.env);
|
|
558
|
+
const sub = parsed.extras[0] ?? "ls";
|
|
559
|
+
if (sub !== "ls") {
|
|
560
|
+
process.stderr.write(`deepdive: unknown sessions sub-command: ${sub}\n`);
|
|
561
|
+
return 2;
|
|
562
|
+
}
|
|
563
|
+
const { sessions, bad } = await listSessions({ dir: config.sessions.dir });
|
|
564
|
+
if (config.jsonOutput) {
|
|
565
|
+
process.stdout.write(JSON.stringify({ sessions, bad }, null, 2) + "\n");
|
|
566
|
+
return 0;
|
|
567
|
+
}
|
|
568
|
+
process.stdout.write(renderSessionsList(sessions) + "\n");
|
|
569
|
+
if (bad.length > 0) {
|
|
570
|
+
process.stderr.write(`\n(${bad.length} session file${bad.length === 1 ? "" : "s"} could not be parsed)\n`);
|
|
571
|
+
}
|
|
572
|
+
return 0;
|
|
573
|
+
}
|
|
574
|
+
async function showCommand(parsed) {
|
|
575
|
+
const config = resolveConfig(parsed.flags, process.env);
|
|
576
|
+
const idArg = parsed.extras[0];
|
|
577
|
+
if (!idArg) {
|
|
578
|
+
process.stderr.write(`deepdive: show requires a session id\n`);
|
|
579
|
+
return 2;
|
|
580
|
+
}
|
|
581
|
+
const id = await resolveSessionId(idArg, { dir: config.sessions.dir });
|
|
582
|
+
const record = await loadSession(id, { dir: config.sessions.dir });
|
|
583
|
+
// Re-render markdown from the stored answer + sources so it stays
|
|
584
|
+
// identical to what the original run printed.
|
|
585
|
+
const markdown = renderAnswerMarkdown(record.question, record.answer, record.sources);
|
|
586
|
+
process.stdout.write(markdown + (markdown.endsWith("\n") ? "" : "\n"));
|
|
587
|
+
return 0;
|
|
588
|
+
}
|
|
589
|
+
async function resumeCommand(parsed) {
|
|
590
|
+
const config = resolveConfig(parsed.flags, process.env);
|
|
591
|
+
const idArg = parsed.extras[0];
|
|
592
|
+
if (!idArg) {
|
|
593
|
+
process.stderr.write(`deepdive: resume requires a session id\n`);
|
|
594
|
+
return 2;
|
|
595
|
+
}
|
|
596
|
+
const id = await resolveSessionId(idArg, { dir: config.sessions.dir });
|
|
597
|
+
const record = await loadSession(id, { dir: config.sessions.dir });
|
|
598
|
+
const newQuestion = parsed.extras[1] ?? record.question;
|
|
599
|
+
// Re-synthesize against the existing source corpus. No search, no
|
|
600
|
+
// browser, no critic — this is the "I want to refine the question
|
|
601
|
+
// without re-spending tokens on retrieval" path.
|
|
602
|
+
const ac = new AbortController();
|
|
603
|
+
const sigint = () => ac.abort();
|
|
604
|
+
process.on("SIGINT", sigint);
|
|
605
|
+
process.on("SIGTERM", sigint);
|
|
606
|
+
let usage = { inputTokens: 0, outputTokens: 0, calls: 0 };
|
|
607
|
+
const onUsage = (u) => {
|
|
608
|
+
usage.inputTokens += u.input_tokens ?? 0;
|
|
609
|
+
usage.outputTokens += u.output_tokens ?? 0;
|
|
610
|
+
usage.calls += 1;
|
|
611
|
+
};
|
|
612
|
+
const streaming = config.streamEnabled &&
|
|
613
|
+
(process.stdout.isTTY || process.env.DEEPDIVE_FORCE_STREAM === "1");
|
|
614
|
+
let streamed = false;
|
|
615
|
+
try {
|
|
616
|
+
if (streaming) {
|
|
617
|
+
process.stdout.write(`# ${escapeHeader(newQuestion)}\n\n`);
|
|
618
|
+
}
|
|
619
|
+
const answer = await synthesize(newQuestion, record.sources, config.llm, ac.signal, streaming
|
|
620
|
+
? (chunk) => {
|
|
621
|
+
streamed = true;
|
|
622
|
+
process.stdout.write(chunk);
|
|
623
|
+
}
|
|
624
|
+
: undefined, onUsage);
|
|
625
|
+
// Cite verification (final only — no in-loop because there's no loop)
|
|
626
|
+
let verification;
|
|
627
|
+
if (config.verifyCitations !== false && answer) {
|
|
628
|
+
verification = runVerify(answer, record.sources, {
|
|
629
|
+
threshold: config.citeMinRecall,
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
const citeFooter = renderCitationHealthFooter(verification);
|
|
633
|
+
const strictFail = config.strictCitations && (verification?.unsupported.length ?? 0) > 0;
|
|
634
|
+
if (streaming && streamed) {
|
|
635
|
+
const tail = "\n\n" + renderSourcesMarkdown(record.sources) + citeFooter;
|
|
636
|
+
process.stdout.write(tail);
|
|
637
|
+
if (!tail.endsWith("\n"))
|
|
638
|
+
process.stdout.write("\n");
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
const md = renderAnswerMarkdown(newQuestion, answer, record.sources);
|
|
642
|
+
process.stdout.write(md + (md.endsWith("\n") ? "" : "\n") + citeFooter);
|
|
643
|
+
}
|
|
644
|
+
if (config.costEnabled && !config.jsonOutput) {
|
|
645
|
+
const cost = estimateCost(usage, config.llm.model, process.env);
|
|
646
|
+
process.stderr.write(renderCostSummary(cost, config.llm.model, config.llm.baseUrl) + "\n");
|
|
647
|
+
}
|
|
648
|
+
process.stderr.write(`session resumed from ${id}\n`);
|
|
432
649
|
return strictFail ? 1 : 0;
|
|
433
650
|
}
|
|
434
651
|
catch (err) {
|