dsh-hashline-edit 0.3.5 → 0.3.6
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.
- package/README.md +3 -2
- package/lib/index.js +16 -10
- package/lib/types/dsh/hide.d.ts +9 -8
- package/lib/types/dsh/index.d.ts +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Hash-anchored file editing for [DeepSeek Harness](https://github.com/deepseek-ai) (dsh) on Windows.
|
|
4
4
|
|
|
5
|
-
`dsh-hashline-edit` is a dsh bundle that shadows the host's built-in `read` with hash-anchored output, registers `apply_patch`
|
|
5
|
+
`dsh-hashline-edit` is a dsh bundle that shadows the host's built-in `read` with hash-anchored output, registers `apply_patch` for precise and batch text changes, and adds `undo_last_edit`. The host's built-in `write` stays visible and is integrated by the write hook; the native `edit`/`str_replace_editor` surface is hidden; there is no pi host support, because this package targets DeepSeek Harness only. Every line a served read shows carries a stable 3- or 4-character base62 anchor (`A–Z`, `a–z`, `0–9`; the width is a build-time setting, see [Anchor width](#anchor-width)) derived from the file's canonical path and the line's content. An `apply_patch` hunk either names served anchors or matches file content; the model never re-types existing code. Anchors for unchanged lines stay stable across edits, and every successful `apply_patch` call returns fresh anchors for the changed lines, so chained calls need no re-read.
|
|
6
6
|
|
|
7
7
|
The semantic core is the [pi-better-edit](https://github.com/Rianico/pi-better-edit) v2.16.0 hashline engine (MIT), carried as an internal engine; the pi host integration has been removed. The `dsh/` tree is this repository's DeepSeek Harness host layer: tool registration, filesystem bridge, UTF-8-only admission, prompt guidance, shell integration, write integration and telemetry. See [`dsh/README.md`](dsh/README.md) for the host-layer map.
|
|
8
8
|
|
|
@@ -107,7 +107,8 @@ read({
|
|
|
107
107
|
|
|
108
108
|
### `apply_patch`
|
|
109
109
|
|
|
110
|
-
The
|
|
110
|
+
The precise and batch file-mutation entry point; the host's built-in `write` stays
|
|
111
|
+
available for whole-file rewrites. One call carries one Codex patch document and commits the whole
|
|
111
112
|
batch as one correlated transaction (pre-mirror, undo rows, deterministic member order, all-or-nothing
|
|
112
113
|
rollback, then per-file store commits).
|
|
113
114
|
|
package/lib/index.js
CHANGED
|
@@ -1376,8 +1376,8 @@ function assertRange(offset, length) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
1378
|
// dsh/hide.ts
|
|
1379
|
-
var
|
|
1380
|
-
var GUIDANCE_SECTIONS = /* @__PURE__ */ new Set(["tool:
|
|
1379
|
+
var NATIVE_EDITOR_TOOLS = ["edit", "str_replace_editor"];
|
|
1380
|
+
var GUIDANCE_SECTIONS = /* @__PURE__ */ new Set(["tool:edit"]);
|
|
1381
1381
|
function readBooleanSource(value, fallback) {
|
|
1382
1382
|
if (typeof value === "boolean") return value;
|
|
1383
1383
|
if (typeof value === "function") {
|
|
@@ -1404,7 +1404,7 @@ function sanitizeHiddenToolNames(config) {
|
|
|
1404
1404
|
return names;
|
|
1405
1405
|
}
|
|
1406
1406
|
function hiddenNames(config) {
|
|
1407
|
-
const names = readBooleanSource(config.hideNativeWriteTools, true) ? [...
|
|
1407
|
+
const names = readBooleanSource(config.hideNativeWriteTools, true) ? [...NATIVE_EDITOR_TOOLS] : [];
|
|
1408
1408
|
const seen = new Set(names);
|
|
1409
1409
|
for (const name2 of sanitizeHiddenToolNames(config)) {
|
|
1410
1410
|
if (!seen.has(name2)) {
|
|
@@ -1414,8 +1414,8 @@ function hiddenNames(config) {
|
|
|
1414
1414
|
}
|
|
1415
1415
|
return names.filter((name2) => name2 !== config.toolName);
|
|
1416
1416
|
}
|
|
1417
|
-
function
|
|
1418
|
-
return `\`${name2}\` is disabled in this profile: precise and batch text changes go through \`${toolName}\` operations. Collect every planned file change into one call. Reading stays with \`read\`, \`glob\`, and \`grep\`; whole-file replacement is one \`*** Update File:\` identity hunk spanning every served line.`;
|
|
1417
|
+
function nativeEditorDenial(toolName, name2) {
|
|
1418
|
+
return `\`${name2}\` is disabled in this profile: precise and batch text changes go through \`${toolName}\` operations. Collect every planned file change into one call. Reading stays with \`read\`, \`glob\`, and \`grep\`; whole-file replacement is one \`*** Update File:\` identity hunk spanning every served line; the built-in \`write\` remains available for whole-file rewrites.`;
|
|
1419
1419
|
}
|
|
1420
1420
|
function transformAssembly(assembly, hidden) {
|
|
1421
1421
|
if (hidden.size === 0) return;
|
|
@@ -1555,7 +1555,7 @@ function registerNativeToolHiding(rootCtx, agentCtx, config) {
|
|
|
1555
1555
|
});
|
|
1556
1556
|
if (disposeAssemble !== void 0) disposers.push(disposeAssemble);
|
|
1557
1557
|
const disposeGuard = tools?.guard?.(
|
|
1558
|
-
(execution) => hidden.has(execution.name) ?
|
|
1558
|
+
(execution) => hidden.has(execution.name) ? nativeEditorDenial(config.toolName, execution.name) : void 0
|
|
1559
1559
|
);
|
|
1560
1560
|
if (disposeGuard !== void 0) disposers.push(disposeGuard);
|
|
1561
1561
|
return () => {
|
|
@@ -13567,8 +13567,10 @@ function installAgentTools(rootCtx, agent, metrics, config = {}) {
|
|
|
13567
13567
|
disposers.push(agentTools.register(buildUndoTool(deps)));
|
|
13568
13568
|
}
|
|
13569
13569
|
disposers.push(registerGuidanceSections(rootCtx, agent.ctx, switches));
|
|
13570
|
-
if (switches.read) {
|
|
13570
|
+
if (switches.read || switches.applyPatch) {
|
|
13571
13571
|
disposers.push(registerWriteHook(rootCtx, agent.ctx, io, bridge?.observations));
|
|
13572
|
+
}
|
|
13573
|
+
if (switches.read) {
|
|
13572
13574
|
disposers.push(registerShellHook(rootCtx, agent.ctx, deps));
|
|
13573
13575
|
}
|
|
13574
13576
|
disposers.push(registerToolObserver(agent.ctx, metrics));
|
|
@@ -13640,9 +13642,13 @@ function apply(rootCtx, config = {}) {
|
|
|
13640
13642
|
const disposers = [];
|
|
13641
13643
|
try {
|
|
13642
13644
|
if (switches.read) {
|
|
13643
|
-
disposers.push(
|
|
13644
|
-
|
|
13645
|
-
|
|
13645
|
+
disposers.push(
|
|
13646
|
+
rootCtx.tools.register(
|
|
13647
|
+
buildReadTool(rootDeps, {
|
|
13648
|
+
spanProvider: createDefaultReadSpanProvider(rootDeps.coreIo)
|
|
13649
|
+
})
|
|
13650
|
+
)
|
|
13651
|
+
);
|
|
13646
13652
|
}
|
|
13647
13653
|
if (switches.applyPatch) {
|
|
13648
13654
|
disposers.push(rootCtx.tools.register(buildApplyPatchTool(rootDeps)));
|
package/lib/types/dsh/hide.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hide the native
|
|
3
|
-
* `apply_patch
|
|
2
|
+
* Hide the native editor tools so precise and batch text changes go through
|
|
3
|
+
* `apply_patch`; the host's built-in `write` stays visible for whole-file rewrites.
|
|
4
4
|
*
|
|
5
5
|
* DSH 0.2.2-rc.1 owns tool declarations in the tool registry, not in the
|
|
6
6
|
* `system-prompt/assemble` waterfall: the waterfall receives sections, contexts
|
|
@@ -20,15 +20,16 @@
|
|
|
20
20
|
* 3. `tools.guard` is the monotonic execution backstop for a stale schema or
|
|
21
21
|
* any residual binding.
|
|
22
22
|
*
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
25
|
-
* lines for the new content
|
|
23
|
+
* Only `edit`/`str_replace_editor` are hidden. `apply_patch` still owns
|
|
24
|
+
* whole-file replacement as one `*** Update File:` identity hunk spanning every
|
|
25
|
+
* served line with `+` lines for the new content; the built-in `write` remains
|
|
26
|
+
* the profile's own whole-file rewrite path, integrated by `write-hook.ts`.
|
|
26
27
|
* The native `apply_patch` name is also denied in the inherited/preset layer
|
|
27
28
|
* when it exists; the plugin's own scoped registration shadows it otherwise.
|
|
28
29
|
*
|
|
29
30
|
* The layer is installed only when `apply_patch` actually registered: hiding
|
|
30
|
-
* the native
|
|
31
|
-
*
|
|
31
|
+
* the native editors without the replacement would leave the profile with no
|
|
32
|
+
* precise-edit entry point.
|
|
32
33
|
*
|
|
33
34
|
* @module dsh-hashline-edit/hide
|
|
34
35
|
*/
|
|
@@ -38,7 +39,7 @@ type BooleanSource = boolean | (() => boolean);
|
|
|
38
39
|
export interface NativeHideConfig {
|
|
39
40
|
/** The registered replacement tool name, protected from `hiddenToolNames`. */
|
|
40
41
|
readonly toolName: string;
|
|
41
|
-
/** Hide `
|
|
42
|
+
/** Hide `edit`/`str_replace_editor`; defaults to true. The host's `write` stays visible. */
|
|
42
43
|
readonly hideNativeWriteTools?: BooleanSource;
|
|
43
44
|
/** Extra global tool names to hide alongside the native set. */
|
|
44
45
|
readonly hiddenToolNames?: readonly string[];
|
package/lib/types/dsh/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* On every `agent/created`, install the hashline tools on the AGENT's
|
|
5
5
|
* own scope layer so they shadow the preset's built-in `read` for that
|
|
6
6
|
* agent (nearest layer wins in dsh's tool registry) and unwind automatically
|
|
7
|
-
* when the agent is disposed. The native `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* when the agent is disposed. The native `edit` and `str_replace_editor`
|
|
8
|
+
* schemas are hidden on the same scope, so `apply_patch` owns precise and
|
|
9
|
+
* batch text changes. The host's built-in `write` stays visible and is
|
|
10
|
+
* integrated by the write hook.
|
|
11
11
|
*
|
|
12
12
|
* `inject` deliberately lists only `tools` and `systemPrompt`: the read-path
|
|
13
13
|
* `ctx.fs` bridge is optional and resolved with `ctx.get`, so a minimal
|
|
@@ -49,8 +49,8 @@ export interface PluginConfig {
|
|
|
49
49
|
read?: boolean;
|
|
50
50
|
/**
|
|
51
51
|
* Expose the hashline `apply_patch` tool and hide the native
|
|
52
|
-
* `edit`/`
|
|
53
|
-
* off keeps every native
|
|
52
|
+
* `edit`/`apply_patch`/`str_replace_editor` tools. Defaults to true;
|
|
53
|
+
* off keeps every native editor tool. The host's `write` is never hidden.
|
|
54
54
|
*/
|
|
55
55
|
applyPatch?: boolean;
|
|
56
56
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hashline-edit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Hash-anchored read/apply_patch tools for DeepSeek Harness (dsh). Every line gets a unique 3- or 4-char hash (A-Za-z0-9, configurable) that stays stable across edits; apply_patch is the only file-mutation entry point and commits one patch batch per transaction. Undo persists across restarts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anchors",
|