dsh-better-edit 0.3.0 → 0.3.2

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 (74) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +9 -5
  3. package/README.zh.md +1 -2
  4. package/lib/constants.js +3 -1
  5. package/lib/contract.js +133 -76
  6. package/lib/drift.js +5 -98
  7. package/lib/dsh-context.js +2 -24
  8. package/lib/edit-engine.js +6 -5
  9. package/lib/edit-pipeline.js +3 -121
  10. package/lib/edit-response.js +16 -8
  11. package/lib/file-kind.js +6 -121
  12. package/lib/file-reader.js +4 -77
  13. package/lib/file-view.js +446 -23
  14. package/lib/fs-bridge.js +39 -1
  15. package/lib/guidance/materialize.js +25 -4
  16. package/lib/guidance/resolve.js +3 -9
  17. package/lib/hash-store.js +6 -3
  18. package/lib/hashline/alphabet.js +2 -6
  19. package/lib/hashline/anchor-pipeline.js +770 -7
  20. package/lib/hashline/apply.js +2 -223
  21. package/lib/hashline/hash-assign.js +248 -13
  22. package/lib/hashline/hash.js +67 -29
  23. package/lib/hashline/hasher.js +2 -23
  24. package/lib/hashline/index.js +7 -1
  25. package/lib/hashline/parse.js +2 -35
  26. package/lib/hashline/pure.js +2 -213
  27. package/lib/hashline/resolve.js +3 -366
  28. package/lib/hashline/served.js +2 -120
  29. package/lib/index.js +0 -2
  30. package/lib/mutation.js +218 -10
  31. package/lib/noop-guard.js +20 -0
  32. package/lib/preview-controller.js +65 -0
  33. package/lib/prompts.js +14 -20
  34. package/lib/read-render.js +3 -139
  35. package/lib/served-store.js +2 -216
  36. package/lib/session-view.js +309 -11
  37. package/lib/tool-edit.js +71 -125
  38. package/lib/tool-undo.js +11 -5
  39. package/lib/truncate.js +3 -95
  40. package/lib/types/constants.d.ts +2 -0
  41. package/lib/types/contract.d.ts +102 -28
  42. package/lib/types/drift.d.ts +5 -29
  43. package/lib/types/dsh-context.d.ts +2 -20
  44. package/lib/types/edit-pipeline.d.ts +3 -44
  45. package/lib/types/file-kind.d.ts +6 -18
  46. package/lib/types/file-reader.d.ts +4 -45
  47. package/lib/types/file-view.d.ts +99 -34
  48. package/lib/types/guidance/materialize.d.ts +3 -3
  49. package/lib/types/guidance/resolve.d.ts +2 -2
  50. package/lib/types/hashline/alphabet.d.ts +1 -5
  51. package/lib/types/hashline/anchor-pipeline.d.ts +111 -10
  52. package/lib/types/hashline/apply.d.ts +1 -22
  53. package/lib/types/hashline/hash-assign.d.ts +25 -19
  54. package/lib/types/hashline/hash.d.ts +8 -9
  55. package/lib/types/hashline/hasher.d.ts +1 -8
  56. package/lib/types/hashline/index.d.ts +7 -1
  57. package/lib/types/hashline/parse.d.ts +1 -7
  58. package/lib/types/hashline/pure.d.ts +1 -26
  59. package/lib/types/hashline/resolve.d.ts +1 -63
  60. package/lib/types/hashline/served.d.ts +1 -43
  61. package/lib/types/mutation.d.ts +63 -10
  62. package/lib/types/noop-guard.d.ts +29 -0
  63. package/lib/types/preview-controller.d.ts +33 -0
  64. package/lib/types/prompts.d.ts +9 -9
  65. package/lib/types/read-render.d.ts +3 -18
  66. package/lib/types/served-store.d.ts +2 -81
  67. package/lib/types/session-view.d.ts +68 -9
  68. package/lib/types/tool-edit.d.ts +3 -14
  69. package/lib/types/truncate.d.ts +3 -29
  70. package/lib/types/validation.d.ts +6 -7
  71. package/lib/types/workspace.d.ts +2 -21
  72. package/lib/validation.js +6 -33
  73. package/lib/workspace.js +2 -27
  74. package/package.json +2 -2
@@ -6,22 +6,22 @@
6
6
  * followed by tight bullets.
7
7
  * @module dsh-better-edit/prompts
8
8
  */
