diff --git a/README.md b/README.md index 647414f..7b1bcb4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,18 @@ The application is written in TypeScript for Bun. It has no third-party runtime configuration, feed parsing, CLI handling, web serving, streaming, and tests all use repository code, Web APIs, or Bun and Node-compatible built-ins. +## See Distil in action + +Collect recent items, review every relevance decision, then generate a focused Markdown +digest. Include and Exclude choices remain reversible until generation starts. + +[](assets/screenshots/workflow.png) + +
+ ## Requirements - [Bun 1.4.3 or newer](https://bun.sh/docs/installation) @@ -139,9 +151,14 @@ Then enable its loopback endpoint: [decision] enabled = true base_url = "http://127.0.0.1:8000" - confidence_threshold = 0.9 + confidence_threshold = 0.85 timeout_seconds = 10 +The default threshold of `0.85` accepts common high-confidence decisions while leaving +less certain items for review. Raise it toward `1` for stricter manual oversight or lower +it cautiously to automate more decisions. Existing explicit configuration values are not +changed automatically. + Distil accepts a Strands include or exclude classification only when it meets the configured confidence threshold. The preview labels those results **Include** or **Exclude**, previously processed items **Seen**, and lower-confidence results **Review**. @@ -161,8 +178,9 @@ Preview selection without calling the generative LLM: bun run distil preview --days 7 The web UI offers Include and Exclude controls beside every unresolved item, plus explicit -bulk controls. CLI `run` stops when review is required; after inspecting `preview`, opt in -to a deterministic bulk decision when appropriate: +bulk controls. Every settled item can be changed from Include to Exclude or back again +until generation starts. CLI `run` stops when review is required; after inspecting +`preview`, opt in to a deterministic bulk decision when appropriate: bun run distil run --review-policy=include bun run distil run --review-policy=exclude diff --git a/assets/screenshots/generated-digest.png b/assets/screenshots/generated-digest.png new file mode 100644 index 0000000..480e0a1 Binary files /dev/null and b/assets/screenshots/generated-digest.png differ diff --git a/assets/screenshots/key-takeaways.png b/assets/screenshots/key-takeaways.png new file mode 100644 index 0000000..cc21f7c Binary files /dev/null and b/assets/screenshots/key-takeaways.png differ diff --git a/assets/screenshots/workflow.png b/assets/screenshots/workflow.png new file mode 100644 index 0000000..1730d6f Binary files /dev/null and b/assets/screenshots/workflow.png differ diff --git a/config.toml b/config.toml index c4238a4..6b12d69 100644 --- a/config.toml +++ b/config.toml @@ -9,7 +9,7 @@ retries = 2 [decision] enabled = true base_url = "http://127.0.0.1:8000" -confidence_threshold = 0.9 +confidence_threshold = 0.85 timeout_seconds = 10 [output] diff --git a/src/config.ts b/src/config.ts index 08bf307..cdb654d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -11,6 +11,7 @@ type TomlValue = string | number | boolean | TomlValue[] | TomlTable; const DEFAULT_OLLAMA_URL = "http://127.0.0.1:11434/v1"; const DEFAULT_OPENAI_URL = "https://api.mistral.ai/v1"; const DEFAULT_DECISION_URL = "http://127.0.0.1:8000"; +const DEFAULT_DECISION_CONFIDENCE = 0.85; export interface EditableConfig { llm: { @@ -82,7 +83,7 @@ export function setupConfig(): Config { decision: { enabled: false, baseUrl: DEFAULT_DECISION_URL, - confidenceThreshold: 0.9, + confidenceThreshold: DEFAULT_DECISION_CONFIDENCE, timeoutMs: 10_000, }, output: { directory: "~/distils", readingTimeMinutes: 5 }, @@ -355,7 +356,7 @@ export function normalizeConfig(raw: TomlTable): Config { baseUrl: decisionBaseUrl, confidenceThreshold: boundedNumber( decisionRaw.confidence_threshold, - 0.9, + DEFAULT_DECISION_CONFIDENCE, 0, 1, "decision.confidence_threshold", diff --git a/src/selection.ts b/src/selection.ts index a9625bc..6878dee 100644 --- a/src/selection.ts +++ b/src/selection.ts @@ -207,14 +207,18 @@ export function unresolvedSelections(result: SelectionResult): ItemSelection[] { return result.items.filter(isPendingSelection); } -export function resolvePendingSelection( +export function resolveSelection( result: SelectionResult, fingerprint: string, policy: ReviewPolicy, ): SelectionResult { const target = result.items.find((selection) => selection.fingerprint === fingerprint); if (!target) throw new Error("Unknown selection fingerprint"); - if (!isPendingSelection(target)) throw new Error("Selection does not require review"); + if (target.kind === "seen") { + throw new Error( + "Seen items must be recollected with Include seen before changing them", + ); + } return resolvedResult( result, result.items.map((selection) => @@ -376,11 +380,18 @@ function manualResolution( source: "user review" | "explicit bulk review", ): ItemSelection { const included = policy === "include"; + const evidence = + selection.kind === "manual" + ? selection.reason.replace( + /^(?:Included|Excluded) by (?:user review|explicit bulk review)\. /, + "", + ) + : selection.reason; return { ...selection, selected: included, kind: "manual", - reason: `${included ? "Included" : "Excluded"} by ${source}. ${selection.reason}`, + reason: `${included ? "Included" : "Excluded"} by ${source}. ${evidence}`, }; } diff --git a/src/web.ts b/src/web.ts index b61c10a..669cd73 100644 --- a/src/web.ts +++ b/src/web.ts @@ -7,7 +7,7 @@ import { streamDistil } from "./prompts.ts"; import { ContentSelector, resolveAllPending, - resolvePendingSelection, + resolveSelection, type SelectionKind, type SelectionPipeline, type SelectionResult, @@ -404,6 +404,12 @@ export class DistilWebApp { if (job?.status !== "complete" || !job.collection || !this.#cachedSelection) { return json({ error: "No completed fetch is available for review" }, 409); } + if (this.#generationInProgress) { + return json( + { error: "The selection cannot change while generation is running" }, + 409, + ); + } let resolution: SelectionResolution; try { @@ -416,7 +422,7 @@ export class DistilWebApp { const policy = resolution.selected ? "include" : "exclude"; const selection = resolution.all ? resolveAllPending(this.#cachedSelection, policy) - : resolvePendingSelection(this.#cachedSelection, resolution.fingerprint, policy); + : resolveSelection(this.#cachedSelection, resolution.fingerprint, policy); this.#cachedSelection = selection; this.#cachedItems = selection.selected; job.result = fetchPayload(job.collection, selection); diff --git a/src/web_ui.ts b/src/web_ui.ts index 0c95773..a09e2e5 100644 --- a/src/web_ui.ts +++ b/src/web_ui.ts @@ -44,7 +44,7 @@ export function homePage( 'Step 2
Check what will shape the digest and resolve any uncertain items.
Step 2
Check what will shape the digest. You can change any included or excluded item before generating.
Collect items to begin reviewing.
', '