dsh-better-edit 0.2.2 → 0.3.1

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 (85) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +317 -240
  3. package/README.zh.md +19 -11
  4. package/lib/constants.js +3 -1
  5. package/lib/contract.js +159 -63
  6. package/lib/drift.js +5 -98
  7. package/lib/dsh-context.js +2 -24
  8. package/lib/edit-engine.js +9 -8
  9. package/lib/edit-pipeline.js +3 -121
  10. package/lib/edit-response.js +16 -8
  11. package/lib/file-kind.js +6 -121
  12. package/lib/file-reader.js +4 -77
  13. package/lib/file-view.js +486 -0
  14. package/lib/guidance/index.js +8 -0
  15. package/lib/guidance/materialize.js +212 -0
  16. package/lib/guidance/parse.js +80 -0
  17. package/lib/guidance/resolve.js +116 -0
  18. package/lib/guidance.js +6 -388
  19. package/lib/hash-store.js +6 -4
  20. package/lib/hashline/alphabet.js +2 -6
  21. package/lib/hashline/anchor-pipeline.js +786 -0
  22. package/lib/hashline/apply.js +2 -223
  23. package/lib/hashline/hash-assign.js +255 -0
  24. package/lib/hashline/hash.js +67 -29
  25. package/lib/hashline/hasher.js +2 -23
  26. package/lib/hashline/index.js +9 -4
  27. package/lib/hashline/parse.js +2 -35
  28. package/lib/hashline/pure.js +2 -213
  29. package/lib/hashline/resolve.js +3 -361
  30. package/lib/hashline/served.js +2 -120
  31. package/lib/index.js +1 -3
  32. package/lib/mutation.js +266 -0
  33. package/lib/noop-guard.js +20 -0
  34. package/lib/preview-controller.js +65 -0
  35. package/lib/prompts.js +14 -20
  36. package/lib/read-and-serve.js +23 -23
  37. package/lib/read-render.js +3 -139
  38. package/lib/served-store.js +2 -216
  39. package/lib/session-view.js +332 -0
  40. package/lib/tool-batch-edit.js +9 -10
  41. package/lib/tool-edit.js +73 -129
  42. package/lib/tool-read.js +3 -5
  43. package/lib/tool-undo.js +16 -10
  44. package/lib/truncate.js +3 -95
  45. package/lib/types/constants.d.ts +2 -0
  46. package/lib/types/contract.d.ts +120 -15
  47. package/lib/types/drift.d.ts +5 -29
  48. package/lib/types/dsh-context.d.ts +2 -20
  49. package/lib/types/edit-engine.d.ts +2 -2
  50. package/lib/types/edit-pipeline.d.ts +3 -44
  51. package/lib/types/file-kind.d.ts +6 -18
  52. package/lib/types/file-reader.d.ts +4 -45
  53. package/lib/types/file-view.d.ts +139 -0
  54. package/lib/types/guidance/index.d.ts +8 -0
  55. package/lib/types/guidance/materialize.d.ts +23 -0
  56. package/lib/types/guidance/parse.d.ts +36 -0
  57. package/lib/types/guidance/resolve.d.ts +55 -0
  58. package/lib/types/guidance.d.ts +6 -127
  59. package/lib/types/hashline/alphabet.d.ts +1 -5
  60. package/lib/types/hashline/anchor-pipeline.d.ts +127 -0
  61. package/lib/types/hashline/apply.d.ts +1 -22
  62. package/lib/types/hashline/hash-assign.d.ts +25 -0
  63. package/lib/types/hashline/hash.d.ts +8 -9
  64. package/lib/types/hashline/hasher.d.ts +1 -8
  65. package/lib/types/hashline/index.d.ts +12 -4
  66. package/lib/types/hashline/parse.d.ts +1 -7
  67. package/lib/types/hashline/pure.d.ts +1 -26
  68. package/lib/types/hashline/resolve.d.ts +1 -58
  69. package/lib/types/hashline/served.d.ts +1 -43
  70. package/lib/types/mutation.d.ts +131 -0
  71. package/lib/types/noop-guard.d.ts +29 -0
  72. package/lib/types/preview-controller.d.ts +33 -0
  73. package/lib/types/prompts.d.ts +9 -9
  74. package/lib/types/read-and-serve.d.ts +6 -5
  75. package/lib/types/read-render.d.ts +3 -18
  76. package/lib/types/served-store.d.ts +2 -81
  77. package/lib/types/session-view.d.ts +92 -0
  78. package/lib/types/tool-edit.d.ts +3 -14
  79. package/lib/types/truncate.d.ts +3 -29
  80. package/lib/types/validation.d.ts +6 -7
  81. package/lib/types/workspace.d.ts +2 -21
  82. package/lib/validation.js +6 -33
  83. package/lib/workspace.js +2 -27
  84. package/lib/write-hook.js +2 -2
  85. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -6,6 +6,39 @@ Entries link to the originating spec issue in [pi-hashline-edit-lsz](https://git
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.1] - 2026-08-21
10
+
11
+ ### Changed
12
+
13
+ - Deepen `Mutation` owns edit lifecycle (C01, #21): collapse `tool-edit` orchestrator (260→121 lines) into `mutation.ts:execute()` deep seam — one interface owning `applySequence → commit → buildBatchResult → recordServedTruncated` with correct `undoUnavailableMessage`/`restoreUnwrittenUndos` branching; `tool-edit` thin adapter `validate → execute`.
14
+
15
+ - Heal guidance ghost (C02, #21): remove `batch_edit` seam — `GUIDANCE_SECTIONS` 4→3, `materialize.ts` ghost `batch_edit.md` cleanup (shipped + custom presets, `ENOENT`-tolerant), keep `BATCH_EDIT_*` as `@deprecated` aliases; order gap `132` preserved.
16
+
17
+ ### Fixed
18
+
19
+ - Dense `servedRows` port `pi-better-edit@7b91958` (post-v1.1.4): `edit-response:buildChanged/buildBatchResult` and `tool-undo` now emit dense `0..n-1` `servedRows` instead of sparse diff rows; `firstChangedLine` fallback to `undoDiffResult` — fixes `E_RANGE_UNVERIFIED` on chained edits.
20
+
21
+ - Fix `tool-undo` SAFETY cast `canonical as unknown as FsEscalationArgs` + `withWorkspace` indentation (2→4 tabs) and `edit-response` biome fixes (no behavior change).
22
+
23
+ - Fix `guidance/resolve.ts` double-tab indent left by `batch_edit` removal on `tool:undo_last_edit` entry.
24
+
25
+ ### Added
26
+
27
+ - Docs: `CLAUDE.md` upstream sync section — last absorbed checkpoint `7b91958` (dense `servedRows`), procedure, checkpoint history, `upstream` remote.
28
+
29
+
30
+ ## [0.3.0] - 2026-08-20
31
+
32
+ ### Changed
33
+
34
+ - **BREAKING** — `edit` now requires `{ path, edits: [[remove_from, remove_to, replacement_text], ...] }` tuple payload (ADR-0003); `batch_edit` removed — single `edit` covers single and batched edits via `edits` arity (ADR-0007). `EDITS_MAX_ITEMS=32`, path nullable (`null` infers from anchors). Old top-level `{remove_from,remove_to,replacement_text}` shape now fails with `[E_BAD_SHAPE]`.
35
+ - Whitespace-insensitive anchors (ADR-0002): `canon()` strips all ASCII whitespace `[ \t\r\n]` (`CANON_VERSION=2`, memoized `getCanon`), snapshot cache versioned so pre-upgrade caches invalidate; formatter-only drift (prettier/black) no longer rotates anchors. String-internal whitespace caveat documented.
36
+ - Orphaned serve healing & served robustness (ADR-0004): `SessionView.patchServed` eagerly heals stale duplicates, `verifyServedRange` disambiguates candidate spans, truncation on rejection-echo/external-shrink ends the `E_RANGE_UNVERIFIED` self-loop.
37
+ - Hashline purity & store seams (ARCH C1-C4): `HashSnapshotIO` injection keeps hashing pure, `recordDiffServes` helper, one `applyOneEdit` composition, `DebouncedPreview` (150ms) extracted, noop-loop folded, per-domain stmt slices.
38
+ - Notices & prompts hygiene: Zed-style terse drift/noop/rejection notices (codes unchanged), lean guidelines (dedupe tool descriptions), tool schema descriptions trimmed to one-liners.
39
+ - README brooks-lint reorg + CONTEXT glossary merge: hook, shining points, Why Hashline before Tools, benchmark section referencing `pi-better-edit/benchmarks/results/` (same hashline algorithm).
40
+
41
+
9
42
  ## [0.2.2] - 2026-08-19
10
43
 
11
44
  ### Added