9
- /**
10
- * One tool's guidance: a brief opener plus concise bullets. The `intro` is
11
- * shown above the bullets; it does not duplicate the tool-schema `description`
12
- * (that already reaches the model through the tool catalog).
13
- */
14
9
  export interface ToolGuidance {
15
- /** One-line lead shown above the bullets. */
16
10
  intro: string;
17
- /** Concise bullets; each is self-contained within its section. */
18
11
  lines: readonly string[];
19
12
  }
20
13
  export declare const EDIT_DESCRIPTION: string;
21
14
  export declare const EDIT_GUIDANCE: ToolGuidance;
22
15
  export declare const READ_DESCRIPTION: string;
23
16
  export declare const READ_GUIDANCE: ToolGuidance;
24
- export declare const BATCH_EDIT_DESCRIPTION: string;
25
- export declare const BATCH_EDIT_GUIDANCE: ToolGuidance;
26
17
  export declare const UNDO_DESCRIPTION: string;
27
18
  export declare const UNDO_GUIDANCE: ToolGuidance;
19
+ /**
20
+ * @deprecated batch_edit guidance seam was removed with ADR-0003 (payload contract
21
+ * merged batch_edit into edit's {path, edits:[[hash,hash,text]]} arity). This alias
22
+ * is kept for backwards compat — use EDIT_DESCRIPTION. The guidance system no
23
+ * longer includes tool:batch_edit.
24
+ */
25
+ export declare const BATCH_EDIT_DESCRIPTION: string;
26
+ /** @deprecated see BATCH_EDIT_DESCRIPTION — use EDIT_GUIDANCE */
27
+ export declare const BATCH_EDIT_GUIDANCE: ToolGuidance;
@@ -1,21 +1,6 @@
1
1
  /**
2
- * Hash-anchored read rendering: turn normalized text into `HASH│content` rows
3
- * with pagination hints, oversized-line markers, and served-row bookkeeping.
4
- * Ported from pi-hashline-edit-lsz's read tool (pi APIs replaced by local
5
- * helpers).
2
+ * @deprecated — private to FileView seam. Use `from "./file-view.js"` instead.
3
+ * Thin shim re-exporting the read path now owned by FileView.
6
4
  * @module dsh-better-edit/read-render
7
5
  */
8
- import { MAX_HASH_LINES } from './hashline/index.js';
9
- import type { ServedRow } from './hashline/served.js';
10
- import { type TruncationResult } from './truncate.js';
11
- export declare function formatPaginationHint(startLine: number, endLine: number, totalLines: number, nextOffset: number, byteLimit?: number): string;
12
- export declare function fmtReadPreview(text: string, options: {
13
- offset?: number;
14
- limit?: number;
15
- }, precomputedHashes?: string[], path?: string, maxLineBytes?: number, maxTruncLines?: number): Promise<{
16
- text: string;
17
- truncation?: TruncationResult;
18
- nextOffset?: number;
19
- served: ServedRow[];
20
- }>;
21
- export { MAX_HASH_LINES };
6
+ export * from "./file-view.js";
@@ -1,84 +1,5 @@
1
1
  /**
2
- * Served state — what the model has been shown, per session and path.
3
- *
4
- * This is the ONE module that owns the served-state concept: the served-row
5
- * merge invariant, the reported-drift set, and the position-reconstruction
6
- * math used by drift notices. Persistence goes through the hash store's
7
- * served domain API (`hash-store.ts`); the reject-and-serve errors and range
8
- * verification live with the hashline module (`hashline/served.ts`); drift
9
- * computation lives in `drift.ts`. Both import from here.
10
- *
11
- * The API is async-only: every operation loads the per-workspace hash store
12
- * and resolves it through the active workspace context. There is deliberately
13
- * no sync half — the two-vocabulary, every-op-twice surface it produced is
14
- * gone.
2
+ * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
15
3
  * @module dsh-better-edit/served-store
16
4
  */
