dsh-hashline-edit 0.2.2 → 0.3.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 (118) hide show
  1. package/README.md +57 -45
  2. package/cordis.patch.yml +9 -3
  3. package/lib/client.js +231 -0
  4. package/lib/index.js +3298 -3957
  5. package/lib/types/dsh/contracts.d.ts +12 -3
  6. package/lib/types/dsh/fs.d.ts +3 -0
  7. package/lib/types/dsh/guidance.d.ts +12 -6
  8. package/lib/types/dsh/hide.d.ts +79 -0
  9. package/lib/types/dsh/host-compat.d.ts +7 -78
  10. package/lib/types/dsh/index.d.ts +53 -10
  11. package/lib/types/dsh/metrics/events.d.ts +1 -1
  12. package/lib/types/dsh/metrics/observer.d.ts +1 -1
  13. package/lib/types/dsh/sandbox.d.ts +2 -2
  14. package/lib/types/dsh/shell-hook.d.ts +1 -1
  15. package/lib/types/dsh/tools/apply-patch.d.ts +38 -0
  16. package/lib/types/dsh/tools/read.d.ts +3 -3
  17. package/lib/types/src/apply-patch/commit.d.ts +49 -0
  18. package/lib/types/src/apply-patch/grammar.d.ts +29 -0
  19. package/lib/types/src/apply-patch/lifecycle.d.ts +32 -0
  20. package/lib/types/src/apply-patch/plan.d.ts +50 -0
  21. package/lib/types/src/apply-patch/render.d.ts +51 -0
  22. package/lib/types/src/apply-patch/resolve.d.ts +129 -0
  23. package/lib/types/src/apply-patch/tool.d.ts +54 -0
  24. package/lib/types/src/apply-patch/types.d.ts +362 -0
  25. package/lib/types/src/domain-errors.d.ts +16 -2
  26. package/lib/types/src/edit-undo.d.ts +11 -2
  27. package/lib/types/src/file-content/index.d.ts +1 -1
  28. package/lib/types/src/file-content/preview.d.ts +1 -1
  29. package/lib/types/src/fs-lifecycle.d.ts +44 -0
  30. package/lib/types/src/hashline/alphabet.d.ts +4 -3
  31. package/lib/types/src/hashline/hash-identity.d.ts +12 -7
  32. package/lib/types/src/host-utils.d.ts +63 -0
  33. package/lib/types/src/mutation-engine/edit-request.d.ts +34 -0
  34. package/lib/types/src/mutation-engine/pipeline.d.ts +8 -1
  35. package/lib/types/src/mutation-engine/types.d.ts +40 -50
  36. package/lib/types/src/served-session/serve-render.d.ts +6 -0
  37. package/lib/types/src/undo-store.d.ts +17 -1
  38. package/package.json +37 -21
  39. package/prompts/apply-patch-guidelines.md +4 -0
  40. package/prompts/apply-patch.md +1 -0
  41. package/prompts/read-guidelines.md +6 -6
  42. package/prompts/read.md +1 -1
  43. package/prompts/undo-last-edit-guidelines.md +2 -2
  44. package/prompts/undo-last-edit-snippet.md +1 -1
  45. package/prompts/undo-last-edit.md +1 -1
  46. package/prompts/zh/apply-patch-guidelines.md +4 -0
  47. package/prompts/zh/apply-patch.md +1 -0
  48. package/prompts/zh/read-guidelines.md +6 -0
  49. package/prompts/zh/read-snippet.md +1 -0
  50. package/prompts/zh/read.md +1 -0
  51. package/prompts/zh/undo-last-edit-guidelines.md +2 -0
  52. package/prompts/zh/undo-last-edit-snippet.md +1 -0
  53. package/prompts/zh/undo-last-edit.md +1 -0
  54. package/src/apply-patch/commit.ts +190 -0
  55. package/src/apply-patch/grammar.ts +620 -0
  56. package/src/apply-patch/index.ts +17 -0
  57. package/src/apply-patch/lifecycle.ts +195 -0
  58. package/src/apply-patch/plan.ts +800 -0
  59. package/src/apply-patch/render.ts +137 -0
  60. package/src/apply-patch/resolve.ts +470 -0
  61. package/src/apply-patch/tool.ts +257 -0
  62. package/src/apply-patch/types.ts +387 -0
  63. package/src/cut-repair.ts +77 -11
  64. package/src/domain-errors.ts +35 -3
  65. package/src/edit-undo.ts +379 -25
  66. package/src/file-content/index.ts +1 -1
  67. package/src/file-content/preview.ts +1 -1
  68. package/src/file-content/served-header.ts +1 -1
  69. package/src/fs-lifecycle.ts +201 -0
  70. package/src/hash-store.ts +18 -1
  71. package/src/hashline/alphabet.ts +7 -7
  72. package/src/hashline/hash-identity.ts +12 -7
  73. package/src/host-utils.ts +224 -0
  74. package/src/mutation-engine/edit-request.ts +39 -0
  75. package/src/mutation-engine/pipeline.ts +198 -27
  76. package/src/mutation-engine/types.ts +39 -57
  77. package/src/mutation-queue.ts +1 -1
  78. package/src/prompts.ts +3 -30
  79. package/src/served-session/serve-render.ts +2 -2
  80. package/src/undo-store.ts +74 -5
  81. package/lib/types/dsh/tools/edit.d.ts +0 -10
  82. package/lib/types/src/edit-tool.d.ts +0 -41
  83. package/lib/types/src/mutation-engine/engine.d.ts +0 -31
  84. package/lib/types/src/payload-contract.d.ts +0 -135
  85. package/prompts/edit-guidelines.md +0 -10
  86. package/prompts/edit-snippet.md +0 -1
  87. package/prompts/edit.md +0 -1
  88. package/prompts/read-snippet.md +0 -1
  89. package/src/bash-classifier.ts +0 -1626
  90. package/src/bash-conversion/decide.ts +0 -812
  91. package/src/bash-display-transform.ts +0 -50
  92. package/src/bash-multifile-config.ts +0 -239
  93. package/src/bash-view-config.ts +0 -158
  94. package/src/edit-normalize.ts +0 -8
  95. package/src/edit-render.ts +0 -161
  96. package/src/edit-tool.ts +0 -118
  97. package/src/edit.ts +0 -136
  98. package/src/integrations/pi-lens/command.ts +0 -712
  99. package/src/integrations/pi-lens/config.ts +0 -148
  100. package/src/integrations/pi-lens/io-bridge-adapter.ts +0 -234
  101. package/src/integrations/pi-lens/io-bridge.ts +0 -112
  102. package/src/integrations/pi-lens/settings-overlay.ts +0 -272
  103. package/src/lifecycle-hooks/index.ts +0 -1992
  104. package/src/lifecycle-hooks/types.ts +0 -64
  105. package/src/mutated-files.ts +0 -75
  106. package/src/mutation-engine/engine.ts +0 -239
  107. package/src/mutation-engine/index.ts +0 -17
  108. package/src/payload-contract.ts +0 -685
  109. package/src/preview-controller.ts +0 -84
  110. package/src/read.ts +0 -865
  111. package/src/search-hook.ts +0 -41
  112. package/src/store-config.ts +0 -73
  113. package/src/store-janitor-warning.ts +0 -169
  114. package/src/store-janitor.ts +0 -539
  115. package/src/store-kernel/settings.ts +0 -233
  116. package/src/store.ts +0 -154
  117. package/src/tui-presenter.ts +0 -134
  118. package/src/write-hook.ts +0 -130
