dsh-hashline-edit 0.3.10 → 0.3.12
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/lib/index.js +45 -9
- package/lib/types/src/prompts-bundled.d.ts +11 -0
- package/package.json +3 -2
- package/src/prompts-bundled.ts +38 -0
- package/src/prompts.ts +21 -5
- package/prompts/apply-patch-guidelines.md +0 -9
- package/prompts/apply-patch.md +0 -1
- package/prompts/read-guidelines.md +0 -6
- package/prompts/read.md +0 -1
- package/prompts/undo-last-edit-guidelines.md +0 -2
- package/prompts/undo-last-edit-snippet.md +0 -1
- package/prompts/undo-last-edit.md +0 -1
- package/prompts/write-guidelines.md +0 -2
- package/prompts/write.md +0 -1
- package/prompts/zh/apply-patch-guidelines.md +0 -9
- package/prompts/zh/apply-patch.md +0 -1
- package/prompts/zh/read-guidelines.md +0 -6
- package/prompts/zh/read-snippet.md +0 -1
- package/prompts/zh/read.md +0 -1
- package/prompts/zh/undo-last-edit-guidelines.md +0 -2
- package/prompts/zh/undo-last-edit-snippet.md +0 -1
- package/prompts/zh/undo-last-edit.md +0 -1
- package/prompts/zh/write-guidelines.md +0 -2
- package/prompts/zh/write.md +0 -1
package/lib/index.js
CHANGED
|
@@ -1883,8 +1883,36 @@ function commandOf(args) {
|
|
|
1883
1883
|
return typeof command === "string" && command.length > 0 ? command : void 0;
|
|
1884
1884
|
}
|
|
1885
1885
|
|
|
1886
|
+
// src/prompts-bundled.ts
|
|
1887
|
+
var BUNDLED_PROMPTS = {
|
|
1888
|
+
"apply-patch-guidelines.md": `- apply_patch: one call = one transaction; batch related changes and split only when an earlier RESULT decides the next.
|
|
1889
|
+
- apply_patch: an identity hunk is \`@@<anchor>\` or \`@@<from>-<to>\` followed by \`+\` lines; an empty body deletes every row of the span. Minimal shape: \`*** Begin Patch\` / \`*** Update File: <path>\` / \`@@<anchor>\` / \`+<new line>\` / \`*** End Patch\`.
|
|
1890
|
+
- apply_patch: an identity anchor is the bare \`{{HASH_LEN}}\` characters before \`\u2502\` in a served row \u2014 never the whole row, never a line number; syntax is \`@@\` plus the anchor with no space between them.
|
|
1891
|
+
- apply_patch: served beats text \u2014 when this session served the file, an identity hunk is REQUIRED, not preferred; a fragment hunk is limited to a file or region this session never served, and a text match never licenses one.
|
|
1892
|
+
- apply_patch: anchors in hand mean no re-read \u2014 apply the identity hunk to the served rows instead of reading the file again; a rejection already serves the current rows back.
|
|
1893
|
+
- apply_patch: change only what the task changes \u2014 an identity hunk carries \`+\` lines for the edited region and no unchanged rows, so a small edit stays a small patch.
|
|
1894
|
+
- 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.
|
|
1895
|
+
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once \u2014 \`E_UNIQUE_MATCH\` writes nothing \u2014 while a stale or unknown anchor is rejected; both serve the current rows back.
|
|
1896
|
+
- apply_patch: a rejection writes nothing; retry from the served \`HASH\u2502content\` rows without another \`read\`.
|
|
1897
|
+
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a new file or an every-line rewrite stays with \`write\`.`,
|
|
1898
|
+
"apply-patch.md": `Change an existing file with \`apply_patch\`; it is the default for every change to an existing file, including a one-line change. \`write\` is only for a new file or for a rewrite where every line changes; a partial change is never a whole-file replacement. Pass the complete patch as \`input\`. When this session already served the file \u2014 through \`read\`, \`grep\`, a \`bash\` view, or a previous \`apply_patch\` result \u2014 every hunk MUST be an identity hunk on a served row: reuse the bare anchor before \`\u2502\` (\`@@<anchor>\` to replace that row, \`@@<from>-<to>\` to replace a span whose anchors you hold), and add only the changed \`+\` lines rather than re-emitting rows you are not changing. Anchors already in hand need no re-read: patch them directly instead of calling \`read\` again. A fragment hunk (\`@@\` or \`@@ <context>\` matched by file text) is legal only for a file or region this session never served; if the file was served, a fragment hunk is the wrong tool even when the text matches, because it discards the anchor check that proves you edited the version you actually saw.`,
|
|
1899
|
+
"read-guidelines.md": `- read: call it for content the tool has never served you; a bash view or an auto-read already served the file, so \`apply_patch\` can use those rows.
|
|
1900
|
+
- read: batch several disjoint ranges in ONE call with \`windows\` \u2014 an offset/limit range, or \`around_anchor\` plus \`radius\` around a line this session served.
|
|
1901
|
+
- read: pass \`mode: "verbatim"\` when you will not \`apply_patch\` the file (config, docs, a README, skill files); otherwise omit it so the rows carry anchors.
|
|
1902
|
+
- read: a window of 61 lines or fewer may widen to its enclosing block; widened rows carry a \`[widened \u2026]\` note. Caps are 80 lines for code/Markdown and 40 for plain text.
|
|
1903
|
+
- read: read several files with parallel \`read\` calls, one file per call.
|
|
1904
|
+
- read: PNG/JPG/GIF/WebP files return as an image attachment for multimodal models; binary files and directories are refused.`,
|
|
1905
|
+
"read.md": `Reads a UTF-8 file as \`HASH\u2502content\` rows in served mode; each row's anchor is the \`apply_patch\` identity anchor for that line, and only the \`{{HASH_LEN}}\` characters before \`\u2502\` 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\`).`,
|
|
1906
|
+
"undo-last-edit-guidelines.md": `- undo_last_edit: reverts the most recent \`apply_patch\` batch that touched the file at \`path\`, and every member of that batch: text hunks plus file lifecycle actions (add/delete/move). The exception is a foreign \`cut\`: undo then restores the source file too. The file must still hold the edited bytes. An out-of-band write makes the call fail with \`E_UNDO_STALE\`, and the file stays byte-identical. Call it as soon as a result is bad.
|
|
1907
|
+
- undo_last_edit: a \`write\` to the file, or a later \`apply_patch\` batch, replaces the undo entry. A read, a bash view or an out-of-band write leaves the entry in place. An apply_patch result is bad when its diff shows \`-HASH\u2502\` rows for lines you meant to keep. Examples are a closing brace, an import, or a declaration.`,
|
|
1908
|
+
"undo-last-edit-snippet.md": `Undo the last \`apply_patch\` batch on the file at \`path\``,
|
|
1909
|
+
"undo-last-edit.md": `Undo the last \`apply_patch\` batch that touched the file at \`path\`, reverting the whole batch \u2014 every text hunk plus file lifecycle actions (add/delete/move) \u2014 to its previous state. Use when an \`apply_patch\` produced incorrect results (e.g., wrong content, duplicated lines, broken syntax). The file must be unchanged since that batch.`,
|
|
1910
|
+
"write-guidelines.md": `- write: the content is the complete file; a partial change stays an \`apply_patch\` identity hunk, even when the whole file is already in context.
|
|
1911
|
+
- write: never paste served \`HASH\u2502\` rows into the content; a line that reproduces a served row is refused as a served hash echo.`,
|
|
1912
|
+
"write.md": `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.`
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1886
1915
|
// src/prompts.ts
|
|
1887
|
-
import { readFileSync } from "node:fs";
|
|
1888
1916
|
function applyReplacements(content, replacements) {
|
|
1889
1917
|
let out = content;
|
|
1890
1918
|
if (replacements) {
|
|
@@ -1894,13 +1922,21 @@ function applyReplacements(content, replacements) {
|
|
|
1894
1922
|
}
|
|
1895
1923
|
return out.split("{{HASH_LEN}}").join(String(HASH_LEN));
|
|
1896
1924
|
}
|
|
1925
|
+
function bundled(relativePath2) {
|
|
1926
|
+
const name2 = relativePath2.slice(relativePath2.lastIndexOf("/") + 1);
|
|
1927
|
+
const body = BUNDLED_PROMPTS[name2];
|
|
1928
|
+
if (body === void 0) {
|
|
1929
|
+
throw new Error(
|
|
1930
|
+
`unknown bundled prompt: ${relativePath2} (bundled: ${Object.keys(BUNDLED_PROMPTS).join(", ")})`
|
|
1931
|
+
);
|
|
1932
|
+
}
|
|
1933
|
+
return body;
|
|
1934
|
+
}
|
|
1897
1935
|
function loadP(relativePath2, replacements) {
|
|
1898
|
-
|
|
1899
|
-
return applyReplacements(content, replacements);
|
|
1936
|
+
return applyReplacements(bundled(relativePath2).trim(), replacements);
|
|
1900
1937
|
}
|
|
1901
1938
|
function loadGuide(relativePath2, replacements) {
|
|
1902
|
-
|
|
1903
|
-
return applyReplacements(content, replacements).split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2));
|
|
1939
|
+
return applyReplacements(bundled(relativePath2), replacements).split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2));
|
|
1904
1940
|
}
|
|
1905
1941
|
|
|
1906
1942
|
// dsh/guidance.ts
|
|
@@ -7104,7 +7140,7 @@ function findEnclosingScope(root, requestedStart, requestedEnd, scopeKinds) {
|
|
|
7104
7140
|
|
|
7105
7141
|
// src/read-expansion/grammar-cache.ts
|
|
7106
7142
|
import { createHash } from "node:crypto";
|
|
7107
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync
|
|
7143
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync, renameSync as renameSync4, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
7108
7144
|
import { dirname as dirname7, join as join8 } from "node:path";
|
|
7109
7145
|
|
|
7110
7146
|
// src/read-expansion/grammar-manifest.ts
|
|
@@ -7199,7 +7235,7 @@ function readVerifiedCache(path, expected) {
|
|
|
7199
7235
|
if (!existsSync3(path)) return void 0;
|
|
7200
7236
|
let bytes;
|
|
7201
7237
|
try {
|
|
7202
|
-
bytes =
|
|
7238
|
+
bytes = readFileSync(path);
|
|
7203
7239
|
} catch {
|
|
7204
7240
|
discardCachedGrammar(path);
|
|
7205
7241
|
return void 0;
|
|
@@ -8479,7 +8515,7 @@ import {
|
|
|
8479
8515
|
constants as constants5,
|
|
8480
8516
|
existsSync as existsSync4,
|
|
8481
8517
|
mkdirSync as mkdirSync6,
|
|
8482
|
-
readFileSync as
|
|
8518
|
+
readFileSync as readFileSync2,
|
|
8483
8519
|
renameSync as renameSync5,
|
|
8484
8520
|
unlinkSync as unlinkSync2,
|
|
8485
8521
|
writeFileSync as writeFileSync3
|
|
@@ -8551,7 +8587,7 @@ function reasonOf2(error) {
|
|
|
8551
8587
|
function readConfigObject(path, onWarn) {
|
|
8552
8588
|
let raw;
|
|
8553
8589
|
try {
|
|
8554
|
-
raw =
|
|
8590
|
+
raw = readFileSync2(path, "utf-8");
|
|
8555
8591
|
} catch (error) {
|
|
8556
8592
|
if (!isMissingFile(error)) onWarn?.(`cannot read config ${path}: ${reasonOf2(error)}`);
|
|
8557
8593
|
return void 0;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED FILE — do not edit by hand.
|
|
3
|
+
*
|
|
4
|
+
* Source of truth: `prompts/*.md`. Regenerate with `node scripts/gen-prompts.mjs`
|
|
5
|
+
* (`pnpm run build` runs it first). The prose lives inline so reinstalling the plugin is
|
|
6
|
+
* the only way — and the only needed way — to change what the model reads.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-hashline-edit/prompts-bundled
|
|
9
|
+
*/
|
|
10
|
+
/** Every shipped prompt body, keyed by its `prompts/<name>.md` basename. */
|
|
11
|
+
export declare const BUNDLED_PROMPTS: Readonly<Record<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.12",
|
|
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",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"lib",
|
|
31
31
|
"cordis.patch.yml",
|
|
32
|
-
"prompts",
|
|
33
32
|
"src",
|
|
34
33
|
"README.md",
|
|
35
34
|
"LICENSE"
|
|
@@ -60,6 +59,8 @@
|
|
|
60
59
|
"format:fix": "oxfmt .",
|
|
61
60
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.dsh.json",
|
|
62
61
|
"build": "node scripts/build-dsh.mjs",
|
|
62
|
+
"prompts:gen": "node scripts/gen-prompts.mjs",
|
|
63
|
+
"prompts:check": "node scripts/gen-prompts.mjs --check",
|
|
63
64
|
"prepublishOnly": "node scripts/build-dsh.mjs && pnpm run typecheck && pnpm run lint && pnpm run test:win",
|
|
64
65
|
"canon:audit": "node scripts/canon-churn-audit.mjs",
|
|
65
66
|
"prepack": "node scripts/build-dsh.mjs",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED FILE — do not edit by hand.
|
|
3
|
+
*
|
|
4
|
+
* Source of truth: `prompts/*.md`. Regenerate with `node scripts/gen-prompts.mjs`
|
|
5
|
+
* (`pnpm run build` runs it first). The prose lives inline so reinstalling the plugin is
|
|
6
|
+
* the only way — and the only needed way — to change what the model reads.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-hashline-edit/prompts-bundled
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Every shipped prompt body, keyed by its `prompts/<name>.md` basename. */
|
|
12
|
+
export const BUNDLED_PROMPTS: Readonly<Record<string, string>> = {
|
|
13
|
+
"apply-patch-guidelines.md": `- apply_patch: one call = one transaction; batch related changes and split only when an earlier RESULT decides the next.
|
|
14
|
+
- apply_patch: an identity hunk is \`@@<anchor>\` or \`@@<from>-<to>\` followed by \`+\` lines; an empty body deletes every row of the span. Minimal shape: \`*** Begin Patch\` / \`*** Update File: <path>\` / \`@@<anchor>\` / \`+<new line>\` / \`*** End Patch\`.
|
|
15
|
+
- apply_patch: an identity anchor is the bare \`{{HASH_LEN}}\` characters before \`│\` in a served row — never the whole row, never a line number; syntax is \`@@\` plus the anchor with no space between them.
|
|
16
|
+
- apply_patch: served beats text — when this session served the file, an identity hunk is REQUIRED, not preferred; a fragment hunk is limited to a file or region this session never served, and a text match never licenses one.
|
|
17
|
+
- apply_patch: anchors in hand mean no re-read — apply the identity hunk to the served rows instead of reading the file again; a rejection already serves the current rows back.
|
|
18
|
+
- apply_patch: change only what the task changes — an identity hunk carries \`+\` lines for the edited region and no unchanged rows, so a small edit stays a small patch.
|
|
19
|
+
- 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.
|
|
20
|
+
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once — \`E_UNIQUE_MATCH\` writes nothing — while a stale or unknown anchor is rejected; both serve the current rows back.
|
|
21
|
+
- apply_patch: a rejection writes nothing; retry from the served \`HASH│content\` rows without another \`read\`.
|
|
22
|
+
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a new file or an every-line rewrite stays with \`write\`.`,
|
|
23
|
+
"apply-patch.md": `Change an existing file with \`apply_patch\`; it is the default for every change to an existing file, including a one-line change. \`write\` is only for a new file or for a rewrite where every line changes; a partial change is never a whole-file replacement. Pass the complete patch as \`input\`. When this session already served the file — through \`read\`, \`grep\`, a \`bash\` view, or a previous \`apply_patch\` result — every hunk MUST be an identity hunk on a served row: reuse the bare anchor before \`│\` (\`@@<anchor>\` to replace that row, \`@@<from>-<to>\` to replace a span whose anchors you hold), and add only the changed \`+\` lines rather than re-emitting rows you are not changing. Anchors already in hand need no re-read: patch them directly instead of calling \`read\` again. A fragment hunk (\`@@\` or \`@@ <context>\` matched by file text) is legal only for a file or region this session never served; if the file was served, a fragment hunk is the wrong tool even when the text matches, because it discards the anchor check that proves you edited the version you actually saw.`,
|
|
24
|
+
"read-guidelines.md": `- read: call it for content the tool has never served you; a bash view or an auto-read already served the file, so \`apply_patch\` can use those rows.
|
|
25
|
+
- read: batch several disjoint ranges in ONE call with \`windows\` — an offset/limit range, or \`around_anchor\` plus \`radius\` around a line this session served.
|
|
26
|
+
- read: pass \`mode: "verbatim"\` when you will not \`apply_patch\` the file (config, docs, a README, skill files); otherwise omit it so the rows carry anchors.
|
|
27
|
+
- read: a window of 61 lines or fewer may widen to its enclosing block; widened rows carry a \`[widened …]\` note. Caps are 80 lines for code/Markdown and 40 for plain text.
|
|
28
|
+
- read: read several files with parallel \`read\` calls, one file per call.
|
|
29
|
+
- read: PNG/JPG/GIF/WebP files return as an image attachment for multimodal models; binary files and directories are refused.`,
|
|
30
|
+
"read.md": `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\`).`,
|
|
31
|
+
"undo-last-edit-guidelines.md": `- undo_last_edit: reverts the most recent \`apply_patch\` batch that touched the file at \`path\`, and every member of that batch: text hunks plus file lifecycle actions (add/delete/move). The exception is a foreign \`cut\`: undo then restores the source file too. The file must still hold the edited bytes. An out-of-band write makes the call fail with \`E_UNDO_STALE\`, and the file stays byte-identical. Call it as soon as a result is bad.
|
|
32
|
+
- undo_last_edit: a \`write\` to the file, or a later \`apply_patch\` batch, replaces the undo entry. A read, a bash view or an out-of-band write leaves the entry in place. An apply_patch result is bad when its diff shows \`-HASH│\` rows for lines you meant to keep. Examples are a closing brace, an import, or a declaration.`,
|
|
33
|
+
"undo-last-edit-snippet.md": `Undo the last \`apply_patch\` batch on the file at \`path\``,
|
|
34
|
+
"undo-last-edit.md": `Undo the last \`apply_patch\` batch that touched the file at \`path\`, reverting the whole batch — every text hunk plus file lifecycle actions (add/delete/move) — to its previous state. Use when an \`apply_patch\` produced incorrect results (e.g., wrong content, duplicated lines, broken syntax). The file must be unchanged since that batch.`,
|
|
35
|
+
"write-guidelines.md": `- write: the content is the complete file; a partial change stays an \`apply_patch\` identity hunk, even when the whole file is already in context.
|
|
36
|
+
- write: never paste served \`HASH│\` rows into the content; a line that reproduces a served row is refused as a served hash echo.`,
|
|
37
|
+
"write.md": `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.`,
|
|
38
|
+
};
|
package/src/prompts.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
1
|
import { HASH_LEN } from "./hashline/alphabet.js";
|
|
2
|
+
import { BUNDLED_PROMPTS } from "./prompts-bundled.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Resolve template variables in shipped prompt prose. Beyond caller-supplied replacements, the
|
|
@@ -16,14 +16,30 @@ function applyReplacements(content: string, replacements?: Record<string, string
|
|
|
16
16
|
return out.split("{{HASH_LEN}}").join(String(HASH_LEN));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Resolve one prompt path to its bundled body.
|
|
21
|
+
*
|
|
22
|
+
* WHY a path rather than a bare name: callers have always named the prompt by its `prompts/`
|
|
23
|
+
* path, and that argument IS the lookup key, so a typo fails at the call site instead of
|
|
24
|
+
* silently serving an empty prompt. Nothing is read from disk — see `prompts-bundled.ts`.
|
|
25
|
+
*/
|
|
26
|
+
function bundled(relativePath: string): string {
|
|
27
|
+
const name = relativePath.slice(relativePath.lastIndexOf("/") + 1);
|
|
28
|
+
const body = BUNDLED_PROMPTS[name];
|
|
29
|
+
if (body === undefined) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`unknown bundled prompt: ${relativePath} (bundled: ${Object.keys(BUNDLED_PROMPTS).join(", ")})`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return body;
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
export function loadP(relativePath: string, replacements?: Record<string, string>): string {
|
|
20
|
-
|
|
21
|
-
return applyReplacements(content, replacements);
|
|
38
|
+
return applyReplacements(bundled(relativePath).trim(), replacements);
|
|
22
39
|
}
|
|
23
40
|
|
|
24
41
|
export function loadGuide(relativePath: string, replacements?: Record<string, string>): string[] {
|
|
25
|
-
|
|
26
|
-
return applyReplacements(content, replacements)
|
|
42
|
+
return applyReplacements(bundled(relativePath), replacements)
|
|
27
43
|
.split("\n")
|
|
28
44
|
.map((line) => line.trim())
|
|
29
45
|
.filter((line) => line.startsWith("- "))
|
|
@@ -1,9 +0,0 @@
|
|
|
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 hunk is `@@<anchor>` or `@@<from>-<to>` followed by `+` lines; an empty body deletes every row of the span. Minimal shape: `*** Begin Patch` / `*** Update File: <path>` / `@@<anchor>` / `+<new line>` / `*** End Patch`.
|
|
3
|
-
- apply_patch: an identity anchor is the bare `{{HASH_LEN}}` characters before `│` in a served row — never the whole row, never a line number; syntax is `@@` plus the anchor with no space between them.
|
|
4
|
-
- apply_patch: served beats text — when this session served the file, an identity hunk is REQUIRED, not preferred; a fragment hunk is limited to a file or region this session never served.
|
|
5
|
-
- apply_patch: anchors in hand mean no re-read — apply the identity hunk to the served rows instead of reading the file again.
|
|
6
|
-
- 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.
|
|
7
|
-
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once — `E_UNIQUE_MATCH` writes nothing — while a stale or unknown anchor is rejected; both serve the current rows back.
|
|
8
|
-
- apply_patch: a rejection writes nothing; retry from the served `HASH│content` rows without another `read`.
|
|
9
|
-
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a new file or an every-line rewrite stays with `write`.
|
package/prompts/apply-patch.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Change an existing file with `apply_patch`; it is the default for every change to an existing file, including a one-line change. `write` is only for a new file or a whole-file rewrite in which every line changes. Pass the complete patch as `input`. When this session already served the file (`read`, `grep`, or a `bash` view), every hunk MUST be an identity hunk on a served row: copy the bare anchor before `│` (`@@<anchor>` or `@@<anchor>-<anchor>`), add only the changed `+` lines, and never paste served content back into the hunk. Do not call `read` again to re-fetch anchors you already hold — apply the patch to them directly. A fragment hunk (`@@` or `@@ <context>` matched by file text) is legal only for a file or region this session never served.
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
- read: call it for content the tool has never served you; a bash view or an auto-read already served the file, so `apply_patch` can use those rows.
|
|
2
|
-
- read: batch several disjoint ranges in ONE call with `windows` — an offset/limit range, or `around_anchor` plus `radius` around a line this session served.
|
|
3
|
-
- read: pass `mode: "verbatim"` when you will not `apply_patch` the file (config, docs, a README, skill files); otherwise omit it so the rows carry anchors.
|
|
4
|
-
- read: a window of 61 lines or fewer may widen to its enclosing block; widened rows carry a `[widened …]` note. Caps are 80 lines for code/Markdown and 40 for plain text.
|
|
5
|
-
- read: read several files with parallel `read` calls, one file per call.
|
|
6
|
-
- read: PNG/JPG/GIF/WebP files return as an image attachment for multimodal models; binary files and directories are refused.
|
package/prompts/read.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
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`).
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
- undo_last_edit: reverts the most recent `apply_patch` batch that touched the file at `path`, and every member of that batch: text hunks plus file lifecycle actions (add/delete/move). The exception is a foreign `cut`: undo then restores the source file too. The file must still hold the edited bytes. An out-of-band write makes the call fail with `E_UNDO_STALE`, and the file stays byte-identical. Call it as soon as a result is bad.
|
|
2
|
-
- undo_last_edit: a `write` to the file, or a later `apply_patch` batch, replaces the undo entry. A read, a bash view or an out-of-band write leaves the entry in place. An apply_patch result is bad when its diff shows `-HASH│` rows for lines you meant to keep. Examples are a closing brace, an import, or a declaration.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Undo the last `apply_patch` batch on the file at `path`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Undo the last `apply_patch` batch that touched the file at `path`, reverting the whole batch — every text hunk plus file lifecycle actions (add/delete/move) — to its previous state. Use when an `apply_patch` produced incorrect results (e.g., wrong content, duplicated lines, broken syntax). The file must be unchanged since that batch.
|
package/prompts/write.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
- apply_patch:一次调用 = 一个事务;把相关改动成批处理,只有当先前的结果决定下一步时才拆分。
|
|
2
|
-
- apply_patch:身份 hunk 形如 `@@<anchor>` 或 `@@<from>-<to>` 后接 `+` 行;空正文会删除该跨度内所有行。最小形状:`*** Begin Patch` / `*** Update File: <path>` / `@@<anchor>` / `+<新行>` / `*** End Patch`。
|
|
3
|
-
- apply_patch:身份锚点是已服务行中 `│` 之前的 {{HASH_LEN}} 个字符——不是整行,也不是行号;语法是 `@@` 直接加锚点,中间不留空格。
|
|
4
|
-
- apply_patch:已服务优先于文本匹配——本会话服务过该文件时必须用身份 hunk(REQUIRED),不是"优先";片段 hunk 仅限本会话从未服务过的文件或区域。
|
|
5
|
-
- apply_patch:锚点在手上就不要重读——直接把身份 hunk 应用到已服务行,而不是再次 `read` 该文件。
|
|
6
|
-
- apply_patch:对已服务文件的单行或单区域改动,一个身份 hunk 就是整次调用;不要因为文件内容已在上下文里就改用 `write`。
|
|
7
|
-
- apply_patch:各 hunk 按顺序针对调用前的文件校验(重叠范围会拒绝整批);片段 hunk 必须恰好匹配一次——`E_UNIQUE_MATCH` 时不写入任何内容——陈旧或未知锚点会被拒绝;两者都会回送当前行。
|
|
8
|
-
- apply_patch:拒绝时不写入任何内容;从回送的 `HASH│content` 行重试,无需再次 `read`。
|
|
9
|
-
- apply_patch:成功时返回改动行的新锚点;补丁只携带改动的行,新建文件或整文件重写留给 `write`。
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
用 `apply_patch` 修改已有文件;对已有文件的每一处改动都默认用它,包括只改一行。`write` 只用于新建文件,或每一行都改变的重写。把完整补丁作为 `input` 传入。当本会话已服务过该文件(`read`、`grep` 或 `bash` 视图)时,每个 hunk 都必须是基于已服务行的身份 hunk:复制 `│` 之前的裸锚点(`@@<anchor>` 或 `@@<anchor>-<anchor>`),只携带改动的 `+` 行,绝不把已服务内容粘回 hunk。锚点已在手上时不要再调 `read` 重取——直接对它们应用补丁。片段 hunk(`@@` 或按文件文本匹配的 `@@ <context>`)仅用于本会话从未服务过的文件或区域。
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
- read:仅在工具尚未服务给你信息时调用,例如自动读取 diff 之外的内容。bash 视图或自动读取已经服务过该文件,因此直接用那些行 apply_patch。
|
|
2
|
-
- read:当一次替换需要多个块或两端边界时,把每个范围放进同一次调用。用 `{ file, windows: [{ offset, limit }] }`。每个窗口都在当轮被服务,因此其锚点可在同一次 apply_patch 调用中使用。窗口也可以是 `{ around_anchor, radius }`,以本会话已服务的某行为中心。本会话未服务过的锚点会被省略,并内联标注 `[Window warning: ...]`。
|
|
3
|
-
- read:61 行及以内的请求窗口可扩展到其所在块;重叠或相邻窗口在此判定前合并。上限为:代码与 Markdown 80 行,纯文本 40 行。扩展的行以 `[widened <requested> -> <served>, <label>]` 开头;超过三个请求窗口的提示为 `[widened N windows: <ranges>]`。超限的 Markdown 章节会裁剪并标注 `(section <extent>)`;超限的代码或纯文本则拒绝且无提示。`mode: "verbatim"` 也会扩展,但不加锚点。
|
|
4
|
-
- read:当你不打算对该文件 apply_patch 时,用 `mode: "verbatim"` 获取无锚点的纯内容。例如配置值、文档、README 或技能内容(SKILL.md 或其所处目录中的任意文件)。当你打算用锚点配合 apply_patch 时,就不要指定 `mode`,让这些行带上锚点。
|
|
5
|
-
- read:每次调用只发送一个文件,形式为 `{ file, windows?, mode? }`,与 `apply_patch` 相同。单个顶层 `mode` 作用于该文件。要读多个文件就并行发起多次 `read` 调用。
|
|
6
|
-
- read:PNG/JPG 图像以图像附件形式返回,供多模态模型使用。像其他文件一样用 `file` 请求。
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
通过 `file`、`windows?`、`mode?` 读取文件;默认返回可直接编辑的 HASH│content 行,`mode: "verbatim"` 在你不编辑时返回纯文本;用 `windows` 在一次调用中批量读取多个范围
|
package/prompts/zh/read.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
通过 `file` 读取一个文本文件,可选 `windows` 与顶层 `mode`。要读多个文件就并行发起多次 `read` 调用。服务模式(默认)把每行返回为 HASH│content,带一个 {{HASH_LEN}} 字符的字母数字哈希。该哈希就是 `apply_patch` 的身份锚点,因此只复制 `│` 之前的 {{HASH_LEN}} 个字符。当你不打算 apply_patch 该文件时,用 `mode: "verbatim"` 获取无锚点的纯文本。`mode: "verbatim"` 不受行数上限限制。用 `windows` 指定范围:`[{ offset, limit }]`(offset 从 1 开始,limit 为行数,最多 16 个窗口)或 `[{ around_anchor: "<anchor>", radius: 10 }]`(针对本会话已服务的某行)。当页面未取全时,用 `windows: [{ offset, limit }]` 从下一个未显示行继续。61 行及以内的请求窗口在返回前可能扩展到其所在块;重叠或相邻的窗口在此判定前会合并。上限为:代码与 Markdown 80 行,纯文本 40 行。扩展页以 `[widened <requested> -> <served>, <label>]` 开头;超过三个请求窗口时折叠为 `[widened N windows: <ranges>]`。超限的 Markdown 章节会裁剪为上限大小的窗口并标注 `(section <extent>)`;超限的代码或纯文本块则拒绝,只返回所请求的窗口。`mode: "verbatim"` 同样会扩展,但不加锚点。行内的 `[...]` 提示描述的是返回结果,而非文件内容。空文件返回 `HASH│`(用 apply_patch 身份 hunk 插入)。PNG/JPG/GIF/WebP 以图像附件形式返回,供多模态模型使用。二进制与目录文件会被拒绝。哈希是文件作用域的:一个锚点绑定于它被服务时所在的文件。
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
- undo_last_edit:还原最近一次触及 `path` 处文件的 `apply_patch` 批次及其每个成员:文本 hunk 加文件生命周期操作(增/删/移动)。例外是外来 `cut`:此时撤销也会还原源文件。文件必须仍保有被编辑后的字节。带外写入会让调用以 `E_UNDO_STALE` 失败,且文件保持字节不变。一旦结果不对就立刻调用它。
|
|
2
|
-
- undo_last_edit:对该文件的 `write`,或之后的一次 `apply_patch` 批次,会替换撤销记录。一次读取、bash 视图或带外写入会保留该记录。当一次 apply_patch 的 diff 显示出你本想保留的行的 `-HASH│` 行时,该结果就是错的。例子包括一个收尾花括号、一句 import 或一个声明。
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
撤销对 `path` 处文件最近一次的 `apply_patch` 批次
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
撤销最近一次触及 `path` 处文件的 `apply_patch` 批次,把整批——每个文本 hunk 加上文件生命周期操作(增/删/移动)——还原到先前状态。当某次 `apply_patch` 产生了错误结果(例如内容错误、重复行、语法损坏)时使用。该文件自那批之后必须未被改动。
|
package/prompts/zh/write.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
用 `write` 覆盖文件前先读取它。`write` 替换整个文件:用于新建文件,或每一行都改变的重写。要改已有文件的一部分,改用已服务行上的 `apply_patch` 身份 hunk。
|