@bendyline/docblocks 2.0.0 → 2.1.1

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 (278) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-2D7Y4IR3.js → chunk-4437YWLE.js} +123 -67
  3. package/dist/{chunk-5MYAICRE.js → chunk-45T5AFCN.js} +44 -57
  4. package/dist/{chunk-PGR7LK6D.js → chunk-6L3JRDE7.js} +14 -6
  5. package/dist/{chunk-RVQHY3XU.js → chunk-6XHOOBYF.js} +0 -1
  6. package/dist/chunk-73OOROXH.js +8 -0
  7. package/dist/{chunk-SI2LU2RP.js → chunk-AYWKIZLD.js} +1 -1
  8. package/dist/{chunk-GCPBEMMH.js → chunk-BVY7GGNV.js} +10 -21
  9. package/dist/{chunk-AEHCVWU5.js → chunk-DZB666V7.js} +0 -1
  10. package/dist/{chunk-75UUF6C4.js → chunk-HI7QEWL6.js} +18 -10
  11. package/dist/chunk-KQ6756AJ.js +28 -0
  12. package/dist/chunk-LMMOFRGQ.js +148 -0
  13. package/dist/{chunk-FNW556FN.js → chunk-M2PUNKHS.js} +0 -1
  14. package/dist/chunk-M5ZNQGR5.js +19 -0
  15. package/dist/chunk-M62ZGJ5I.js +51 -0
  16. package/dist/chunk-OQCPBOQA.js +168 -0
  17. package/dist/{chunk-EGNDADXB.js → chunk-QI6YKTQV.js} +2 -3
  18. package/dist/chunk-SJBB5OD7.js +227 -0
  19. package/dist/{chunk-EZKJZUNJ.js → chunk-XAMILHQP.js} +0 -1
  20. package/dist/{chunk-J32GU3F3.js → chunk-YM7O3PWO.js} +249 -222
  21. package/dist/{chunk-RQJRQF46.js → chunk-ZO7G53QP.js} +41 -49
  22. package/dist/document/index.d.ts +358 -6
  23. package/dist/document/index.js +24 -4
  24. package/dist/filesystem/electron.d.ts +73 -4
  25. package/dist/filesystem/electron.js +16 -4
  26. package/dist/filesystem/index.d.ts +228 -22
  27. package/dist/filesystem/index.js +133 -20
  28. package/dist/filesystem/indexeddb.d.ts +284 -5
  29. package/dist/filesystem/indexeddb.js +22 -5
  30. package/dist/filesystem/memory.d.ts +152 -4
  31. package/dist/filesystem/memory.js +12 -4
  32. package/dist/filesystem/native.d.ts +136 -4
  33. package/dist/filesystem/native.js +27 -4
  34. package/dist/host/index.d.ts +32 -9
  35. package/dist/host/index.js +26 -30
  36. package/dist/index.d.ts +14 -10
  37. package/dist/index.js +204 -10
  38. package/dist/mcp/index.d.ts +33 -4
  39. package/dist/mcp/index.js +31 -4
  40. package/dist/mcp/zod.d.ts +645 -643
  41. package/dist/mcp/zod.js +700 -885
  42. package/dist/share/index.d.ts +43 -0
  43. package/dist/share/index.js +12 -0
  44. package/dist/{types-CsX6EN2t.d.ts → types-BEg5SQ1_.d.ts} +1 -1
  45. package/dist/{types-eOlt9J7n.d.ts → types-CueK0tvU.d.ts} +34 -11
  46. package/dist/vscode/index.d.ts +225 -3
  47. package/dist/vscode/index.js +389 -3
  48. package/dist/workspace/index.d.ts +141 -4
  49. package/dist/workspace/index.js +28 -3
  50. package/package.json +10 -5
  51. package/dist/chunk-2D7Y4IR3.js.map +0 -1
  52. package/dist/chunk-5MYAICRE.js.map +0 -1
  53. package/dist/chunk-75UUF6C4.js.map +0 -1
  54. package/dist/chunk-AEHCVWU5.js.map +0 -1
  55. package/dist/chunk-AYZ4HN5M.js +0 -20
  56. package/dist/chunk-AYZ4HN5M.js.map +0 -1
  57. package/dist/chunk-EGNDADXB.js.map +0 -1
  58. package/dist/chunk-EZKJZUNJ.js.map +0 -1
  59. package/dist/chunk-FNW556FN.js.map +0 -1
  60. package/dist/chunk-GCPBEMMH.js.map +0 -1
  61. package/dist/chunk-J32GU3F3.js.map +0 -1
  62. package/dist/chunk-PGR7LK6D.js.map +0 -1
  63. package/dist/chunk-RQJRQF46.js.map +0 -1
  64. package/dist/chunk-RVQHY3XU.js.map +0 -1
  65. package/dist/chunk-SI2LU2RP.js.map +0 -1
  66. package/dist/chunk-W5UUUII5.js +0 -142
  67. package/dist/chunk-W5UUUII5.js.map +0 -1
  68. package/dist/document/document-session.d.ts +0 -127
  69. package/dist/document/document-session.d.ts.map +0 -1
  70. package/dist/document/document-session.js +0 -749
  71. package/dist/document/document-session.js.map +0 -1
  72. package/dist/document/filesystem-target.d.ts +0 -17
  73. package/dist/document/filesystem-target.d.ts.map +0 -1
  74. package/dist/document/filesystem-target.js +0 -70
  75. package/dist/document/filesystem-target.js.map +0 -1
  76. package/dist/document/index.d.ts.map +0 -1
  77. package/dist/document/index.js.map +0 -1
  78. package/dist/document/recovery-journal.d.ts +0 -125
  79. package/dist/document/recovery-journal.d.ts.map +0 -1
  80. package/dist/document/recovery-journal.js +0 -385
  81. package/dist/document/recovery-journal.js.map +0 -1
  82. package/dist/document/types.d.ts +0 -89
  83. package/dist/document/types.d.ts.map +0 -1
  84. package/dist/document/types.js +0 -9
  85. package/dist/document/types.js.map +0 -1
  86. package/dist/filesystem/commit-lock.d.ts +0 -3
  87. package/dist/filesystem/commit-lock.d.ts.map +0 -1
  88. package/dist/filesystem/commit-lock.js +0 -20
  89. package/dist/filesystem/commit-lock.js.map +0 -1
  90. package/dist/filesystem/dbk-workspace.d.ts +0 -34
  91. package/dist/filesystem/dbk-workspace.d.ts.map +0 -1
  92. package/dist/filesystem/dbk-workspace.js +0 -85
  93. package/dist/filesystem/dbk-workspace.js.map +0 -1
  94. package/dist/filesystem/electron-provider-v2.d.ts +0 -36
  95. package/dist/filesystem/electron-provider-v2.d.ts.map +0 -1
  96. package/dist/filesystem/electron-provider-v2.js +0 -503
  97. package/dist/filesystem/electron-provider-v2.js.map +0 -1
  98. package/dist/filesystem/electron-provider.d.ts +0 -35
  99. package/dist/filesystem/electron-provider.d.ts.map +0 -1
  100. package/dist/filesystem/electron-provider.js +0 -69
  101. package/dist/filesystem/electron-provider.js.map +0 -1
  102. package/dist/filesystem/electron.d.ts.map +0 -1
  103. package/dist/filesystem/electron.js.map +0 -1
  104. package/dist/filesystem/file-media-provider.d.ts +0 -23
  105. package/dist/filesystem/file-media-provider.d.ts.map +0 -1
  106. package/dist/filesystem/file-media-provider.js +0 -85
  107. package/dist/filesystem/file-media-provider.js.map +0 -1
  108. package/dist/filesystem/filesystem-content-container.d.ts +0 -24
  109. package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
  110. package/dist/filesystem/filesystem-content-container.js +0 -153
  111. package/dist/filesystem/filesystem-content-container.js.map +0 -1
  112. package/dist/filesystem/fs-error.d.ts +0 -46
  113. package/dist/filesystem/fs-error.d.ts.map +0 -1
  114. package/dist/filesystem/fs-error.js +0 -170
  115. package/dist/filesystem/fs-error.js.map +0 -1
  116. package/dist/filesystem/index.d.ts.map +0 -1
  117. package/dist/filesystem/index.js.map +0 -1
  118. package/dist/filesystem/indexeddb-content-container.d.ts +0 -22
  119. package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
  120. package/dist/filesystem/indexeddb-content-container.js +0 -100
  121. package/dist/filesystem/indexeddb-content-container.js.map +0 -1
  122. package/dist/filesystem/indexeddb-provider-v2.d.ts +0 -96
  123. package/dist/filesystem/indexeddb-provider-v2.d.ts.map +0 -1
  124. package/dist/filesystem/indexeddb-provider-v2.js +0 -1241
  125. package/dist/filesystem/indexeddb-provider-v2.js.map +0 -1
  126. package/dist/filesystem/indexeddb-provider.d.ts +0 -39
  127. package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
  128. package/dist/filesystem/indexeddb-provider.js +0 -145
  129. package/dist/filesystem/indexeddb-provider.js.map +0 -1
  130. package/dist/filesystem/indexeddb-store.d.ts +0 -34
  131. package/dist/filesystem/indexeddb-store.d.ts.map +0 -1
  132. package/dist/filesystem/indexeddb-store.js +0 -165
  133. package/dist/filesystem/indexeddb-store.js.map +0 -1
  134. package/dist/filesystem/indexeddb.d.ts.map +0 -1
  135. package/dist/filesystem/indexeddb.js.map +0 -1
  136. package/dist/filesystem/legacy-v2-adapter.d.ts +0 -62
  137. package/dist/filesystem/legacy-v2-adapter.d.ts.map +0 -1
  138. package/dist/filesystem/legacy-v2-adapter.js +0 -499
  139. package/dist/filesystem/legacy-v2-adapter.js.map +0 -1
  140. package/dist/filesystem/memory-provider-v2.d.ts +0 -92
  141. package/dist/filesystem/memory-provider-v2.d.ts.map +0 -1
  142. package/dist/filesystem/memory-provider-v2.js +0 -615
  143. package/dist/filesystem/memory-provider-v2.js.map +0 -1
  144. package/dist/filesystem/memory-provider.d.ts +0 -54
  145. package/dist/filesystem/memory-provider.d.ts.map +0 -1
  146. package/dist/filesystem/memory-provider.js +0 -132
  147. package/dist/filesystem/memory-provider.js.map +0 -1
  148. package/dist/filesystem/memory.d.ts.map +0 -1
  149. package/dist/filesystem/memory.js.map +0 -1
  150. package/dist/filesystem/move-entry.d.ts +0 -9
  151. package/dist/filesystem/move-entry.d.ts.map +0 -1
  152. package/dist/filesystem/move-entry.js +0 -103
  153. package/dist/filesystem/move-entry.js.map +0 -1
  154. package/dist/filesystem/move-error.d.ts +0 -53
  155. package/dist/filesystem/move-error.d.ts.map +0 -1
  156. package/dist/filesystem/move-error.js +0 -99
  157. package/dist/filesystem/move-error.js.map +0 -1
  158. package/dist/filesystem/native-provider-v2.d.ts +0 -75
  159. package/dist/filesystem/native-provider-v2.d.ts.map +0 -1
  160. package/dist/filesystem/native-provider-v2.js +0 -849
  161. package/dist/filesystem/native-provider-v2.js.map +0 -1
  162. package/dist/filesystem/native-provider.d.ts +0 -53
  163. package/dist/filesystem/native-provider.d.ts.map +0 -1
  164. package/dist/filesystem/native-provider.js +0 -471
  165. package/dist/filesystem/native-provider.js.map +0 -1
  166. package/dist/filesystem/native.d.ts.map +0 -1
  167. package/dist/filesystem/native.js.map +0 -1
  168. package/dist/filesystem/types.d.ts +0 -83
  169. package/dist/filesystem/types.d.ts.map +0 -1
  170. package/dist/filesystem/types.js +0 -16
  171. package/dist/filesystem/types.js.map +0 -1
  172. package/dist/filesystem/v2.d.ts +0 -172
  173. package/dist/filesystem/v2.d.ts.map +0 -1
  174. package/dist/filesystem/v2.js +0 -16
  175. package/dist/filesystem/v2.js.map +0 -1
  176. package/dist/filesystem/workspace-path.d.ts +0 -21
  177. package/dist/filesystem/workspace-path.d.ts.map +0 -1
  178. package/dist/filesystem/workspace-path.js +0 -80
  179. package/dist/filesystem/workspace-path.js.map +0 -1
  180. package/dist/host/filesystem-v2.d.ts +0 -45
  181. package/dist/host/filesystem-v2.d.ts.map +0 -1
  182. package/dist/host/filesystem-v2.js +0 -13
  183. package/dist/host/filesystem-v2.js.map +0 -1
  184. package/dist/host/git.d.ts +0 -200
  185. package/dist/host/git.d.ts.map +0 -1
  186. package/dist/host/git.js +0 -15
  187. package/dist/host/git.js.map +0 -1
  188. package/dist/host/index.d.ts.map +0 -1
  189. package/dist/host/index.js.map +0 -1
  190. package/dist/host/types.d.ts +0 -232
  191. package/dist/host/types.d.ts.map +0 -1
  192. package/dist/host/types.js +0 -10
  193. package/dist/host/types.js.map +0 -1
  194. package/dist/host/wire-policy.d.ts +0 -22
  195. package/dist/host/wire-policy.d.ts.map +0 -1
  196. package/dist/host/wire-policy.js +0 -92
  197. package/dist/host/wire-policy.js.map +0 -1
  198. package/dist/index.d.ts.map +0 -1
  199. package/dist/index.js.map +0 -1
  200. package/dist/mcp/index.d.ts.map +0 -1
  201. package/dist/mcp/index.js.map +0 -1
  202. package/dist/mcp/types.d.ts +0 -466
  203. package/dist/mcp/types.d.ts.map +0 -1
  204. package/dist/mcp/types.js +0 -25
  205. package/dist/mcp/types.js.map +0 -1
  206. package/dist/mcp/wire.d.ts +0 -29
  207. package/dist/mcp/wire.d.ts.map +0 -1
  208. package/dist/mcp/wire.js +0 -1046
  209. package/dist/mcp/wire.js.map +0 -1
  210. package/dist/mcp/zod.d.ts.map +0 -1
  211. package/dist/mcp/zod.js.map +0 -1
  212. package/dist/vscode/index.d.ts.map +0 -1
  213. package/dist/vscode/index.js.map +0 -1
  214. package/dist/vscode/messages.d.ts +0 -204
  215. package/dist/vscode/messages.d.ts.map +0 -1
  216. package/dist/vscode/messages.js +0 -494
  217. package/dist/vscode/messages.js.map +0 -1
  218. package/dist/workspace/index.d.ts.map +0 -1
  219. package/dist/workspace/index.js.map +0 -1
  220. package/dist/workspace/reconcile-electron.d.ts +0 -19
  221. package/dist/workspace/reconcile-electron.d.ts.map +0 -1
  222. package/dist/workspace/reconcile-electron.js +0 -42
  223. package/dist/workspace/reconcile-electron.js.map +0 -1
  224. package/dist/workspace/types.d.ts +0 -69
  225. package/dist/workspace/types.d.ts.map +0 -1
  226. package/dist/workspace/types.js +0 -2
  227. package/dist/workspace/types.js.map +0 -1
  228. package/dist/workspace/workspace-manager.d.ts +0 -47
  229. package/dist/workspace/workspace-manager.d.ts.map +0 -1
  230. package/dist/workspace/workspace-manager.js +0 -126
  231. package/dist/workspace/workspace-manager.js.map +0 -1
  232. package/src/document/document-session.ts +0 -834
  233. package/src/document/filesystem-target.ts +0 -109
  234. package/src/document/index.ts +0 -41
  235. package/src/document/recovery-journal.ts +0 -536
  236. package/src/document/types.ts +0 -116
  237. package/src/filesystem/commit-lock.ts +0 -29
  238. package/src/filesystem/dbk-workspace.ts +0 -135
  239. package/src/filesystem/electron-provider-v2.ts +0 -630
  240. package/src/filesystem/electron-provider.ts +0 -99
  241. package/src/filesystem/electron.ts +0 -3
  242. package/src/filesystem/file-media-provider.ts +0 -103
  243. package/src/filesystem/filesystem-content-container.ts +0 -164
  244. package/src/filesystem/fs-error.ts +0 -234
  245. package/src/filesystem/index.ts +0 -143
  246. package/src/filesystem/indexeddb-content-container.ts +0 -112
  247. package/src/filesystem/indexeddb-provider-v2.ts +0 -1740
  248. package/src/filesystem/indexeddb-provider.ts +0 -171
  249. package/src/filesystem/indexeddb-store.ts +0 -207
  250. package/src/filesystem/indexeddb.ts +0 -12
  251. package/src/filesystem/legacy-v2-adapter.ts +0 -779
  252. package/src/filesystem/memory-provider-v2.ts +0 -896
  253. package/src/filesystem/memory-provider.ts +0 -180
  254. package/src/filesystem/memory.ts +0 -15
  255. package/src/filesystem/move-entry.ts +0 -142
  256. package/src/filesystem/move-error.ts +0 -159
  257. package/src/filesystem/native-provider-v2.ts +0 -1165
  258. package/src/filesystem/native-provider.ts +0 -537
  259. package/src/filesystem/native.ts +0 -16
  260. package/src/filesystem/types.ts +0 -114
  261. package/src/filesystem/v2.ts +0 -231
  262. package/src/filesystem/workspace-path.ts +0 -92
  263. package/src/host/filesystem-v2.ts +0 -104
  264. package/src/host/git.ts +0 -246
  265. package/src/host/index.ts +0 -93
  266. package/src/host/types.ts +0 -274
  267. package/src/host/wire-policy.ts +0 -103
  268. package/src/index.ts +0 -10
  269. package/src/mcp/index.ts +0 -3
  270. package/src/mcp/types.ts +0 -594
  271. package/src/mcp/wire.ts +0 -1280
  272. package/src/mcp/zod.ts +0 -1000
  273. package/src/vscode/index.ts +0 -2
  274. package/src/vscode/messages.ts +0 -704
  275. package/src/workspace/index.ts +0 -17
  276. package/src/workspace/reconcile-electron.ts +0 -65
  277. package/src/workspace/types.ts +0 -67
  278. package/src/workspace/workspace-manager.ts +0 -151
