@bendyline/docblocks 2.0.0 → 2.1.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 (286) hide show
  1. package/dist/{chunk-J32GU3F3.js → chunk-6IYMTYMQ.js} +249 -221
  2. package/dist/chunk-6IYMTYMQ.js.map +1 -0
  3. package/dist/{chunk-75UUF6C4.js → chunk-B56KWCSE.js} +2 -2
  4. package/dist/{chunk-RVQHY3XU.js → chunk-BNKV7MTO.js} +1 -1
  5. package/dist/{chunk-RVQHY3XU.js.map → chunk-BNKV7MTO.js.map} +1 -1
  6. package/dist/chunk-BXMF5YQJ.js +149 -0
  7. package/dist/chunk-BXMF5YQJ.js.map +1 -0
  8. package/dist/{chunk-PGR7LK6D.js → chunk-COYQXQK3.js} +14 -5
  9. package/dist/chunk-COYQXQK3.js.map +1 -0
  10. package/dist/{chunk-RQJRQF46.js → chunk-DN7A33LL.js} +42 -49
  11. package/dist/chunk-DN7A33LL.js.map +1 -0
  12. package/dist/chunk-FA7UNOXK.js +20 -0
  13. package/dist/chunk-FA7UNOXK.js.map +1 -0
  14. package/dist/chunk-GM5YXU4L.js +29 -0
  15. package/dist/chunk-GM5YXU4L.js.map +1 -0
  16. package/dist/{chunk-SI2LU2RP.js → chunk-JS6XFWQK.js} +2 -1
  17. package/dist/chunk-JS6XFWQK.js.map +1 -0
  18. package/dist/{chunk-EGNDADXB.js → chunk-MNSZ7EZN.js} +2 -2
  19. package/dist/chunk-P3DVZQ6S.js +228 -0
  20. package/dist/chunk-P3DVZQ6S.js.map +1 -0
  21. package/dist/chunk-P4WATND4.js +52 -0
  22. package/dist/chunk-P4WATND4.js.map +1 -0
  23. package/dist/chunk-RVPGQBWR.js +169 -0
  24. package/dist/chunk-RVPGQBWR.js.map +1 -0
  25. package/dist/chunk-U722UUFN.js +9 -0
  26. package/dist/chunk-U722UUFN.js.map +1 -0
  27. package/dist/{chunk-GCPBEMMH.js → chunk-VTCSF7VS.js} +11 -21
  28. package/dist/chunk-VTCSF7VS.js.map +1 -0
  29. package/dist/{chunk-2D7Y4IR3.js → chunk-WJKYY5QR.js} +123 -66
  30. package/dist/chunk-WJKYY5QR.js.map +1 -0
  31. package/dist/{chunk-5MYAICRE.js → chunk-XUML3MKV.js} +44 -56
  32. package/dist/chunk-XUML3MKV.js.map +1 -0
  33. package/dist/document/index.d.ts +358 -6
  34. package/dist/document/index.js +24 -3
  35. package/dist/document/index.js.map +1 -1
  36. package/dist/filesystem/electron.d.ts +73 -4
  37. package/dist/filesystem/electron.js +16 -3
  38. package/dist/filesystem/electron.js.map +1 -1
  39. package/dist/filesystem/index.d.ts +228 -22
  40. package/dist/filesystem/index.js +133 -19
  41. package/dist/filesystem/index.js.map +1 -1
  42. package/dist/filesystem/indexeddb.d.ts +284 -5
  43. package/dist/filesystem/indexeddb.js +22 -4
  44. package/dist/filesystem/indexeddb.js.map +1 -1
  45. package/dist/filesystem/memory.d.ts +152 -4
  46. package/dist/filesystem/memory.js +12 -3
  47. package/dist/filesystem/memory.js.map +1 -1
  48. package/dist/filesystem/native.d.ts +136 -4
  49. package/dist/filesystem/native.js +27 -3
  50. package/dist/filesystem/native.js.map +1 -1
  51. package/dist/host/index.d.ts +32 -9
  52. package/dist/host/index.js +26 -29
  53. package/dist/host/index.js.map +1 -1
  54. package/dist/index.d.ts +14 -10
  55. package/dist/index.js +204 -9
  56. package/dist/index.js.map +1 -1
  57. package/dist/mcp/index.d.ts +33 -4
  58. package/dist/mcp/index.js +31 -3
  59. package/dist/mcp/index.js.map +1 -1
  60. package/dist/mcp/zod.d.ts +637 -635
  61. package/dist/mcp/zod.js +700 -884
  62. package/dist/mcp/zod.js.map +1 -1
  63. package/dist/share/index.d.ts +43 -0
  64. package/dist/share/index.js +13 -0
  65. package/dist/share/index.js.map +1 -0
  66. package/dist/{types-CsX6EN2t.d.ts → types-BEg5SQ1_.d.ts} +1 -1
  67. package/dist/{types-eOlt9J7n.d.ts → types-CueK0tvU.d.ts} +34 -11
  68. package/dist/vscode/index.d.ts +220 -3
  69. package/dist/vscode/index.js +382 -2
  70. package/dist/vscode/index.js.map +1 -1
  71. package/dist/workspace/index.d.ts +141 -4
  72. package/dist/workspace/index.js +28 -2
  73. package/dist/workspace/index.js.map +1 -1
  74. package/package.json +9 -5
  75. package/dist/chunk-2D7Y4IR3.js.map +0 -1
  76. package/dist/chunk-5MYAICRE.js.map +0 -1
  77. package/dist/chunk-AYZ4HN5M.js +0 -20
  78. package/dist/chunk-AYZ4HN5M.js.map +0 -1
  79. package/dist/chunk-GCPBEMMH.js.map +0 -1
  80. package/dist/chunk-J32GU3F3.js.map +0 -1
  81. package/dist/chunk-PGR7LK6D.js.map +0 -1
  82. package/dist/chunk-RQJRQF46.js.map +0 -1
  83. package/dist/chunk-SI2LU2RP.js.map +0 -1
  84. package/dist/chunk-W5UUUII5.js +0 -142
  85. package/dist/chunk-W5UUUII5.js.map +0 -1
  86. package/dist/document/document-session.d.ts +0 -127
  87. package/dist/document/document-session.d.ts.map +0 -1
  88. package/dist/document/document-session.js +0 -749
  89. package/dist/document/document-session.js.map +0 -1
  90. package/dist/document/filesystem-target.d.ts +0 -17
  91. package/dist/document/filesystem-target.d.ts.map +0 -1
  92. package/dist/document/filesystem-target.js +0 -70
  93. package/dist/document/filesystem-target.js.map +0 -1
  94. package/dist/document/index.d.ts.map +0 -1
  95. package/dist/document/recovery-journal.d.ts +0 -125
  96. package/dist/document/recovery-journal.d.ts.map +0 -1
  97. package/dist/document/recovery-journal.js +0 -385
  98. package/dist/document/recovery-journal.js.map +0 -1
  99. package/dist/document/types.d.ts +0 -89
  100. package/dist/document/types.d.ts.map +0 -1
  101. package/dist/document/types.js +0 -9
  102. package/dist/document/types.js.map +0 -1
  103. package/dist/filesystem/commit-lock.d.ts +0 -3
  104. package/dist/filesystem/commit-lock.d.ts.map +0 -1
  105. package/dist/filesystem/commit-lock.js +0 -20
  106. package/dist/filesystem/commit-lock.js.map +0 -1
  107. package/dist/filesystem/dbk-workspace.d.ts +0 -34
  108. package/dist/filesystem/dbk-workspace.d.ts.map +0 -1
  109. package/dist/filesystem/dbk-workspace.js +0 -85
  110. package/dist/filesystem/dbk-workspace.js.map +0 -1
  111. package/dist/filesystem/electron-provider-v2.d.ts +0 -36
  112. package/dist/filesystem/electron-provider-v2.d.ts.map +0 -1
  113. package/dist/filesystem/electron-provider-v2.js +0 -503
  114. package/dist/filesystem/electron-provider-v2.js.map +0 -1
  115. package/dist/filesystem/electron-provider.d.ts +0 -35
  116. package/dist/filesystem/electron-provider.d.ts.map +0 -1
  117. package/dist/filesystem/electron-provider.js +0 -69
  118. package/dist/filesystem/electron-provider.js.map +0 -1
  119. package/dist/filesystem/electron.d.ts.map +0 -1
  120. package/dist/filesystem/file-media-provider.d.ts +0 -23
  121. package/dist/filesystem/file-media-provider.d.ts.map +0 -1
  122. package/dist/filesystem/file-media-provider.js +0 -85
  123. package/dist/filesystem/file-media-provider.js.map +0 -1
  124. package/dist/filesystem/filesystem-content-container.d.ts +0 -24
  125. package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
  126. package/dist/filesystem/filesystem-content-container.js +0 -153
  127. package/dist/filesystem/filesystem-content-container.js.map +0 -1
  128. package/dist/filesystem/fs-error.d.ts +0 -46
  129. package/dist/filesystem/fs-error.d.ts.map +0 -1
  130. package/dist/filesystem/fs-error.js +0 -170
  131. package/dist/filesystem/fs-error.js.map +0 -1
  132. package/dist/filesystem/index.d.ts.map +0 -1
  133. package/dist/filesystem/indexeddb-content-container.d.ts +0 -22
  134. package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
  135. package/dist/filesystem/indexeddb-content-container.js +0 -100
  136. package/dist/filesystem/indexeddb-content-container.js.map +0 -1
  137. package/dist/filesystem/indexeddb-provider-v2.d.ts +0 -96
  138. package/dist/filesystem/indexeddb-provider-v2.d.ts.map +0 -1
  139. package/dist/filesystem/indexeddb-provider-v2.js +0 -1241
  140. package/dist/filesystem/indexeddb-provider-v2.js.map +0 -1
  141. package/dist/filesystem/indexeddb-provider.d.ts +0 -39
  142. package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
  143. package/dist/filesystem/indexeddb-provider.js +0 -145
  144. package/dist/filesystem/indexeddb-provider.js.map +0 -1
  145. package/dist/filesystem/indexeddb-store.d.ts +0 -34
  146. package/dist/filesystem/indexeddb-store.d.ts.map +0 -1
  147. package/dist/filesystem/indexeddb-store.js +0 -165
  148. package/dist/filesystem/indexeddb-store.js.map +0 -1
  149. package/dist/filesystem/indexeddb.d.ts.map +0 -1
  150. package/dist/filesystem/legacy-v2-adapter.d.ts +0 -62
  151. package/dist/filesystem/legacy-v2-adapter.d.ts.map +0 -1
  152. package/dist/filesystem/legacy-v2-adapter.js +0 -499
  153. package/dist/filesystem/legacy-v2-adapter.js.map +0 -1
  154. package/dist/filesystem/memory-provider-v2.d.ts +0 -92
  155. package/dist/filesystem/memory-provider-v2.d.ts.map +0 -1
  156. package/dist/filesystem/memory-provider-v2.js +0 -615
  157. package/dist/filesystem/memory-provider-v2.js.map +0 -1
  158. package/dist/filesystem/memory-provider.d.ts +0 -54
  159. package/dist/filesystem/memory-provider.d.ts.map +0 -1
  160. package/dist/filesystem/memory-provider.js +0 -132
  161. package/dist/filesystem/memory-provider.js.map +0 -1
  162. package/dist/filesystem/memory.d.ts.map +0 -1
  163. package/dist/filesystem/move-entry.d.ts +0 -9
  164. package/dist/filesystem/move-entry.d.ts.map +0 -1
  165. package/dist/filesystem/move-entry.js +0 -103
  166. package/dist/filesystem/move-entry.js.map +0 -1
  167. package/dist/filesystem/move-error.d.ts +0 -53
  168. package/dist/filesystem/move-error.d.ts.map +0 -1
  169. package/dist/filesystem/move-error.js +0 -99
  170. package/dist/filesystem/move-error.js.map +0 -1
  171. package/dist/filesystem/native-provider-v2.d.ts +0 -75
  172. package/dist/filesystem/native-provider-v2.d.ts.map +0 -1
  173. package/dist/filesystem/native-provider-v2.js +0 -849
  174. package/dist/filesystem/native-provider-v2.js.map +0 -1
  175. package/dist/filesystem/native-provider.d.ts +0 -53
  176. package/dist/filesystem/native-provider.d.ts.map +0 -1
  177. package/dist/filesystem/native-provider.js +0 -471
  178. package/dist/filesystem/native-provider.js.map +0 -1
  179. package/dist/filesystem/native.d.ts.map +0 -1
  180. package/dist/filesystem/types.d.ts +0 -83
  181. package/dist/filesystem/types.d.ts.map +0 -1
  182. package/dist/filesystem/types.js +0 -16
  183. package/dist/filesystem/types.js.map +0 -1
  184. package/dist/filesystem/v2.d.ts +0 -172
  185. package/dist/filesystem/v2.d.ts.map +0 -1
  186. package/dist/filesystem/v2.js +0 -16
  187. package/dist/filesystem/v2.js.map +0 -1
  188. package/dist/filesystem/workspace-path.d.ts +0 -21
  189. package/dist/filesystem/workspace-path.d.ts.map +0 -1
  190. package/dist/filesystem/workspace-path.js +0 -80
  191. package/dist/filesystem/workspace-path.js.map +0 -1
  192. package/dist/host/filesystem-v2.d.ts +0 -45
  193. package/dist/host/filesystem-v2.d.ts.map +0 -1
  194. package/dist/host/filesystem-v2.js +0 -13
  195. package/dist/host/filesystem-v2.js.map +0 -1
  196. package/dist/host/git.d.ts +0 -200
  197. package/dist/host/git.d.ts.map +0 -1
  198. package/dist/host/git.js +0 -15
  199. package/dist/host/git.js.map +0 -1
  200. package/dist/host/index.d.ts.map +0 -1
  201. package/dist/host/types.d.ts +0 -232
  202. package/dist/host/types.d.ts.map +0 -1
  203. package/dist/host/types.js +0 -10
  204. package/dist/host/types.js.map +0 -1
  205. package/dist/host/wire-policy.d.ts +0 -22
  206. package/dist/host/wire-policy.d.ts.map +0 -1
  207. package/dist/host/wire-policy.js +0 -92
  208. package/dist/host/wire-policy.js.map +0 -1
  209. package/dist/index.d.ts.map +0 -1
  210. package/dist/mcp/index.d.ts.map +0 -1
  211. package/dist/mcp/types.d.ts +0 -466
  212. package/dist/mcp/types.d.ts.map +0 -1
  213. package/dist/mcp/types.js +0 -25
  214. package/dist/mcp/types.js.map +0 -1
  215. package/dist/mcp/wire.d.ts +0 -29
  216. package/dist/mcp/wire.d.ts.map +0 -1
  217. package/dist/mcp/wire.js +0 -1046
  218. package/dist/mcp/wire.js.map +0 -1
  219. package/dist/mcp/zod.d.ts.map +0 -1
  220. package/dist/vscode/index.d.ts.map +0 -1
  221. package/dist/vscode/messages.d.ts +0 -204
  222. package/dist/vscode/messages.d.ts.map +0 -1
  223. package/dist/vscode/messages.js +0 -494
  224. package/dist/vscode/messages.js.map +0 -1
  225. package/dist/workspace/index.d.ts.map +0 -1
  226. package/dist/workspace/reconcile-electron.d.ts +0 -19
  227. package/dist/workspace/reconcile-electron.d.ts.map +0 -1
  228. package/dist/workspace/reconcile-electron.js +0 -42
  229. package/dist/workspace/reconcile-electron.js.map +0 -1
  230. package/dist/workspace/types.d.ts +0 -69
  231. package/dist/workspace/types.d.ts.map +0 -1
  232. package/dist/workspace/types.js +0 -2
  233. package/dist/workspace/types.js.map +0 -1
  234. package/dist/workspace/workspace-manager.d.ts +0 -47
  235. package/dist/workspace/workspace-manager.d.ts.map +0 -1
  236. package/dist/workspace/workspace-manager.js +0 -126
  237. package/dist/workspace/workspace-manager.js.map +0 -1
  238. package/src/document/document-session.ts +0 -834
  239. package/src/document/filesystem-target.ts +0 -109
  240. package/src/document/index.ts +0 -41
  241. package/src/document/recovery-journal.ts +0 -536
  242. package/src/document/types.ts +0 -116
  243. package/src/filesystem/commit-lock.ts +0 -29
  244. package/src/filesystem/dbk-workspace.ts +0 -135
  245. package/src/filesystem/electron-provider-v2.ts +0 -630
  246. package/src/filesystem/electron-provider.ts +0 -99
  247. package/src/filesystem/electron.ts +0 -3
  248. package/src/filesystem/file-media-provider.ts +0 -103
  249. package/src/filesystem/filesystem-content-container.ts +0 -164
  250. package/src/filesystem/fs-error.ts +0 -234
  251. package/src/filesystem/index.ts +0 -143
  252. package/src/filesystem/indexeddb-content-container.ts +0 -112
  253. package/src/filesystem/indexeddb-provider-v2.ts +0 -1740
  254. package/src/filesystem/indexeddb-provider.ts +0 -171
  255. package/src/filesystem/indexeddb-store.ts +0 -207
  256. package/src/filesystem/indexeddb.ts +0 -12
  257. package/src/filesystem/legacy-v2-adapter.ts +0 -779
  258. package/src/filesystem/memory-provider-v2.ts +0 -896
  259. package/src/filesystem/memory-provider.ts +0 -180
  260. package/src/filesystem/memory.ts +0 -15
  261. package/src/filesystem/move-entry.ts +0 -142
  262. package/src/filesystem/move-error.ts +0 -159
  263. package/src/filesystem/native-provider-v2.ts +0 -1165
  264. package/src/filesystem/native-provider.ts +0 -537
  265. package/src/filesystem/native.ts +0 -16
  266. package/src/filesystem/types.ts +0 -114
  267. package/src/filesystem/v2.ts +0 -231
  268. package/src/filesystem/workspace-path.ts +0 -92
  269. package/src/host/filesystem-v2.ts +0 -104
  270. package/src/host/git.ts +0 -246
  271. package/src/host/index.ts +0 -93
  272. package/src/host/types.ts +0 -274
  273. package/src/host/wire-policy.ts +0 -103
  274. package/src/index.ts +0 -10
  275. package/src/mcp/index.ts +0 -3
  276. package/src/mcp/types.ts +0 -594
  277. package/src/mcp/wire.ts +0 -1280
  278. package/src/mcp/zod.ts +0 -1000
  279. package/src/vscode/index.ts +0 -2
  280. package/src/vscode/messages.ts +0 -704
  281. package/src/workspace/index.ts +0 -17
  282. package/src/workspace/reconcile-electron.ts +0 -65
  283. package/src/workspace/types.ts +0 -67
  284. package/src/workspace/workspace-manager.ts +0 -151
  285. /package/dist/{chunk-75UUF6C4.js.map → chunk-B56KWCSE.js.map} +0 -0
  286. /package/dist/{chunk-EGNDADXB.js.map → chunk-MNSZ7EZN.js.map} +0 -0