17
- export type ServedEntry = {
18
- position: number;
19
- hash: string | null;
20
- };
21
- /**
22
- * Map a caller to the served-state session key. dsh passes the live session id
23
- * (`exec.agent.session.id`); callers without one (tests, previews) share a
24
- * process-local fallback so hashline verification never fabricates a session.
25
- */
26
- export declare function sessionKeyFor(sessionId?: string): string;
27
- /**
28
- * Merge served rows into a copy of the stored array. This single helper owns
29
- * the served-merge invariant shared by {@link recordServed} and
30
- * {@link recordServedTruncated}:
31
- *
32
- * - positions are validated before anything is written (invalid rows throw
33
- * and never reach the store);
34
- * - when `truncateTo` is given, positions beyond the file's line count are
35
- * dropped FIRST — a serve of the current file state must never leave a hash
36
- * at an old position beyond the line count, because that stale claim makes
37
- * a chained edit's boundary anchor look ambiguous (`E_RANGE_UNVERIFIED`,
38
- * "served at N positions") instead of verifying cleanly;
39
- * - when `clearFrom` is given, positions at/after the mutation's first
40
- * changed line are re-shaped by the edit, so the model's previous view of
41
- * them is cleared before the diff rows land;
42
- * - trailing never-served markers are trimmed so an empty tail never grows
43
- * the stored array.
44
- *
45
- * Underscore-prefixed: internal, exported only so the invariant has a direct
46
- * test seam.
47
- */
48
- export declare function _mergeServedRows(current: (string | null)[], rows: ServedEntry[], options?: {
49
- truncateTo?: number;
50
- clearFrom?: number;
51
- }): (string | null)[];
52
- /** The served array for one session+path, or `[]` when nothing was served. */
53
- export declare function loadServed(sessionKey: string, path: string): Promise<(string | null)[]>;
54
- /**
55
- * Record served rows for one session+path. Without `lineCount` the rows merge
56
- * into the stored array as-is; with it, the stored array is truncated to the
57
- * file's current line count before the rows land (see
58
- * {@link _mergeServedRows} for why). Failures are logged, never thrown — a
59
- * store problem must not fail the read that produced these rows.
60
- */
61
- export declare function recordServed(sessionKey: string, path: string, rows: ServedEntry[], lineCount?: number): Promise<void>;
62
- /**
63
- * Record post-mutation diff serves against the file's CURRENT length. The
64
- * stored array is truncated to `lineCount` and cleared from `clearFrom`
65
- * (the edit's first changed line) before the diff rows land, so a hash that
66
- * survived into the diff never keeps its pre-edit position claim.
67
- */
68
- export declare function recordServedTruncated(sessionKey: string, path: string, rows: ServedEntry[], lineCount: number, clearFrom?: number): Promise<void>;
69
- /** The hashes already reported as drifted for one session+path. */
70
- export declare function driftReported(sessionKey: string, path: string): Promise<Set<string>>;
71
- /** Mark hashes as already reported as drifted, so later notices skip them. */
72
- export declare function markDriftReported(sessionKey: string, path: string, hashes: string[]): Promise<void>;
73
- /** Clear the reported-drift set for one session+path (a fresh read resets it). */
74
- export declare function clearDriftReported(sessionKey: string, path: string): Promise<void>;
75
- /** Drop every served row and reported-drift mark for one session. */
76
- export declare function wipeServedState(sessionKey: string): Promise<void>;
77
- /** Every served position of a hash in a served array (the E_RANGE_UNVERIFIED probe). */
78
- export declare function servedPositionsOf(served: (string | null)[], hash: string): number[];
79
- /**
80
- * Reconstruct where a drifted hash sits in the current file: map through the
81
- * nearest surviving served neighbor (below, else above), else fall back to
82
- * the served index plus the range's line delta.
83
- */
84
- export declare function currentPositionOfDrifted(served: (string | null)[], currentPositions: Map<string, number>, surviving: Set<string>, servedIndex: number, delta: number): number;
5
+ export * from "./session-view.js";
@@ -7,10 +7,10 @@
7
7
  * + recording drift rows) — a side effect hidden inside a "notice" module.
8
8
  *
9
9
  * This seam co-locates that invariant. Public surface:
10
- * view(sessionKey, path) → {served, reported}
10
+ * view(sessionKey, path) -> {served, reported}
11
11
  * recordRead(sessionKey, path, rows, lineCount)
12
12
  * recordEdit(sessionKey, path, rows, lineCount, clearFrom)
13
- * scanDrift(sessionKey, path, resultHashes, resultLines, range) → notice?
13
+ * scanDrift(sessionKey, path, resultHashes, resultLines, range) -> notice?
14
14
  * servedPositionsOf, currentPositionOfDrifted, _mergeServedRows (via served-store)
15
15
  *
16
16
  * Explicit Workspace note: loadHashStore(cwd) now requires cwd. The
@@ -20,14 +20,73 @@
20
20
  * via served-store still fall back to workspaceCwd() for backwards compat
21
21
  * but are marked deprecated.
22
22
  *
