dsh-hashline-edit 0.1.1 → 0.2.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 (130) hide show
  1. package/README.md +70 -69
  2. package/cordis.patch.yml +1 -1
  3. package/lib/index.js +4143 -4518
  4. package/lib/types/dsh/contracts.d.ts +69 -6
  5. package/lib/types/dsh/fs.d.ts +38 -3
  6. package/lib/types/dsh/guidance.d.ts +5 -5
  7. package/lib/types/dsh/hide.d.ts +78 -0
  8. package/lib/types/dsh/host-compat.d.ts +7 -78
  9. package/lib/types/dsh/index.d.ts +17 -7
  10. package/lib/types/dsh/metrics/events.d.ts +8 -1
  11. package/lib/types/dsh/metrics/instrument.d.ts +20 -14
  12. package/lib/types/dsh/metrics/observer.d.ts +28 -0
  13. package/lib/types/dsh/sandbox.d.ts +2 -2
  14. package/lib/types/dsh/shell-hook.d.ts +17 -8
  15. package/lib/types/dsh/shell-view.d.ts +52 -0
  16. package/lib/types/dsh/tools/apply-patch.d.ts +38 -0
  17. package/lib/types/dsh/tools/context.d.ts +19 -1
  18. package/lib/types/dsh/tools/output.d.ts +32 -4
  19. package/lib/types/dsh/tools/read.d.ts +12 -15
  20. package/lib/types/dsh/tools/undo.d.ts +5 -0
  21. package/lib/types/dsh/write-hook.d.ts +8 -22
  22. package/lib/types/src/apply-patch/commit.d.ts +49 -0
  23. package/lib/types/src/apply-patch/grammar.d.ts +29 -0
  24. package/lib/types/src/apply-patch/lifecycle.d.ts +32 -0
  25. package/lib/types/src/apply-patch/plan.d.ts +50 -0
  26. package/lib/types/src/apply-patch/render.d.ts +51 -0
  27. package/lib/types/src/apply-patch/resolve.d.ts +129 -0
  28. package/lib/types/src/apply-patch/tool.d.ts +54 -0
  29. package/lib/types/src/apply-patch/types.d.ts +362 -0
  30. package/lib/types/src/domain-errors.d.ts +16 -2
  31. package/lib/types/src/edit-undo.d.ts +11 -2
  32. package/lib/types/src/file-content/detection.d.ts +17 -0
  33. package/lib/types/src/file-content/index.d.ts +2 -2
  34. package/lib/types/src/file-content/preview.d.ts +1 -1
  35. package/lib/types/src/fs-lifecycle.d.ts +44 -0
  36. package/lib/types/src/hashline/resolve.d.ts +6 -0
  37. package/lib/types/src/host-utils.d.ts +63 -0
  38. package/lib/types/src/mutation-engine/batch-span-gate.d.ts +6 -0
  39. package/lib/types/src/mutation-engine/edit-request.d.ts +34 -0
  40. package/lib/types/src/mutation-engine/pipeline.d.ts +18 -3
  41. package/lib/types/src/mutation-engine/types.d.ts +50 -58
  42. package/lib/types/src/read-expansion/grammar-manifest.d.ts +4 -2
  43. package/lib/types/src/read-expansion/java-decoration.d.ts +21 -0
  44. package/lib/types/src/read-expansion/span-expansion.d.ts +6 -2
  45. package/lib/types/src/read-expansion/span-kind.d.ts +3 -2
  46. package/lib/types/src/read-expansion/vue-decoration.d.ts +14 -0
  47. package/lib/types/src/served-session/serve-render.d.ts +9 -3
  48. package/lib/types/src/undo-store.d.ts +17 -1
  49. package/package.json +10 -22
  50. package/prompts/apply-patch-guidelines.md +10 -0
  51. package/prompts/apply-patch.md +1 -0
  52. package/prompts/read-guidelines.md +5 -5
  53. package/prompts/read.md +1 -1
  54. package/prompts/undo-last-edit-guidelines.md +2 -2
  55. package/prompts/undo-last-edit-snippet.md +1 -1
  56. package/prompts/undo-last-edit.md +1 -1
  57. package/src/apply-patch/commit.ts +190 -0
  58. package/src/apply-patch/grammar.ts +620 -0
  59. package/src/apply-patch/index.ts +17 -0
  60. package/src/apply-patch/lifecycle.ts +195 -0
  61. package/src/apply-patch/plan.ts +800 -0
  62. package/src/apply-patch/render.ts +137 -0
  63. package/src/apply-patch/resolve.ts +470 -0
  64. package/src/apply-patch/tool.ts +257 -0
  65. package/src/apply-patch/types.ts +387 -0
  66. package/src/cut-repair.ts +77 -11
  67. package/src/domain-errors.ts +58 -10
  68. package/src/edit-undo.ts +379 -25
  69. package/src/file-content/detection.ts +34 -0
  70. package/src/file-content/index.ts +2 -2
  71. package/src/file-content/preview.ts +1 -1
  72. package/src/file-content/served-header.ts +1 -1
  73. package/src/fs-lifecycle.ts +201 -0
  74. package/src/hash-store.ts +18 -1
  75. package/src/hashline/lease-resolve.ts +14 -8
  76. package/src/hashline/resolve.ts +30 -27
  77. package/src/host-utils.ts +224 -0
  78. package/src/mutation-engine/batch-span-gate.ts +17 -4
  79. package/src/mutation-engine/edit-request.ts +39 -0
  80. package/src/mutation-engine/pipeline.ts +535 -63
  81. package/src/mutation-engine/types.ts +49 -65
  82. package/src/mutation-queue.ts +1 -1
  83. package/src/prompts.ts +0 -28
  84. package/src/read-expansion/ast-provider.ts +4 -0
  85. package/src/read-expansion/grammar-manifest.ts +21 -2
  86. package/src/read-expansion/java-decoration.ts +34 -0
  87. package/src/read-expansion/span-expansion.ts +6 -2
  88. package/src/read-expansion/span-kind.ts +3 -1
  89. package/src/read-expansion/vue-decoration.ts +43 -0
  90. package/src/served-session/serve-render.ts +5 -5
  91. package/src/undo-store.ts +74 -5
  92. package/lib/types/dsh/encoding-bridge.d.ts +0 -25
  93. package/lib/types/dsh/encoding.d.ts +0 -144
  94. package/lib/types/dsh/tools/edit.d.ts +0 -10
  95. package/lib/types/src/edit-tool.d.ts +0 -41
  96. package/lib/types/src/mutation-engine/engine.d.ts +0 -31
  97. package/lib/types/src/payload-contract.d.ts +0 -124
  98. package/prompts/edit-guidelines.md +0 -10
  99. package/prompts/edit-snippet.md +0 -1
  100. package/prompts/edit.md +0 -1
  101. package/src/bash-classifier.ts +0 -1626
  102. package/src/bash-conversion/decide.ts +0 -812
  103. package/src/bash-display-transform.ts +0 -50
  104. package/src/bash-multifile-config.ts +0 -239
  105. package/src/bash-view-config.ts +0 -158
  106. package/src/edit-normalize.ts +0 -8
  107. package/src/edit-render.ts +0 -161
  108. package/src/edit-tool.ts +0 -116
  109. package/src/edit.ts +0 -136
  110. package/src/integrations/pi-lens/command.ts +0 -712
  111. package/src/integrations/pi-lens/config.ts +0 -148
  112. package/src/integrations/pi-lens/io-bridge-adapter.ts +0 -234
  113. package/src/integrations/pi-lens/io-bridge.ts +0 -112
  114. package/src/integrations/pi-lens/settings-overlay.ts +0 -272
  115. package/src/lifecycle-hooks/index.ts +0 -1992
  116. package/src/lifecycle-hooks/types.ts +0 -64
  117. package/src/mutated-files.ts +0 -75
  118. package/src/mutation-engine/engine.ts +0 -173
  119. package/src/mutation-engine/index.ts +0 -17
  120. package/src/payload-contract.ts +0 -637
  121. package/src/preview-controller.ts +0 -84
  122. package/src/read.ts +0 -865
  123. package/src/search-hook.ts +0 -41
  124. package/src/store-config.ts +0 -73
  125. package/src/store-janitor-warning.ts +0 -169
  126. package/src/store-janitor.ts +0 -539
  127. package/src/store-kernel/settings.ts +0 -233
  128. package/src/store.ts +0 -154
  129. package/src/tui-presenter.ts +0 -134
  130. package/src/write-hook.ts +0 -130
