dsh-hashline-edit 0.2.2 → 0.2.3

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 (108) hide show
  1. package/README.md +57 -45
  2. package/cordis.patch.yml +3 -3
  3. package/lib/index.js +3175 -3943
  4. package/lib/types/dsh/contracts.d.ts +12 -3
  5. package/lib/types/dsh/fs.d.ts +3 -0
  6. package/lib/types/dsh/guidance.d.ts +5 -5
  7. package/lib/types/dsh/hide.d.ts +79 -0
  8. package/lib/types/dsh/host-compat.d.ts +7 -78
  9. package/lib/types/dsh/index.d.ts +21 -9
  10. package/lib/types/dsh/metrics/events.d.ts +1 -1
  11. package/lib/types/dsh/metrics/observer.d.ts +1 -1
  12. package/lib/types/dsh/sandbox.d.ts +2 -2
  13. package/lib/types/dsh/shell-hook.d.ts +1 -1
  14. package/lib/types/dsh/tools/apply-patch.d.ts +38 -0
  15. package/lib/types/dsh/tools/read.d.ts +3 -3
  16. package/lib/types/src/apply-patch/commit.d.ts +49 -0
  17. package/lib/types/src/apply-patch/grammar.d.ts +29 -0
  18. package/lib/types/src/apply-patch/lifecycle.d.ts +32 -0
  19. package/lib/types/src/apply-patch/plan.d.ts +50 -0
  20. package/lib/types/src/apply-patch/render.d.ts +51 -0
  21. package/lib/types/src/apply-patch/resolve.d.ts +129 -0
  22. package/lib/types/src/apply-patch/tool.d.ts +54 -0
  23. package/lib/types/src/apply-patch/types.d.ts +362 -0
  24. package/lib/types/src/domain-errors.d.ts +16 -2
  25. package/lib/types/src/edit-undo.d.ts +11 -2
  26. package/lib/types/src/file-content/index.d.ts +1 -1
  27. package/lib/types/src/file-content/preview.d.ts +1 -1
  28. package/lib/types/src/fs-lifecycle.d.ts +44 -0
  29. package/lib/types/src/hashline/alphabet.d.ts +4 -3
  30. package/lib/types/src/hashline/hash-identity.d.ts +12 -7
  31. package/lib/types/src/host-utils.d.ts +63 -0
  32. package/lib/types/src/mutation-engine/edit-request.d.ts +34 -0
  33. package/lib/types/src/mutation-engine/pipeline.d.ts +8 -1
  34. package/lib/types/src/mutation-engine/types.d.ts +40 -50
  35. package/lib/types/src/served-session/serve-render.d.ts +6 -0
  36. package/lib/types/src/undo-store.d.ts +17 -1
  37. package/package.json +18 -21
  38. package/prompts/apply-patch-guidelines.md +10 -0
  39. package/prompts/apply-patch.md +1 -0
  40. package/prompts/read-guidelines.md +4 -4
  41. package/prompts/read.md +1 -1
  42. package/prompts/undo-last-edit-guidelines.md +2 -2
  43. package/prompts/undo-last-edit-snippet.md +1 -1
  44. package/prompts/undo-last-edit.md +1 -1
  45. package/src/apply-patch/commit.ts +190 -0
  46. package/src/apply-patch/grammar.ts +620 -0
  47. package/src/apply-patch/index.ts +17 -0
  48. package/src/apply-patch/lifecycle.ts +195 -0
  49. package/src/apply-patch/plan.ts +800 -0
  50. package/src/apply-patch/render.ts +137 -0
  51. package/src/apply-patch/resolve.ts +470 -0
  52. package/src/apply-patch/tool.ts +257 -0
  53. package/src/apply-patch/types.ts +387 -0
  54. package/src/cut-repair.ts +77 -11
  55. package/src/domain-errors.ts +35 -3
  56. package/src/edit-undo.ts +379 -25
  57. package/src/file-content/index.ts +1 -1
  58. package/src/file-content/preview.ts +1 -1
  59. package/src/file-content/served-header.ts +1 -1
  60. package/src/fs-lifecycle.ts +201 -0
  61. package/src/hash-store.ts +18 -1
  62. package/src/hashline/alphabet.ts +7 -7
  63. package/src/hashline/hash-identity.ts +12 -7
  64. package/src/host-utils.ts +224 -0
  65. package/src/mutation-engine/edit-request.ts +39 -0
  66. package/src/mutation-engine/pipeline.ts +198 -27
  67. package/src/mutation-engine/types.ts +39 -57
  68. package/src/mutation-queue.ts +1 -1
  69. package/src/prompts.ts +3 -30
  70. package/src/served-session/serve-render.ts +2 -2
  71. package/src/undo-store.ts +74 -5
  72. package/lib/types/dsh/tools/edit.d.ts +0 -10
  73. package/lib/types/src/edit-tool.d.ts +0 -41
  74. package/lib/types/src/mutation-engine/engine.d.ts +0 -31
  75. package/lib/types/src/payload-contract.d.ts +0 -135
  76. package/prompts/edit-guidelines.md +0 -10
  77. package/prompts/edit-snippet.md +0 -1
  78. package/prompts/edit.md +0 -1
  79. package/src/bash-classifier.ts +0 -1626
  80. package/src/bash-conversion/decide.ts +0 -812
  81. package/src/bash-display-transform.ts +0 -50
  82. package/src/bash-multifile-config.ts +0 -239
  83. package/src/bash-view-config.ts +0 -158
  84. package/src/edit-normalize.ts +0 -8
  85. package/src/edit-render.ts +0 -161
  86. package/src/edit-tool.ts +0 -118
  87. package/src/edit.ts +0 -136
  88. package/src/integrations/pi-lens/command.ts +0 -712
  89. package/src/integrations/pi-lens/config.ts +0 -148
  90. package/src/integrations/pi-lens/io-bridge-adapter.ts +0 -234
  91. package/src/integrations/pi-lens/io-bridge.ts +0 -112
  92. package/src/integrations/pi-lens/settings-overlay.ts +0 -272
  93. package/src/lifecycle-hooks/index.ts +0 -1992
  94. package/src/lifecycle-hooks/types.ts +0 -64
  95. package/src/mutated-files.ts +0 -75
  96. package/src/mutation-engine/engine.ts +0 -239
  97. package/src/mutation-engine/index.ts +0 -17
  98. package/src/payload-contract.ts +0 -685
  99. package/src/preview-controller.ts +0 -84
  100. package/src/read.ts +0 -865
  101. package/src/search-hook.ts +0 -41
  102. package/src/store-config.ts +0 -73
  103. package/src/store-janitor-warning.ts +0 -169
  104. package/src/store-janitor.ts +0 -539
  105. package/src/store-kernel/settings.ts +0 -233
  106. package/src/store.ts +0 -154
  107. package/src/tui-presenter.ts +0 -134
  108. 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
- }