23
+ * Ownership: This file now OWNS the served-merge invariant
24
+ * (_mergeServedRows), the position-reconstruction math, and the drift
25
+ * computation. Deleting it would scatter the served+drift invariant
26
+ * across 4 files — it concentrates (deep).
27
+ *
23
28
  * @module dsh-better-edit/session-view
24
29
  */
25
- export { sessionKeyFor, _mergeServedRows, loadServed, recordServed, recordServedTruncated, driftReported, markDriftReported, clearDriftReported, wipeServedState, servedPositionsOf, currentPositionOfDrifted, } from "./served-store.js";
26
- export type { ServedEntry } from "./served-store.js";
27
- export { computeDrift, scanDrift, DRIFT_NOTICE_HEADING } from "./drift.js";
28
- export type { DriftRow, ComputeDriftInput, DriftNoticeResult, } from "./drift.js";
29
- export { withWorkspace, workspaceCwd } from "./workspace.js";
30
- export { execCwd, execSessionKey } from "./dsh-context.js";
31
- export { configDir, hashStorePath, resolveTarget } from "./paths.js";
30
+ import type { ToolExecution } from "@deepseek-ai/dsh-tools";
31
+ import type { ServedRow, ResolvedRange } from "./hashline/served.js";
32
+ import { configDir, hashStorePath, resolveTarget } from "./paths.js";
33
+ export declare function withWorkspace<T>(cwd: string, fn: () => Promise<T>): Promise<T>;
34
+ export declare function workspaceCwd(): string | undefined;
35
+ export declare function sessionKeyFor(sessionId?: string): string;
36
+ export declare function execCwd(exec: ToolExecution): string;
37
+ export declare function execSessionKey(exec: ToolExecution): string;
38
+ export { configDir, hashStorePath, resolveTarget };
32
39
  export { loadHashStore, shutdownHashStore, withStore } from "./hash-store.js";
33
40
  export type { HashStore } from "./hash-store.js";
41
+ export type ServedEntry = {
42
+ position: number;
43
+ hash: string | null;
44
+ };
45
+ /**
46
+ * Merge served rows into a copy of the stored array. This single helper owns
47
+ * the served-merge invariant shared by recordServed and recordServedTruncated.
48
+ * Eagerly heals orphaned serves: if the same hash is written at a new position
49
+ * the old position is nulled (O(n) scan, no extra I/O). This prevents a
50
+ * partial re-serve from leaving a stale duplicate behind (ADR-0008).
51
+ */
52
+ export declare function _mergeServedRows(current: (string | null)[], rows: ServedEntry[], options?: {
53
+ truncateTo?: number;
54
+ clearFrom?: number;
55
+ }): (string | null)[];
56
+ export declare function loadServed(sessionKey: string, path: string): Promise<(string | null)[]>;
57
+ export declare function recordServed(sessionKey: string, path: string, rows: ServedEntry[], lineCount?: number): Promise<void>;
58
+ export declare function recordServedTruncated(sessionKey: string, path: string, rows: ServedEntry[], lineCount: number, clearFrom?: number): Promise<void>;
59
+ export declare function driftReported(sessionKey: string, path: string): Promise<Set<string>>;
60
+ export declare function markDriftReported(sessionKey: string, path: string, hashes: string[]): Promise<void>;
61
+ export declare function clearDriftReported(sessionKey: string, path: string): Promise<void>;
62
+ export declare function wipeServedState(sessionKey: string): Promise<void>;
63
+ export declare function servedPositionsOf(served: (string | null)[], hash: string): number[];
64
+ export declare function currentPositionOfDrifted(served: (string | null)[], currentPositions: Map<string, number>, surviving: Set<string>, servedIndex: number, delta: number): number;
65
+ export declare const DRIFT_NOTICE_HEADING = "drift:";
66
+ export interface DriftRow extends ServedRow {
67
+ content: string;
68
+ drifted: boolean;
69
+ }
70
+ export interface ComputeDriftInput {
71
+ served: (string | null)[];
72
+ resultHashes: string[];
73
+ resultLines: string[];
74
+ range: ResolvedRange;
75
+ reported: Set<string>;
76
+ cap?: number;
77
+ }
78
+ export interface DriftNoticeResult {
79
+ text: string;
80
+ rows: DriftRow[];
81
+ total: number;
82
+ allAlreadyReported: boolean;
83
+ }
84
+ export declare function computeDrift(input: ComputeDriftInput): DriftNoticeResult | undefined;
85
+ export declare function scanDrift(input: {
86
+ sessionKey: string;
87
+ served: (string | null)[];
88
+ resultHashes: string[];
89
+ resultLines: string[];
90
+ range: ResolvedRange;
91
+ path: string;
92
+ }): Promise<string | undefined>;
@@ -1,23 +1,12 @@
1
1
  /**
2
2
  * The dsh `edit` tool: hash-anchored literal range edits that shadow the
3
- * built-in `edit` on the agent's own scope layer. Registered through the
4
- * agent context so the model-facing contract (remove_from/remove_to hashes,
5
- * served-range verification, reject-and-serve) replaces the built-in one.
3
+ * built-in `edit` on the agent's own scope layer. Now the sole mutation tool
4
+ * (batch_edit removed, ADR-0007): payload is { path: string|null, edits: [[remove_from,remove_to,replacement_text],...] }
5
+ * single-file atomic batch, null path inference via anchors.
6
6
  * @module dsh-better-edit/tool-edit
7
7
  */
