@ricsam/r5d-worker 0.0.137 → 0.0.139

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 (236) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7543
  4. package/dist/mjs/package.json +1 -1
  5. package/dist/mjs/personal/action-scheduler.mjs +31 -0
  6. package/dist/mjs/personal/client.mjs +215 -0
  7. package/dist/mjs/personal/runtime.mjs +359 -0
  8. package/dist/mjs/personal/tcp.mjs +217 -0
  9. package/dist/mjs/runtime/adapter.mjs +42 -0
  10. package/dist/mjs/runtime/client.mjs +95 -0
  11. package/dist/mjs/runtime/daemon.mjs +131 -0
  12. package/dist/mjs/runtime/executor.mjs +436 -0
  13. package/dist/mjs/runtime/index.mjs +15 -0
  14. package/dist/mjs/runtime/protocol.mjs +139 -0
  15. package/dist/mjs/runtime/pty-host.mjs +156 -0
  16. package/dist/mjs/runtime/pty.mjs +127 -0
  17. package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
  18. package/dist/mjs/runtime/releases/grants.mjs +93 -0
  19. package/dist/mjs/runtime/releases/main.mjs +101 -0
  20. package/dist/mjs/runtime/releases/manager.mjs +541 -0
  21. package/dist/mjs/runtime/releases/process.mjs +88 -0
  22. package/dist/mjs/runtime/releases/retirement.mjs +18 -0
  23. package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
  24. package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
  25. package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
  26. package/dist/mjs/runtime/storage.mjs +156 -0
  27. package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
  28. package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
  29. package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
  30. package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
  31. package/dist/mjs/runtime/workspace/files.mjs +308 -0
  32. package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
  33. package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
  34. package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
  35. package/dist/types/main.d.ts +0 -1167
  36. package/dist/types/personal/action-scheduler.d.ts +23 -0
  37. package/dist/types/personal/client.d.ts +14 -0
  38. package/dist/types/personal/runtime.d.ts +121 -0
  39. package/dist/types/personal/tcp.d.ts +14 -0
  40. package/dist/types/runtime/client.d.ts +3 -1
  41. package/dist/types/runtime/executor.d.ts +6 -1
  42. package/dist/types/runtime/protocol.d.ts +176 -4
  43. package/dist/types/runtime/pty.d.ts +1 -0
  44. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  45. package/dist/types/runtime/releases/grants.d.ts +16 -0
  46. package/dist/types/runtime/releases/manager.d.ts +145 -0
  47. package/dist/types/runtime/releases/process.d.ts +14 -0
  48. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  49. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  50. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  51. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  52. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  53. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  54. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  55. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  56. package/dist/types/runtime/workspace/files.d.ts +21 -0
  57. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  58. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  59. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  60. package/package.json +8 -6
  61. package/dist/cjs/atomic-rename.cjs +0 -303
  62. package/dist/cjs/browser-upload.cjs +0 -73
  63. package/dist/cjs/cli-update.cjs +0 -108
  64. package/dist/cjs/command-launcher.cjs +0 -423
  65. package/dist/cjs/control-command-policy.cjs +0 -177
  66. package/dist/cjs/git-blob-hash.cjs +0 -41
  67. package/dist/cjs/git-identity.cjs +0 -39
  68. package/dist/cjs/git-process-environment.cjs +0 -133
  69. package/dist/cjs/inline-output.cjs +0 -62
  70. package/dist/cjs/main.cjs +0 -7517
  71. package/dist/cjs/managed-paths.cjs +0 -215
  72. package/dist/cjs/plan-lint.cjs +0 -165
  73. package/dist/cjs/plan-parser.cjs +0 -127
  74. package/dist/cjs/plan-paths.cjs +0 -53
  75. package/dist/cjs/port-forward-client.cjs +0 -206
  76. package/dist/cjs/process-tree.cjs +0 -117
  77. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  78. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  79. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  80. package/dist/cjs/project-workspace-state.cjs +0 -972
  81. package/dist/cjs/project-worktrees.cjs +0 -1713
  82. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  83. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  84. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  85. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  86. package/dist/cjs/recovery-journal.cjs +0 -742
  87. package/dist/cjs/recovery-output-window.cjs +0 -77
  88. package/dist/cjs/recovery-protocol.cjs +0 -31
  89. package/dist/cjs/recovery-store.cjs +0 -252
  90. package/dist/cjs/registry-auth.cjs +0 -310
  91. package/dist/cjs/repository-transition-policy.cjs +0 -49
  92. package/dist/cjs/runtime-version.cjs +0 -88
  93. package/dist/cjs/session-file-mutations.cjs +0 -61
  94. package/dist/cjs/supervisor.cjs +0 -147
  95. package/dist/cjs/three-way-merge.cjs +0 -346
  96. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  97. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  98. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  99. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  100. package/dist/cjs/workspace-command-targets.cjs +0 -63
  101. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  102. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  103. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  104. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  105. package/dist/cjs/workspace-git-sync.cjs +0 -3595
  106. package/dist/cjs/workspace-hydration-ledger.cjs +0 -83
  107. package/dist/cjs/workspace-hydration-merge.cjs +0 -448
  108. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  109. package/dist/cjs/workspace-incident-state.cjs +0 -37
  110. package/dist/cjs/workspace-merge-projection.cjs +0 -628
  111. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  112. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  113. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  114. package/dist/cjs/workspace-path-move.cjs +0 -195
  115. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  116. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  117. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  118. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  119. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  120. package/dist/mjs/atomic-rename.mjs +0 -261
  121. package/dist/mjs/browser-upload.mjs +0 -42
  122. package/dist/mjs/command-launcher.mjs +0 -393
  123. package/dist/mjs/control-command-policy.mjs +0 -146
  124. package/dist/mjs/git-blob-hash.mjs +0 -16
  125. package/dist/mjs/git-identity.mjs +0 -15
  126. package/dist/mjs/git-process-environment.mjs +0 -105
  127. package/dist/mjs/inline-output.mjs +0 -37
  128. package/dist/mjs/managed-paths.mjs +0 -174
  129. package/dist/mjs/plan-lint.mjs +0 -129
  130. package/dist/mjs/plan-parser.mjs +0 -94
  131. package/dist/mjs/plan-paths.mjs +0 -25
  132. package/dist/mjs/port-forward-client.mjs +0 -172
  133. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  134. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  135. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  136. package/dist/mjs/project-workspace-state.mjs +0 -937
  137. package/dist/mjs/project-worktrees.mjs +0 -1657
  138. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  139. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  140. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  141. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  142. package/dist/mjs/recovery-journal.mjs +0 -694
  143. package/dist/mjs/recovery-output-window.mjs +0 -53
  144. package/dist/mjs/recovery-protocol.mjs +0 -6
  145. package/dist/mjs/recovery-store.mjs +0 -217
  146. package/dist/mjs/registry-auth.mjs +0 -269
  147. package/dist/mjs/repository-transition-policy.mjs +0 -22
  148. package/dist/mjs/runtime-version.mjs +0 -54
  149. package/dist/mjs/session-file-mutations.mjs +0 -37
  150. package/dist/mjs/supervisor.mjs +0 -114
  151. package/dist/mjs/three-way-merge.mjs +0 -318
  152. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  153. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  154. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  155. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  156. package/dist/mjs/workspace-command-targets.mjs +0 -37
  157. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  158. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  159. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  160. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  161. package/dist/mjs/workspace-git-sync.mjs +0 -3553
  162. package/dist/mjs/workspace-hydration-ledger.mjs +0 -58
  163. package/dist/mjs/workspace-hydration-merge.mjs +0 -414
  164. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  165. package/dist/mjs/workspace-incident-state.mjs +0 -12
  166. package/dist/mjs/workspace-merge-projection.mjs +0 -594
  167. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  168. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  169. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  170. package/dist/mjs/workspace-path-move.mjs +0 -160
  171. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  172. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  173. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  174. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  175. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  176. package/dist/types/atomic-rename.d.ts +0 -78
  177. package/dist/types/browser-upload.d.ts +0 -7
  178. package/dist/types/command-launcher.d.ts +0 -104
  179. package/dist/types/control-command-policy.d.ts +0 -53
  180. package/dist/types/git-blob-hash.d.ts +0 -10
  181. package/dist/types/git-identity.d.ts +0 -9
  182. package/dist/types/git-process-environment.d.ts +0 -9
  183. package/dist/types/inline-output.d.ts +0 -3
  184. package/dist/types/managed-paths.d.ts +0 -19
  185. package/dist/types/plan-lint.d.ts +0 -16
  186. package/dist/types/plan-parser.d.ts +0 -38
  187. package/dist/types/plan-paths.d.ts +0 -36
  188. package/dist/types/port-forward-client.d.ts +0 -8
  189. package/dist/types/project-checkout-garbage.d.ts +0 -86
  190. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  191. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  192. package/dist/types/project-workspace-state.d.ts +0 -188
  193. package/dist/types/project-worktrees.d.ts +0 -397
  194. package/dist/types/pty-output-coalescer.d.ts +0 -20
  195. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  196. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  197. package/dist/types/recovery-journal-stall-fixture.d.ts +0 -1
  198. package/dist/types/recovery-journal-thread.d.ts +0 -1
  199. package/dist/types/recovery-journal.d.ts +0 -248
  200. package/dist/types/recovery-output-window.d.ts +0 -19
  201. package/dist/types/recovery-protocol.d.ts +0 -59
  202. package/dist/types/recovery-store.d.ts +0 -52
  203. package/dist/types/registry-auth.d.ts +0 -47
  204. package/dist/types/repository-transition-policy.d.ts +0 -26
  205. package/dist/types/runtime-version.d.ts +0 -1
  206. package/dist/types/session-file-mutations.d.ts +0 -22
  207. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  208. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  209. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  210. package/dist/types/supervisor.d.ts +0 -23
  211. package/dist/types/three-way-merge.d.ts +0 -77
  212. package/dist/types/working-tree-mirror.d.ts +0 -424
  213. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  214. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  215. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  216. package/dist/types/workspace-command-targets.d.ts +0 -37
  217. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  218. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  219. package/dist/types/workspace-filesystem-job-types.d.ts +0 -302
  220. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  221. package/dist/types/workspace-git-sync.d.ts +0 -514
  222. package/dist/types/workspace-hydration-ledger.d.ts +0 -76
  223. package/dist/types/workspace-hydration-merge.d.ts +0 -103
  224. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  225. package/dist/types/workspace-incident-state.d.ts +0 -19
  226. package/dist/types/workspace-merge-projection.d.ts +0 -69
  227. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  228. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  229. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  230. package/dist/types/workspace-path-move.d.ts +0 -21
  231. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  232. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  233. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  234. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  235. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  236. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,215 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var managed_paths_exports = {};
