dsh-better-edit 0.8.2 → 1.0.0

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 (75) hide show
  1. package/CHANGELOG.md +158 -99
  2. package/README.md +2 -2
  3. package/README.zh.md +3 -3
  4. package/cordis.patch.yml +1 -1
  5. package/lib/constants.js +19 -4
  6. package/lib/contract.js +136 -79
  7. package/lib/domain-errors.js +570 -0
  8. package/lib/edit-diff.js +33 -7
  9. package/lib/file-encoding-state.js +27 -7
  10. package/lib/file-view.js +305 -82
  11. package/lib/fs-bridge.js +23 -7
  12. package/lib/hash-store.js +404 -278
  13. package/lib/hashline/anchor-pipeline.js +586 -378
  14. package/lib/hashline/hash-assign.js +21 -22
  15. package/lib/hashline/hash.js +6 -6
  16. package/lib/hashline/index.js +1 -1
  17. package/lib/hashline/resolve.js +1 -1
  18. package/lib/hashline/served-guard.js +181 -0
  19. package/lib/index.js +1 -1
  20. package/lib/mutation/engine.js +392 -96
  21. package/lib/mutation.js +22 -130
  22. package/lib/noop-guard.js +20 -9
  23. package/lib/prompts.js +20 -18
  24. package/lib/read-and-serve.js +44 -20
  25. package/lib/sandbox.js +1 -1
  26. package/lib/session-view.js +57 -43
  27. package/lib/snapshot-store/index.js +97 -0
  28. package/lib/snapshot-store/lineage-store.js +400 -0
  29. package/lib/snapshot-store/migrate.js +80 -0
  30. package/lib/snapshot-store/pairing.js +412 -0
  31. package/lib/snapshot-store/txn.js +63 -0
  32. package/lib/snapshot-store/vacuum.js +243 -0
  33. package/lib/store-lifecycle.js +13 -1
  34. package/lib/store-retry.js +34 -0
  35. package/lib/tool-edit.js +90 -44
  36. package/lib/tool-read.js +29 -1
  37. package/lib/tool-str-replace-editor.js +26 -18
  38. package/lib/tool-undo.js +25 -8
  39. package/lib/types/constants.d.ts +5 -2
  40. package/lib/types/contract.d.ts +76 -71
  41. package/lib/types/domain-errors.d.ts +410 -0
  42. package/lib/types/edit-response.d.ts +1 -1
  43. package/lib/types/file-encoding-state.d.ts +1 -0
  44. package/lib/types/file-view.d.ts +35 -6
  45. package/lib/types/hash-store.d.ts +38 -19
  46. package/lib/types/hashline/anchor-pipeline.d.ts +117 -36
  47. package/lib/types/hashline/hash-assign.d.ts +5 -5
  48. package/lib/types/hashline/hash.d.ts +1 -1
  49. package/lib/types/hashline/index.d.ts +2 -2
  50. package/lib/types/hashline/served-guard.d.ts +100 -0
  51. package/lib/types/index.d.ts +2 -2
  52. package/lib/types/mutation/engine.d.ts +49 -30
  53. package/lib/types/mutation.d.ts +1 -39
  54. package/lib/types/noop-guard.d.ts +4 -4
  55. package/lib/types/prompts.d.ts +1 -1
  56. package/lib/types/read-and-serve.d.ts +6 -0
  57. package/lib/types/sandbox.d.ts +1 -1
  58. package/lib/types/session-view.d.ts +38 -9
  59. package/lib/types/snapshot-store/index.d.ts +28 -0
  60. package/lib/types/snapshot-store/lineage-store.d.ts +96 -0
  61. package/lib/types/snapshot-store/migrate.d.ts +16 -0
  62. package/lib/types/snapshot-store/pairing.d.ts +99 -0
  63. package/lib/types/snapshot-store/txn.d.ts +12 -0
  64. package/lib/types/snapshot-store/vacuum.d.ts +79 -0
  65. package/lib/types/store-lifecycle.d.ts +0 -1
  66. package/lib/types/store-retry.d.ts +6 -0
  67. package/lib/types/tool-edit.d.ts +2 -2
  68. package/lib/types/tool-str-replace-editor.d.ts +2 -2
  69. package/lib/types/utils.d.ts +5 -6
  70. package/lib/types/workspace-context.d.ts +0 -1
  71. package/lib/undo-edit.js +27 -11
  72. package/lib/utils.js +12 -12
  73. package/lib/workspace-context.js +4 -8
  74. package/lib/write-hook.js +13 -4
  75. package/package.json +9 -10
package/lib/write-hook.js CHANGED
@@ -10,6 +10,7 @@ import { execCwd, execSessionKey, withWorkspace } from "./workspace-context.js";
10
10
  import { loadServed } from "./session-view.js";
