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.
- package/README.md +57 -45
- package/cordis.patch.yml +3 -3
- package/lib/index.js +3175 -3943
- package/lib/types/dsh/contracts.d.ts +12 -3
- package/lib/types/dsh/fs.d.ts +3 -0
- package/lib/types/dsh/guidance.d.ts +5 -5
- package/lib/types/dsh/hide.d.ts +79 -0
- package/lib/types/dsh/host-compat.d.ts +7 -78
- package/lib/types/dsh/index.d.ts +21 -9
- package/lib/types/dsh/metrics/events.d.ts +1 -1
- package/lib/types/dsh/metrics/observer.d.ts +1 -1
- package/lib/types/dsh/sandbox.d.ts +2 -2
- package/lib/types/dsh/shell-hook.d.ts +1 -1
- package/lib/types/dsh/tools/apply-patch.d.ts +38 -0
- package/lib/types/dsh/tools/read.d.ts +3 -3
- package/lib/types/src/apply-patch/commit.d.ts +49 -0
- package/lib/types/src/apply-patch/grammar.d.ts +29 -0
- package/lib/types/src/apply-patch/lifecycle.d.ts +32 -0
- package/lib/types/src/apply-patch/plan.d.ts +50 -0
- package/lib/types/src/apply-patch/render.d.ts +51 -0
- package/lib/types/src/apply-patch/resolve.d.ts +129 -0
- package/lib/types/src/apply-patch/tool.d.ts +54 -0
- package/lib/types/src/apply-patch/types.d.ts +362 -0
- package/lib/types/src/domain-errors.d.ts +16 -2
- package/lib/types/src/edit-undo.d.ts +11 -2
- package/lib/types/src/file-content/index.d.ts +1 -1
- package/lib/types/src/file-content/preview.d.ts +1 -1
- package/lib/types/src/fs-lifecycle.d.ts +44 -0
- package/lib/types/src/hashline/alphabet.d.ts +4 -3
- package/lib/types/src/hashline/hash-identity.d.ts +12 -7
- package/lib/types/src/host-utils.d.ts +63 -0
- package/lib/types/src/mutation-engine/edit-request.d.ts +34 -0
- package/lib/types/src/mutation-engine/pipeline.d.ts +8 -1
- package/lib/types/src/mutation-engine/types.d.ts +40 -50
- package/lib/types/src/served-session/serve-render.d.ts +6 -0
- package/lib/types/src/undo-store.d.ts +17 -1
- package/package.json +18 -21
- package/prompts/apply-patch-guidelines.md +10 -0
- package/prompts/apply-patch.md +1 -0
- package/prompts/read-guidelines.md +4 -4
- package/prompts/read.md +1 -1
- package/prompts/undo-last-edit-guidelines.md +2 -2
- package/prompts/undo-last-edit-snippet.md +1 -1
- package/prompts/undo-last-edit.md +1 -1
- package/src/apply-patch/commit.ts +190 -0
- package/src/apply-patch/grammar.ts +620 -0
- package/src/apply-patch/index.ts +17 -0
- package/src/apply-patch/lifecycle.ts +195 -0
- package/src/apply-patch/plan.ts +800 -0
- package/src/apply-patch/render.ts +137 -0
- package/src/apply-patch/resolve.ts +470 -0
- package/src/apply-patch/tool.ts +257 -0
- package/src/apply-patch/types.ts +387 -0
- package/src/cut-repair.ts +77 -11
- package/src/domain-errors.ts +35 -3
- package/src/edit-undo.ts +379 -25
- package/src/file-content/index.ts +1 -1
- package/src/file-content/preview.ts +1 -1
- package/src/file-content/served-header.ts +1 -1
- package/src/fs-lifecycle.ts +201 -0
- package/src/hash-store.ts +18 -1
- package/src/hashline/alphabet.ts +7 -7
- package/src/hashline/hash-identity.ts +12 -7
- package/src/host-utils.ts +224 -0
- package/src/mutation-engine/edit-request.ts +39 -0
- package/src/mutation-engine/pipeline.ts +198 -27
- package/src/mutation-engine/types.ts +39 -57
- package/src/mutation-queue.ts +1 -1
- package/src/prompts.ts +3 -30
- package/src/served-session/serve-render.ts +2 -2
- package/src/undo-store.ts +74 -5
- package/lib/types/dsh/tools/edit.d.ts +0 -10
- package/lib/types/src/edit-tool.d.ts +0 -41
- package/lib/types/src/mutation-engine/engine.d.ts +0 -31
- package/lib/types/src/payload-contract.d.ts +0 -135
- package/prompts/edit-guidelines.md +0 -10
- package/prompts/edit-snippet.md +0 -1
- package/prompts/edit.md +0 -1
- package/src/bash-classifier.ts +0 -1626
- package/src/bash-conversion/decide.ts +0 -812
- package/src/bash-display-transform.ts +0 -50
- package/src/bash-multifile-config.ts +0 -239
- package/src/bash-view-config.ts +0 -158
- package/src/edit-normalize.ts +0 -8
- package/src/edit-render.ts +0 -161
- package/src/edit-tool.ts +0 -118
- package/src/edit.ts +0 -136
- package/src/integrations/pi-lens/command.ts +0 -712
- package/src/integrations/pi-lens/config.ts +0 -148
- package/src/integrations/pi-lens/io-bridge-adapter.ts +0 -234
- package/src/integrations/pi-lens/io-bridge.ts +0 -112
- package/src/integrations/pi-lens/settings-overlay.ts +0 -272
- package/src/lifecycle-hooks/index.ts +0 -1992
- package/src/lifecycle-hooks/types.ts +0 -64
- package/src/mutated-files.ts +0 -75
- package/src/mutation-engine/engine.ts +0 -239
- package/src/mutation-engine/index.ts +0 -17
- package/src/payload-contract.ts +0 -685
- package/src/preview-controller.ts +0 -84
- package/src/read.ts +0 -865
- package/src/search-hook.ts +0 -41
- package/src/store-config.ts +0 -73
- package/src/store-janitor-warning.ts +0 -169
- package/src/store-janitor.ts +0 -539
- package/src/store-kernel/settings.ts +0 -233
- package/src/store.ts +0 -154
- package/src/tui-presenter.ts +0 -134
- 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
|
-
}
|