dissentry 0.7.0 → 0.8.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 CHANGED
@@ -18,7 +18,13 @@ Dissentry is an X-style timeline for AI models. You `@mention` a model to ask it
18
18
 
19
19
  You decide whether each note is right, and the **Trust** page shows which models get corrected and whose notes hold up, on *your* questions.
20
20
 
21
- <p align="center"><img src="https://raw.githubusercontent.com/Lihaila/dissentry/main/docs/screenshots/thread.jpg" alt="An answer from DeepSeek with a dissent note that Claude, Qwen and Gemini agree on" width="900" /></p>
21
+ <p align="center">
22
+ <a href="https://dissentry.lihaila.com/promo.mp4" title="Watch the 32-second Dissentry promo video">
23
+ <img src="https://raw.githubusercontent.com/Lihaila/dissentry/main/docs/screenshots/promo-poster.jpg" alt="Watch the 32-second Dissentry promo video" width="900" />
24
+ </a>
25
+ <br/>
26
+ <sub><a href="https://dissentry.lihaila.com/promo.mp4">Watch 32s promo video (1080p MP4)</a> · <a href="https://github.com/Lihaila/dissentry/releases/download/v0.7.0/dissentry-promo.mp4">Download MP4</a></sub>
27
+ </p>
22
28
 
23
29
  ## Features
24
30
 
@@ -30,7 +36,8 @@ You decide whether each note is right, and the **Trust** page shows which models
30
36
  - **Or bring your own keys**: OpenAI, Anthropic, Gemini, DeepSeek, Qwen (with 1-click regional & Coding Plan endpoints), xAI, Mistral, Groq, any OpenAI-compatible endpoint, plus **Ollama** and **LM Studio** for local models — with a searchable model picker.
31
37
  - **Share as image**: turn any answer and its notes into a polished card for X, in one click.
32
38
  - **Token usage & personal trust scores**: tokens and estimated cost per answer and per model, plus trust stats built from your own verdicts.
33
- - **Private by design**: keys, chats, attachments, generated media, and your custom profile avatar stay in your browser (IndexedDB / localStorage). No accounts, no telemetry.
39
+ - **Local vs. Cloud clarity & Local-only thread lock**: every model is clearly labeled **Local** or **Cloud**, the composer shows before sending whether a post stays on your device or shares context with cloud checkers, and a 1-click **Local only** lock enforces a hard privacy boundary across the entire thread (including replies, quotes, and checks).
40
+ - **Private & persistent by design**: keys, chats, attachments, generated media, and your custom profile avatar stay on your device. Running `npx dissentry` automatically syncs to `~/.dissentry/data.json` (`0600` owner-only permissions) and auto-restores if browser data is cleared; the hosted web app requests browser persistent storage and supports 1-click local JSON file auto-backup. No accounts, no telemetry.
34
41
  - **Four languages**: English, 简体中文, 日本語, 한국어.
35
42
  - **Works behind proxies**: HTTP, HTTPS and SOCKS5 with a bypass list (local version).
36
43
 
@@ -97,7 +104,7 @@ DISSENTRY_LIVE=1 OPENAI_API_KEY=… npx vitest run tests/live.test.ts # option
97
104
  |---|---|
98
105
  | `src/lib/engine.ts` | posting, parallel streaming replies, media dispatch, checkers, note merging, usage |
99
106
  | `src/lib/context.ts` | shared thread memory → multimodal model messages; checker prompt |
100
- | `src/lib/media.ts`, `src/lib/files.ts` | image/audio/video generation adapters; local attachment & avatar processing |
107
+ | `src/lib/media.ts`, `src/lib/files.ts`, `src/lib/persistence.ts` | image/audio/video generation; local attachment & avatar processing; disk & file persistence |
101
108
  | `src/lib/notes.ts`, `src/lib/claims.ts` | checker JSON parsing, note merging, disputed-claim highlighting |
102
109
  | `src/lib/providers.ts`, `src/lib/openrouter.ts` | provider adapters (web search, DeepThink, model picker), OpenRouter sign-in (OAuth PKCE) |
103
110
  | `src/i18n/` | UI strings in four languages |
package/dist/server.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { serve } from "@hono/node-server";
3
3
  import { spawn } from "child_process";
4
4
  import { existsSync } from "fs";
5
+ import { homedir } from "os";
5
6
  import { dirname, join as join2 } from "path";
6
7
  import { fileURLToPath } from "url";
7
8
 
@@ -79,7 +80,7 @@ function dispatcherFor(target, mode, bypass = "") {
79
80
  }
80
81
 
81
82
  // server/app.ts
82
- import { readFile, stat } from "fs/promises";
83
+ import { mkdir, readFile, rename, rm, stat, writeFile } from "fs/promises";
83
84
  import { extname, join, normalize, sep } from "path";
84
85
  var TARGET_HEADER = "x-dissentry-target";
85
86
  var upstreamFetch = (url, init, dispatcher) => dispatcher ? undiciFetch(url, { ...init, dispatcher }) : fetch(url, init);
@@ -142,7 +143,47 @@ function createApp(opts) {
142
143
  }
143
144
  await next();
144
145
  });