11
11
  import { HASH_SEP } from "./hashline/hash-assign.js";
12
12
  import { abortIf, splitLines } from "./utils.js";
13
+ import { formatError } from "./domain-errors.js";
13
14
  const AUTO_READ_HEADING = "--- Auto-read (hashline anchors) ---";
14
15
  /**
15
16
  * Find a copied hashline prefix without treating arbitrary `3-char│` text as
@@ -40,10 +41,15 @@ export async function servedHashEchoDenial(io, rawPath, content, cwd, sessionKey
40
41
  const match = findServedHashEcho(content, served);
41
42
  if (!match)
42
43
  return undefined;
43
- return (`[MODEL] [E_SERVED_ECHO] Refused write to ${rawPath}: line ${match.line} begins with ` +
44
- `the exact ${match.hash}${HASH_SEP} anchor served for this session, path, and line. ` +
45
- `HASH${HASH_SEP} anchors are tool output, not file content. ` +
46
- "Retry with file content only (remove the entire copied anchor chain). Nothing was written.");
44
+ // A write echo names the same session/path/line the anchor was served for,
45
+ // so the served line equals the content line.
46
+ return formatError("E_SUSPICIOUS_TEXT", {
47
+ target: "write",
48
+ path: rawPath,
49
+ line: match.line,
50
+ hash: match.hash,
51
+ servedLine: match.line,
52
+ });
47
53
  }
48
54
  /**
49
55
  * Register the pre-write echo guard and post-write auto-read on the calling
@@ -65,6 +71,9 @@ export function registerWriteHook(rootCtx, agentCtx, io) {
65
71
  const content = args?.content;
66
72
  if (typeof rawPath !== "string" || typeof content !== "string")
67
73
  return next();
74
+ // F2: no mode escape here — the built-in write tool takes file_path /
75
+ // content only, so a mode branch would be dead and the refusal below
76
+ // must not promise it.
68
77
  const cwd = execCwd(exec);
69
78
  return withWorkspace(cwd, async () => {
70
79
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-edit",
3
- "version": "0.8.2",
3
+ "version": "1.0.0",
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",
@@ -52,12 +52,11 @@
52
52
  "prepare": "tsc -p tsconfig.json && husky",
53
53
  "build": "tsc -p tsconfig.json",
54
54
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
55
+ "typecheck:test": "tsc --noEmit -p tsconfig.test.json",
55
56
  "test": "vitest run",
56
57
  "test:watch": "vitest",
57
58
  "prepublishOnly": "npm run typecheck && npm test && node scripts/assert-tagged.mjs",
58
59
  "benchmark": "node benchmark/run.mjs",
59
- "postpublish": "node scripts/tag-current.mjs",
60
- "release": "node scripts/release.mjs",
61
60
  "lint": "oxlint .",
62
61
  "lint:fix": "oxlint --fix .",
63
62
  "format": "oxfmt --check .",
@@ -77,12 +76,12 @@
77
76
  "@commitlint/cli": "^21.2.2",
78
77
  "@commitlint/config-conventional": "^21.2.2",
79
78
  "@deepseek-ai/cordis": "^4.0.1",
80
- "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
81
- "@deepseek-ai/dsh-fs": "0.1.1-rc.2",
82
- "@deepseek-ai/dsh-home-paths": "0.1.1-rc.2",
83
- "@deepseek-ai/dsh-sandbox": "0.1.1-rc.2",
84
- "@deepseek-ai/dsh-session": "0.1.1-rc.2",
85
- "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
79
+ "@deepseek-ai/dsh-agent": "0.1.6-alpha.2",
80
+ "@deepseek-ai/dsh-fs": "0.1.6-alpha.2",
81
+ "@deepseek-ai/dsh-home-paths": "0.1.6-alpha.2",
82
+ "@deepseek-ai/dsh-sandbox": "0.1.6-alpha.2",
83
+ "@deepseek-ai/dsh-session": "0.1.6-alpha.2",
84
+ "@deepseek-ai/dsh-tools": "0.1.6-alpha.2",
86
85
  "@semantic-release/changelog": "^7.0.0",
87
86
  "@semantic-release/git": "^11.0.1",
88
87
  "@semantic-release/github": "^12.0.9",
@@ -91,7 +90,7 @@
91
90
  "conventional-changelog-conventionalcommits": "^8.0.0",
92
91
  "husky": "^9.1.7",
93
92
  "js-tiktoken": "1.0.21",
94
- "oxfmt": ">=0.15",
93
+ "oxfmt": "0.67.0",
95
94
  "oxlint": ">=1",
96
95
  "semantic-release": "^25.0.9",
97
96
  "tsx": ">=4",