30
- __export(managed_paths_exports, {
31
- BRANCH_NAME_MAX_LENGTH: () => BRANCH_NAME_MAX_LENGTH,
32
- BRANCH_NAME_PATTERN: () => BRANCH_NAME_PATTERN,
33
- assertDisjointManagedRoots: () => assertDisjointManagedRoots,
34
- assertPathInside: () => assertPathInside,
35
- managedBranchPath: () => managedBranchPath,
36
- managedProjectRoot: () => managedProjectRoot,
37
- validateCheckoutPathSegments: () => validateCheckoutPathSegments,
38
- validateManagedBranchName: () => validateManagedBranchName
39
- });
40
- module.exports = __toCommonJS(managed_paths_exports);
41
- var import_node_fs = __toESM(require("node:fs"), 1);
42
- var import_node_path = __toESM(require("node:path"), 1);
43
- const BRANCH_NAME_MAX_LENGTH = 45;
44
- const BRANCH_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
45
- const PROJECT_SEGMENT_PATTERN = /^[a-z0-9._-]+$/;
46
- const WINDOWS_RESERVED_PATH_SEGMENT = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
47
- const INTERNAL_PROJECT_PATH_SEGMENTS = /* @__PURE__ */ new Set([".r5d-retired-checkouts"]);
48
- function lstatIfExists(targetPath) {
49
- try {
50
- return import_node_fs.default.lstatSync(targetPath);
51
- } catch (error) {
52
- if (error.code === "ENOENT") return null;
53
- throw error;
54
- }
55
- }
56
- function fsyncDirectory(directoryPath) {
57
- const descriptor = import_node_fs.default.openSync(directoryPath, "r");
58
- try {
59
- import_node_fs.default.fsyncSync(descriptor);
60
- } finally {
61
- import_node_fs.default.closeSync(descriptor);
62
- }
63
- }
64
- function fsyncCreatedDirectoryChain(directoryPath, preexistingAncestorPath) {
65
- let current = import_node_path.default.resolve(directoryPath);
66
- const ancestor = import_node_path.default.resolve(preexistingAncestorPath);
67
- const relative = import_node_path.default.relative(ancestor, current);
68
- if (relative === ".." || relative.startsWith(`..${import_node_path.default.sep}`) || import_node_path.default.isAbsolute(relative)) {
69
- throw new Error(`Managed root escaped its durability ancestor: ${current}`);
70
- }
71
- while (true) {
72
- fsyncDirectory(current);
73
- if (current === ancestor) return;
74
- current = import_node_path.default.dirname(current);
75
- }
76
- }
77
- function canonicalizeManagedRoot(root) {
78
- const resolvedRoot = import_node_path.default.resolve(root.rootPath);
79
- let preexistingAncestor = resolvedRoot;
80
- while (!lstatIfExists(preexistingAncestor)) {
81
- const parent = import_node_path.default.dirname(preexistingAncestor);
82
- if (parent === preexistingAncestor) {
83
- throw new Error(`Could not find an existing ancestor for ${root.label} (${resolvedRoot})`);
84
- }
85
- preexistingAncestor = parent;
86
- }
87
- let canonicalPreexistingAncestor;
88
- try {
89
- canonicalPreexistingAncestor = import_node_fs.default.realpathSync(preexistingAncestor);
90
- if (!import_node_fs.default.statSync(canonicalPreexistingAncestor).isDirectory()) {
91
- throw new Error("the nearest existing ancestor is not a directory");
92
- }
93
- } catch (error) {
94
- throw new Error(`Could not validate the existing ancestor of ${root.label} (${resolvedRoot})`, { cause: error });
95
- }
96
- try {
97
- import_node_fs.default.mkdirSync(resolvedRoot, { recursive: true });
98
- } catch (error) {
99
- throw new Error(`Could not prepare ${root.label} (${resolvedRoot}) for overlap validation`, { cause: error });
100
- }
101
- const rootStats = import_node_fs.default.statSync(resolvedRoot, { bigint: true });
102
- if (!rootStats.isDirectory()) {
103
- throw new Error(`Managed root is not a directory: ${root.label} (${resolvedRoot})`);
104
- }
105
- const canonicalRoot = import_node_fs.default.realpathSync(resolvedRoot);
106
- fsyncCreatedDirectoryChain(canonicalRoot, canonicalPreexistingAncestor);
107
- return {
108
- ...root,
109
- rootPath: canonicalRoot,
110
- identity: { device: rootStats.dev, inode: rootStats.ino }
111
- };
112
- }
113
- function pathContains(root, candidate) {
114
- const relative = import_node_path.default.relative(root, candidate);
115
- return relative === "" || !relative.startsWith(`..${import_node_path.default.sep}`) && relative !== ".." && !import_node_path.default.isAbsolute(relative);
116
- }
117
- function identitiesMatch(left, right) {
118
- return left.device === right.device && left.inode === right.inode;
119
- }
120
- function pathOrFilesystemContains(root, candidate) {
121
- if (pathContains(root.rootPath, candidate.rootPath) || identitiesMatch(root.identity, candidate.identity)) {
122
- return true;
123
- }
124
- let ancestor = import_node_path.default.dirname(candidate.rootPath);
125
- while (true) {
126
- const stats = import_node_fs.default.statSync(ancestor, { bigint: true });
127
- if (identitiesMatch(root.identity, { device: stats.dev, inode: stats.ino })) return true;
128
- const parent = import_node_path.default.dirname(ancestor);
129
- if (parent === ancestor) return false;
130
- ancestor = parent;
131
- }
132
- }
133
- function assertDisjointManagedRoots(roots) {
134
- const canonical = roots.map(canonicalizeManagedRoot);
135
- for (let leftIndex = 0; leftIndex < canonical.length; leftIndex += 1) {
136
- const left = canonical[leftIndex];
137
- for (let rightIndex = leftIndex + 1; rightIndex < canonical.length; rightIndex += 1) {
138
- const right = canonical[rightIndex];
139
- if (pathOrFilesystemContains(left, right) || pathOrFilesystemContains(right, left)) {
140
- throw new Error(`Managed roots overlap: ${left.label} (${left.rootPath}) and ${right.label} (${right.rootPath}) must be disjoint`);
141
- }
142
- }
143
- }
144
- }
145
- function validateManagedBranchName(branchName) {
146
- if (typeof branchName !== "string" || branchName.length === 0) {
147
- throw new Error("Branch name is required");
148
- }
149
- if (branchName.length > BRANCH_NAME_MAX_LENGTH) {
150
- throw new Error(`Branch name must be ${BRANCH_NAME_MAX_LENGTH} characters or fewer`);
151
- }
152
- if (!BRANCH_NAME_PATTERN.test(branchName)) {
153
- throw new Error(`Invalid branch name from server: ${branchName}`);
154
- }
155
- const reserved = branchName.split("/").find((segment) => WINDOWS_RESERVED_PATH_SEGMENT.test(segment));
156
- if (reserved) {
157
- throw new Error(`Invalid branch name from server: reserved path segment '${reserved}'`);
158
- }
159
- }
160
- function validateCheckoutPathSegments(value) {
161
- if (!Array.isArray(value) || value.length !== 2) {
162
- throw new Error("Invalid checkout path from server: expected namespace and project segments");
163
- }
164
- const segments = value;
165
- for (const segment of segments) {
166
- if (typeof segment !== "string" || !PROJECT_SEGMENT_PATTERN.test(segment) || segment !== segment.toLowerCase() || segment === "." || segment === ".." || segment === ".git" || INTERNAL_PROJECT_PATH_SEGMENTS.has(segment) || segment.endsWith(".") || WINDOWS_RESERVED_PATH_SEGMENT.test(segment)) {
167
- throw new Error(`Invalid checkout path segment from server: ${String(segment)}`);
168
- }
169
- }
170
- return [segments[0], segments[1]];
171
- }
172
- function assertPathInside(root, candidate, label) {
173
- const resolvedRoot = import_node_path.default.resolve(root);
174
- const resolvedCandidate = import_node_path.default.resolve(candidate);
175
- const relative = import_node_path.default.relative(resolvedRoot, resolvedCandidate);
176
- if (relative === ".." || relative.startsWith(`..${import_node_path.default.sep}`) || import_node_path.default.isAbsolute(relative)) {
177
- throw new Error(`${label} escapes its managed root: ${candidate}`);
178
- }
179
- }
180
- function assertNoSymlinkComponents(root, candidate) {
181
- assertPathInside(root, candidate, "Checkout path");
182
- const relative = import_node_path.default.relative(import_node_path.default.resolve(root), import_node_path.default.resolve(candidate));
183
- let current = import_node_path.default.resolve(root);
184
- for (const component of relative.split(import_node_path.default.sep).filter(Boolean)) {
185
- current = import_node_path.default.join(current, component);
186
- if (!import_node_fs.default.existsSync(current)) break;
187
- if (import_node_fs.default.lstatSync(current).isSymbolicLink()) {
188
- throw new Error(`Checkout path contains a symbolic link: ${current}`);
189
- }
190
- }
191
- }
192
- function managedProjectRoot(projectsRoot, checkoutPathSegments) {
193
- const segments = validateCheckoutPathSegments(checkoutPathSegments);
194
- const result = import_node_path.default.join(projectsRoot, ...segments);
195
- assertNoSymlinkComponents(projectsRoot, result);
196
- return result;
197
- }
198
- function managedBranchPath(projectsRoot, checkoutPathSegments, branchName) {
199
- validateManagedBranchName(branchName);
200
- const projectRoot = managedProjectRoot(projectsRoot, checkoutPathSegments);
201
- const result = import_node_path.default.join(projectRoot, ...branchName.split("/"));
202
- assertNoSymlinkComponents(projectRoot, result);
203
- return result;
204
- }
205
- // Annotate the CommonJS export names for ESM import in node:
206
- 0 && (module.exports = {
207
- BRANCH_NAME_MAX_LENGTH,
208
- BRANCH_NAME_PATTERN,
209
- assertDisjointManagedRoots,
210
- assertPathInside,
211
- managedBranchPath,
212
- managedProjectRoot,
213
- validateCheckoutPathSegments,
214
- validateManagedBranchName
215
- });
@@ -1,165 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var plan_lint_exports = {};
30
- __export(plan_lint_exports, {
31
- formatPlanLintErrors: () => formatPlanLintErrors,
32
- lintPlanContent: () => lintPlanContent,
33
- lintPlans: () => lintPlans
34
- });
35
- module.exports = __toCommonJS(plan_lint_exports);
36
- var import_promises = __toESM(require("node:fs/promises"), 1);
37
- var import_node_path = __toESM(require("node:path"), 1);
38
- var import_picomatch = __toESM(require("picomatch"), 1);
39
- var import_plan_parser = require("./plan-parser.cjs");
40
- var import_plan_paths = require("./plan-paths.cjs");
41
- var import_plan_parser2 = require("./plan-parser.cjs");
42
- const LEGACY_SCHEMA_FIELD_REGEX = /^\s*(type|status|parent|phase|discovered_problem)\s*:/m;
43
- function lintPlanContent(planId, content) {
44
- const errors = [];
45
- const lines = content.split(/\r?\n/);
46
- if (/^---(?:\r?\n|$)/.test(content)) {
47
- errors.push({
48
- planId,
49
- severity: "error",
50
- message: "YAML frontmatter is not supported. Use plain Markdown with a ## Tasks checklist.",
51
- line: 1
52
- });
53
- }
54
- if (LEGACY_SCHEMA_FIELD_REGEX.test(content)) {
55
- errors.push({
56
- planId,
57
- severity: "error",
58
- message: "Legacy plan schema fields are not supported. Remove type/status/parent/phase/discovered_problem metadata."
59
- });
60
- }
61
- const titleLineIndex = lines.findIndex((line) => /^# .+\S\s*$/.test(line));
62
- if (titleLineIndex === -1) {
63
- errors.push({
64
- planId,
65
- severity: "error",
66
- message: "Plan must start with or contain an H1 title, for example '# Implementation Plan'."
67
- });
68
- }
69
- const range = (0, import_plan_parser.getTasksSectionRange)(content);
70
- if (!range) {
71
- errors.push({
72
- planId,
73
- severity: "error",
74
- message: "Plan is missing a ## Tasks section."
75
- });
76
- return errors;
77
- }
78
- const taskIds = /* @__PURE__ */ new Set();
79
- let taskCount = 0;
80
- for (let index = range.startIndex + 1; index < range.endIndex; index += 1) {
81
- const line = lines[index] ?? "";
82
- if (line.trim() === "") continue;
83
- const match = line.match(import_plan_parser.PLAN_TASK_LINE_REGEX);
84
- if (!match || !match[3].trim()) {
85
- errors.push({
86
- planId,
87
- severity: "error",
88
- line: index + 1,
89
- message: 'Malformed task line. Use "- [ ] task-id: Description" or "- [x] task-id: Description".'
90
- });
91
- continue;
92
- }
93
- taskCount += 1;
94
- const taskId = match[2];
95
- if (taskIds.has(taskId)) {
96
- errors.push({
97
- planId,
98
- severity: "error",
99
- line: index + 1,
100
- message: `Duplicate task id "${taskId}".`
101
- });
102
- }
103
- taskIds.add(taskId);
104
- }
105
- if (taskCount === 0) {
106
- errors.push({
107
- planId,
108
- severity: "error",
109
- message: "Plan must include at least one task in the ## Tasks section.",
110
- line: range.startIndex + 1
111
- });
112
- }
113
- return errors;
114
- }
115
- async function lintPlans(plansDir, glob) {
116
- const errors = [];
117
- let entries;
118
- try {
119
- entries = await import_promises.default.readdir(plansDir, { withFileTypes: true });
120
- } catch (error) {
121
- if (error.code !== "ENOENT") throw error;
122
- entries = [];
123
- }
124
- const matches = glob ? (0, import_picomatch.default)(glob) : null;
125
- let lintedPlanCount = 0;
126
- for (const entry of entries) {
127
- if (!entry.isFile() || !entry.name.endsWith(import_plan_paths.PLAN_EXTENSION)) continue;
128
- const planId = entry.name.slice(0, -import_plan_paths.PLAN_EXTENSION.length);
129
- if (!import_plan_parser2.PLAN_TASK_ID_REGEX.test(planId) || matches && !matches(entry.name) && !matches(planId)) continue;
130
- const content = await import_promises.default.readFile(import_node_path.default.join(plansDir, entry.name), "utf8");
131
- lintedPlanCount += 1;
132
- errors.push(...lintPlanContent(planId, content));
133
- }
134
- return {
135
- type: "plan_lint",
136
- errors,
137
- errorCount: errors.filter((error) => error.severity === "error").length,
138
- warningCount: errors.filter((error) => error.severity === "warning").length,
139
- lintedPlanCount
140
- };
141
- }
142
- function formatPlanLintErrors(errors) {
143
- if (errors.length === 0) return "";
144
- const lines = ["## Plan Lint Errors", ""];
145
- const byPlan = /* @__PURE__ */ new Map();
146
- for (const error of errors) {
147
- byPlan.set(error.planId, [...byPlan.get(error.planId) ?? [], error]);
148
- }
149
- for (const [planId, planErrors] of byPlan) {
150
- lines.push(`### ${planId}.plan.md`);
151
- for (const error of planErrors) {
152
- const location = error.line ? ` line ${error.line}` : "";
153
- lines.push(`- ${error.severity.toUpperCase()}${location}: ${error.message}`);
154
- }
155
- lines.push("");
156
- }
157
- lines.push("Fix these issues by editing the Markdown plan file.");
158
- return lines.join("\n");
159
- }
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
162
- formatPlanLintErrors,
163
- lintPlanContent,
164
- lintPlans
165
- });
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var plan_parser_exports = {};
20
- __export(plan_parser_exports, {
21
- PLAN_TASKS_HEADING_REGEX: () => PLAN_TASKS_HEADING_REGEX,
22
- PLAN_TASK_ID_REGEX: () => PLAN_TASK_ID_REGEX,
23
- PLAN_TASK_LINE_REGEX: () => PLAN_TASK_LINE_REGEX,
24
- createPlanMarkdown: () => createPlanMarkdown,
25
- formatPlanTitle: () => formatPlanTitle,
26
- getPlanMetadata: () => getPlanMetadata,
27
- getTasksSectionRange: () => getTasksSectionRange,
28
- parseMarkdownPlan: () => parseMarkdownPlan,
29
- parsePlan: () => parsePlan,
30
- updateTaskCheckbox: () => updateTaskCheckbox
31
- });
32
- module.exports = __toCommonJS(plan_parser_exports);
33
- const PLAN_TASK_ID_REGEX = /^[a-z0-9][a-z0-9-]*$/;
34
- const PLAN_TASK_LINE_REGEX = /^- \[( |x)\] ([a-z0-9][a-z0-9-]*): (.+)$/;
35
- const PLAN_TASKS_HEADING_REGEX = /^## Tasks\s*$/;
36
- function getPlanMetadata(content) {
37
- const title = content.split(/\r?\n/).map((line) => line.match(/^# (.+)$/)?.[1]?.trim()).find((value) => Boolean(value));
38
- return { title: title || "Untitled Plan" };
39
- }
40
- function getTasksSectionRange(content) {
41
- const lines = content.split(/\r?\n/);
42
- const startIndex = lines.findIndex((line) => PLAN_TASKS_HEADING_REGEX.test(line));
43
- if (startIndex === -1) return null;
44
- let endIndex = lines.length;
45
- for (let index = startIndex + 1; index < lines.length; index += 1) {
46
- if (/^##\s+/.test(lines[index] ?? "")) {
47
- endIndex = index;
48
- break;
49
- }
50
- }
51
- return { startIndex, endIndex };
52
- }
53
- function parseMarkdownPlan(content, planId) {
54
- const lines = content.split(/\r?\n/);
55
- const { title } = getPlanMetadata(content);
56
- const range = getTasksSectionRange(content);
57
- const tasks = [];
58
- if (range) {
59
- for (let index = range.startIndex + 1; index < range.endIndex; index += 1) {
60
- const line = lines[index] ?? "";
61
- const match = line.match(PLAN_TASK_LINE_REGEX);
62
- if (!match) continue;
63
- const description = match[3].trim();
64
- if (!description) continue;
65
- tasks.push({
66
- id: match[2],
67
- description,
68
- checked: match[1] === "x",
69
- lineNumber: index + 1
70
- });
71
- }
72
- }
73
- const currentTask = tasks.find((task) => !task.checked) ?? null;
74
- return {
75
- id: planId,
76
- title,
77
- content,
78
- tasks,
79
- currentTask,
80
- complete: tasks.length > 0 && tasks.every((task) => task.checked),
81
- tasksStartLine: range ? range.startIndex + 1 : null,
82
- tasksEndLine: range ? range.endIndex : null
83
- };
84
- }
85
- const parsePlan = parseMarkdownPlan;
86
- function createPlanMarkdown(planId, title = formatPlanTitle(planId)) {
87
- return `# ${title}
88
-
89
- Brief implementation notes.
90
-
91
- ## Tasks
92
- `;
93
- }
94
- function updateTaskCheckbox(content, taskId, checked) {
95
- if (!PLAN_TASK_ID_REGEX.test(taskId)) {
96
- throw new Error(`Invalid task id: ${taskId}`);
97
- }
98
- const lines = content.split(/\r?\n/);
99
- const range = getTasksSectionRange(content);
100
- if (!range) {
101
- throw new Error("Plan is missing a ## Tasks section.");
102
- }
103
- for (let index = range.startIndex + 1; index < range.endIndex; index += 1) {
104
- const line = lines[index] ?? "";
105
- const match = line.match(PLAN_TASK_LINE_REGEX);
106
- if (!match || match[2] !== taskId) continue;
107
- lines[index] = `- [${checked ? "x" : " "}] ${match[2]}: ${match[3].trim()}`;
108
- return lines.join("\n");
109
- }
110
- throw new Error(`Task not found in plan: ${taskId}`);
111
- }
112
- function formatPlanTitle(planId) {
113
- return planId.split("-").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
114
- }
115
- // Annotate the CommonJS export names for ESM import in node:
116
- 0 && (module.exports = {
117
- PLAN_TASKS_HEADING_REGEX,
118
- PLAN_TASK_ID_REGEX,
119
- PLAN_TASK_LINE_REGEX,
120
- createPlanMarkdown,
121
- formatPlanTitle,
122
- getPlanMetadata,
123
- getTasksSectionRange,
124
- parseMarkdownPlan,
125
- parsePlan,
126
- updateTaskCheckbox
127
- });
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var plan_paths_exports = {};
20
- __export(plan_paths_exports, {
21
- PLAN_EXTENSION: () => PLAN_EXTENSION,
22
- assertPlanTarget: () => assertPlanTarget,
23
- getWorkerPlanPath: () => getWorkerPlanPath,
24
- getWorkerPlansPath: () => getWorkerPlansPath,
25
- validatePlanId: () => validatePlanId
26
- });
27
- module.exports = __toCommonJS(plan_paths_exports);
28
- var import_plan_parser = require("./plan-parser.cjs");
29
- const PLAN_EXTENSION = ".plan.md";
30
- function validatePlanId(planId) {
31
- if (!import_plan_parser.PLAN_TASK_ID_REGEX.test(planId)) throw new Error(`Invalid plan id: ${planId}`);
32
- }
33
- function assertPlanTarget(target) {
34
- if (target.type === "workspace" && target.rootProfile !== "visible_projects") {
35
- throw new Error("Ordinary plans are unavailable in canonical synchronization sessions");
36
- }
37
- }
38
- function getWorkerPlansPath(target) {
39
- assertPlanTarget(target);
40
- return target.type === "project" ? "$R5D_ROOT/plans/$R5D_PROJECT_ID/$R5D_BRANCH_NAME" : "$R5D_ROOT/plans/workspace";
41
- }
42
- function getWorkerPlanPath(target, planId) {
43
- validatePlanId(planId);
44
- return `${getWorkerPlansPath(target)}/${planId}${PLAN_EXTENSION}`;
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- PLAN_EXTENSION,
49
- assertPlanTarget,
50
- getWorkerPlanPath,
51
- getWorkerPlansPath,
52
- validatePlanId
53
- });