package/src/host/index.ts DELETED
@@ -1,93 +0,0 @@
1
- /**
2
- * Host bridge — shared types + runtime access for the Electron desktop
3
- * host. The renderer calls `getDocBlocksHost()` to reach the preload
4
- * contextBridge; `isElectronHost()` gates desktop-only UI branches.
5
- */
6
-
7
- export type {
8
- DocBlocksHostAPI,
9
- DocBlocksHostFsAPI,
10
- DocBlocksHostExternalAPI,
11
- DocBlocksHostWorkspacesAPI,
12
- DocBlocksHostShellAPI,
13
- DocBlocksHostExportAPI,
14
- DocBlocksHostFfmpegAPI,
15
- DocBlocksHostUpdaterAPI,
16
- DocBlocksHostLifecycleAPI,
17
- ElectronWorkspaceInfo,
18
- ExternalBinaryCommitResult,
19
- HostCloseReason,
20
- HostEnvironment,
21
- HostExportTargetGrant,
22
- HostPrepareCloseRequest,
23
- HostPrepareCloseResult,
24
- MenuCommand,
25
- OpenRequest,
26
- UpdateInstallResult,
27
- UpdaterStatus,
28
- } from './types.js';
29
-
30
- export type {
31
- DocBlocksHostGitAPI,
32
- GitBranchInfo,
33
- GitCapabilities,
34
- GitCloneHandle,
35
- GitCloneProgress,
36
- GitError,
37
- GitErrorCode,
38
- GitFileAtRevision,
39
- GitFileChange,
40
- GitFileStatusCode,
41
- GitLogEntry,
42
- GitLogOptions,
43
- GitRemoteInfo,
44
- GitRepoDetection,
45
- GitResult,
46
- GitRevision,
47
- GitStatus,
48
- } from './git.js';
49
-
50
- export {
51
- ELECTRON_FILE_SYSTEM_V2_CAPABILITIES,
52
- type DocBlocksHostFsV2API,
53
- type HostFileSystemV2OpenRequest,
54
- type HostFileSystemV2Result,
55
- type HostFileSystemV2WatchMessage,
56
- } from './filesystem-v2.js';
57
-
58
- export {
59
- HOST_WIRE_LIMITS,
60
- isBoundedBytePayload,
61
- isBoundedString,
62
- isTrustedRendererUrl,
63
- parseExternalHttpUrl,
64
- parseOpenRequest,
65
- } from './wire-policy.js';
66
-
67
- import type { DocBlocksHostAPI } from './types.js';
68
-
69
- /** True when running inside the Electron desktop shell. */
70
- export function isElectronHost(): boolean {
71
- if (typeof globalThis === 'undefined') return false;
72
- const host = (globalThis as { docBlocksHost?: unknown }).docBlocksHost;
73
- return (
74
- typeof host === 'object' &&
75
- host !== null &&
76
- typeof (host as { fs?: unknown }).fs === 'object' &&
77
- (host as { fs?: unknown }).fs !== null
78
- );
79
- }
80
-
81
- /** Return the host API, or throw if not running under Electron. */
82
- export function getDocBlocksHost(): DocBlocksHostAPI {
83
- const host = (globalThis as { docBlocksHost?: DocBlocksHostAPI }).docBlocksHost;
84
- if (!host) {
85
- throw new Error('docBlocksHost is not available — not running under Electron?');
86
- }
87
- return host;
88
- }
89
-
90
- /** Return the host API, or null if not running under Electron. */
91
- export function maybeGetDocBlocksHost(): DocBlocksHostAPI | null {
92
- return (globalThis as { docBlocksHost?: DocBlocksHostAPI }).docBlocksHost ?? null;
93
- }
package/src/host/types.ts DELETED
@@ -1,274 +0,0 @@
1
- /**
2
- * DocBlocksHostAPI — the contract exposed by the Electron desktop shell
3
- * to its renderer process via contextBridge.
4
- *
5
- * This file is the single source of truth for the host ↔ renderer
6
- * bridge. The Electron preload script exposes an implementation matching
7
- * this shape; the React renderer calls it through `window.docBlocksHost`.
8
- */
9
-
10
- import type { FileCommitResult, FileSystemEntry, FileMeta } from '../filesystem/types.js';
11
- import type { DocBlocksHostFsV2API } from './filesystem-v2.js';
12
- import type { DocBlocksHostGitAPI } from './git.js';
13
-
14
- /** Filesystem operations scoped to a main-owned registered workspace id. */
15
- export interface DocBlocksHostFsAPI {
16
- readFile(workspaceId: string, path: string): Promise<string | null>;
17
- writeFile(workspaceId: string, path: string, content: string): Promise<void>;
18
- commitFile(
19
- workspaceId: string,
20
- path: string,
21
- content: string,
22
- expectedContent: string | null,
23
- ): Promise<FileCommitResult>;
24
- delete(workspaceId: string, path: string): Promise<void>;
25
- rename(workspaceId: string, oldPath: string, newPath: string): Promise<void>;
26
- readDirectory(workspaceId: string, path: string): Promise<FileSystemEntry[]>;
27
- exists(workspaceId: string, path: string): Promise<boolean>;
28
- createDirectory(workspaceId: string, path: string): Promise<void>;
29
- stat(workspaceId: string, path: string): Promise<FileMeta | null>;
30
- readBinary(workspaceId: string, path: string): Promise<ArrayBuffer | null>;
31
- writeBinary(workspaceId: string, path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
32
- /**
33
- * Subscribe to change notifications for a watched root. Returns an
34
- * unsubscribe function. The main process uses chokidar under the hood.
35
- */
36
- watch(workspaceId: string, onChange: (path: string) => void): () => void;
37
- }
38
-
39
- /** Descriptor returned for an Electron-managed workspace (backed by a folder). */
40
- export interface ElectronWorkspaceInfo {
41
- id: string;
42
- name: string;
43
- /** Display/persistence metadata only. Privileged host calls accept `id`, never this path. */
44
- rootPath: string;
45
- }
46
-
47
- /** Workspace-management operations exposed to the renderer. */
48
- export interface DocBlocksHostWorkspacesAPI {
49
- /** List only folders already persisted as trusted main-process roots. */
50
- list(): Promise<ElectronWorkspaceInfo[]>;
51
- /**
52
- * Return the default workspace (creating DocBlocks inside the operating
53
- * system's Documents folder on first call, or the user's configured default).
54
- */
55
- getDefault(): Promise<ElectronWorkspaceInfo>;
56
- /**
57
- * Open the native folder picker. Returns null if the user cancels.
58
- * The selected folder is registered in the main process whitelist.
59
- */
60
- pickFolder(): Promise<ElectronWorkspaceInfo | null>;
61
- /**
62
- * Re-register a previously picker-approved workspace by main-owned id.
63
- * Called on app startup before any filesystem operation.
64
- */
65
- register(workspaceId: string): Promise<void>;
66
- /** Remove a workspace from the trusted whitelist. */
67
- unregister(id: string): Promise<void>;
68
- }
69
-
70
- /** Shell operations — reveal in Finder/Explorer, open external URLs. */
71
- export interface DocBlocksHostShellAPI {
72
- /** Reveal a registered workspace root or one root-relative entry. */
73
- revealInFolder(workspaceId: string, workspacePath?: string): Promise<void>;
74
- /** Open a URL in the default browser. */
75
- openExternal(url: string): Promise<void>;
76
- }
77
-
78
- /** Exact, main-owned export authority. The display path is never authority. */
79
- export interface HostExportTargetGrant {
80
- /** Null means this is a display-only suggestion and save must show a picker. */
81
- grantId: string | null;
82
- displayPath: string;
83
- }
84
-
85
- /** Native export target selection and binary file writing. */
86
- export interface DocBlocksHostExportAPI {
87
- /** Resolve an exact remembered grant or a display-only host suggestion. */
88
- resolveTarget(documentId: string, filename: string): Promise<HostExportTargetGrant>;
89
- /** Open the native Save dialog and remember the selected target. */
90
- pickTarget(
91
- documentId: string,
92
- filename: string,
93
- currentGrantId?: string | null,
94
- ): Promise<HostExportTargetGrant | null>;
95
- /** Write only to an exact target granted by the main process. */
96
- save(
97
- documentId: string,
98
- filename: string,
99
- grantId: string | null,
100
- data: ArrayBuffer | Uint8Array,
101
- ): Promise<HostExportTargetGrant | null>;
102
- }
103
-
104
- /** System ffmpeg detection and invocation. */
105
- export interface DocBlocksHostFfmpegAPI {
106
- /** True if `ffmpeg` is available on PATH (or bundled). */
107
- available(): Promise<boolean>;
108
- /** Version string from `ffmpeg -version`, or null if unavailable. */
109
- version(): Promise<string | null>;
110
- /** Render a physically contained workspace-relative Markdown file to MP4. */
111
- renderVideo(
112
- workspaceId: string,
113
- markdownPath: string,
114
- options: { fps?: number; quality?: 'draft' | 'normal' | 'high' },
115
- ): Promise<string>;
116
- }
117
-
118
- /** Auto-updater control. */
119
- export interface DocBlocksHostUpdaterAPI {
120
- /** Kick off a check; resolves to true if an update is available. */
121
- checkForUpdates(): Promise<boolean>;
122
- /** Current app version string. */
123
- getVersion(): Promise<string>;
124
- /**
125
- * Quit the app and apply a downloaded update. Should only be called
126
- * after an `UpdaterStatus` of kind `'downloaded'` has been observed.
127
- */
128
- quitAndInstall(): Promise<UpdateInstallResult>;
129
- /**
130
- * Subscribe to updater status events. Returns an unsubscribe function.
131
- */
132
- onStatus(listener: (status: UpdaterStatus) => void): () => void;
133
- }
134
-
135
- export type UpdateInstallResult = 'installing' | 'cancelled' | 'not-ready';
136
-
137
- export type UpdaterStatus =
138
- | { kind: 'checking' }
139
- | { kind: 'available'; version: string; releaseNotes?: string; releaseUrl?: string }
140
- | { kind: 'not-available' }
141
- | { kind: 'downloading'; percent: number }
142
- | { kind: 'downloaded'; version: string; releaseNotes?: string; releaseUrl?: string }
143
- | { kind: 'error'; message: string };
144
-
145
- /** Menu-command events pushed from the main process to the renderer. */
146
- export type MenuCommand =
147
- | 'file:new'
148
- | 'file:openFolder'
149
- | 'file:revealWorkspace'
150
- | 'file:settings'
151
- | 'git:commit'
152
- | 'git:push'
153
- | 'git:pull'
154
- | 'git:fetch'
155
- | 'git:newBranch'
156
- | 'git:switchBranch'
157
- | 'git:history'
158
- | 'git:clone'
159
- | 'git:openOnRemote'
160
- | 'git:createPullRequest'
161
- | 'help:about'
162
- | 'help:checkForUpdates'
163
- | 'help:viewOnGitHub';
164
-
165
- /**
166
- * OS open-file / deep-link event resolved by the host.
167
- * - 'workspace-file': a file inside an already-registered workspace.
168
- * - 'external-file': a loose markdown file outside any workspace — opened in a
169
- * transient workspace and saved through an opaque resource grant.
170
- * - 'external-bundle': a `.dbk`/zip bundle — unpacked into a transient
171
- * workspace and re-zipped through an opaque resource grant on save.
172
- */
173
- export type OpenRequest =
174
- | {
175
- kind: 'workspace-file';
176
- workspaceId: string;
177
- /** Slash-prefixed path relative to the workspace root. */
178
- path: string;
179
- }
180
- | { kind: 'external-file'; resourceId: string; name: string }
181
- | { kind: 'external-bundle'; resourceId: string; name: string };
182
-
183
- /**
184
- * Read/write access to individual OS files the user has explicitly opened
185
- * (via "Open With" / deep link), outside the workspace-root whitelist. The
186
- * main process gates these with owner-scoped, exact-file capabilities.
187
- */
188
- export interface DocBlocksHostExternalAPI {
189
- readText(resourceId: string): Promise<string | null>;
190
- readBinary(resourceId: string): Promise<ArrayBuffer | null>;
191
- writeText(resourceId: string, content: string): Promise<void>;
192
- writeBinary(resourceId: string, data: ArrayBuffer | Uint8Array): Promise<void>;
193
- commitText(
194
- resourceId: string,
195
- content: string,
196
- expectedContent: string | null,
197
- ): Promise<FileCommitResult>;
198
- commitBinary(
199
- resourceId: string,
200
- data: ArrayBuffer | Uint8Array,
201
- expectedVersion: string | null,
202
- ): Promise<ExternalBinaryCommitResult>;
203
- /** Revoke one external resource when its transient document is closed. */
204
- revoke(resourceId: string): Promise<void>;
205
- }
206
-
207
- export type ExternalBinaryCommitResult =
208
- | { status: 'committed'; version: string }
209
- | { status: 'conflict'; version: string | null; data: ArrayBuffer | null };
210
-
211
- /** Environment metadata provided by the host. */
212
- export interface HostEnvironment {
213
- platform: 'darwin' | 'win32' | 'linux';
214
- appVersion: string;
215
- isDev: boolean;
216
- }
217
-
218
- export type HostCloseReason =
219
- | 'window-close'
220
- | 'app-quit'
221
- | 'update-install'
222
- | 'reload'
223
- | 'force-reload';
224
-
225
- export interface HostPrepareCloseRequest {
226
- requestId: string;
227
- reason: HostCloseReason;
228
- /** Absolute epoch-millisecond deadline chosen by the main process. */
229
- deadline: number;
230
- }
231
-
232
- export type HostPrepareCloseResult =
233
- | { status: 'ready'; persistedRevision: number }
234
- | {
235
- status: 'blocked';
236
- code: 'save-failed' | 'external-conflict' | 'not-ready';
237
- message: string;
238
- };
239
-
240
- /**
241
- * Main-owned close handshake. Preload privately correlates replies; the
242
- * renderer never chooses request or window identifiers.
243
- */
244
- export interface DocBlocksHostLifecycleAPI {
245
- onPrepareClose(
246
- listener: (request: HostPrepareCloseRequest) => Promise<HostPrepareCloseResult>,
247
- ): () => void;
248
- onCancelClose(listener: (requestId: string) => void): () => void;
249
- }
250
-
251
- /** The full DocBlocks desktop host API. */
252
- export interface DocBlocksHostAPI {
253
- env: HostEnvironment;
254
- fs: DocBlocksHostFsAPI;
255
- fsV2: DocBlocksHostFsV2API;
256
- external: DocBlocksHostExternalAPI;
257
- workspaces: DocBlocksHostWorkspacesAPI;
258
- shell: DocBlocksHostShellAPI;
259
- exports: DocBlocksHostExportAPI;
260
- ffmpeg: DocBlocksHostFfmpegAPI;
261
- git: DocBlocksHostGitAPI;
262
- updater: DocBlocksHostUpdaterAPI;
263
- lifecycle: DocBlocksHostLifecycleAPI;
264
- /**
265
- * Subscribe to menu commands dispatched by the native menu.
266
- * Returns an unsubscribe function.
267
- */
268
- onMenuCommand(listener: (cmd: MenuCommand) => void): () => void;
269
- /**
270
- * Subscribe to open-file / open-url requests from the OS.
271
- * Returns an unsubscribe function.
272
- */
273
- onOpenRequest(listener: (request: OpenRequest) => void): () => void;
274
- }
@@ -1,103 +0,0 @@
1
- import type { OpenRequest } from './types.js';
2
-
3
- /** Quantitative limits shared by privileged host boundaries. */
4
- export const HOST_WIRE_LIMITS = Object.freeze({
5
- identifierCharacters: 256,
6
- labelCharacters: 1_024,
7
- pathCharacters: 4_096,
8
- urlCharacters: 8_192,
9
- messageCharacters: 2_000,
10
- documentCharacters: 20 * 1024 * 1024,
11
- binaryBytes: 100 * 1024 * 1024,
12
- base64Characters: 140 * 1024 * 1024,
13
- arrayEntries: 10_000,
14
- });
15
-
16
- function hasExactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {
17
- const actual = Object.keys(value);
18
- return (
19
- actual.length === keys.length &&
20
- keys.every((key) => Object.prototype.hasOwnProperty.call(value, key))
21
- );
22
- }
23
-
24
- export function isBoundedString(
25
- value: unknown,
26
- maximumCharacters: number,
27
- minimumCharacters = 0,
28
- ): value is string {
29
- return (
30
- typeof value === 'string' &&
31
- value.length >= minimumCharacters &&
32
- value.length <= maximumCharacters &&
33
- !value.includes('\0')
34
- );
35
- }
36
-
37
- export function isBoundedBytePayload(
38
- value: unknown,
39
- maximumBytes = HOST_WIRE_LIMITS.binaryBytes,
40
- ): value is ArrayBuffer | Uint8Array {
41
- return (
42
- (value instanceof ArrayBuffer || value instanceof Uint8Array) &&
43
- value.byteLength <= maximumBytes
44
- );
45
- }
46
-
47
- /** Parse one exact, bounded main-to-renderer open request. */
48
- export function parseOpenRequest(value: unknown): OpenRequest | null {
49
- if (typeof value !== 'object' || value === null || Array.isArray(value)) return null;
50
- const record = value as Record<string, unknown>;
51
-
52
- if (record.kind === 'workspace-file') {
53
- if (!hasExactKeys(record, ['kind', 'workspaceId', 'path'])) return null;
54
- if (!isBoundedString(record.workspaceId, HOST_WIRE_LIMITS.identifierCharacters, 1)) return null;
55
- if (!isBoundedString(record.path, HOST_WIRE_LIMITS.pathCharacters, 1)) return null;
56
- return { kind: 'workspace-file', workspaceId: record.workspaceId, path: record.path };
57
- }
58
-
59
- if (record.kind === 'external-file' || record.kind === 'external-bundle') {
60
- if (!hasExactKeys(record, ['kind', 'resourceId', 'name'])) return null;
61
- if (!isBoundedString(record.resourceId, HOST_WIRE_LIMITS.identifierCharacters, 1)) return null;
62
- if (!isBoundedString(record.name, HOST_WIRE_LIMITS.labelCharacters, 1)) return null;
63
- return { kind: record.kind, resourceId: record.resourceId, name: record.name };
64
- }
65
-
66
- return null;
67
- }
68
-
69
- /** Return one canonical HTTP(S) URL, or null when external navigation is unsafe. */
70
- export function parseExternalHttpUrl(value: unknown): string | null {
71
- if (!isBoundedString(value, HOST_WIRE_LIMITS.urlCharacters, 1)) return null;
72
- try {
73
- const url = new URL(value);
74
- if (url.protocol !== 'http:' && url.protocol !== 'https:') return null;
75
- if (url.username || url.password) return null;
76
- const canonical = url.href;
77
- return canonical.length <= HOST_WIRE_LIMITS.urlCharacters ? canonical : null;
78
- } catch {
79
- return null;
80
- }
81
- }
82
-
83
- /** True only for the packaged renderer origin or the exact configured dev origin. */
84
- export function isTrustedRendererUrl(value: unknown, developmentOrigin?: string): boolean {
85
- if (!isBoundedString(value, HOST_WIRE_LIMITS.urlCharacters, 1)) return false;
86
- try {
87
- const url = new URL(value);
88
- if (
89
- url.protocol === 'app:' &&
90
- url.hostname === 'docblocks' &&
91
- url.port === '' &&
92
- url.username === '' &&
93
- url.password === ''
94
- ) {
95
- return true;
96
- }
97
- if (!developmentOrigin) return false;
98
- const trustedDevelopmentOrigin = new URL(developmentOrigin);
99
- return url.origin === trustedDevelopmentOrigin.origin;
100
- } catch {
101
- return false;
102
- }
103
- }
package/src/index.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * @bendyline/docblocks — Core package
3
- *
4
- * Re-exports filesystem, document, workspace, and host modules for convenience.
5
- */
6
-
7
- export * from './filesystem/index.js';
8
- export * from './document/index.js';
9
- export * from './workspace/index.js';
10
- export * from './host/index.js';
package/src/mcp/index.ts DELETED
@@ -1,3 +0,0 @@
1
- /** Exact, bounded wire contracts shared by DocBlocks MCP implementations. */
2
- export * from './types.js';
3
- export * from './wire.js';