dsh-better-edit 0.3.2 → 0.4.0-rc.1

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.
@@ -0,0 +1,236 @@
1
+ /**
2
+ * StoreLifecycle — deep module owning store lifecycle (central GC + row TTL + WAL).
3
+ *
4
+ * Previously scattered: handleGitPollution + served/undo prune + pruneMissing throttling
5
+ * in hash-store.ts openStore, and runCentralJanitorIfDue throttling in hash-store.ts
6
+ * but scheduled from index.ts apply/session-start. No locality: WAL, TTL, readdir and
7
+ * throttling lived in different places and leaked stores/openings Maps.
8
+ *
9
+ * This module owns lastPruneMsByStore, lastJanitorMs, live-set computation, readdir/stat,
10
+ * and exposes onStoreOpen / onAppStart / onSessionStart / onClose.
11
+ * @module dsh-better-edit/store-lifecycle
12
+ */
13
+ import { appendFileSync, existsSync, readFileSync } from "node:fs";
14
+ import { readdir, rm, stat } from "node:fs/promises";
15
+ import { dirname, join } from "node:path";
16
+ import { DatabaseSync } from "node:sqlite";
17
+ import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
18
+ import { hashStorePath, loadConfig } from "./paths.js";
19
+ import { workspaceCwd } from "./workspace.js";
20
+ import { errCode, splitLines } from "./utils.js";
21
+ import { HASH_STORE_BUSY_TIMEOUT, SERVED_TTL_MS } from "./constants.js";
22
+ // ---- throttling state (owned here) ----
23
+ let lastPruneMsByStore = new Map();
24
+ let lastJanitorMs = 0;
25
+ const PRUNE_THROTTLE_MS = 24 * 60 * 60 * 1000;
26
+ const JANITOR_THROTTLE_MS = 24 * 60 * 60 * 1000;
27
+ let getStores;
28
+ let getOpenings;
29
+ export function setStoresGetter(getS, getO) {
30
+ getStores = getS;
31
+ getOpenings = getO;
32
+ }
33
+ // ---- git pollution state ----
34
+ const warnedGitWarn = new Set();
35
+ function gitignoreHasEntry(ws) {
36
+ try {
37
+ const content = readFileSync(join(ws, ".gitignore"), "utf-8");
38
+ return content.split("\n").some((l) => {
39
+ const t = l.trim();
40
+ return t === ".dsh_better_edit" || t === ".dsh_better_edit/" || t.startsWith(".dsh_better_edit/");
41
+ });
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ function handleGitPollution(storePath) {
48
+ try {
49
+ const cfg = loadConfig();
50
+ if (cfg.storeDir !== "workspace")
51
+ return;
52
+ const ws = dirname(dirname(storePath));
53
+ if (!existsSync(join(ws, ".git")) || gitignoreHasEntry(ws))
54
+ return;
55
+ if (cfg.autoGitignore) {
56
+ const gitignorePath = join(ws, ".gitignore");
57
+ try {
58
+ if (!existsSync(gitignorePath)) {
59
+ appendFileSync(gitignorePath, ".dsh_better_edit/\n");
60
+ }
61
+ else {
62
+ const content = readFileSync(gitignorePath, "utf-8");
63
+ const prefix = content.length > 0 && !content.endsWith("\n") ? "\n" : "";
64
+ appendFileSync(gitignorePath, `${prefix}.dsh_better_edit/\n`);
65
+ }
66
+ }
67
+ catch (error) {
68
+ console.warn(`dsh-better-edit: failed to update .gitignore for ${ws}: ${error instanceof Error ? error.message : String(error)}`);
69
+ }
70
+ return;
71
+ }
72
+ if (warnedGitWarn.has(ws))
73
+ return;
74
+ warnedGitWarn.add(ws);
75
+ console.warn(`dsh-better-edit: workspace store at ${ws}/.dsh_better_edit/ not in .gitignore — add ".dsh_better_edit/" to .gitignore or set storeDir: central / autoGitignore: true`);
76
+ }
77
+ catch (error) {
78
+ console.warn(`dsh-better-edit: handleGitPollution failed: ${error instanceof Error ? error.message : String(error)}`); // best-effort, never throw at store open
79
+ }
80
+ }
81
+ // ---- central janitor ----
82
+ export async function runCentralJanitorIfDue() {
83
+ const now = Date.now();
84
+ if (now - lastJanitorMs < JANITOR_THROTTLE_MS)
85
+ return;
86
+ lastJanitorMs = now;
87
+ let cfg;
88
+ try {
89
+ cfg = loadConfig();
90
+ }
91
+ catch (error) {
92
+ console.warn(`dsh-better-edit: loadConfig failed in janitor: ${error instanceof Error ? error.message : String(error)}`);
93
+ return;
94
+ }
95
+ if (cfg.storeDir === "workspace")
96
+ return;
97
+ const runtimeDir = join(resolveDshHome(), "plugins", "dsh-better-edit", "runtime");
98
+ let entries;
99
+ try {
100
+ entries = await readdir(runtimeDir);
101
+ }
102
+ catch (error) {
103
+ if (errCode(error) === "ENOENT")
104
+ return;
105
+ console.error("central janitor readdir failed:", error);
106
+ return;
107
+ }
108
+ const liveDirs = new Set();
109
+ if (getStores) {
110
+ for (const storePath of getStores().keys()) {
111
+ if (storePath.startsWith(runtimeDir + "/")) {
112
+ const base = storePath.slice(runtimeDir.length + 1).split("/")[0];
113
+ if (base)
114
+ liveDirs.add(base);
115
+ }
116
+ }
117
+ }
118
+ if (getOpenings) {
119
+ for (const storePath of getOpenings().keys()) {
120
+ if (storePath.startsWith(runtimeDir + "/")) {
121
+ const base = storePath.slice(runtimeDir.length + 1).split("/")[0];
122
+ if (base)
123
+ liveDirs.add(base);
124
+ }
125
+ }
126
+ }
127
+ const infos = [];
128
+ for (const name of entries) {
129
+ if (liveDirs.has(name))
130
+ continue;
131
+ const dir = join(runtimeDir, name);
132
+ try {
133
+ const st = await stat(dir);
134
+ if (!st.isDirectory())
135
+ continue;
136
+ let totalBytes = 0;
137
+ for (const file of ["hash-store.sqlite", "hash-store.sqlite-wal", "hash-store.sqlite-shm", ".wsPath"]) {
138
+ try {
139
+ totalBytes += (await stat(join(dir, file))).size;
140
+ }
141
+ catch { }
142
+ }
143
+ infos.push({ name, dir, mtimeMs: st.mtimeMs, totalBytes });
144
+ }
145
+ catch (error) {
146
+ console.warn(`dsh-better-edit: stat failed for central dir ${dir}: ${error instanceof Error ? error.message : String(error)}`);
147
+ }
148
+ }
149
+ infos.sort((a, b) => a.mtimeMs - b.mtimeMs);
150
+ const maxAgeMs = cfg.storeMaxAgeS * 1000;
151
+ const toDelete = [];
152
+ for (const info of infos) {
153
+ if (now - info.mtimeMs > maxAgeMs)
154
+ toDelete.push(info);
155
+ }
156
+ let remaining = infos.filter((info) => !toDelete.includes(info));
157
+ let currentCount = liveDirs.size + remaining.length + toDelete.length;
158
+ let currentBytes = [...remaining, ...toDelete].reduce((sum, info) => sum + info.totalBytes, 0);
159
+ for (const info of [...remaining].sort((a, b) => a.mtimeMs - b.mtimeMs)) {
160
+ if (currentCount < 100 && currentBytes < cfg.storeMaxTotalBytes)
161
+ break;
162
+ toDelete.push(info);
163
+ currentCount--;
164
+ currentBytes -= info.totalBytes;
165
+ remaining = remaining.filter((x) => x !== info);
166
+ }
167
+ for (const info of toDelete) {
168
+ try {
169
+ const dbPath = join(info.dir, "hash-store.sqlite");
170
+ if (existsSync(dbPath)) {
171
+ const tmpDb = new DatabaseSync(dbPath, { timeout: HASH_STORE_BUSY_TIMEOUT });
172
+ try {
173
+ tmpDb.exec("PRAGMA wal_checkpoint(TRUNCATE)");
174
+ }
175
+ catch (error) {
176
+ console.warn(`dsh-better-edit: wal_checkpoint failed for ${dbPath}: ${error instanceof Error ? error.message : String(error)}`);
177
+ }
178
+ finally {
179
+ try {
180
+ tmpDb.close();
181
+ }
182
+ catch (error) {
183
+ console.warn(`dsh-better-edit: close failed for ${dbPath}: ${error instanceof Error ? error.message : String(error)}`);
184
+ }
185
+ }
186
+ }
187
+ await rm(info.dir, { recursive: true, force: true });
188
+ }
189
+ catch (error) {
190
+ console.error("central janitor delete failed for", info.dir, error);
191
+ }
192
+ }
193
+ }
194
+ // Called from hash-store openStore after db is ready
195
+ export async function onStoreOpen(storePath, stmts, store) {
196
+ handleGitPollution(storePath);
197
+ // Row TTL — always (not throttled) but cheap
198
+ try {
199
+ stmts.servedPruneOlderThan(Date.now() - SERVED_TTL_MS);
200
+ }
201
+ catch (error) {
202
+ console.warn(`dsh-better-edit: served prune failed for ${storePath}: ${error instanceof Error ? error.message : String(error)}`);
203
+ }
204
+ try {
205
+ const cfg = loadConfig();
206
+ if (cfg.undo_ttl_s !== -1) {
207
+ stmts.undoPruneOlderThan(Date.now() - cfg.undo_ttl_s * 1000);
208
+ }
209
+ }
210
+ catch (error) {
211
+ console.warn(`dsh-better-edit: undo prune failed for ${storePath}: ${error instanceof Error ? error.message : String(error)}`);
212
+ }
213
+ // pruneMissing throttled per-store 24h
214
+ try {
215
+ const lastPrune = lastPruneMsByStore.get(storePath) ?? 0;
216
+ if (Date.now() - lastPrune > PRUNE_THROTTLE_MS) {
217
+ lastPruneMsByStore.set(storePath, Date.now());
218
+ store.pruneMissing().catch((e) => console.error("pruneMissing failed:", e));
219
+ }
220
+ }
221
+ catch (error) {
222
+ console.warn(`dsh-better-edit: pruneMissing throttling check failed: ${error instanceof Error ? error.message : String(error)}`);
223
+ }
224
+ }
225
+ export async function onAppStart() {
226
+ await runCentralJanitorIfDue();
227
+ }
228
+ export async function onSessionStart() {
229
+ await runCentralJanitorIfDue();
230
+ }
231
+ // For tests
232
+ export function _resetLifecycleForTests() {
233
+ lastPruneMsByStore = new Map();
234
+ lastJanitorMs = 0;
235
+ warnedGitWarn.clear();
236
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * StoreTenancy — deep module owning tenancy (where DB lives).
3
+ * Owns config (yaml+env, validation, fallback, mtime cache), canonical path via
4
+ * CanonicalPath seam, hash/sanitized basename, sidecar, migration, and
5
+ * tenancyFor() → {dir, mode, runtimeDir, canonical}. File-per-workspace
6
+ * central keeps static prepare() and isolated WAL; no PID level.
7
+ * @module dsh-better-edit/store-tenancy
8
+ */
9
+ import { homedir } from "node:os";
10
+ import { isAbsolute, join, dirname, parse } from "node:path";
11
+ import { resolve as resolvePath } from "node:path";
12
+ import { cpSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
13
+ import { createHash } from "node:crypto";
14
+ import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
15
+ import { errCode } from "./utils.js";
16
+ import { canonicalSync } from "./canonical-path.js";
17
+ import { loadConfig } from "./store-config.js";
18
+ export { loadConfig, _resetConfigCache, expand } from "./store-config.js";
19
+ function sanitizedBasename(ws) {
20
+ const base = parse(canonicalSync(ws)).base || "root";
21
+ const sanitized = base.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 32);
22
+ return sanitized.length > 0 ? sanitized : "root";
23
+ }
24
+ function hash8(ws) {
25
+ const canonical = canonicalSync(ws);
26
+ return createHash("sha1").update(canonical).digest("hex").slice(0, 8);
27
+ }
28
+ function ensureWsPathSidecar(dir, canonicalWs) {
29
+ try {
30
+ const wsPathFile = join(dir, ".wsPath");
31
+ if (existsSync(wsPathFile)) {
32
+ const existing = readFileSync(wsPathFile, "utf-8").trim();
33
+ if (existing !== canonicalWs) {
34
+ console.warn(`dsh-better-edit: central store collision for ${dir}: stored wsPath "${existing}" != current "${canonicalWs}" — keeping existing, hash collision risk`);
35
+ }
36
+ return;
37
+ }
38
+ mkdirSync(dir, { recursive: true });
39
+ writeFileSync(wsPathFile, `${canonicalWs}\n`, "utf-8");
40
+ }
41
+ catch {
42
+ // best-effort, never throw at path resolution
43
+ }
44
+ }
45
+ function migrateLegacyIfNeeded(cwd, centralDir) {
46
+ try {
47
+ const legacyDir = join(resolvePath(cwd), ".dsh_better_edit");
48
+ const centralDb = join(centralDir, "hash-store.sqlite");
49
+ const legacyDb = join(legacyDir, "hash-store.sqlite");
50
+ if (!existsSync(centralDb) && existsSync(legacyDb)) {
51
+ mkdirSync(centralDir, { recursive: true });
52
+ cpSync(legacyDir, centralDir, { recursive: true, force: false, errorOnExist: false });
53
+ ensureWsPathSidecar(centralDir, canonicalSync(cwd));
54
+ console.warn(`dsh-better-edit: migrated legacy workspace store ${legacyDir} -> ${centralDir}`);
55
+ }
56
+ }
57
+ catch {
58
+ // best-effort
59
+ }
60
+ }
61
+ export function tenancyFor(cwd) {
62
+ if (cwd === undefined) {
63
+ return {
64
+ dir: join(resolveDshHome(), "plugins", "dsh-better-edit"),
65
+ mode: "central",
66
+ canonical: "",
67
+ };
68
+ }
69
+ const cfg = loadConfig();
70
+ const sd = cfg.storeDir;
71
+ if (sd === "workspace") {
72
+ return { dir: join(resolvePath(cwd), ".dsh_better_edit"), mode: "workspace", canonical: canonicalSync(cwd) };
73
+ }
74
+ const canonical = canonicalSync(cwd);
75
+ const h = hash8(cwd);
76
+ if (sd === "central") {
77
+ const dir = join(resolveDshHome(), "plugins", "dsh-better-edit", "runtime", `${sanitizedBasename(cwd)}-${h}`);
78
+ ensureWsPathSidecar(dir, canonical);
79
+ migrateLegacyIfNeeded(cwd, dir);
80
+ return { dir, mode: "central", runtimeDir: join(resolveDshHome(), "plugins", "dsh-better-edit", "runtime"), canonical };
81
+ }
82
+ const dir = join(sd, h);
83
+ ensureWsPathSidecar(dir, canonical);
84
+ migrateLegacyIfNeeded(cwd, dir);
85
+ return { dir, mode: "custom", runtimeDir: sd, canonical };
86
+ }
87
+ // Compat shims — paths.ts delegates here
88
+ export function configDir(cwd) {
89
+ return tenancyFor(cwd).dir;
90
+ }
91
+ export function hashStorePath(cwd) {
92
+ return join(tenancyFor(cwd).dir, "hash-store.sqlite");
93
+ }
94
+ export function hashStoreDir(cwd) {
95
+ return tenancyFor(cwd).dir;
96
+ }
97
+ export function legacyHashStorePath(cwd) {
98
+ if (cwd === undefined)
99
+ return join(resolveDshHome(), "plugins", "dsh-better-edit", "hash-store.json");
100
+ return join(resolvePath(cwd), ".dsh_better_edit", "hash-store.json");
101
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Canonical path resolution — single seam for symlink-aware canonicalization.
3
+ * Pure traversal owns the visited-set + ELOOP + ENOENT (lexical tail) invariant.
4
+ * Two adapters justify the seam: sync (hash8, sanitizedBasename, central tenancy)
5
+ * and async (resolveTarget). Byte-identical to the previous duplicated impl.
6
+ * @module dsh-better-edit/canonical-path
7
+ */
8
+ /** Sync adapter — lstatSync + readlinkSync. */
9
+ export declare function canonicalSync(inputPath: string): string;
10
+ /** Async adapter — lstat + readlink. Thin async shell over the same traversal. */
11
+ export declare function canonicalAsync(inputPath: string): Promise<string>;
@@ -55,22 +55,28 @@ export interface HashStore {
55
55
  getUndo(path: string): UndoRecord | undefined;
56
56
  upsertUndo(path: string, entry: UndoRecord): void;
57
57
  deleteUndo(path: string): void;
58
- /** The served hashes array for a session+path, healing a corrupt row; [] when nothing was served. */
58
+ pruneUndoOlderThan(ts: number): void;
59
+ /** Delete every row family's entries for paths that no longer exist on disk. */
60
+ pruneMissing(): Promise<void>;
61
+ }
62
+ /**
63
+ * Served persistence — internal, owned by SessionView. Not part of the public HashStore API.
64
+ * SessionView is the sole owner of the served merge invariant; HashStore is the persistence adapter.
65
+ */
66
+ export interface ServedPersistence {
59
67
  getServed(sessionKey: string, path: string): (string | null)[];
60
- /** The reported-drift hash set for a session+path (lenient parse, never deletes). */
61
68
  getServedReported(sessionKey: string, path: string): Set<string>;
62
- /** Persist the hashes JSON column for a session+path. */
63
69
  upsertServed(sessionKey: string, path: string, hashesJson: string): void;
64
- /** Persist the reported-drift JSON column for a session+path (inserting a fresh empty hashes row). */
65
70
  upsertServedReported(sessionKey: string, path: string, reportedJson: string): void;
66
71
  clearServedReported(sessionKey: string, path: string): void;
67
72
  deleteServed(sessionKey: string, path: string): void;
68
73
  deleteServedByPath(path: string): void;
69
74
  wipeServed(sessionKey: string): void;
70
75
  pruneServedOlderThan(ts: number): void;
71
- /** Delete every row family's entries for paths that no longer exist on disk. */
72
- pruneMissing(): Promise<void>;
73
76
  }
77
+ export type InternalHashStore = HashStore & ServedPersistence;
78
+ /** Load the store as served persistence — internal, for SessionView only. */
79
+ export declare function loadServedStore(cwd?: string): Promise<ServedPersistence>;
74
80
  export declare function isCorruptionError(error: unknown): boolean;
75
81
  /**
76
82
  * Load (and cache) the hash store for the given cwd — or, when omitted, the
@@ -1,24 +1,4 @@
1
- /**
2
- * On-disk home for dsh-better-edit state. Inside a tool call the store lives
3
- * co-located with the files being edited: `<workspace>/.dsh_better_edit/` (the
4
- * workspace is the session cwd, carried through the execution by
5
- * `withWorkspace`). Outside a tool call — tests, previews, startup — the store
6
- * falls back to the shared DeepSeek Harness home
7
- * (`$DSH_HOME/plugins/dsh-better-edit`, default `~/.dsh/plugins/dsh-better-edit`),
8
- * so a caller without a workspace never writes into an arbitrary cwd.
9
- * @param cwd - the workspace root, or undefined for the shared-home fallback.
10
- */
11
- export declare function configDir(cwd?: string): string;
12
- export declare function hashStorePath(cwd?: string): string;
13
- export declare function legacyHashStorePath(cwd?: string): string;
14
- export declare function hashStoreDir(cwd?: string): string;
1
+ export * from "./store-tenancy.js";
2
+ export { canonicalAsync as resolveTarget } from "./canonical-path.js";
3
+ export { canonicalSync } from "./canonical-path.js";
15
4
  export declare function toCwd(filePath: string, cwd: string): string;
16
- /**
17
- * Canonicalize a path, resolving every symlink component to its target
18
- * (loop-guarded, ELOOP on cycles). Non-existent final components resolve
19
- * lexically — the canonical form of a not-yet-created file. The hashline
20
- * tools key their state by canonical absolute paths, so the same file reached
21
- * through different symlink spellings lands on the same store rows.
22
- * @param path - the path to canonicalize (absolute or relative).
23
- */
24
- export declare function resolveTarget(path: string): Promise<string>;
@@ -36,7 +36,7 @@ export declare function sessionKeyFor(sessionId?: string): string;
36
36
  export declare function execCwd(exec: ToolExecution): string;
37
37
  export declare function execSessionKey(exec: ToolExecution): string;
38
38
  export { configDir, hashStorePath, resolveTarget };
39
- export { loadHashStore, shutdownHashStore, withStore } from "./hash-store.js";
39
+ export { loadHashStore, loadServedStore, shutdownHashStore, withStore } from "./hash-store.js";
40
40
  export type { HashStore } from "./hash-store.js";
41
41
  export type ServedEntry = {
42
42
  position: number;
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ export declare function expand(filePath: string): string;
3
+ declare const StoreConfigSchema: z.ZodObject<{
4
+ storeDir: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
5
+ autoGitignore: z.ZodDefault<z.ZodBoolean>;
6
+ undo_ttl_s: z.ZodDefault<z.ZodNumber>;
7
+ storeMaxAgeS: z.ZodDefault<z.ZodNumber>;
8
+ storeMaxTotalBytes: z.ZodDefault<z.ZodNumber>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ storeDir: string;
11
+ autoGitignore: boolean;
12
+ undo_ttl_s: number;
13
+ storeMaxAgeS: number;
14
+ storeMaxTotalBytes: number;
15
+ }, {
16
+ storeDir?: string | undefined;
17
+ autoGitignore?: boolean | undefined;
18
+ undo_ttl_s?: number | undefined;
19
+ storeMaxAgeS?: number | undefined;
20
+ storeMaxTotalBytes?: number | undefined;
21
+ }>;
22
+ export type StoreConfig = z.infer<typeof StoreConfigSchema>;
23
+ /** Default config.yaml content with comments — generated when the file does not exist. */
24
+ export declare const DEFAULT_CONFIG_YAML = "# dsh-better-edit config\n# Location: $DSH_HOME/plugins/dsh-better-edit/config.yaml\n# Docs: https://github.com/Rianico/dsh-better-edit#configuration\n# Generated with defaults on first load \u2014 edit or delete freely.\n# DB files are disposable caches \u2014 safe to delete, rebuilt on next `read`.\n\n# where the store lives: \"central\" (default, in $DSH_HOME/.../runtime/<name>-<hash8>/) | \"workspace\" (legacy <ws>/.dsh_better_edit/) | \"/abs/path\" (custom root)\nstoreDir: central\n\n# workspace only: when .git exists but .gitignore lacks .dsh_better_edit/, true = auto-append \".dsh_better_edit/\", false = warn once\nautoGitignore: false\n\n# undo history TTL in seconds; -1 = keep forever (default 604800 = 7 days)\nundo_ttl_s: 604800\n\n# central janitor: max idle age in seconds before evicting runtime/<name>-<hash8>/ (default 2592000 = 30 days)\nstoreMaxAgeS: 2592000\n\n# central janitor: max total bytes under runtime/ before LRU eviction (default 524288000 = 500 MB)\nstoreMaxTotalBytes: 524288000\n";
25
+ /**
26
+ * Ensure a default config.yaml exists in the plugin home.
27
+ * Idempotent and concurrent-safe (wx) — never overwrites an existing file.
28
+ * Best-effort: failures are logged but never throw to the caller.
29
+ */
30
+ export declare function ensureDefaultConfig(homeDir?: string): Promise<void>;
31
+ export declare function loadConfig(): StoreConfig;
32
+ export declare function _resetConfigCache(): void;
33
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { HashStore } from "./hash-store.js";
2
+ export declare function setStoresGetter(getS: () => Map<string, {
3
+ path: string;
4
+ }>, getO: () => Map<string, Promise<any>>): void;
5
+ export declare function runCentralJanitorIfDue(): Promise<void>;
6
+ export declare function onStoreOpen(storePath: string, stmts: {
7
+ servedPruneOlderThan: (ts: number) => void;
8
+ undoPruneOlderThan: (ts: number) => void;
9
+ }, store: HashStore): Promise<void>;
10
+ export declare function onAppStart(): Promise<void>;
11
+ export declare function onSessionStart(): Promise<void>;
12
+ export declare function _resetLifecycleForTests(): void;
@@ -0,0 +1,13 @@
1
+ export { loadConfig, _resetConfigCache, expand } from "./store-config.js";
2
+ export type { StoreConfig } from "./store-config.js";
3
+ export interface Tenancy {
4
+ dir: string;
5
+ mode: "workspace" | "central" | "custom";
6
+ runtimeDir?: string;
7
+ canonical: string;
8
+ }
9
+ export declare function tenancyFor(cwd?: string): Tenancy;
10
+ export declare function configDir(cwd?: string): string;
11
+ export declare function hashStorePath(cwd?: string): string;
12
+ export declare function hashStoreDir(cwd?: string): string;
13
+ export declare function legacyHashStorePath(cwd?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-edit",
3
- "version": "0.3.2",
3
+ "version": "0.4.0-rc.1",
4
4
  "type": "module",
5
5
  "description": "Hash-anchored read/edit/undo_last_edit tools for DeepSeek Harness (dsh). Every line gets a unique 3-char hash (A-Za-z0-9) that stays stable across edits; stale or ambiguous anchors are rejected, never fuzzy-matched. Undo persists across restarts.",
6
6
  "main": "lib/index.js",
@@ -56,7 +56,8 @@
56
56
  "dependencies": {
57
57
  "diff": "^8.0.2",
58
58
  "file-type": "^21.3.0",
59
- "xxhash-wasm": "^1.1.0"
59
+ "xxhash-wasm": "^1.1.0",
60
+ "zod": "^3.25.76"
60
61
  },
61
62
  "engines": {
62
63
  "node": "^22.19.0 || >=24.0.0"
@@ -76,9 +77,9 @@
76
77
  "@deepseek-ai/dsh-agent": "0.1.0-rc.6",
77
78
  "@deepseek-ai/dsh-fs": "0.1.0-rc.6",
78
79
  "@deepseek-ai/dsh-home-paths": "0.1.0-rc.6",
80
+ "@deepseek-ai/dsh-sandbox": "^0.1.0-rc.6",
79
81
  "@deepseek-ai/dsh-session": "0.1.0-rc.6",
80
82
  "@deepseek-ai/dsh-tools": "0.1.0-rc.6",
81
- "@deepseek-ai/dsh-sandbox": "^0.1.0-rc.6",
82
83
  "@types/node": "^24.0.0",
83
84
  "@vitest/coverage-v8": "^4.1.10",
84
85
  "js-tiktoken": "1.0.21",