@@ -1,180 +0,0 @@
1
- /**
2
- * In-memory filesystem used by transient loose-file and DBK workspaces.
3
- *
4
- * MemoryFileSystemProviderV2 is authoritative. This class is the temporary
5
- * text-oriented v1 facade retained while callers migrate to the byte contract.
6
- */
7
-
8
- import { FsError, type FsOperation } from './fs-error.js';
9
- import {
10
- MemoryFileSystemProviderV2,
11
- type MemoryFileSystemV2ReplacementFile,
12
- } from './memory-provider-v2.js';
13
- import type { FileCommitResult, FileSystemEntry, FileSystemProvider, FileMeta } from './types.js';
14
- import { parseWorkspacePath, type WorkspacePath } from './workspace-path.js';
15
-
16
- export type MemoryFileSystemSnapshotFile =
17
- | {
18
- readonly kind: 'text';
19
- readonly path: string;
20
- readonly content: string;
21
- }
22
- | {
23
- readonly kind: 'binary';
24
- readonly path: string;
25
- readonly data: ArrayBuffer | Uint8Array;
26
- };
27
-
28
- /** Complete provider-relative state for a transient memory workspace. */
29
- export interface MemoryFileSystemSnapshot {
30
- readonly files: readonly MemoryFileSystemSnapshotFile[];
31
- readonly directories?: readonly string[];
32
- }
33
-
34
- function canonicalPath(path: string): WorkspacePath {
35
- return parseWorkspacePath(path);
36
- }
37
-
38
- function entryPath(path: string, operation: FsOperation): WorkspacePath {
39
- const canonical = canonicalPath(path);
40
- if (!canonical) {
41
- throw new FsError('invalid-path', 'The workspace root is not a file entry.', {
42
- operation,
43
- path,
44
- });
45
- }
46
- return canonical;
47
- }
48
-
49
- function decode(data: ArrayBuffer): string {
50
- return new TextDecoder().decode(data);
51
- }
52
-
53
- /**
54
- * Legacy facade over the correctness-first memory provider.
55
- *
56
- * Synchronous seed/snapshot replacement methods remain because DBK import
57
- * fully stages external bytes before publishing one atomic in-memory swap.
58
- */
59
- export class MemoryFileSystemProvider implements FileSystemProvider {
60
- public readonly id: string;
61
- public readonly label: string;
62
- public readonly v2: MemoryFileSystemProviderV2;
63
-
64
- public constructor(id: string, label: string) {
65
- this.id = id;
66
- this.label = label;
67
- this.v2 = new MemoryFileSystemProviderV2(id, label);
68
- }
69
-
70
- /** Monotonic version of the complete in-memory tree. */
71
- public get treeVersion(): number {
72
- return this.v2.mutationRevision;
73
- }
74
-
75
- /** Capture an owned deterministic copy of the complete transient tree. */
76
- public captureContents(): MemoryFileSystemSnapshot {
77
- const state = this.v2.captureState();
78
- return {
79
- files: state.files.map((file) =>
80
- file.payloadKind === 'text'
81
- ? { kind: 'text' as const, path: file.path, content: decode(file.data) }
82
- : { kind: 'binary' as const, path: file.path, data: file.data.slice(0) },
83
- ),
84
- directories: [...state.directories],
85
- };
86
- }
87
-
88
- /** Atomically replace the complete tree after validating and owning all input. */
89
- public replaceContents(snapshot: MemoryFileSystemSnapshot, expectedTreeVersion?: number): void {
90
- const files: MemoryFileSystemV2ReplacementFile[] = snapshot.files.map((file) => ({
91
- path: entryPath(file.path, 'write'),
92
- payloadKind: file.kind,
93
- data: file.kind === 'text' ? new TextEncoder().encode(file.content) : file.data,
94
- }));
95
- const directories = (snapshot.directories ?? []).map((path) =>
96
- entryPath(path, 'create-directory'),
97
- );
98
- this.v2.replaceState({ files, directories }, expectedTreeVersion);
99
- }
100
-
101
- /** Seed synchronously before publishing a transient provider to consumers. */
102
- public seedText(path: string, content: string): void {
103
- this.v2.seedText(entryPath(path, 'write'), content);
104
- }
105
-
106
- public async readFile(path: string): Promise<string | null> {
107
- const file = await this.v2.readFile(entryPath(path, 'read'));
108
- return file ? decode(file.data) : null;
109
- }
110
-
111
- public async writeFile(path: string, content: string): Promise<void> {
112
- await this.v2.writeText(entryPath(path, 'write'), content, { createParents: true });
113
- }
114
-
115
- public commitFile(
116
- path: string,
117
- content: string,
118
- expectedContent: string | null,
119
- ): Promise<FileCommitResult> {
120
- return this.v2.commitText(entryPath(path, 'write'), content, expectedContent);
121
- }
122
-
123
- public async delete(path: string): Promise<void> {
124
- await this.v2.remove(entryPath(path, 'remove'), { recursive: true, missing: 'ignore' });
125
- }
126
-
127
- public async rename(oldPath: string, newPath: string): Promise<void> {
128
- await this.v2.move(entryPath(oldPath, 'move'), entryPath(newPath, 'move'), {
129
- createParents: true,
130
- });
131
- }
132
-
133
- public async readDirectory(path: string): Promise<FileSystemEntry[]> {
134
- const canonical = canonicalPath(path);
135
- try {
136
- const entries = await this.v2.readDirectory(canonical);
137
- return entries.map((entry) => ({
138
- kind: entry.kind,
139
- name: entry.name,
140
- path: entry.path,
141
- }));
142
- } catch (error: unknown) {
143
- // Preserve the v1 missing-directory behavior only on the compatibility facade.
144
- if (error instanceof FsError && error.code === 'not-found') return [];
145
- throw error;
146
- }
147
- }
148
-
149
- public async exists(path: string): Promise<boolean> {
150
- return (await this.v2.stat(canonicalPath(path))) !== null;
151
- }
152
-
153
- public async createDirectory(path: string): Promise<void> {
154
- await this.v2.createDirectory(canonicalPath(path), { createParents: true });
155
- }
156
-
157
- public async stat(path: string): Promise<FileMeta | null> {
158
- const canonical = canonicalPath(path);
159
- if (!canonical) return null;
160
- const entry = await this.v2.stat(canonical);
161
- if (!entry || entry.kind !== 'file') return null;
162
- return {
163
- name: entry.name,
164
- path: entry.path,
165
- size: entry.size,
166
- lastModified: entry.lastModified,
167
- };
168
- }
169
-
170
- public async readBinary(path: string): Promise<ArrayBuffer | null> {
171
- const canonical = entryPath(path, 'read');
172
- const file = this.v2.readCompatibilityFile(canonical);
173
- if (!file || file.payloadKind !== 'binary') return null;
174
- return file.data;
175
- }
176
-
177
- public async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {
178
- await this.v2.writeBinary(entryPath(path, 'write'), data, { createParents: true });
179
- }
180
- }
@@ -1,15 +0,0 @@
1
- /** Transient in-memory filesystem provider entry point. */
2
- export {
3
- MemoryFileSystemProvider,
4
- type MemoryFileSystemSnapshot,
5
- type MemoryFileSystemSnapshotFile,
6
- } from './memory-provider.js';
7
- export {
8
- MemoryFileSystemProviderV2,
9
- type MemoryFilePayloadKind,
10
- type MemoryFileSystemV2CompatibilityFile,
11
- type MemoryFileSystemV2Replacement,
12
- type MemoryFileSystemV2ReplacementFile,
13
- type MemoryFileSystemV2State,
14
- type MemoryFileSystemV2StateFile,
15
- } from './memory-provider-v2.js';
@@ -1,142 +0,0 @@
1
- import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';
2
- import {
3
- describeEntryMove,
4
- describePartialMove,
5
- FileSystemMoveRecoveryError,
6
- FileSystemPartialMoveError,
7
- } from './move-error.js';
8
- import { parseWorkspacePath } from './workspace-path.js';
9
-
10
- function normalisePath(path: string): string {
11
- return parseWorkspacePath(path);
12
- }
13
-
14
- function dirname(path: string): string {
15
- const slash = path.lastIndexOf('/');
16
- return slash < 0 ? '' : path.slice(0, slash);
17
- }
18
-
19
- function basename(path: string): string {
20
- const slash = path.lastIndexOf('/');
21
- return slash < 0 ? path : path.slice(slash + 1);
22
- }
23
-
24
- /** Return the hidden companion directory used for a document's media and versions. */
25
- export function documentCompanionPath(documentPath: string): string {
26
- const rooted = documentPath.replace(/\\/g, '/').startsWith('/');
27
- const clean = parseWorkspacePath(documentPath);
28
- if (!clean) throw new Error('The workspace root has no document companion path.');
29
- const parent = dirname(clean);
30
- const name = basename(clean).replace(/\.[^.]+$/, '');
31
- if (parent) return `${parent}/${name}_files`;
32
- return rooted ? `/${name}_files` : `${name}_files`;
33
- }
34
-
35
- function isMarkdownPath(path: string): boolean {
36
- return /\.md$/i.test(basename(path));
37
- }
38
-
39
- /**
40
- * Move an explorer entry without overwriting an existing entry. Markdown files
41
- * carry their hidden `<basename>_files` companion directory with them.
42
- */
43
- export async function moveFileSystemEntry(
44
- provider: FileSystemProvider,
45
- oldPath: string,
46
- newPath: string,
47
- kind: 'file' | 'directory',
48
- ): Promise<void> {
49
- const providerV2 = getFileSystemProviderV2(provider);
50
- const exists = (candidate: string): Promise<boolean> =>
51
- providerV2
52
- ? providerV2.stat(parseWorkspacePath(candidate)).then((entry) => entry !== null)
53
- : provider.exists(candidate);
54
- const move = (source: string, destination: string): Promise<void> =>
55
- providerV2
56
- ? providerV2
57
- .move(parseWorkspacePath(source), parseWorkspacePath(destination), {
58
- createParents: true,
59
- })
60
- .then(() => undefined)
61
- : provider.rename(source, destination);
62
-
63
- const oldNormalised = normalisePath(oldPath);
64
- const newNormalised = normalisePath(newPath);
65
- if (oldNormalised === newNormalised) return;
66
-
67
- if (kind === 'directory' && newNormalised.startsWith(`${oldNormalised}/`)) {
68
- throw new Error('A folder cannot be moved into itself.');
69
- }
70
- if (await exists(newPath)) {
71
- throw new Error(`An entry named "${basename(newPath)}" already exists there.`);
72
- }
73
-
74
- let oldCompanion: string | null = null;
75
- let newCompanion: string | null = null;
76
- if (kind === 'file' && isMarkdownPath(oldPath)) {
77
- const candidate = documentCompanionPath(oldPath);
78
- if (await exists(candidate)) {
79
- oldCompanion = candidate;
80
- newCompanion = documentCompanionPath(newPath);
81
- if (
82
- normalisePath(oldCompanion) !== normalisePath(newCompanion) &&
83
- (await exists(newCompanion))
84
- ) {
85
- throw new Error(`The companion folder "${basename(newCompanion)}" already exists there.`);
86
- }
87
- }
88
- }
89
-
90
- try {
91
- await move(oldPath, newPath);
92
- } catch (error: unknown) {
93
- const state = await describeEntryMove(provider, oldPath, newPath);
94
- if (state.source === 'present' && state.destination === 'missing') throw error;
95
- throw new FileSystemMoveRecoveryError(oldPath, newPath, state, error);
96
- }
97
- if (!oldCompanion || !newCompanion) return;
98
-
99
- try {
100
- await move(oldCompanion, newCompanion);
101
- } catch (error: unknown) {
102
- // Keep the document and its assets together when the second half fails.
103
- try {
104
- await move(newPath, oldPath);
105
- } catch (rollbackError: unknown) {
106
- const state = await describePartialMove(
107
- provider,
108
- oldPath,
109
- newPath,
110
- oldCompanion,
111
- newCompanion,
112
- );
113
- throw new FileSystemPartialMoveError(
114
- oldPath,
115
- newPath,
116
- oldCompanion,
117
- newCompanion,
118
- state,
119
- error,
120
- rollbackError,
121
- );
122
- }
123
- const state = await describePartialMove(provider, oldPath, newPath, oldCompanion, newCompanion);
124
- const restoredSourceOnly =
125
- state.source === 'present' &&
126
- state.destination === 'missing' &&
127
- state.companionSource === 'present' &&
128
- state.companionDestination === 'missing';
129
- if (!restoredSourceOnly) {
130
- throw new FileSystemPartialMoveError(
131
- oldPath,
132
- newPath,
133
- oldCompanion,
134
- newCompanion,
135
- state,
136
- error,
137
- null,
138
- );
139
- }
140
- throw error;
141
- }
142
- }
@@ -1,159 +0,0 @@
1
- import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';
2
- import { parseWorkspacePath } from './workspace-path.js';
3
-
4
- export type FileSystemPathPresence = 'present' | 'missing' | 'unknown';
5
-
6
- export interface FileSystemPartialMoveState {
7
- readonly source: FileSystemPathPresence;
8
- readonly destination: FileSystemPathPresence;
9
- readonly companionSource: FileSystemPathPresence;
10
- readonly companionDestination: FileSystemPathPresence;
11
- }
12
-
13
- export type FileSystemMoveLocation = 'source' | 'destination' | 'both' | 'neither' | 'unknown';
14
-
15
- export interface FileSystemEntryMoveState {
16
- readonly source: FileSystemPathPresence;
17
- readonly destination: FileSystemPathPresence;
18
- }
19
-
20
- function locationFromPresence(
21
- source: FileSystemPathPresence,
22
- destination: FileSystemPathPresence,
23
- ): FileSystemMoveLocation {
24
- if (source === 'unknown' || destination === 'unknown') return 'unknown';
25
- if (source === 'present' && destination === 'present') return 'both';
26
- if (source === 'present') return 'source';
27
- if (destination === 'present') return 'destination';
28
- return 'neither';
29
- }
30
-
31
- /**
32
- * One provider move failed without restoring a provable source-only state.
33
- * This is backend-neutral: callers must use `location`, never infer from the
34
- * original exception or a provider's advertised move atomicity.
35
- */
36
- export class FileSystemMoveRecoveryError extends Error {
37
- public readonly code = 'partial-move' as const;
38
-
39
- public constructor(
40
- public readonly sourcePath: string,
41
- public readonly destinationPath: string,
42
- public readonly state: FileSystemEntryMoveState,
43
- public readonly moveError: unknown,
44
- ) {
45
- super(
46
- `The move did not restore one authoritative path. Entry location: ${locationFromPresence(
47
- state.source,
48
- state.destination,
49
- )}.`,
50
- );
51
- this.name = 'FileSystemMoveRecoveryError';
52
- }
53
-
54
- public get location(): FileSystemMoveLocation {
55
- return locationFromPresence(this.state.source, this.state.destination);
56
- }
57
-
58
- /** Alias used by DocumentSession's document-retarget recovery protocol. */
59
- public get documentLocation(): FileSystemMoveLocation {
60
- return this.location;
61
- }
62
- }
63
-
64
- /**
65
- * A compound document/companion move failed and the document rollback also
66
- * failed. Callers must use the recorded post-state instead of assuming the
67
- * original path is still authoritative.
68
- */
69
- export class FileSystemPartialMoveError extends Error {
70
- readonly code = 'partial-move' as const;
71
-
72
- constructor(
73
- readonly sourcePath: string,
74
- readonly destinationPath: string,
75
- readonly companionSourcePath: string,
76
- readonly companionDestinationPath: string,
77
- readonly state: FileSystemPartialMoveState,
78
- readonly moveError: unknown,
79
- readonly rollbackError: unknown,
80
- ) {
81
- super(
82
- `The document move could not be rolled back. Document location: ${locationFromPresence(
83
- state.source,
84
- state.destination,
85
- )}; companion location: ${locationFromPresence(
86
- state.companionSource,
87
- state.companionDestination,
88
- )}.`,
89
- );
90
- this.name = 'FileSystemPartialMoveError';
91
- }
92
-
93
- get documentLocation(): FileSystemMoveLocation {
94
- return locationFromPresence(this.state.source, this.state.destination);
95
- }
96
-
97
- get companionLocation(): FileSystemMoveLocation {
98
- return locationFromPresence(this.state.companionSource, this.state.companionDestination);
99
- }
100
- }
101
-
102
- export function isFileSystemPartialMoveError(error: unknown): error is FileSystemPartialMoveError {
103
- return error instanceof FileSystemPartialMoveError;
104
- }
105
-
106
- export function isFileSystemMoveRecoveryError(
107
- error: unknown,
108
- ): error is FileSystemMoveRecoveryError {
109
- return error instanceof FileSystemMoveRecoveryError;
110
- }
111
-
112
- export function isFileSystemMoveStateError(
113
- error: unknown,
114
- ): error is FileSystemMoveRecoveryError | FileSystemPartialMoveError {
115
- return isFileSystemMoveRecoveryError(error) || isFileSystemPartialMoveError(error);
116
- }
117
-
118
- async function probePath(
119
- provider: FileSystemProvider,
120
- path: string,
121
- ): Promise<FileSystemPathPresence> {
122
- try {
123
- const providerV2 = getFileSystemProviderV2(provider);
124
- const present = providerV2
125
- ? (await providerV2.stat(parseWorkspacePath(path))) !== null
126
- : await provider.exists(path);
127
- return present ? 'present' : 'missing';
128
- } catch {
129
- return 'unknown';
130
- }
131
- }
132
-
133
- export async function describePartialMove(
134
- provider: FileSystemProvider,
135
- sourcePath: string,
136
- destinationPath: string,
137
- companionSourcePath: string,
138
- companionDestinationPath: string,
139
- ): Promise<FileSystemPartialMoveState> {
140
- const [source, destination, companionSource, companionDestination] = await Promise.all([
141
- probePath(provider, sourcePath),
142
- probePath(provider, destinationPath),
143
- probePath(provider, companionSourcePath),
144
- probePath(provider, companionDestinationPath),
145
- ]);
146
- return { source, destination, companionSource, companionDestination };
147
- }
148
-
149
- export async function describeEntryMove(
150
- provider: FileSystemProvider,
151
- sourcePath: string,
152
- destinationPath: string,
153
- ): Promise<FileSystemEntryMoveState> {
154
- const [source, destination] = await Promise.all([
155
- probePath(provider, sourcePath),
156
- probePath(provider, destinationPath),
157
- ]);
158
- return { source, destination };
159
- }