145
- app2.get("/api/health", (c) => c.json({ ok: true, proxy: true, systemProxy: describeProxy(envProxyUrl()) ?? null }));
146
+ const dataFile = opts.dataDir ? join(opts.dataDir, "data.json") : void 0;
147
+ app2.get("/api/health", (c) => c.json({
148
+ ok: true,
149
+ proxy: true,
150
+ systemProxy: describeProxy(envProxyUrl()) ?? null,
151
+ storage: Boolean(dataFile),
152
+ dataFile: dataFile ? opts.dataFileDisplay ?? dataFile : null
153
+ }));
154
+ if (opts.dataDir && dataFile) {
155
+ const dir = opts.dataDir;
156
+ const file = dataFile;
157
+ app2.get("/api/storage", async (c) => {
158
+ try {
159
+ const raw = await readFile(file, "utf8");
160
+ return c.body(raw, 200, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
161
+ } catch (e) {
162
+ if (e.code === "ENOENT") return c.json({ empty: true }, 200);
163
+ return c.json({ error: e.message }, 500);
164
+ }
165
+ });
166
+ app2.put("/api/storage", async (c) => {
167
+ const raw = await c.req.text();
168
+ if (raw.length > 100 * 1024 * 1024) return c.json({ error: "Payload too large" }, 413);
169
+ let parsed;
170
+ try {
171
+ parsed = JSON.parse(raw);
172
+ } catch {
173
+ return c.json({ error: "Invalid JSON" }, 400);
174
+ }
175
+ if (parsed?.app !== "dissentry") return c.json({ error: "Not a Dissentry snapshot" }, 400);
176
+ await mkdir(dir, { recursive: true, mode: 448 });
177
+ const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
178
+ await writeFile(tmp, raw, { encoding: "utf8", mode: 384 });
179
+ await rename(tmp, file);
180
+ return c.json({ ok: true, savedAt: Date.now() });
181
+ });
182
+ app2.delete("/api/storage", async (c) => {
183
+ await rm(file, { force: true });
184
+ return c.json({ ok: true });
185
+ });
186
+ }
146
187
  app2.all("/api/proxy", async (c) => {
147
188
  const target = c.req.header(TARGET_HEADER);
148
189
  let url;
@@ -236,6 +277,8 @@ Usage: npx dissentry [options]
236
277
  --port <n> Port to listen on (default 4317, env PORT)
237
278
  --host <addr> Address to bind (default 127.0.0.1, env HOST)
238
279
  --allow-host <h> Extra Host header to accept, comma separated (env DISSENTRY_ALLOWED_HOSTS)
280
+ --data-dir <dir> Directory for local disk persistence (default ~/.dissentry, env DISSENTRY_DATA_DIR)
281
+ --no-disk Disable automatic local disk persistence
239
282
  --no-open Do not open the browser
240
283
  `);
241
284
  process.exit(0);
@@ -243,6 +286,9 @@ Usage: npx dissentry [options]
243
286
  var port = Number(opt("port") ?? process.env.PORT ?? 4317);
244
287
  var host = opt("host") ?? process.env.HOST ?? "127.0.0.1";
245
288
  var extraHosts = (opt("allow-host") ?? process.env.DISSENTRY_ALLOWED_HOSTS ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
289
+ var home = homedir();
290
+ var dataDir = flag("no-disk") ? void 0 : opt("data-dir") ?? process.env.DISSENTRY_DATA_DIR ?? join2(home, ".dissentry");
291
+ var dataFileDisplay = dataDir ? join2(dataDir, "data.json").replace(home, "~") : void 0;
246
292
  var here = dirname(fileURLToPath(import.meta.url));
247
293
  var webDir = join2(here, "web");
248
294
  if (!existsSync(join2(webDir, "index.html"))) {
@@ -252,13 +298,15 @@ if (!existsSync(join2(webDir, "index.html"))) {
252
298
  if (host !== "127.0.0.1" && host !== "localhost" && host !== "::1" && extraHosts.length === 0) {
253
299
  console.warn(`! Binding to ${host}. Requests are still only accepted with a localhost Host header; pass --allow-host <your-hostname> to reach it from other machines (and put it behind auth).`);
254
300
  }
255
- var app = createApp({ allowedHosts: ["localhost", "127.0.0.1", "[::1]", ...extraHosts], webDir });
301
+ var app = createApp({ allowedHosts: ["localhost", "127.0.0.1", "[::1]", ...extraHosts], webDir, dataDir, dataFileDisplay });
256
302
  serve({ fetch: app.fetch, port, hostname: host }, (info) => {
257
303
  const url = `http://localhost:${info.port}`;
258
304
  console.log(`
259
305
  Dissentry is running at ${url}
260
- Your data stays in this browser. API keys never leave this machine except to the provider you call.
306
+ API keys never leave this machine except to the provider you call.
261
307
  Press Ctrl+C to stop.
308
+ `);
309
+ if (dataFileDisplay) console.log(` Local disk persistence: ${dataFileDisplay} (owner-only permissions, auto-restores if browser data is cleared).
262
310
  `);
263
311
  if (envProxyUrl()) console.log(` System proxy detected: ${describeProxy(envProxyUrl())} (used when Settings \u2192 Network proxy is "System").
264
312
  `);