فهرست منبع

fix(qmd): use shared Oivo cache for direct CLI

Direct qmd shell calls now default to /srv/.cache when present and ignore EPIPE from closed pipes.

Session-Id: 019ed817
Push-Allowed: yes
Claude 3 هفته پیش
والد
کامیت
d84af60a89
3فایلهای تغییر یافته به همراه25 افزوده شده و 0 حذف شده
  1. 8 0
      bin/qmd
  2. 8 0
      dist/cli/qmd.js
  3. 9 0
      src/cli/qmd.ts

+ 8 - 0
bin/qmd

@@ -15,6 +15,14 @@ done
 # to avoid native module ABI mismatches (e.g., better-sqlite3 compiled for bun vs node)
 DIR="$(cd -P "$(dirname "$SOURCE")/.." && pwd)"
 
+# Oivo installs the shared project index under /srv/.cache/qmd so spawned
+# agents, cron jobs, and shell calls all read the same database. The MCP preset
+# injects XDG_CACHE_HOME explicitly, but direct `qmd ...` calls do not; without
+# this default they silently create/read an empty ~/.cache/qmd/index.sqlite.
+if [ -z "${INDEX_PATH:-}" ] && [ -z "${XDG_CACHE_HOME:-}" ] && [ -d /srv/.cache/qmd ]; then
+  export XDG_CACHE_HOME=/srv/.cache
+fi
+
 # Detect the package manager that installed dependencies by checking lockfiles.
 # $BUN_INSTALL is intentionally NOT checked — it only indicates that bun exists
 # on the system, not that it was used to install this package (see #361).

+ 8 - 0
dist/cli/qmd.js

@@ -16,6 +16,14 @@ import { createEmbeddingProvider, resolveProviderKind, ModelMismatchError, } fro
 // Enable production mode - allows using default database path
 // Tests must set INDEX_PATH or use createStore() with explicit path
 enableProductionMode();
+for (const stream of [process.stdout, process.stderr]) {
+    stream.on("error", (error) => {
+        if (error.code === "EPIPE") {
+            process.exit(0);
+        }
+        throw error;
+    });
+}
 // =============================================================================
 // Store/DB lifecycle (no legacy singletons in store.ts)
 // =============================================================================

+ 9 - 0
src/cli/qmd.ts

@@ -112,6 +112,15 @@ import {
 // Tests must set INDEX_PATH or use createStore() with explicit path
 enableProductionMode();
 
+for (const stream of [process.stdout, process.stderr]) {
+  stream.on("error", (error: NodeJS.ErrnoException) => {
+    if (error.code === "EPIPE") {
+      process.exit(0);
+    }
+    throw error;
+  });
+}
+
 // =============================================================================
 // Store/DB lifecycle (no legacy singletons in store.ts)
 // =============================================================================