@@ -1,84 +0,0 @@
1
- import { getPreviewInput, type RPreview, type RRState } from "./edit-render.js";
2
-
3
- export const PREVIEW_DEBOUNCE_MS = 150;
4
-
5
- export interface PreviewHost {
6
- cwd: string;
7
- executionStarted: boolean;
8
- argsComplete: boolean;
9
- state: RRState;
10
- invalidate: () => void;
11
- }
12
-
13
- export type PreviewCompute = (args: unknown, cwd: string) => Promise<RPreview>;
14
-
15
- // SAFETY: large-class — cohesive store owns DB and cache as single owner; split would scatter invariants.
16
- export class DebouncedPreview {
17
- constructor(
18
- private readonly compute: PreviewCompute,
19
- private readonly debounceMs: number = PREVIEW_DEBOUNCE_MS,
20
- private readonly getSessionId?: () => string | undefined,
21
- ) {}
22
-
23
- renderCall(host: PreviewHost, args: unknown): void {
24
- const { state } = host;
25
- const previewInput = getPreviewInput(args);
26
- if (host.executionStarted || !host.argsComplete || !previewInput) {
27
- this.cancel(state);
28
- return;
29
- }
30
- const argsKey = JSON.stringify(previewInput);
31
- if (state.argsKey === argsKey) return;
32
- this.cancel(state);
33
- state.argsKey = argsKey;
34
- const previewGeneration = (state.previewGeneration ?? 0) + 1;
35
- state.previewGeneration = previewGeneration;
36
- // WHY: (#168-class) the compute's session is bound at arm time: if the serving session
37
- // WHY: changed before the timer fires, verifying these anchors against the new session
38
- // WHY: would mint a false E_UNKNOWN_ANCHOR, so the stale compute is dropped (cancelled)
39
- // WHY: and the next renderCall re-arms against the session that actually serves anchors.
40
- const armedSessionId = this.getSessionId?.();
41
- state.previewTimer = setTimeout(() => {
42
- delete state.previewTimer;
43
- if (this.getSessionId && this.getSessionId() !== armedSessionId) {
44
- this.cancel(state);
45
- host.invalidate();
46
- return;
47
- }
48
- this.compute(args, host.cwd)
49
- .then((preview) => {
50
- if (state.argsKey === argsKey && state.previewGeneration === previewGeneration) {
51
- state.preview = preview;
52
- host.invalidate();
53
- }
54
- })
55
- .catch((err: unknown) => {
56
- if (state.argsKey === argsKey && state.previewGeneration === previewGeneration) {
57
- state.preview = {
58
- error: err instanceof Error ? err.message : String(err),
59
- };
60
- host.invalidate();
61
- }
62
- });
63
- }, this.debounceMs);
64
- }
65
-
66
- cancel(state: RRState): void {
67
- if (state.previewTimer) {
68
- clearTimeout(state.previewTimer);
69
- delete state.previewTimer;
70
- }
71
- delete state.argsKey;
72
- delete state.preview;
73
- state.previewGeneration = (state.previewGeneration ?? 0) + 1;
74
- }
75
-
76
- clearResult(state: RRState): void {
77
- if (state.previewTimer) {
78
- clearTimeout(state.previewTimer);
79
- delete state.previewTimer;
80
- }
81
- delete state.preview;
82
- state.previewGeneration = (state.previewGeneration ?? 0) + 1;
83
- }
84
- }