@@ -1,272 +0,0 @@
1
- /**
2
- * Interactive settings overlay — the headed form of `/pi-better-edit settings`.
3
- *
4
- * WHY this module keeps no I/O of its own: every diagnostic line derives from the
5
- * existing resolvers, readers and env consts, so the overlay cannot drift from the
6
- * status text it mirrors. Writes go through the matching saver for the active scope.
7
- */
8
- import {
9
- Container,
10
- SettingsList,
11
- Text,
12
- type SettingItem,
13
- type SettingsListTheme,
14
- } from "@earendil-works/pi-tui";
15
-
16
- import {
17
- BASH_VIEW_ENV_VAR,
18
- readBashViewConfig,
19
- resolveBashViewModeWithSource,
20
- saveBashViewConfig,
21
- type BashViewMode,
22
- } from "../../bash-view-config.js";
23
- import {
24
- READ_EXPANSION_ENV_VAR,
25
- readReadExpansionConfig,
26
- resolveReadExpansionModeWithSource,
27
- saveReadExpansionConfig,
28
- type ReadExpansionMode,
29
- } from "../../read-expansion-config.js";
30
- import { resolveBashMultiFileSettingsWithSources } from "../../bash-multifile-config.js";
31
- import type { ConfigScope } from "../../json-config.js";
32
- import {
33
- readLensBridgeConfig,
34
- resolveEffectiveLensModeWithSource,
35
- saveLensBridgeConfig,
36
- LENS_BRIDGE_ENV_VAR,
37
- type LensBridgeMode,
38
- } from "./config.js";
39
- import { saveStoreJanitorConfig } from "../../store-config.js";
40
- import {
41
- readStoreJanitorConfig,
42
- resolveStoreJanitorSettingsWithSources,
43
- STORE_JANITOR_ENV_VAR,
44
- } from "../../store-kernel/settings.js";
45
-
46
- /** WHY a local theme: pi-tui 0.85.1 ships the interface but no factory, so identity styling keeps the rows legible without inventing border art. */
47
- function getSettingsListTheme(): SettingsListTheme {
48
- return {
49
- label: (text: string): string => text,
50
- value: (text: string): string => text,
51
- description: (text: string): string => text,
52
- cursor: "> ",
53
- hint: (text: string): string => text,
54
- };
55
- }
56
-
57
- function envDisplay(raw: string | undefined): string {
58
- if (raw === undefined) return "unset";
59
- const trimmed = raw.trim();
60
- return trimmed.length > 0 ? trimmed : "unset";
61
- }
62
-
63
- function lensLine2(cwd: string): string {
64
- const effective = resolveEffectiveLensModeWithSource(cwd);
65
- const config = readLensBridgeConfig(cwd);
66
- const line =
67
- `Effective: ${effective.mode} (source: ${effective.source}) ` +
68
- `\u2022 Global: ${config.global ?? "unset"} \u2022 Env: ${envDisplay(process.env[LENS_BRIDGE_ENV_VAR])}`;
69
- return effective.source === "env"
70
- ? `\u26a0\ufe0f Overridden by ${LENS_BRIDGE_ENV_VAR} \u2022 ${line}`
71
- : line;
72
- }
73
-
74
- function bashViewLine2(cwd: string): string {
75
- const effective = resolveBashViewModeWithSource(cwd);
76
- const config = readBashViewConfig(cwd);
77
- const line =
78
- `Effective: ${effective.value} (source: ${effective.source}) ` +
79
- `\u2022 Global: ${config.global ?? "unset"} \u2022 Env: ${envDisplay(process.env[BASH_VIEW_ENV_VAR])}`;
80
- return effective.source === "env"
81
- ? `\u26a0\ufe0f Overridden by ${BASH_VIEW_ENV_VAR} \u2022 ${line}`
82
- : line;
83
- }
84
-
85
- function readExpansionLine2(cwd: string): string {
86
- const effective = resolveReadExpansionModeWithSource(cwd);
87
- const config = readReadExpansionConfig(cwd);
88
- const line =
89
- `Effective: ${effective.value} (source: ${effective.source}) ` +
90
- `\u2022 Global: ${config.global ?? "unset"} \u2022 Env: ${envDisplay(process.env[READ_EXPANSION_ENV_VAR])}`;
91
- return effective.source === "env"
92
- ? `\u26a0\ufe0f Overridden by ${READ_EXPANSION_ENV_VAR} \u2022 ${line}`
93
- : line;
94
- }
95
-
96
- /**
97
- * The multi-file caps, REPORTED ONLY (ADR-0049 M6): the overlay's `SettingsList` is enum-only
98
- * (ADR-0038), so numeric editing belongs to `/pi-better-edit bash-view multi-file …`. This line still
99
- * names each cap's rung, because a display that showed the effective numbers without their source
100
- * would hide which file to edit.
101
- */
102
- function multiFileLine(cwd: string): string {
103
- const caps = resolveBashMultiFileSettingsWithSources(cwd);
104
- return (
105
- `Multi-file caps: maxFiles ${caps.maxFiles.value} (source: ${caps.maxFiles.source}) ` +
106
- `\u2022 maxRows ${caps.maxRows.value} (source: ${caps.maxRows.source})`
107
- );
108
- }
109
-
110
- function storeLine2(cwd: string): string {
111
- const effective = resolveStoreJanitorSettingsWithSources(cwd);
112
- const config = readStoreJanitorConfig(cwd);
113
- const line =
114
- `Effective: ${effective.mode.value} (source: ${effective.mode.source}) ` +
115
- `\u2022 Global: ${config.global?.mode ?? "unset"} \u2022 Env: ${envDisplay(process.env[STORE_JANITOR_ENV_VAR])}`;
116
- return effective.mode.source === "env"
117
- ? `\u26a0\ufe0f Overridden by ${STORE_JANITOR_ENV_VAR} \u2022 ${line}`
118
- : line;
119
- }
120
-
121
- function targetScopeLine2(scope: ConfigScope): string {
122
- return `Effective: ${scope} (source: switch) \u2022 Global: n/a \u2022 Env: n/a`;
123
- }
124
-
125
- /**
126
- * The overlay: a title plus the four-row settings list. The list keeps the item
127
- * array by reference, so refreshes mutate descriptions in place and invalidate.
128
- */
129
- export class SettingsOverlay extends Container {
130
- private readonly cwd: string;
131
- private readonly done: (result: undefined) => void;
132
- private scope: ConfigScope = "project";
133
- private readonly items: SettingItem[];
134
- private readonly list: SettingsList;
135
-
136
- constructor(cwd: string, done: (result: undefined) => void) {
137
- super();
138
- this.cwd = cwd;
139
- this.done = done;
140
- this.items = [
141
- {
142
- id: "target-scope",
143
- label: "Target scope",
144
- description: `Write scope for the rows below\n${targetScopeLine2(this.scope)}`,
145
- currentValue: this.scope,
146
- values: ["project", "global"],
147
- },
148
- {
149
- id: "lens",
150
- label: "Lens bridge",
151
- description: `Bridge to pi-lens diagnostics\n${lensLine2(this.cwd)}`,
152
- currentValue: resolveEffectiveLensModeWithSource(this.cwd).mode,
153
- values: ["auto", "on", "off"],
154
- },
155
- {
156
- id: "bash-view",
157
- label: "Bash view",
158
- description: `Bash view interception switch\n${bashViewLine2(this.cwd)}\n${multiFileLine(this.cwd)}`,
159
- currentValue: resolveBashViewModeWithSource(this.cwd).value,
160
- values: ["on", "off"],
161
- },
162
- {
163
- id: "read-expansion",
164
- label: "Read expansion",
165
- description: `Read window expansion switch\n${readExpansionLine2(this.cwd)}`,
166
- currentValue: resolveReadExpansionModeWithSource(this.cwd).value,
167
- values: ["on", "off"],
168
- },
169
- {
170
- id: "store",
171
- label: "Store janitor",
172
- description: `Store janitor sweep switch\n${storeLine2(this.cwd)}`,
173
- currentValue: resolveStoreJanitorSettingsWithSources(this.cwd).mode.value,
174
- values: ["on", "off"],
175
- },
176
- ];
177
- this.list = new SettingsList(
178
- this.items,
179
- 8,
180
- getSettingsListTheme(),
181
- (id, newValue) => {
182
- this.handleChange(id, newValue);
183
- },
184
- () => {
185
- this.done(undefined);
186
- },
187
- );
188
- this.addChild(new Text("pi-better-edit settings", 1, 0));
189
- this.addChild(this.list);
190
- }
191
-
192
- /** WHY a delegating input: Container owns layout only, so focus keys reach the list. */
193
- handleInput(data: string): void {
194
- this.list.handleInput(data);
195
- }
196
-
197
- /** Test and routing seam to surface a row's two-line description. */
198
- selectItem(id: string): void {
199
- this.list.selectItem(id);
200
- }
201
-
202
- /** Active write scope; the Target Scope row cycles it without persisting. */
203
- currentScope(): ConfigScope {
204
- return this.scope;
205
- }
206
-
207
- private handleChange(id: string, newValue: string): void {
208
- if (id === "target-scope") {
209
- this.scope = newValue === "global" ? "global" : "project";
210
- this.refreshAll();
211
- return;
212
- }
213
- if (id === "lens" && (newValue === "auto" || newValue === "on" || newValue === "off")) {
214
- const mode: LensBridgeMode = newValue;
215
- saveLensBridgeConfig(mode, this.scope, this.cwd);
216
- this.refreshRow("lens");
217
- return;
218
- }
219
- if (id === "bash-view" && (newValue === "on" || newValue === "off")) {
220
- const mode: BashViewMode = newValue;
221
- saveBashViewConfig(mode, this.scope, this.cwd);
222
- this.refreshRow("bash-view");
223
- return;
224
- }
225
- if (id === "read-expansion" && (newValue === "on" || newValue === "off")) {
226
- const mode: ReadExpansionMode = newValue;
227
- saveReadExpansionConfig(mode, this.scope, this.cwd);
228
- this.refreshRow("read-expansion");
229
- return;
230
- }
231
- if (id === "store" && (newValue === "on" || newValue === "off")) {
232
- saveStoreJanitorConfig({ mode: newValue }, this.scope, this.cwd);
233
- this.refreshRow("store");
234
- }
235
- }
236
-
237
- private refreshRow(id: string): void {
238
- const item = this.items.find((candidate) => candidate.id === id);
239
- if (item === undefined) return;
240
- if (id === "lens") {
241
- const effective = resolveEffectiveLensModeWithSource(this.cwd);
242
- this.list.updateValue(id, effective.mode);
243
- item.description = `Bridge to pi-lens diagnostics\n${lensLine2(this.cwd)}`;
244
- } else if (id === "bash-view") {
245
- const effective = resolveBashViewModeWithSource(this.cwd);
246
- this.list.updateValue(id, effective.value);
247
- item.description = `Bash view interception switch\n${bashViewLine2(this.cwd)}\n${multiFileLine(this.cwd)}`;
248
- } else if (id === "read-expansion") {
249
- const effective = resolveReadExpansionModeWithSource(this.cwd);
250
- this.list.updateValue(id, effective.value);
251
- item.description = `Read window expansion switch\n${readExpansionLine2(this.cwd)}`;
252
- } else if (id === "store") {
253
- const effective = resolveStoreJanitorSettingsWithSources(this.cwd);
254
- this.list.updateValue(id, effective.mode.value);
255
- item.description = `Store janitor sweep switch\n${storeLine2(this.cwd)}`;
256
- }
257
- this.list.invalidate();
258
- this.invalidate();
259
- }
260
-
261
- private refreshAll(): void {
262
- const scopeItem = this.items.find((candidate) => candidate.id === "target-scope");
263
- if (scopeItem !== undefined) {
264
- this.list.updateValue("target-scope", this.scope);
265
- scopeItem.description = `Write scope for the rows below\n${targetScopeLine2(this.scope)}`;
266
- }
267
- this.refreshRow("lens");
268
- this.refreshRow("bash-view");
269
- this.refreshRow("read-expansion");
270
- this.refreshRow("store");
271
- }
272
- }