dsh-hashline-edit 0.3.6 → 0.3.8
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 +1 -1
- package/lib/index.js +20 -1
- package/lib/types/dsh/guidance.d.ts +5 -4
- package/package.json +1 -1
- package/prompts/apply-patch-guidelines.md +4 -1
- package/prompts/apply-patch.md +1 -1
- package/prompts/read.md +1 -1
- package/prompts/write-guidelines.md +2 -0
- package/prompts/write.md +1 -0
- package/prompts/zh/apply-patch-guidelines.md +3 -1
- package/prompts/zh/apply-patch.md +1 -1
- package/prompts/zh/write-guidelines.md +2 -0
- package/prompts/zh/write.md +1 -0
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ pnpm pack
|
|
|
55
55
|
dsh plugin add ./dsh-hashline-edit-0.2.1.tgz
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
The bundle ships `lib/index.js` plus `lib/types/**`; `prompts/` must sit next to `lib/` in the installed package (it is in `files`). Guidance
|
|
58
|
+
The bundle ships `lib/index.js` plus `lib/types/**`; `prompts/` must sit next to `lib/` in the installed package (it is in `files`). Guidance text is bundled with the package and injected statically — there is no runtime override file.
|
|
59
59
|
|
|
60
60
|
## The anchored model
|
|
61
61
|
|
package/lib/index.js
CHANGED
|
@@ -1917,6 +1917,12 @@ var GUIDANCE_SECTIONS2 = [
|
|
|
1917
1917
|
orderName: "TOOL_READ",
|
|
1918
1918
|
renderDefault: () => guidanceText(loadP("../prompts/read.md"), loadGuide("../prompts/read-guidelines.md"))
|
|
1919
1919
|
},
|
|
1920
|
+
{
|
|
1921
|
+
name: "tool:write",
|
|
1922
|
+
defaultOrder: 1300,
|
|
1923
|
+
orderName: "TOOL_WRITE",
|
|
1924
|
+
renderDefault: () => guidanceText(loadP("../prompts/write.md"), loadGuide("../prompts/write-guidelines.md"))
|
|
1925
|
+
},
|
|
1920
1926
|
{
|
|
1921
1927
|
name: "tool:apply_patch",
|
|
1922
1928
|
defaultOrder: 1350,
|
|
@@ -1961,10 +1967,23 @@ function orderResolver(registry) {
|
|
|
1961
1967
|
function sectionEnabled(name2, toggles) {
|
|
1962
1968
|
if (toggles === void 0) return true;
|
|
1963
1969
|
if (name2 === "tool:read") return toggles.read;
|
|
1970
|
+
if (name2 === "tool:write") return toggles.applyPatch;
|
|
1964
1971
|
if (name2 === "tool:apply_patch") return toggles.applyPatch;
|
|
1965
1972
|
if (name2 === "tool:undo_last_edit") return toggles.undo;
|
|
1966
1973
|
return true;
|
|
1967
1974
|
}
|
|
1975
|
+
function toolVisible(agentCtx, name2) {
|
|
1976
|
+
const candidate = agentCtx.tools;
|
|
1977
|
+
if (candidate === void 0 || typeof candidate.get !== "function") return void 0;
|
|
1978
|
+
try {
|
|
1979
|
+
return candidate.get(name2) !== void 0;
|
|
1980
|
+
} catch {
|
|
1981
|
+
return void 0;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
function sectionText(section, agentCtx) {
|
|
1985
|
+
return section.name === "tool:write" && toolVisible(agentCtx, "write") === false ? "" : section.renderDefault();
|
|
1986
|
+
}
|
|
1968
1987
|
function registerGuidanceSections(rootCtx, agentCtx, enabled) {
|
|
1969
1988
|
const registry = registryFor(agentCtx) ?? registryFor(rootCtx);
|
|
1970
1989
|
if (registry === void 0) {
|
|
@@ -1981,7 +2000,7 @@ function registerGuidanceSections(rootCtx, agentCtx, enabled) {
|
|
|
1981
2000
|
registry.section({
|
|
1982
2001
|
name: section.name,
|
|
1983
2002
|
order: orderFor(section),
|
|
1984
|
-
text: section
|
|
2003
|
+
text: sectionText(section, agentCtx)
|
|
1985
2004
|
})
|
|
1986
2005
|
);
|
|
1987
2006
|
} catch (error) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hashline guidance sections for the dsh host layer.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `tool:undo_last_edit` — because the hashline tools
|
|
4
|
+
* Four prompt sections are owned here — `tool:read`, `tool:write`,
|
|
5
|
+
* `tool:apply_patch` and `tool:undo_last_edit` — because the hashline tools
|
|
6
|
+
* shadow the preset's built-ins and must bring their own brief.
|
|
6
7
|
* built-ins and must bring their own brief. The compiled default text IS the
|
|
7
8
|
* pi-side guidance (`prompts/*.md`) loaded through `src/prompts.ts`, so the dsh
|
|
8
9
|
* and pi hosts cannot drift about the tool contract.
|
|
@@ -23,11 +24,11 @@ export interface GuidanceSection {
|
|
|
23
24
|
/** Order used when the harness registry names no slot for this section. */
|
|
24
25
|
readonly defaultOrder: number;
|
|
25
26
|
/** The `systemPrompt.getSectionOrder` slot this section shadows, when one exists. */
|
|
26
|
-
readonly orderName?: "TOOL_READ" | "TOOL_EDIT" | "TOOL_APPLY_PATCH";
|
|
27
|
+
readonly orderName?: "TOOL_READ" | "TOOL_WRITE" | "TOOL_EDIT" | "TOOL_APPLY_PATCH";
|
|
27
28
|
/** The compiled default text. */
|
|
28
29
|
renderDefault(): string;
|
|
29
30
|
}
|
|
30
|
-
/** The
|
|
31
|
+
/** The four sections, in default-order sequence. */
|
|
31
32
|
export declare const GUIDANCE_SECTIONS: readonly GuidanceSection[];
|
|
32
33
|
/** Render the compiled default text for one section. */
|
|
33
34
|
export declare function renderSectionDefault(name: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hashline-edit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
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",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
- apply_patch: one call = one transaction; batch related changes and split only when an earlier RESULT decides the next.
|
|
2
|
+
- apply_patch: an identity anchor is the bare `{{HASH_LEN}}` characters before `│` in a served row — never the whole row, never a line number.
|
|
3
|
+
- apply_patch: prefer identity hunks that name served `HASH│` anchors; a fragment hunk is only for text this session never served.
|
|
4
|
+
- apply_patch: for a one-line or single-region change to a served file, one identity hunk is the whole call; do not switch to `write` because the file content is already in context.
|
|
2
5
|
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once — add context to disambiguate, never guess — while identity hunks target served rows and a stale or unknown anchor is rejected; both serve the current rows back.
|
|
3
6
|
- apply_patch: a rejection writes nothing; retry from the served `HASH│content` rows without another `read`.
|
|
4
|
-
- apply_patch: success returns fresh anchors for changed lines;
|
|
7
|
+
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a whole-file rewrite stays with `write`.
|
package/prompts/apply-patch.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Change, create, delete, move, copy or cut UTF-8 text files with a single transactional patch; this is the default for every change to an existing file, including a one-line change, and `write` is only for a new file or a whole-file rewrite. Pass the complete patch as `input`. Prefer identity hunks that target served `HASH│` anchors (`@@<anchor>`) over fragment hunks matched by file text; prefer a fragment hunk only for text this session never served.
|
package/prompts/read.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Reads a UTF-8 file as `HASH│content` rows in served mode; each row's anchor is the `apply_patch` identity anchor for that line. Pass `mode: "verbatim"` for plain text with no anchors when you will not apply_patch; verbatim is not capped by line budget. Batch disjoint ranges in one call with `windows` (offset/limit or `around_anchor`).
|
|
1
|
+
Reads a UTF-8 file as `HASH│content` rows in served mode; each row's anchor is the `apply_patch` identity anchor for that line, and only the `{{HASH_LEN}}` characters before `│` are the anchor. Pass `mode: "verbatim"` for plain text with no anchors when you will not apply_patch; verbatim is not capped by line budget. Batch disjoint ranges in one call with `windows` (offset/limit or `around_anchor`).
|
package/prompts/write.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Read a file before overwriting it with `write`. `write` replaces the whole file: use it for a new file, or for a rewrite where every line changes. For a change to part of an existing file, use `apply_patch` identity hunks on the served rows instead.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
- apply_patch:一次调用 = 一个事务;把相关改动成批处理,只有当先前的结果决定下一步时才拆分。
|
|
2
|
+
- apply_patch:身份锚点是已服务行中 `│` 之前的 {{HASH_LEN}} 个字符——不是整行,也不是行号。
|
|
3
|
+
- apply_patch:对已服务文件的单行或单区域改动,一个身份 hunk 就是整次调用;不要因为文件内容已在上下文里就改用 `write`。
|
|
2
4
|
- apply_patch:各 hunk 按顺序针对调用前的文件校验(重叠范围会拒绝整批);片段 hunk 必须恰好匹配一次——补充上下文以消歧,绝不猜测——身份 hunk 定位已服务的行,陈旧或未知锚点会被拒绝;两者都会回送当前行。
|
|
3
5
|
- apply_patch:拒绝时不写入任何内容;从回送的 `HASH│content` 行重试,无需再次 `read`。
|
|
4
|
-
- apply_patch
|
|
6
|
+
- apply_patch:成功时返回改动行的新锚点;补丁只携带改动的行,整文件重写留给 `write`。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
用单个事务补丁修改、创建、删除、移动、复制或剪切 UTF-8 文本文件。对已有文件的每一处改动都默认用它,包括只改一行;`write` 只用于新建文件或整文件重写。把完整补丁作为 `input` 传入。优先使用指向已服务 `HASH│` 锚点的身份 hunk(`@@<anchor>`),而不是按文件文本匹配的片段 hunk;片段 hunk 仅用于本会话从未服务过的文本。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
用 `write` 覆盖文件前先读取它。`write` 替换整个文件:用于新建文件,或每一行都改变的重写。要改已有文件的一部分,改用已服务行上的 `apply_patch` 身份 hunk。
|