dsh-better-edit 1.2.3 → 1.2.5

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +39 -20
  3. package/README.zh.md +39 -31
  4. package/lib/contract.js +53 -22
  5. package/lib/domain-errors.js +18 -10
  6. package/lib/edit-mode.js +11 -0
  7. package/lib/encoding.js +2 -0
  8. package/lib/file-encoding-state.js +138 -44
  9. package/lib/file-view.js +26 -205
  10. package/lib/fs-bridge.js +53 -71
  11. package/lib/hashline/anchor-pipeline.js +8 -499
  12. package/lib/hashline/hash-assign.js +55 -4
  13. package/lib/hashline/index.js +5 -2
  14. package/lib/hashline/served-evidence.js +531 -0
  15. package/lib/index.js +177 -33
  16. package/lib/mutation/engine.js +19 -61
  17. package/lib/mutation.js +63 -105
  18. package/lib/noop-guard.js +24 -38
  19. package/lib/paths.js +9 -5
  20. package/lib/preset-toolset.js +144 -0
  21. package/lib/prompts.js +3 -3
  22. package/lib/read-and-serve.js +51 -53
  23. package/lib/reclaim.js +65 -0
  24. package/lib/self-heal.js +14 -13
  25. package/lib/session-view.js +79 -49
  26. package/lib/store/index.js +14 -14
  27. package/lib/store-config.js +4 -5
  28. package/lib/store-lifecycle.js +1 -1
  29. package/lib/tool-edit.js +14 -56
  30. package/lib/tool-read.js +2 -8
  31. package/lib/tool-str-replace-editor.js +34 -18
  32. package/lib/tool-undo.js +42 -24
  33. package/lib/types/contract.d.ts +11 -20
  34. package/lib/types/domain-errors.d.ts +14 -10
  35. package/lib/types/edit-mode.d.ts +11 -0
  36. package/lib/types/encoding.d.ts +1 -0
  37. package/lib/types/file-encoding-state.d.ts +51 -14
  38. package/lib/types/file-view.d.ts +18 -56
  39. package/lib/types/fs-bridge.d.ts +0 -1
  40. package/lib/types/hashline/anchor-pipeline.d.ts +6 -128
  41. package/lib/types/hashline/hash-assign.d.ts +40 -0
  42. package/lib/types/hashline/index.d.ts +6 -4
  43. package/lib/types/hashline/served-evidence.d.ts +152 -0
  44. package/lib/types/mutation/engine.d.ts +4 -12
  45. package/lib/types/mutation.d.ts +10 -58
  46. package/lib/types/noop-guard.d.ts +2 -33
  47. package/lib/types/paths.d.ts +0 -1
  48. package/lib/types/preset-toolset.d.ts +61 -0
  49. package/lib/types/reclaim.d.ts +36 -0
  50. package/lib/types/self-heal.d.ts +9 -3
  51. package/lib/types/session-view.d.ts +38 -8
  52. package/lib/types/store/index.d.ts +12 -11
  53. package/lib/types/store-config.d.ts +1 -1
  54. package/lib/types/store-lifecycle.d.ts +12 -2
  55. package/lib/types/tool-edit.d.ts +2 -4
  56. package/lib/types/tool-read.d.ts +0 -5
  57. package/lib/types/tool-str-replace-editor.d.ts +0 -6
  58. package/lib/types/tool-undo.d.ts +0 -5
  59. package/package.json +3 -2
  60. package/lib/drift.js +0 -5
  61. package/lib/dsh-context.js +0 -5
  62. package/lib/edit-engine.js +0 -7
  63. package/lib/edit-normalize.js +0 -9
  64. package/lib/edit-pipeline.js +0 -6
  65. package/lib/file-kind.js +0 -6
  66. package/lib/file-reader.js +0 -6
  67. package/lib/guidance/index.js +0 -8
  68. package/lib/hashline/alphabet.js +0 -2
  69. package/lib/hashline/apply.js +0 -2
  70. package/lib/hashline/hasher.js +0 -2
  71. package/lib/hashline/parse.js +0 -2
  72. package/lib/hashline/pure.js +0 -2
  73. package/lib/hashline/resolve.js +0 -3
  74. package/lib/hashline/served.js +0 -2
  75. package/lib/preview-controller.js +0 -65
  76. package/lib/read-render.js +0 -6
  77. package/lib/schema.js +0 -24
  78. package/lib/served-store.js +0 -5
  79. package/lib/tool-batch-edit.js +0 -190
  80. package/lib/truncate.js +0 -6
  81. package/lib/types/drift.d.ts +0 -5
  82. package/lib/types/dsh-context.d.ts +0 -5
  83. package/lib/types/edit-engine.d.ts +0 -7
  84. package/lib/types/edit-normalize.d.ts +0 -1
  85. package/lib/types/edit-pipeline.d.ts +0 -6
  86. package/lib/types/file-kind.d.ts +0 -6
  87. package/lib/types/file-reader.d.ts +0 -6
  88. package/lib/types/guidance/index.d.ts +0 -8
  89. package/lib/types/hashline/alphabet.d.ts +0 -1
  90. package/lib/types/hashline/apply.d.ts +0 -1
  91. package/lib/types/hashline/hasher.d.ts +0 -1
  92. package/lib/types/hashline/parse.d.ts +0 -1
  93. package/lib/types/hashline/pure.d.ts +0 -1
  94. package/lib/types/hashline/resolve.d.ts +0 -1
  95. package/lib/types/hashline/served.d.ts +0 -1
  96. package/lib/types/preview-controller.d.ts +0 -33
  97. package/lib/types/read-render.d.ts +0 -6
  98. package/lib/types/schema.d.ts +0 -25
  99. package/lib/types/served-store.d.ts +0 -5
  100. package/lib/types/tool-batch-edit.d.ts +0 -25
  101. package/lib/types/truncate.d.ts +0 -6
  102. package/lib/types/validation.d.ts +0 -6
  103. package/lib/types/workspace.d.ts +0 -5
  104. package/lib/validation.js +0 -6
  105. package/lib/workspace.js +0 -5
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Self-healing watcher for hash-anchored tools.
3
- * Restores `read`/`edit` on the agent's own scope layer if an external
4
- * preset deletes them (e.g. router-standard stage advance).
3
+ * Restores the hashline tools the install actually registered when an external
4
+ * preset deletes them (e.g. router-standard stage advance). The heal set is the
5
+ * installed set: a tool the preset gate declined has no definition to restore,
6
+ * so a `tools/change` can never resurrect it (Rianico/dsh-better-edit#110).
5
7
  * See Rianico/dsh-better-edit#43.
6
8
  * @module dsh-better-edit/self-heal
7
9
  */
@@ -23,7 +25,11 @@ export interface SelfHealOptions {
23
25
  };
24
26
  toolsSvc: unknown;
25
27
  hashReadDef: unknown;
26
- hashEditDef: unknown;
28
+ /**
29
+ * Omitted when the preset gate declined the hashline `edit`: an absent
30
+ * definition is the watcher's "never heal this" signal, not a takeover.
31
+ */
32
+ hashEditDef?: unknown;
27
33
  /** ADR-0015 shadow def; when present the watcher also heals `str_replace_editor`. */
28
34
  hashStrReplaceDef?: unknown;
29
35
  healMinIntervalMs?: number;
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * Public surface: _mergeServedRows, loadServed, recordServed,
11
11
  * recordServedTruncated, driftReported, markDriftReported,
12
- * clearDriftReported, wipeServedState, servedPositionsOf,
13
- * currentPositionOfDrifted, computeDrift, scanDrift, and
12
+ * clearDriftReported, wipeServedState, servedPositionsOf (re-exported from
13
+ * hashline/served-evidence), currentPositionOfDrifted, computeDrift, scanDrift, and
14
14
  * hash-store persistence delegation (ServedPersistence).
15
15
  *
16
16
  * Ownership: This file OWNS the served-merge invariant
@@ -23,7 +23,10 @@
23
23
  * @module dsh-better-edit/session-view
24
24
  */
25
25
  import { type AnchorReservations, type ServedPersistence } from "./hash-store.js";
26
- import type { ServedRow, ResolvedRange } from "./hashline/anchor-pipeline.js";
26
+ import type { ServedRow } from "./domain-errors.js";
27
+ import { servedPositionsOf } from "./hashline/served-evidence.js";
28
+ import type { ResolvedRange } from "./hashline/served-evidence.js";
29
+ export { servedPositionsOf };
27
30
  export { loadHashStore, loadServedStore, shutdownHashStore, withStore } from "./hash-store.js";
28
31
  export type { HashStore } from "./hash-store.js";
29
32
  export type ServedEntry = {
@@ -60,16 +63,40 @@ export declare function loadRetiredAnchors(sessionKey: string, path: string): Pr
60
63
  export declare function retireAnchorsInStore(store: ServedPersistence, sessionKey: string, path: string, hashes: Iterable<string>): void;
61
64
  /** Keep freed anchors dead for this session until it has seen the whole file again. */
62
65
  export declare function retireAnchors(sessionKey: string, path: string, hashes: Iterable<string>): Promise<void>;
63
- /** Full-file context for a complete read — when present and matching `rows`, the call is a full read. */
64
- export interface FullReadContext {
66
+ /**
67
+ * Caller-owned transaction: revive retired anchors inside the caller's unit.
68
+ *
69
+ * The undo restore is the one path that brings a retired assignment back: when the
70
+ * pre-edit line returns byte-identically, its pre-edit anchor is live again, so the
71
+ * retirement that the edit recorded must move with the restore (ADR-0017 reversal).
72
+ * Anchors not in the store's retired set are left untouched; the entry's `deathPos`
73
+ * does not matter — the anchor's line is back, so the whole entry goes.
74
+ */
75
+ export declare function unretireAnchorsInStore(store: ServedPersistence, sessionKey: string, path: string, hashes: Iterable<string>): void;
76
+ /**
77
+ * Serve context: what the read showed of the file, plus the full-read verdict the read computed.
78
+ *
79
+ * `fullRead` is the ONE authority (ADR-0035). It is `FileView.fullRead` — a fact about the read
80
+ * REQUEST (no `offset`, no `limit`, no requested windows, no truncation) — and never a fact about
81
+ * the `rows` this call happens to carry: a page whose rows cover every line is still a page.
82
+ */
83
+ export interface ServeContext {
65
84
  hashes: readonly string[];
66
85
  canons?: readonly (string | null)[];
67
86
  /**
68
87
  * Full content the hashes were computed from. When present (with `hashes`),
69
88
  * recordServed also materializes-or-adopts the serve snapshot and grants
70
- * leases for `rows` as-is through the store's single transaction.
89
+ * leases for `rows` as-is through the store's single transaction — for a page too: a shown
90
+ * anchor must stay editable, so the grant is not a full-read effect.
71
91
  */
72
92
  content?: string;
93
+ /**
94
+ * True only for an untruncated whole-file read with no page request — gates the three hazard/
95
+ * cache effects a full read owns (retired anchors, hazard cards, the whole canon array).
96
+ * Nothing else: the lease grant below is unconditional, and `recordServedTruncated` has no
97
+ * verdict at all.
98
+ */
99
+ fullRead: boolean;
73
100
  }
74
101
  /** Serve-snapshot context for lease granting: content parallel to `hashes`. */
75
102
  export interface ServeSnapshot {
@@ -83,8 +110,12 @@ export interface ServeSnapshot {
83
110
  * `false` means the write rolled back and no lease was granted, so the caller must not advertise
84
111
  * the rows' anchors as usable: that is a partial failure of the caller's operation, not a failed
85
112
  * operation. The best-effort contract is unchanged — this never throws.
113
+ *
114
+ * The context's `fullRead` verdict — not the shape of `rows` — decides whether this serve also
115
+ * performs the full-read effects (clearing retired anchors and hazard cards, overwriting the whole
116
+ * canon array); everything else here belongs to every serve alike (ADR-0035).
86
117
  */
87
- export declare function recordServed(sessionKey: string, path: string, rows: ServedEntry[], lineCount?: number, full?: FullReadContext): Promise<boolean>;
118
+ export declare function recordServed(sessionKey: string, path: string, rows: ServedEntry[], lineCount?: number, full?: ServeContext): Promise<boolean>;
88
119
  /**
89
120
  * Record a truncated serve — the `served` row merge and the lease grant derived from it — as ONE
90
121
  * unit, and report whether it landed.
@@ -99,7 +130,6 @@ export declare function driftReported(sessionKey: string, path: string): Promise
99
130
  export declare function markDriftReported(sessionKey: string, path: string, hashes: string[]): Promise<void>;
100
131
  export declare function clearDriftReported(sessionKey: string, path: string): Promise<void>;
101
132
  export declare function wipeServedState(sessionKey: string): Promise<void>;
102
- export declare function servedPositionsOf(served: (string | null)[], hash: string): number[];
103
133
  export declare function currentPositionOfDrifted(served: (string | null)[], currentPositions: Map<string, number>, surviving: Set<string>, servedIndex: number, delta: number): number;
104
134
  export declare const DRIFT_NOTICE_HEADING = "[USER] drift:";
105
135
  /**
@@ -1,25 +1,26 @@
1
1
  /**
2
- * Store — deep module owning tenancy + lifecycle + path resolution.
2
+ * Store — seam VIEW over tenancy + lifecycle + path resolution.
3
3
  *
4
- * Single seam that answers "which store, where, and is it open?"
5
- * Tenancy (where DB lives) and lifecycle (central GC + row TTL + WAL)
6
- * are private details of this seam; hash-store keeps only schema +
7
- * row-family domain logic and imports path resolution from here.
8
- * StoreConfig remains the config complement seam but its path is
9
- * resolved via this Store seam.
4
+ * Single seam that answers "which store, where, and is it open?" for its
5
+ * consumers. This file owns no behaviour: every export below is a re-export
6
+ * of code owned by a leaf module.
7
+ *
8
+ * Ownership direction, stated once and not to be inverted:
9
+ * `store-config` → `store-tenancy` → this barrel, and `hash-store` → this
10
+ * barrel. The leaves hold the code — `store-tenancy` resolves where the DB
11
+ * lives and imports `loadConfig` FROM `store-config`, which resolves its own
12
+ * path through `resolveDshHome` — while this file is the view they surface
13
+ * through.
10
14
  *
11
15
  * YAGNI-gated: DB plumbing (openDb/buildStore/quarantine/busy-retry/
12
16
  * WAL/legacy JSON migration) stays in hash-store for now and is
13
17
  * re-exported here for testability without importing domain helpers
14
- * — full plumbing move is deferred to avoid contract risk. Old
15
- * store-tenancy/store-lifecycle files are kept as compat shims
16
- * re-exporting from this seam (reversible).
18
+ * — full plumbing move is deferred to avoid contract risk.
17
19
  *
18
20
  * @module dsh-better-edit/store
19
21
  */
20
22
  export { tenancyFor, configDir, hashStorePath, hashStoreDir, legacyHashStorePath, loadConfig, _resetConfigCache, expand, } from "../store-tenancy.js";
21
23
  export type { Tenancy, StoreConfig } from "../store-tenancy.js";
22
24
  export { onStoreOpen, onAppStart, onSessionStart, setStoresGetter, runCentralJanitorIfDue, _resetLifecycleForTests, } from "../store-lifecycle.js";
23
- export { loadConfig as loadStoreConfig } from "../store-config.js";
24
25
  export { isCorruptionError, loadHashStore, shutdownHashStore, withStore, findSnapshotPathsByHashes, upsertSnapshotFor, } from "../hash-store.js";
25
26
  export type { HashStore, InternalHashStore, ServedPersistence } from "../hash-store.js";
@@ -12,7 +12,7 @@ declare const StoreConfigSchema: z.ZodObject<{
12
12
  }, z.core.$strip>;
13
13
  export type StoreConfig = z.infer<typeof StoreConfigSchema>;
14
14
  /** Default config.yaml content with comments — generated when the file does not exist. */
15
- 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# encoding: deterministic BOM\u2192UTF-8 first, guessing only when autoGuessEncoding:true\n# when true, FS_NOT_TEXT scores supportedEncodings and surfaces top-3 previews for model pick\nautoGuessEncoding: false\n# when true, legacy files (GBK etc.) migrate to UTF-8 on first write\nnormalizeToUtf8: false\n# allowlist scored for top-3 previews when autoGuessEncoding:true\nsupportedEncodings: [gbk, big5, shift_jis, euc-kr, windows-1251, iso-8859-1]\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";
15
+ export declare const DEFAULT_CONFIG_YAML: string;
16
16
  /**
17
17
  * Ensure a default config.yaml exists in the plugin home.
18
18
  * Idempotent and concurrent-safe (wx) — never overwrites an existing file.
@@ -1,11 +1,21 @@
1
- import type { HashStore } from "./hash-store.js";
1
+ import type { VacuumResult } from "./snapshot-store/index.js";
2
+ /**
3
+ * The store face `onStoreOpen` calls, typed structurally: the handle is a leaf here, and
4
+ * importing the store's own type re-closes the `hash-store ↔ store-lifecycle` cycle.
5
+ */
6
+ interface OpenStoreFace {
7
+ pruneUndoOlderThan(ts: number): void;
8
+ pruneMissing(): Promise<void>;
9
+ vacuumSnapshots(): VacuumResult;
10
+ }
2
11
  export declare function setStoresGetter(getS: () => Map<string, {
3
12
  path: string;
4
13
  }>, getO: () => Map<string, Promise<any>>): void;
5
14
  export declare function runCentralJanitorIfDue(): Promise<void>;
6
15
  export declare function onStoreOpen(storePath: string, stmts: {
7
16
  servedPruneOlderThan: (ts: number) => void;
8
- }, store: HashStore): Promise<void>;
17
+ }, store: OpenStoreFace): Promise<void>;
9
18
  export declare function onAppStart(): Promise<void>;
10
19
  export declare function onSessionStart(): Promise<void>;
11
20
  export declare function _resetLifecycleForTests(): void;
21
+ export {};
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * The dsh `edit` tool: hash-anchored literal range edits that shadow the
3
3
  * built-in `edit` on the agent's own scope layer. Now the sole mutation tool
4
- * (batch_edit removed, ADR-0007): payload is { file: string|null, edits: [{anchor_from,anchor_to,replace_with},...] }
5
- * single-file atomic batch, legacy null file inference via anchors.
4
+ * (batch_edit removed, ADR-0007): payload is { file: string, edits: [{anchor_from,anchor_to,replace_with},...] }
5
+ * single-file atomic batch; the file is named explicitly, never inferred (#117).
6
6
  * @module dsh-better-edit/tool-edit
7
7
  */
8
- import type { Context } from "@deepseek-ai/cordis";
9
8
  import type { FileIO } from "./fs-bridge.js";
10
9
  import type { FsSandboxController } from "./sandbox.js";
11
10
  export declare function buildEditTool(io: FileIO, sandbox: FsSandboxController): import("@deepseek-ai/dsh-tools").ToolDefinition;
12
- export declare function registerEditTool(_rootCtx: Context, agentCtx: Context, io: FileIO, sandbox: FsSandboxController): () => void;
@@ -5,7 +5,6 @@
5
5
  * shown the lines it targets.
6
6
  * @module dsh-better-edit/tool-read
7
7
  */
8
- import type { Context } from "@deepseek-ai/cordis";
9
8
  import type { FileIO } from "./fs-bridge.js";
10
9
  /**
11
10
  * Register the hash-anchored `read` tool on the calling agent's scope.
@@ -15,7 +14,3 @@ import type { FileIO } from "./fs-bridge.js";
15
14
  * @returns the exact disposer that unregisters the tool.
16
15
  */
17
16
  export declare function buildReadTool(io: FileIO): import("@deepseek-ai/dsh-tools").ToolDefinition;
18
- /**
19
- * Register the hashline tool on the calling agent’s scope (own layer).
20
- */
21
- export declare function registerReadTool(_rootCtx: Context, agentCtx: Context, io: FileIO): () => void;
@@ -25,9 +25,3 @@ import type { FsSandboxController } from "./sandbox.js";
25
25
  import type { FileIO } from "./fs-bridge.js";
26
26
  export declare const STR_REPLACE_EDITOR_DESCRIPTION: string;
27
27
  export declare function buildStrReplaceEditorTool(io: FileIO, sandbox: FsSandboxController): import("@deepseek-ai/dsh-tools").ToolDefinition;
28
- /** Register the shadow `str_replace_editor` on the calling agent's scope (own layer). */
29
- export declare function registerStrReplaceEditorTool(agentCtx: {
30
- tools: {
31
- register(def: unknown): () => void;
32
- };
33
- }, io: FileIO, sandbox: FsSandboxController): () => void;
@@ -4,7 +4,6 @@
4
4
  * external write clears the history instead of being overwritten.
5
5
  * @module dsh-better-edit/tool-undo
6
6
  */
7
- import type { Context } from "@deepseek-ai/cordis";
8
7
  import type { FileIO } from "./fs-bridge.js";
9
8
  import type { FsSandboxController } from "./sandbox.js";
10
9
  /**
@@ -15,7 +14,3 @@ import type { FsSandboxController } from "./sandbox.js";
15
14
  * @returns the exact disposer that unregisters the tool.
16
15
  */
17
16
  export declare function buildUndoTool(io: FileIO, sandbox: FsSandboxController): import("@deepseek-ai/dsh-tools").ToolDefinition;
18
- /**
19
- * Register the hashline tool on the calling agent’s scope (own layer).
20
- */
21
- export declare function registerUndoTool(_rootCtx: Context, agentCtx: Context, io: FileIO, sandbox: FsSandboxController): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-edit",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "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.",
5
5
  "keywords": [
6
6
  "anchors",
@@ -94,7 +94,8 @@
94
94
  }
95
95
  },
96
96
  "scripts": {
97
- "build": "tsc -p tsconfig.json",
97
+ "build": "pnpm run clean && tsc -p tsconfig.json",
98
+ "clean": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\"",
98
99
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
99
100
  "typecheck:test": "tsc --noEmit -p tsconfig.test.json",
100
101
  "test": "vitest run",
package/lib/drift.js DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
3
- * @module dsh-better-edit/drift
4
- */
5
- export * from "./session-view.js";
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
3
- * @module dsh-better-edit/dsh-context
4
- */
5
- export * from "./session-view.js";
@@ -1,7 +0,0 @@
1
- /**
2
- * @deprecated — private to Mutation seam. Use `from "./mutation/engine.js"` instead.
3
- * Thin shim re-exporting the engine now owned by Mutation.
4
- * @module dsh-better-edit/edit-engine
5
- */
6
- export * from "./mutation/engine.js";
7
- export { persistUndoAndWrite, commit, commitSingle, commitBatch } from "./mutation.js";
@@ -1,9 +0,0 @@
1
- import { isRec, normalizeFilePath } from "./utils.js";
2
- export function normReq(input) {
3
- if (!isRec(input)) {
4
- return input;
5
- }
6
- const record = { ...input };
7
- normalizeFilePath(record);
8
- return record;
9
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * @deprecated — private to Mutation seam. Use `from "./mutation.js"` instead.
3
- * Thin shim re-exporting the pipeline now owned by Mutation.
4
- * @module dsh-better-edit/edit-pipeline
5
- */
6
- export * from "./mutation.js";
package/lib/file-kind.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @deprecated — private to FileView seam. Use `from "./file-view.js"` instead.
3
- * Thin shim re-exporting the read path now owned by FileView.
4
- * @module dsh-better-edit/file-kind
5
- */
6
- export * from "./file-view.js";
@@ -1,6 +0,0 @@
1
- /**
2
- * @deprecated — private to FileView seam. Use `from "./file-view.js"` instead.
3
- * Thin shim re-exporting the read path now owned by FileView.
4
- * @module dsh-better-edit/file-reader
5
- */
6
- export * from "./file-view.js";
@@ -1,8 +0,0 @@
1
- /**
2
- * Barrel for guidance sub-seams — parse (pure), resolve (IO-light), materialize (IO-heavy).
3
- * Re-exported via `src/guidance.ts` so existing `from "./guidance.js"` imports keep working.
4
- * @module dsh-better-edit/guidance/index
5
- */
6
- export * from "./parse.js";
7
- export * from "./resolve.js";
8
- export * from "./materialize.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to HashAssign seam. Use `from "./hash-assign.js"` instead.
2
- export * from "./hash-assign.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to AnchorPipeline seam. Use `from "./anchor-pipeline.js"` instead.
2
- export * from "./anchor-pipeline.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to HashAssign seam. Use `from "./hash-assign.js"` instead.
2
- export * from "./hash-assign.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to AnchorPipeline seam. Use `from "./anchor-pipeline.js"` instead.
2
- export * from "./anchor-pipeline.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to HashAssign seam. Use `from "./hash-assign.js"` instead.
2
- export * from "./hash-assign.js";
@@ -1,3 +0,0 @@
1
- // @deprecated — private to AnchorPipeline seam. Use `from "./anchor-pipeline.js"` instead.
2
- // stripBarePrefixes, stripDiffPrefixes, swapReversedRanges, valEdit are @internal to AnchorPipeline.
3
- export * from "./anchor-pipeline.js";
@@ -1,2 +0,0 @@
1
- // @deprecated — private to AnchorPipeline seam. Use `from "./anchor-pipeline.js"` instead.
2
- export * from "./anchor-pipeline.js";
@@ -1,65 +0,0 @@
1
- /**
2
- * Debounced preview controller — extracted from buildToolDef so hashline seams
3
- * stay pure and the debounce invariant is testable.
4
- * @module dsh-better-edit/preview-controller
5
- */
6
- export const PREVIEW_DEBOUNCE_MS = 150;
7
- export function getPreviewInput(_args) {
8
- return null;
9
- }
10
- export class DebouncedPreview {
11
- compute;
12
- debounceMs;
13
- constructor(compute, debounceMs = PREVIEW_DEBOUNCE_MS) {
14
- this.compute = compute;
15
- this.debounceMs = debounceMs;
16
- }
17
- renderCall(host, args) {
18
- const { state } = host;
19
- const previewInput = getPreviewInput(args);
20
- if (host.executionStarted || !host.argsComplete || !previewInput) {
21
- this.cancel(state);
22
- return;
23
- }
24
- const argsKey = JSON.stringify(previewInput);
25
- if (state.argsKey === argsKey)
26
- return;
27
- this.cancel(state);
28
- state.argsKey = argsKey;
29
- const previewGeneration = (state.previewGeneration ?? 0) + 1;
30
- state.previewGeneration = previewGeneration;
31
- state.previewTimer = setTimeout(() => {
32
- state.previewTimer = undefined;
33
- this.compute(args, host.cwd)
34
- .then((preview) => {
35
- if (state.argsKey === argsKey && state.previewGeneration === previewGeneration) {
36
- state.preview = preview;
37
- host.invalidate();
38
- }
39
- })
40
- .catch((err) => {
41
- if (state.argsKey === argsKey && state.previewGeneration === previewGeneration) {
42
- state.preview = { error: err instanceof Error ? err.message : String(err) };
43
- host.invalidate();
44
- }
45
- });
46
- }, this.debounceMs);
47
- }
48
- cancel(state) {
49
- if (state.previewTimer) {
50
- clearTimeout(state.previewTimer);
51
- state.previewTimer = undefined;
52
- }
53
- state.argsKey = undefined;
54
- state.preview = undefined;
55
- state.previewGeneration = (state.previewGeneration ?? 0) + 1;
56
- }
57
- clearResult(state) {
58
- if (state.previewTimer) {
59
- clearTimeout(state.previewTimer);
60
- state.previewTimer = undefined;
61
- }
62
- state.preview = undefined;
63
- state.previewGeneration = (state.previewGeneration ?? 0) + 1;
64
- }
65
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * @deprecated — private to FileView seam. Use `from "./file-view.js"` instead.
3
- * Thin shim re-exporting the read path now owned by FileView.
4
- * @module dsh-better-edit/read-render
5
- */
6
- export * from "./file-view.js";
package/lib/schema.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * Shared model-facing parameter schemas for the hashline tools, expressed in
3
- * the dsh schema DSL (not TypeBox). `path` is deliberately NOT `required` at
4
- * the schema level: the tools accept the built-in `file_path` spelling too
5
- * (the implicit parameter root stays open), and enforce path presence in
6
- * `assertEditRequest` after `normalizeFilePath` aliasing.
7
- * @module dsh-better-edit/schema
8
- */
9
- export const replacementTextSchema = {
10
- type: 'string',
11
- description: 'Replacement text as a single string with \\n line separators; every \\n separates lines, so a trailing \\n adds a final empty line. Mirror the removed lines exactly, blank lines included. A replacement that is only blank lines is written as one \\n per blank line. Use "" to delete the range.',
12
- };
13
- export const removeFromSchema = {
14
- type: 'string',
15
- description: 'Bare 3-char HASH only (e.g. "aB3") — copy just the hash from the leftmost column of a read row like `aB3│content`; never the line content. Marks the FIRST line to remove (inclusive)',
16
- };
17
- export const removeToSchema = {
18
- type: 'string',
19
- description: 'Bare 3-char HASH only (e.g. "aB3") — copy just the hash from the leftmost column of a read row like `aB3│content`; never the line content. Marks the LAST line to remove (inclusive)',
20
- };
21
- export const pathSchema = {
22
- type: 'string',
23
- description: 'Path to edit. Required — always provide it explicitly; it is only auto-resolved from the anchors as a fallback when omitted by mistake.',
24
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
3
- * @module dsh-better-edit/served-store
4
- */
5
- export * from "./session-view.js";