8
8
  import type { Context } from "@deepseek-ai/cordis";
9
9
  import type { FileIO } from "./fs-bridge.js";
10
10
  import type { FsSandboxController } from "./sandbox.js";
11
- /**
12
- * Register the hash-anchored `edit` tool on the calling agent's scope.
13
- * @param _rootCtx - host context (logger, lifecycle).
14
- * @param agentCtx - the agent's scoped context; registrations here land on the
15
- * agent's OWN scope layer, shadowing the preset's built-in `edit`.
16
- * @param io - the filesystem bridge (ctx.fs backed in deployment).
17
- * @returns the exact disposer that unregisters the tool.
18
- */
19
11
  export declare function buildEditTool(io: FileIO, sandbox: FsSandboxController): import("@deepseek-ai/dsh-tools").ToolDefinition;
20
- /**
21
- * Register the hashline tool on the calling agent’s scope (own layer).
22
- */
23
12
  export declare function registerEditTool(_rootCtx: Context, agentCtx: Context, io: FileIO, sandbox: FsSandboxController): () => void;
@@ -1,32 +1,6 @@
1
1
  /**
2
- * Truncation utilities for read output (ported from pi-coding-agent's shared
3
- * tool rendering): keep the head of a text payload within line and byte caps,
4
- * never emitting partial lines.
2
+ * @deprecated — private to FileView seam. Use `from "./file-view.js"` instead.
3
+ * Thin shim re-exporting the read path now owned by FileView.
5
4
  * @module dsh-better-edit/truncate
6
5
  */
7
- export declare const DEFAULT_MAX_LINES = 2000;
8
- export declare const DEFAULT_MAX_BYTES: number;
9
- export interface TruncationResult {
10
- content: string;
11
- truncated: boolean;
12
- truncatedBy: 'lines' | 'bytes' | null;
13
- totalLines: number;
14
- totalBytes: number;
15
- outputLines: number;
16
- outputBytes: number;
17
- lastLinePartial: boolean;
18
- firstLineExceedsLimit: boolean;
19
- maxLines: number;
20
- maxBytes: number;
21
- }
22
- /** Format bytes as a human-readable size. */
23
- export declare function formatSize(bytes: number): string;
24
- /**
25
- * Truncate content from the head (keep the first N lines/bytes). Suitable for
26
- * file reads; never returns partial lines. When the first line alone exceeds
27
- * the byte limit the content is emptied with `firstLineExceedsLimit`.
28
- */
29
- export declare function truncateHead(content: string, options?: {
30
- maxLines?: number;
31
- maxBytes?: number;
32
- }): TruncationResult;
6
+ export * from "./file-view.js";
@@ -1,7 +1,6 @@
1
- import type { LFile } from "./file-kind.js";
2
- export declare function valAccess(absolutePath: string, path: string, accessMode?: number): Promise<void>;
3
- export declare function valKind(file: LFile, path: string): asserts file is {
4
- kind: "text";
5
- text: string;
6
- hadUtf8DecodeErrors?: true;
7
- };
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/validation
5
+ */
6
+ export * from "./file-view.js";
@@ -1,24 +1,5 @@
1
1
  /**
2
- * Per-call workspace context. dsh serves several sessions in one process, each
3
- * with its own cwd, and only the tool execution knows which one it belongs to —
4
- * so a module-global "current cwd" would race between parallel sessions. The
5
- * store path is derived per tool call from the session cwd; this module carries
6
- * that cwd through the async execution so every store access inside the call
7
- * (served rows, undo, hash snapshots) lands in the right per-workspace store.
2
+ * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
8
3
  * @module dsh-better-edit/workspace
9
4
  */
