dsh-better-edit 1.2.3 → 1.2.4

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,61 @@
1
+ /**
2
+ * Preset tool-policy gate: which hashline-owned tools one agent install may
3
+ * register. The registry cannot enforce a preset's policy for this plugin —
4
+ * scope restrictions filter only *inherited* tools, never a scope's own
5
+ * registrations (Rianico/dsh-better-edit#110) — so the install consults the
6
+ * composed preset's own layer instead.
7
+ *
8
+ * `read` is unconditional: it is the plugin's core capability and the source of
9
+ * every anchor. Every mutating tool is installed only when the preset's layer
10
+ * resolves the matching tool, which keeps `edit` paired with `read` and never
11
+ * shadows a tool the preset did not compose.
12
+ *
13
+ * The probe is an optional-service seam: no `agentPresets` service, no composed
14
+ * preset (preset-free composition), or no scope-read API (`acquireScope` on
15
+ * 0.2.x, `standingKeyFor` on older registries) keeps today's unconditional
16
+ * install, so a host that predates 0.2.1 keeps its pre-gate behavior.
17
+ * @module dsh-better-edit/preset-toolset
18
+ */
19
+ import type { Context } from "@deepseek-ai/cordis";
20
+ /** The hashline-owned tools one install may register. `read` is always installed. */
21
+ export interface HashlineToolset {
22
+ /** The hashline `edit` (also gates `undo`). */
23
+ edit: boolean;
24
+ /** The governed `str_replace_editor` shadow (ADR-0015). */
25
+ strReplaceEditor: boolean;
26
+ /** `undo_last_edit` — follows {@link HashlineToolset.edit}, see {@link toolsetFor}. */
27
+ undo: boolean;
28
+ /** A preset that neither resolves `write` nor composed one needs no guard. */
29
+ writeHook: boolean;
30
+ }
31
+ /** Today's install — the fallback for every composition the gate cannot read. */
32
+ export declare const UNCONDITIONAL_TOOLSET: HashlineToolset;
33
+ /**
34
+ * Derive the toolset from one predicate over preset tool names. `undo` follows
35
+ * `edit` because `undo_last_edit` reverts only hashline edits: installing it
36
+ * beside no `edit` would advertise a history that can never exist.
37
+ */
38
+ export declare function toolsetFor(resolves: (name: string) => boolean): HashlineToolset;
39
+ /**
40
+ * Keep only the guidance sections whose tool was installed. `tool:read` always
41
+ * stays; the edit and undo sections follow their tools so the prompt never
42
+ * advertises a catalog entry the agent does not have.
43
+ */
44
+ export declare function sectionsForToolset<T extends {
45
+ name: string;
46
+ }>(sections: readonly T[], toolset: HashlineToolset): T[];
47
+ /** The host surface the probe touches; `logger` is optional so a bare host works. */
48
+ export interface PresetProbeHost {
49
+ get(service: string): object | undefined;
50
+ logger?: {
51
+ warn(message: string): void;
52
+ };
53
+ }
54
+ /**
55
+ * Resolve the toolset for one agent from its composed preset. Every failure —
56
+ * a missing service, an unreadable preset, a rejected scope read, or a throwing
57
+ * registry — falls back to {@link UNCONDITIONAL_TOOLSET} (and warns), never to a
58
+ * smaller set: the gate may only ever remove a tool it has positively seen the
59
+ * preset decline.
60
+ */
61
+ export declare function resolveToolset(host: PresetProbeHost, agentCtx: Context): Promise<HashlineToolset>;
@@ -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;
@@ -60,6 +60,16 @@ export declare function loadRetiredAnchors(sessionKey: string, path: string): Pr
60
60
  export declare function retireAnchorsInStore(store: ServedPersistence, sessionKey: string, path: string, hashes: Iterable<string>): void;
61
61
  /** Keep freed anchors dead for this session until it has seen the whole file again. */
62
62
  export declare function retireAnchors(sessionKey: string, path: string, hashes: Iterable<string>): Promise<void>;
63
+ /**
64
+ * Caller-owned transaction: revive retired anchors inside the caller's unit.
65
+ *
66
+ * The undo restore is the one path that brings a retired assignment back: when the
67
+ * pre-edit line returns byte-identically, its pre-edit anchor is live again, so the
68
+ * retirement that the edit recorded must move with the restore (ADR-0017 reversal).
69
+ * Anchors not in the store's retired set are left untouched; the entry's `deathPos`
70
+ * does not matter — the anchor's line is back, so the whole entry goes.
71
+ */
72
+ export declare function unretireAnchorsInStore(store: ServedPersistence, sessionKey: string, path: string, hashes: Iterable<string>): void;
63
73
  /** Full-file context for a complete read — when present and matching `rows`, the call is a full read. */
64
74
  export interface FullReadContext {
65
75
  hashes: readonly string[];
@@ -1,8 +1,8 @@
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
8
  import type { Context } from "@deepseek-ai/cordis";
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.4",
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",