10
- /**
11
- * Run `fn` with the given workspace cwd active for this async execution.
12
- * Every `loadHashStore()` (and any store access) inside `fn` resolves the
13
- * `<cwd>/.dsh_better_edit` store.
14
- * @param cwd - the session workspace root (absolute).
15
- * @param fn - the tool body.
16
- * @returns the body's result.
17
- */
18
- export declare function withWorkspace<T>(cwd: string, fn: () => Promise<T>): Promise<T>;
19
- /**
20
- * The workspace cwd active for this async execution, or undefined outside a
21
- * tool call (tests, previews, startup) — callers fall back to the shared
22
- * `$DSH_HOME` store then.
23
- */
24
- export declare function workspaceCwd(): string | undefined;
5
+ export * from "./session-view.js";
package/lib/validation.js CHANGED
@@ -1,33 +1,6 @@
1
- import { constants } from "node:fs";
2
- import { access as fsAccess } from "fs/promises";
3
- import { errCode } from "./utils.js";
4
- export async function valAccess(absolutePath, path, accessMode = constants.R_OK) {
5
- try {
6
- await fsAccess(absolutePath, accessMode);
7
- }
8
- catch (error) {
9
- const code = errCode(error);
10
- if (code === "ENOENT") {
11
- throw new Error(`[E_NOT_FOUND] File not found: ${path}`);
12
- }
13
- if (code === "EACCES" || code === "EPERM") {
14
- const accessLabel = accessMode & constants.W_OK ? "not writable" : "not readable";
15
- throw new Error(`[E_ACCESS] File is ${accessLabel}: ${path}`);
16
- }
17
- if (code === "ELOOP") {
18
- throw new Error(`[E_ACCESS] Too many symbolic links while resolving: ${path}`);
19
- }
20
- throw new Error(`[E_ACCESS] Cannot access file: ${path}`);
21
- }
22
- }
23
- export function valKind(file, path) {
24
- if (file.kind === "directory") {
25
- throw new Error(`[E_NOT_TEXT] Path is a directory: ${path}. Use ls to inspect directories.`);
26
- }
27
- if (file.kind === "binary") {
28
- throw new Error(`[E_NOT_TEXT] Path is a binary file: ${path} (${file.description}). Hashline edit only supports text files.`);
29
- }
30
- if (file.kind === "image") {
31
- throw new Error(`[E_NOT_TEXT] Path is an image file: ${path}. Hashline edit only supports text files.`);
32
- }
33
- }
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/validation
5
+ */
6
+ export * from "./file-view.js";
package/lib/workspace.js CHANGED
@@ -1,30 +1,5 @@
1
1
  /**
2
- * Per-call workspace context. dsh serves several sessions in one process, each
3
- * with its own cwd, and only the tool execution knows which one it belongs to —
4
- * so a module-global "current cwd" would race between parallel sessions. The
5
- * store path is derived per tool call from the session cwd; this module carries
6
- * that cwd through the async execution so every store access inside the call
7
- * (served rows, undo, hash snapshots) lands in the right per-workspace store.
2
+ * @deprecated — private to SessionView seam. Use `from "./session-view.js"` instead.
8
3
  * @module dsh-better-edit/workspace
9
4
  */
10
- import { AsyncLocalStorage } from 'node:async_hooks';
11
- const current = new AsyncLocalStorage();
12
- /**
13
- * Run `fn` with the given workspace cwd active for this async execution.
14
- * Every `loadHashStore()` (and any store access) inside `fn` resolves the
15
- * `<cwd>/.dsh_better_edit` store.
16
- * @param cwd - the session workspace root (absolute).
17
- * @param fn - the tool body.
18
- * @returns the body's result.
19
- */
20
- export function withWorkspace(cwd, fn) {
21
- return current.run(cwd, fn);
22
- }
23
- /**
24
- * The workspace cwd active for this async execution, or undefined outside a
25
- * tool call (tests, previews, startup) — callers fall back to the shared
26
- * `$DSH_HOME` store then.
27
- */
28
- export function workspaceCwd() {
29
- return current.getStore();
30
- }
5
+ export * from "./session-view.js";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-better-edit",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
- "description": "Hash-anchored read/edit/batch_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
+ "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",
7
7
  "types": "lib/types/index.d.ts",
8
8
  "exports": {