@marktrue/dsh-mobile-remote 3.2.4-alpha.9 → 3.2.4-rc.1-app

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 (362) hide show
  1. package/DSH-Remote-v3.2.4.apk +4 -0
  2. package/README.md +6 -256
  3. package/manifest.json +21 -0
  4. package/package.json +12 -68
  5. package/CHANGELOG.md +0 -1598
  6. package/CONTRIBUTING.md +0 -59
  7. package/FAQ.md +0 -111
  8. package/cordis.patch.yml +0 -14
  9. package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +0 -125
  10. package/docs/01-PRD.md +0 -148
  11. package/docs/02-architecture.md +0 -249
  12. package/docs/03-api.md +0 -1339
  13. package/docs/04-security.md +0 -108
  14. package/docs/05-test-cases.md +0 -405
  15. package/docs/06-install-run.md +0 -372
  16. package/docs/07-user-manual.md +0 -70
  17. package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +0 -86
  18. package/docs/09-compatibility.md +0 -238
  19. package/docs/10-release.md +0 -1040
  20. package/docs/11-notification-reliability.md +0 -45
  21. package/docs/12-implementation-status.md +0 -41
  22. package/docs/13-device-acceptance-2026-11-03.md +0 -37
  23. package/docs/16-next-window-handoff-2026-11-04.md +0 -44
  24. package/docs/17-remaining-work-review-2026-11-04.md +0 -53
  25. package/docs/18-device-reliability-acceptance-2026-11-04.md +0 -63
  26. package/docs/19-issue-followup-2026-11-04.md +0 -39
  27. package/docs/20-dsh-022-compatibility-2026-11-05.md +0 -32
  28. package/docs/screenshots/01-home.png +0 -0
  29. package/docs/screenshots/02-notifications.png +0 -0
  30. package/docs/screenshots/03-sessions.png +0 -0
  31. package/docs/screenshots/04-chat.png +0 -0
  32. package/docs/screenshots/05-settings.png +0 -0
  33. package/docs/screenshots/06-new-session.png +0 -0
  34. package/docs/screenshots/pgy-appstore.jpg +0 -0
  35. package/docs/screenshots/pgy-mobile-app.jpg +0 -0
  36. package/docs/screenshots/pgy-pc-client.jpg +0 -0
  37. package/lib/account-usage.js +0 -145
  38. package/lib/app-alignment.js +0 -112
  39. package/lib/app-carrier-store.js +0 -1972
  40. package/lib/app-carrier.js +0 -609
  41. package/lib/client.js +0 -1196
  42. package/lib/desktop-form.js +0 -738
  43. package/lib/endpoint-registry.js +0 -178
  44. package/lib/git-read-bundled-provider.js +0 -460
  45. package/lib/git-read-service.js +0 -620
  46. package/lib/host-manager-update.js +0 -178
  47. package/lib/host-update-capabilities.js +0 -203
  48. package/lib/index.js +0 -10732
  49. package/lib/npm-update-source.js +0 -226
  50. package/lib/plugin-content-digest.js +0 -80
  51. package/lib/plugin-self-update.js +0 -1098
  52. package/lib/plugin-update-controller.js +0 -340
  53. package/lib/plugin-update-log.js +0 -164
  54. package/lib/plugin-update-transaction.js +0 -322
  55. package/lib/plugin-update.js +0 -309
  56. package/lib/runtime-dependency-snapshot.js +0 -345
  57. package/lib/session-title-cache.js +0 -123
  58. package/lib/session-title-refresh.js +0 -261
  59. package/lib/tool-process.js +0 -20
  60. package/lib/update-fetch.js +0 -24
  61. package/lib/update-lock-arbiter.js +0 -170
  62. package/lib/update-supervisor.js +0 -346
  63. package/node_modules/ansi-regex/index.d.ts +0 -37
  64. package/node_modules/ansi-regex/index.js +0 -10
  65. package/node_modules/ansi-regex/license +0 -9
  66. package/node_modules/ansi-regex/package.json +0 -55
  67. package/node_modules/ansi-regex/readme.md +0 -78
  68. package/node_modules/ansi-styles/index.d.ts +0 -345
  69. package/node_modules/ansi-styles/index.js +0 -163
  70. package/node_modules/ansi-styles/license +0 -9
  71. package/node_modules/ansi-styles/package.json +0 -56
  72. package/node_modules/ansi-styles/readme.md +0 -152
  73. package/node_modules/camelcase/index.d.ts +0 -63
  74. package/node_modules/camelcase/index.js +0 -76
  75. package/node_modules/camelcase/license +0 -9
  76. package/node_modules/camelcase/package.json +0 -43
  77. package/node_modules/camelcase/readme.md +0 -99
  78. package/node_modules/cliui/CHANGELOG.md +0 -76
  79. package/node_modules/cliui/LICENSE.txt +0 -14
  80. package/node_modules/cliui/README.md +0 -115
  81. package/node_modules/cliui/index.js +0 -354
  82. package/node_modules/cliui/package.json +0 -65
  83. package/node_modules/color-convert/CHANGELOG.md +0 -54
  84. package/node_modules/color-convert/LICENSE +0 -21
  85. package/node_modules/color-convert/README.md +0 -68
  86. package/node_modules/color-convert/conversions.js +0 -839
  87. package/node_modules/color-convert/index.js +0 -81
  88. package/node_modules/color-convert/package.json +0 -48
  89. package/node_modules/color-convert/route.js +0 -97
  90. package/node_modules/color-name/LICENSE +0 -8
  91. package/node_modules/color-name/README.md +0 -11
  92. package/node_modules/color-name/index.js +0 -152
  93. package/node_modules/color-name/package.json +0 -28
  94. package/node_modules/decamelize/index.js +0 -13
  95. package/node_modules/decamelize/license +0 -21
  96. package/node_modules/decamelize/package.json +0 -38
  97. package/node_modules/decamelize/readme.md +0 -48
  98. package/node_modules/dijkstrajs/.travis.yml +0 -4
  99. package/node_modules/dijkstrajs/CONTRIBUTING.md +0 -8
  100. package/node_modules/dijkstrajs/LICENSE.md +0 -19
  101. package/node_modules/dijkstrajs/README.md +0 -18
  102. package/node_modules/dijkstrajs/dijkstra.js +0 -165
  103. package/node_modules/dijkstrajs/package.json +0 -60
  104. package/node_modules/dijkstrajs/test/dijkstra.test.js +0 -96
  105. package/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
  106. package/node_modules/emoji-regex/README.md +0 -73
  107. package/node_modules/emoji-regex/es2015/index.js +0 -6
  108. package/node_modules/emoji-regex/es2015/text.js +0 -6
  109. package/node_modules/emoji-regex/index.d.ts +0 -23
  110. package/node_modules/emoji-regex/index.js +0 -6
  111. package/node_modules/emoji-regex/package.json +0 -50
  112. package/node_modules/emoji-regex/text.js +0 -6
  113. package/node_modules/find-up/index.d.ts +0 -137
  114. package/node_modules/find-up/index.js +0 -89
  115. package/node_modules/find-up/license +0 -9
  116. package/node_modules/find-up/package.json +0 -53
  117. package/node_modules/find-up/readme.md +0 -156
  118. package/node_modules/get-caller-file/LICENSE.md +0 -6
  119. package/node_modules/get-caller-file/README.md +0 -41
  120. package/node_modules/get-caller-file/index.d.ts +0 -2
  121. package/node_modules/get-caller-file/index.js +0 -22
  122. package/node_modules/get-caller-file/index.js.map +0 -1
  123. package/node_modules/get-caller-file/package.json +0 -42
  124. package/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  125. package/node_modules/is-fullwidth-code-point/index.js +0 -50
  126. package/node_modules/is-fullwidth-code-point/license +0 -9
  127. package/node_modules/is-fullwidth-code-point/package.json +0 -42
  128. package/node_modules/is-fullwidth-code-point/readme.md +0 -39
  129. package/node_modules/locate-path/index.d.ts +0 -83
  130. package/node_modules/locate-path/index.js +0 -65
  131. package/node_modules/locate-path/license +0 -9
  132. package/node_modules/locate-path/package.json +0 -45
  133. package/node_modules/locate-path/readme.md +0 -122
  134. package/node_modules/p-limit/index.d.ts +0 -38
  135. package/node_modules/p-limit/index.js +0 -57
  136. package/node_modules/p-limit/license +0 -9
  137. package/node_modules/p-limit/package.json +0 -52
  138. package/node_modules/p-limit/readme.md +0 -101
  139. package/node_modules/p-locate/index.d.ts +0 -64
  140. package/node_modules/p-locate/index.js +0 -52
  141. package/node_modules/p-locate/license +0 -9
  142. package/node_modules/p-locate/package.json +0 -53
  143. package/node_modules/p-locate/readme.md +0 -90
  144. package/node_modules/p-try/index.d.ts +0 -39
  145. package/node_modules/p-try/index.js +0 -9
  146. package/node_modules/p-try/license +0 -9
  147. package/node_modules/p-try/package.json +0 -42
  148. package/node_modules/p-try/readme.md +0 -58
  149. package/node_modules/path-exists/index.d.ts +0 -28
  150. package/node_modules/path-exists/index.js +0 -23
  151. package/node_modules/path-exists/license +0 -9
  152. package/node_modules/path-exists/package.json +0 -39
  153. package/node_modules/path-exists/readme.md +0 -52
  154. package/node_modules/pngjs/.eslintignore +0 -2
  155. package/node_modules/pngjs/.eslintrc.json +0 -19
  156. package/node_modules/pngjs/.prettierignore +0 -3
  157. package/node_modules/pngjs/LICENSE +0 -20
  158. package/node_modules/pngjs/README.md +0 -429
  159. package/node_modules/pngjs/browser.js +0 -16096
  160. package/node_modules/pngjs/coverage/lcov-report/base.css +0 -354
  161. package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +0 -881
  162. package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +0 -554
  163. package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +0 -77
  164. package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +0 -647
  165. package/node_modules/pngjs/coverage/lcov-report/constants.js.html +0 -176
  166. package/node_modules/pngjs/coverage/lcov-report/crc.js.html +0 -200
  167. package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
  168. package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +0 -593
  169. package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +0 -152
  170. package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +0 -143
  171. package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +0 -611
  172. package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +0 -359
  173. package/node_modules/pngjs/coverage/lcov-report/index.html +0 -426
  174. package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +0 -365
  175. package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +0 -230
  176. package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +0 -248
  177. package/node_modules/pngjs/coverage/lcov-report/packer.js.html +0 -467
  178. package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +0 -128
  179. package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +0 -575
  180. package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +0 -404
  181. package/node_modules/pngjs/coverage/lcov-report/parser.js.html +0 -950
  182. package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +0 -116
  183. package/node_modules/pngjs/coverage/lcov-report/png.js.html +0 -662
  184. package/node_modules/pngjs/coverage/lcov-report/prettify.css +0 -101
  185. package/node_modules/pngjs/coverage/lcov-report/prettify.js +0 -1007
  186. package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  187. package/node_modules/pngjs/coverage/lcov-report/sorter.js +0 -169
  188. package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +0 -584
  189. package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +0 -215
  190. package/node_modules/pngjs/coverage/lcov.info +0 -2177
  191. package/node_modules/pngjs/lib/bitmapper.js +0 -267
  192. package/node_modules/pngjs/lib/bitpacker.js +0 -158
  193. package/node_modules/pngjs/lib/chunkstream.js +0 -189
  194. package/node_modules/pngjs/lib/constants.js +0 -32
  195. package/node_modules/pngjs/lib/crc.js +0 -40
  196. package/node_modules/pngjs/lib/filter-pack.js +0 -171
  197. package/node_modules/pngjs/lib/filter-parse-async.js +0 -24
  198. package/node_modules/pngjs/lib/filter-parse-sync.js +0 -21
  199. package/node_modules/pngjs/lib/filter-parse.js +0 -177
  200. package/node_modules/pngjs/lib/format-normaliser.js +0 -93
  201. package/node_modules/pngjs/lib/interlace.js +0 -95
  202. package/node_modules/pngjs/lib/packer-async.js +0 -50
  203. package/node_modules/pngjs/lib/packer-sync.js +0 -56
  204. package/node_modules/pngjs/lib/packer.js +0 -129
  205. package/node_modules/pngjs/lib/paeth-predictor.js +0 -16
  206. package/node_modules/pngjs/lib/parser-async.js +0 -165
  207. package/node_modules/pngjs/lib/parser-sync.js +0 -108
  208. package/node_modules/pngjs/lib/parser.js +0 -290
  209. package/node_modules/pngjs/lib/png-sync.js +0 -12
  210. package/node_modules/pngjs/lib/png.js +0 -194
  211. package/node_modules/pngjs/lib/sync-inflate.js +0 -168
  212. package/node_modules/pngjs/lib/sync-reader.js +0 -45
  213. package/node_modules/pngjs/package.json +0 -73
  214. package/node_modules/qrcode/README.md +0 -770
  215. package/node_modules/qrcode/bin/qrcode +0 -159
  216. package/node_modules/qrcode/helper/to-sjis-browser.js +0 -2
  217. package/node_modules/qrcode/helper/to-sjis.js +0 -105
  218. package/node_modules/qrcode/lib/browser.js +0 -76
  219. package/node_modules/qrcode/lib/can-promise.js +0 -7
  220. package/node_modules/qrcode/lib/core/alignment-pattern.js +0 -83
  221. package/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -59
  222. package/node_modules/qrcode/lib/core/bit-buffer.js +0 -37
  223. package/node_modules/qrcode/lib/core/bit-matrix.js +0 -65
  224. package/node_modules/qrcode/lib/core/byte-data.js +0 -30
  225. package/node_modules/qrcode/lib/core/error-correction-code.js +0 -135
  226. package/node_modules/qrcode/lib/core/error-correction-level.js +0 -50
  227. package/node_modules/qrcode/lib/core/finder-pattern.js +0 -22
  228. package/node_modules/qrcode/lib/core/format-info.js +0 -29
  229. package/node_modules/qrcode/lib/core/galois-field.js +0 -69
  230. package/node_modules/qrcode/lib/core/kanji-data.js +0 -54
  231. package/node_modules/qrcode/lib/core/mask-pattern.js +0 -234
  232. package/node_modules/qrcode/lib/core/mode.js +0 -167
  233. package/node_modules/qrcode/lib/core/numeric-data.js +0 -43
  234. package/node_modules/qrcode/lib/core/polynomial.js +0 -62
  235. package/node_modules/qrcode/lib/core/qrcode.js +0 -495
  236. package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -56
  237. package/node_modules/qrcode/lib/core/regex.js +0 -31
  238. package/node_modules/qrcode/lib/core/segments.js +0 -330
  239. package/node_modules/qrcode/lib/core/utils.js +0 -63
  240. package/node_modules/qrcode/lib/core/version-check.js +0 -9
  241. package/node_modules/qrcode/lib/core/version.js +0 -163
  242. package/node_modules/qrcode/lib/index.js +0 -12
  243. package/node_modules/qrcode/lib/renderer/canvas.js +0 -63
  244. package/node_modules/qrcode/lib/renderer/png.js +0 -78
  245. package/node_modules/qrcode/lib/renderer/svg-tag.js +0 -81
  246. package/node_modules/qrcode/lib/renderer/svg.js +0 -19
  247. package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +0 -85
  248. package/node_modules/qrcode/lib/renderer/terminal/terminal.js +0 -49
  249. package/node_modules/qrcode/lib/renderer/terminal.js +0 -9
  250. package/node_modules/qrcode/lib/renderer/utf8.js +0 -71
  251. package/node_modules/qrcode/lib/renderer/utils.js +0 -99
  252. package/node_modules/qrcode/lib/server.js +0 -138
  253. package/node_modules/qrcode/license +0 -10
  254. package/node_modules/qrcode/package.json +0 -77
  255. package/node_modules/require-directory/.jshintrc +0 -67
  256. package/node_modules/require-directory/.npmignore +0 -1
  257. package/node_modules/require-directory/.travis.yml +0 -3
  258. package/node_modules/require-directory/LICENSE +0 -22
  259. package/node_modules/require-directory/README.markdown +0 -184
  260. package/node_modules/require-directory/index.js +0 -86
  261. package/node_modules/require-directory/package.json +0 -40
  262. package/node_modules/require-main-filename/CHANGELOG.md +0 -26
  263. package/node_modules/require-main-filename/LICENSE.txt +0 -14
  264. package/node_modules/require-main-filename/README.md +0 -26
  265. package/node_modules/require-main-filename/index.js +0 -18
  266. package/node_modules/require-main-filename/package.json +0 -35
  267. package/node_modules/set-blocking/CHANGELOG.md +0 -26
  268. package/node_modules/set-blocking/LICENSE.txt +0 -14
  269. package/node_modules/set-blocking/README.md +0 -31
  270. package/node_modules/set-blocking/index.js +0 -7
  271. package/node_modules/set-blocking/package.json +0 -42
  272. package/node_modules/string-width/index.d.ts +0 -29
  273. package/node_modules/string-width/index.js +0 -47
  274. package/node_modules/string-width/license +0 -9
  275. package/node_modules/string-width/package.json +0 -56
  276. package/node_modules/string-width/readme.md +0 -50
  277. package/node_modules/strip-ansi/index.d.ts +0 -17
  278. package/node_modules/strip-ansi/index.js +0 -4
  279. package/node_modules/strip-ansi/license +0 -9
  280. package/node_modules/strip-ansi/package.json +0 -54
  281. package/node_modules/strip-ansi/readme.md +0 -46
  282. package/node_modules/which-module/LICENSE +0 -13
  283. package/node_modules/which-module/README.md +0 -58
  284. package/node_modules/which-module/index.js +0 -9
  285. package/node_modules/which-module/package.json +0 -41
  286. package/node_modules/wrap-ansi/index.js +0 -186
  287. package/node_modules/wrap-ansi/license +0 -9
  288. package/node_modules/wrap-ansi/package.json +0 -61
  289. package/node_modules/wrap-ansi/readme.md +0 -97
  290. package/node_modules/y18n/CHANGELOG.md +0 -35
  291. package/node_modules/y18n/LICENSE +0 -13
  292. package/node_modules/y18n/README.md +0 -109
  293. package/node_modules/y18n/index.js +0 -188
  294. package/node_modules/y18n/package.json +0 -39
  295. package/node_modules/yargs/CHANGELOG.md +0 -420
  296. package/node_modules/yargs/LICENSE +0 -21
  297. package/node_modules/yargs/README.md +0 -140
  298. package/node_modules/yargs/build/lib/apply-extends.d.ts +0 -2
  299. package/node_modules/yargs/build/lib/apply-extends.js +0 -65
  300. package/node_modules/yargs/build/lib/argsert.d.ts +0 -2
  301. package/node_modules/yargs/build/lib/argsert.js +0 -65
  302. package/node_modules/yargs/build/lib/command.d.ts +0 -64
  303. package/node_modules/yargs/build/lib/command.js +0 -416
  304. package/node_modules/yargs/build/lib/common-types.d.ts +0 -36
  305. package/node_modules/yargs/build/lib/common-types.js +0 -25
  306. package/node_modules/yargs/build/lib/completion-templates.d.ts +0 -2
  307. package/node_modules/yargs/build/lib/completion-templates.js +0 -50
  308. package/node_modules/yargs/build/lib/completion.d.ts +0 -21
  309. package/node_modules/yargs/build/lib/completion.js +0 -135
  310. package/node_modules/yargs/build/lib/is-promise.d.ts +0 -1
  311. package/node_modules/yargs/build/lib/is-promise.js +0 -9
  312. package/node_modules/yargs/build/lib/levenshtein.d.ts +0 -1
  313. package/node_modules/yargs/build/lib/levenshtein.js +0 -58
  314. package/node_modules/yargs/build/lib/middleware.d.ts +0 -10
  315. package/node_modules/yargs/build/lib/middleware.js +0 -57
  316. package/node_modules/yargs/build/lib/obj-filter.d.ts +0 -1
  317. package/node_modules/yargs/build/lib/obj-filter.js +0 -14
  318. package/node_modules/yargs/build/lib/parse-command.d.ts +0 -11
  319. package/node_modules/yargs/build/lib/parse-command.js +0 -36
  320. package/node_modules/yargs/build/lib/process-argv.d.ts +0 -2
  321. package/node_modules/yargs/build/lib/process-argv.js +0 -31
  322. package/node_modules/yargs/build/lib/usage.d.ts +0 -49
  323. package/node_modules/yargs/build/lib/usage.js +0 -540
  324. package/node_modules/yargs/build/lib/validation.d.ts +0 -34
  325. package/node_modules/yargs/build/lib/validation.js +0 -330
  326. package/node_modules/yargs/build/lib/yargs.d.ts +0 -274
  327. package/node_modules/yargs/build/lib/yargs.js +0 -1190
  328. package/node_modules/yargs/build/lib/yerror.d.ts +0 -4
  329. package/node_modules/yargs/build/lib/yerror.js +0 -11
  330. package/node_modules/yargs/index.js +0 -40
  331. package/node_modules/yargs/locales/be.json +0 -46
  332. package/node_modules/yargs/locales/de.json +0 -46
  333. package/node_modules/yargs/locales/en.json +0 -51
  334. package/node_modules/yargs/locales/es.json +0 -46
  335. package/node_modules/yargs/locales/fi.json +0 -49
  336. package/node_modules/yargs/locales/fr.json +0 -53
  337. package/node_modules/yargs/locales/hi.json +0 -49
  338. package/node_modules/yargs/locales/hu.json +0 -46
  339. package/node_modules/yargs/locales/id.json +0 -50
  340. package/node_modules/yargs/locales/it.json +0 -46
  341. package/node_modules/yargs/locales/ja.json +0 -51
  342. package/node_modules/yargs/locales/ko.json +0 -49
  343. package/node_modules/yargs/locales/nb.json +0 -44
  344. package/node_modules/yargs/locales/nl.json +0 -49
  345. package/node_modules/yargs/locales/nn.json +0 -44
  346. package/node_modules/yargs/locales/pirate.json +0 -13
  347. package/node_modules/yargs/locales/pl.json +0 -49
  348. package/node_modules/yargs/locales/pt.json +0 -45
  349. package/node_modules/yargs/locales/pt_BR.json +0 -48
  350. package/node_modules/yargs/locales/ru.json +0 -46
  351. package/node_modules/yargs/locales/th.json +0 -46
  352. package/node_modules/yargs/locales/tr.json +0 -48
  353. package/node_modules/yargs/locales/zh_CN.json +0 -48
  354. package/node_modules/yargs/locales/zh_TW.json +0 -47
  355. package/node_modules/yargs/package.json +0 -92
  356. package/node_modules/yargs/yargs.js +0 -14
  357. package/node_modules/yargs-parser/CHANGELOG.md +0 -601
  358. package/node_modules/yargs-parser/LICENSE.txt +0 -14
  359. package/node_modules/yargs-parser/README.md +0 -449
  360. package/node_modules/yargs-parser/index.js +0 -1032
  361. package/node_modules/yargs-parser/lib/tokenize-arg-string.js +0 -40
  362. package/node_modules/yargs-parser/package.json +0 -46
@@ -1,620 +0,0 @@
1
- import { createHash, randomUUID } from "node:crypto";
2
- import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
3
- import { lstat, realpath } from "node:fs/promises";
4
- import { createBundledGitReadProvider } from "./git-read-bundled-provider.js";
5
-
6
- const MAX_GRAPH_TIPS = 5;
7
- const MAX_TRACKED_FILES = 200;
8
- const FILE_HISTORY_DEFAULT_LIMIT = 20;
9
- const FILE_HISTORY_MAX_LIMIT = 100;
10
- const FILE_HISTORY_MAX_COMMITS = 5000;
11
- const FILE_HISTORY_TIMEOUT_MS = 20_000;
12
- const MAX_FILE_HISTORY_SNAPSHOTS = 8;
13
- const REF_KIND_ORDER = { head: 0, localBranch: 1, remoteBranch: 2, other: 3 };
14
- const FILE_HISTORY_REASONS = new Set(["not-tracked", "no-history", "path-invalid"]);
15
-
16
- function failure(code, status, message = code) {
17
- const error = new Error(message);
18
- error.code = code;
19
- error.status = status;
20
- return error;
21
- }
22
-
23
- // The provider contract is additive: v1.1.0 providers expose the new methods,
24
- // while legacy v1.0.0 providers stay compatible and their raw ref strings are
25
- // projected into the structured DTO by this facade.
26
- const providerCompatible = (provider) => /^1\.\d+\.\d+$/.test(String(provider?.contractVersion ?? ""))
27
- && ["repositoryRoot", "branches", "resolveTip", "graph", "commit"].every((method) => typeof provider[method] === "function");
28
-
29
- const compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
30
- const refShortName = (name) => name === "HEAD" ? "HEAD" : String(name).replace(/^refs\/(?:heads|remotes|tags)\//, "");
31
- const trimSubject = (value) => [...String(value)].slice(0, 200).join("");
32
- const emptyRefDetails = () => ({ refsDetail: [], tagsDetail: [] });
33
- const sortRefDetails = (rows) => rows.sort((left, right) => (REF_KIND_ORDER[left.kind] ?? 9) - (REF_KIND_ORDER[right.kind] ?? 9) || compareText(left.name, right.name));
34
- const sortTagDetails = (rows) => rows.sort((left, right) => compareText(left.name, right.name));
35
-
36
- /** Project provider-owned ref records onto the commit they resolve to. */
37
- function refDetailsFromRecords(records, commitOid, { fullTags = false } = {}) {
38
- const target = String(commitOid ?? "").toLowerCase();
39
- const refs = [], tags = [], seen = new Set();
40
- for (const record of Array.isArray(records) ? records : []) {
41
- if (!record || String(record.commitOid ?? "").toLowerCase() !== target) continue;
42
- const name = typeof record.name === "string" ? record.name : "";
43
- if (!name) continue;
44
- const shortName = typeof record.shortName === "string" && record.shortName ? record.shortName : refShortName(name);
45
- if (record.kind === "tag") {
46
- const key = `tag\0${shortName}`;
47
- if (seen.has(key)) continue;
48
- seen.add(key);
49
- const tag = { name, shortName, oid: target, annotated: record.annotated === true };
50
- if (fullTags) {
51
- if (typeof record.tagger === "string" && record.tagger) tag.tagger = record.tagger;
52
- const date = Number(record.date);
53
- if (Number.isFinite(date) && date > 0) tag.date = date;
54
- if (typeof record.subject === "string" && record.subject) tag.subject = trimSubject(record.subject);
55
- if (typeof record.hint === "string" && record.hint) tag.hint = record.hint;
56
- }
57
- tags.push(tag);
58
- continue;
59
- }
60
- const kind = ["head", "localBranch", "remoteBranch"].includes(record.kind) ? record.kind : "other";
61
- const key = `${kind}\0${shortName}`;
62
- if (seen.has(key)) continue;
63
- seen.add(key);
64
- const detail = { kind, name, shortName, oid: target };
65
- if (record.current === true) detail.current = true;
66
- refs.push(detail);
67
- }
68
- return { refsDetail: sortRefDetails(refs), tagsDetail: sortTagDetails(tags) };
69
- }
70
-
71
- /**
72
- * String fallback for legacy providers: parse raw decorations such as
73
- * `HEAD -> refs/heads/main`, `refs/remotes/origin/main` and
74
- * `tag: refs/tags/v1.0.0`. Annotated metadata is unavailable here, so tags
75
- * are advertised as lightweight name-level entries.
76
- */
77
- function refDetailsFromLegacyRefs(rawRefs, commitOid, { tags = [] } = {}) {
78
- const target = String(commitOid ?? "");
79
- const refs = [], tagRows = [], seen = new Set();
80
- let currentBranch = null;
81
- const addRef = (kind, name, shortName, extra = {}) => {
82
- const key = `${kind}\0${shortName}`;
83
- if (seen.has(key)) return;
84
- seen.add(key);
85
- refs.push({ kind, name, shortName, oid: target, ...extra });
86
- };
87
- const addTag = (value) => {
88
- let name = String(value ?? "").trim();
89
- if (name.startsWith("tag: ")) name = name.slice(5).trim();
90
- if (!name) return;
91
- if (!name.startsWith("refs/tags/")) name = `refs/tags/${name}`;
92
- const shortName = name.slice(10);
93
- if (!shortName) return;
94
- const key = `tag\0${shortName}`;
95
- if (seen.has(key)) return;
96
- seen.add(key);
97
- tagRows.push({ name, shortName, oid: target, annotated: false });
98
- };
99
- const addRefValue = (value) => {
100
- const raw = String(value ?? "").trim();
101
- if (!raw) return;
102
- if (raw === "HEAD") return addRef("head", "HEAD", "HEAD", { current: true });
103
- if (raw.startsWith("HEAD -> ")) {
104
- addRef("head", "HEAD", "HEAD", { current: true });
105
- const next = raw.slice(8).trim();
106
- if (!next) return undefined;
107
- // Providers may decorate with shortened branch names (`HEAD -> main`)
108
- // instead of full ref names; normalize the branch form here. The target
109
- // of HEAD is by definition the current branch, marked after parsing.
110
- if (next.startsWith("refs/heads/")) { currentBranch = next.slice(11); return addRef("localBranch", next, currentBranch); }
111
- if (next.startsWith("refs/")) return addRefValue(next);
112
- currentBranch = next;
113
- return addRef("localBranch", `refs/heads/${next}`, next);
114
- }
115
- if (raw.startsWith("tag: ")) return addTag(raw.slice(5));
116
- if (raw === "refs/stash") return;
117
- if (raw.startsWith("refs/heads/")) return addRef("localBranch", raw, raw.slice(11));
118
- if (raw.startsWith("refs/remotes/")) return raw.endsWith("/HEAD") ? undefined : addRef("remoteBranch", raw, raw.slice(13));
119
- if (raw.startsWith("refs/tags/")) return addTag(raw);
120
- return addRef("other", raw, raw);
121
- };
122
- for (const raw of Array.isArray(rawRefs) ? rawRefs : []) addRefValue(raw);
123
- for (const raw of Array.isArray(tags) ? tags : []) addTag(raw);
124
- // `current` is set once HEAD has been seen, so decoration order does not matter.
125
- if (currentBranch !== null) {
126
- const row = refs.find((entry) => entry.kind === "localBranch" && entry.shortName === currentBranch);
127
- if (row) row.current = true;
128
- }
129
- return { refsDetail: sortRefDetails(refs), tagsDetail: sortTagDetails(tagRows) };
130
- }
131
-
132
- const mergeRefDetails = (primary, secondary) => {
133
- const refs = new Map(), tags = new Map();
134
- for (const row of [...primary.refsDetail, ...secondary.refsDetail]) {
135
- const key = `${row.kind}\0${row.shortName}`;
136
- if (!refs.has(key)) refs.set(key, row);
137
- }
138
- for (const row of [...primary.tagsDetail, ...secondary.tagsDetail]) {
139
- if (!tags.has(row.shortName)) tags.set(row.shortName, row);
140
- }
141
- return { refsDetail: sortRefDetails([...refs.values()]), tagsDetail: sortTagDetails([...tags.values()]) };
142
- };
143
-
144
- const HISTORY_STATUS_WORDS = { added: "A", modified: "M", deleted: "D", renamed: "R", copied: "C", "type-changed": "T" };
145
- const historyStatus = (value) => {
146
- const text = String(value ?? "").trim();
147
- const word = HISTORY_STATUS_WORDS[text.toLowerCase()];
148
- if (word) return word;
149
- const upper = text.toUpperCase();
150
- return ["A", "M", "D", "R", "C", "T"].includes(upper[0]) ? upper[0] : "M";
151
- };
152
-
153
- /** Session-authorized read facade over an optional external or bundled provider. */
154
- export function createGitReadService(ctx, { bundledProvider, now = () => Date.now(), snapshotTtlMs = 5 * 60_000, pollIntervalMs = 30_000, onChanged } = {}) {
155
- const get = (name) => { try { return ctx.get?.(name); } catch { return undefined; } };
156
- const external = get("gitReadProvider");
157
- let externalAvailable = false;
158
- try { externalAvailable = providerCompatible(external) && external.capabilities?.().available === true; } catch {}
159
- const bundled = bundledProvider ?? createBundledGitReadProvider(ctx);
160
- const provider = externalAvailable ? external : bundled;
161
- const bindings = new Map();
162
- const repositoryIdFor = (sessionId, root) => `repo_${createHash("sha256").update(`${sessionId}\0${root}`).digest("base64url").slice(0, 32)}`;
163
- const inside = (child, parent) => {
164
- const path = relative(resolve(parent), resolve(child));
165
- return path === "" || (path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path));
166
- };
167
- const authorizedRoot = async (cwd) => {
168
- if (typeof cwd !== "string" || !cwd) throw failure("repository-not-authorized", 403);
169
- try {
170
- const canonicalCwd = await realpath(cwd);
171
- const workspacePaths = get("workspaceRegistry")?.list?.()?.map((entry) => entry?.path) ?? [];
172
- const workspaces = await Promise.all(workspacePaths.filter((path) => typeof path === "string").map((path) => realpath(path).catch(() => null)));
173
- if (!workspaces.some((path) => path && inside(canonicalCwd, path))) throw failure("repository-not-authorized", 403);
174
- const root = await realpath(await provider.repositoryRoot(canonicalCwd));
175
- if (!inside(canonicalCwd, root) || !workspaces.some((path) => path && inside(root, path))) throw failure("repository-not-authorized", 403);
176
- return root;
177
- } catch (error) {
178
- if (["git-provider-unavailable", "not-git-repository"].includes(error?.code)) throw failure(error.code, error.status);
179
- throw failure("repository-not-authorized", 403);
180
- }
181
- };
182
- const session = (sessionId) => {
183
- if (typeof sessionId !== "string" || sessionId === "") throw failure("session-not-found", 404);
184
- const value = get("sessions")?.get?.(sessionId);
185
- if (!value) throw failure("session-not-found", 404);
186
- return value;
187
- };
188
- const binding = async (sessionId, repositoryId) => {
189
- const value = bindings.get(repositoryId);
190
- if (!value || value.sessionId !== sessionId) throw failure("repository-not-authorized", 403);
191
- const current = session(sessionId);
192
- const currentRoot = await authorizedRoot(current?.header?.cwd);
193
- if (currentRoot !== value.root) throw failure("repository-not-authorized", 403);
194
- return value;
195
- };
196
- const worktreeSnapshots = new Map();
197
- const snapshots = new Map();
198
- const fileCursors = new Map();
199
- const historySnapshots = new Map();
200
- const historyCursors = new Map();
201
- const refSignatures = new Map();
202
- const keepBounded = (map, maximum) => {
203
- while (map.size > maximum) map.delete(map.keys().next().value);
204
- };
205
- const prune = () => {
206
- for (const [id, item] of snapshots) if (item.expiresAt <= now()) snapshots.delete(id);
207
- for (const [id, item] of fileCursors) if (item.expiresAt <= now()) fileCursors.delete(id);
208
- for (const [id, item] of historySnapshots) if (item.expiresAt <= now()) historySnapshots.delete(id);
209
- for (const [id, item] of historyCursors) if (item.expiresAt <= now()) historyCursors.delete(id);
210
- };
211
- let pollTimer = null;
212
- let pollInFlight = null;
213
- let unsubscribeProvider = null;
214
- const validOid = (value) => typeof value === "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(value);
215
- const safeFilePath = (value) => typeof value === "string" && value !== "" && !isAbsolute(value) && !/^(?:[A-Za-z]:[\\/]|\\\\|[a-z][a-z\d+.-]*:\/\/)/i.test(value) && !value.split(/[\\/]/).includes("..") && !value.includes("\0");
216
- const validRef = (value) => value === "HEAD" || (typeof value === "string" && /^refs\/(?:heads|remotes)\/[A-Za-z0-9._/-]+$/.test(value) && !value.includes("..") && !value.includes("//") && !value.includes("@{") && !/(^|\/)\.|\/$|\.lock(?:\/|$)|[/.]$/.test(value));
217
- const stale = () => failure("graph-stale", 409);
218
- const hasNewFileMethods = (candidate) => typeof candidate?.files === "function" && typeof candidate?.fileHistory === "function";
219
- const bundledProviderReady = () => {
220
- try { return bundled.capabilities?.().available === true; } catch { return false; }
221
- };
222
- // Truthful capability: only the ACTIVE provider may serve the new endpoints.
223
- // A legacy external provider must not be mixed with bundled data (its graph
224
- // and commit facts come from a different source); a bundled provider also
225
- // needs its Git subprocess to be usable.
226
- const fileHistoryFeature = () => {
227
- if (!hasNewFileMethods(provider)) return false;
228
- if (provider !== bundled) return true;
229
- return bundledProviderReady();
230
- };
231
- const fileReader = () => {
232
- if (!hasNewFileMethods(provider)) throw failure("provider-incompatible", 503);
233
- return provider;
234
- };
235
- const readRefRecords = async (root) => {
236
- if (typeof provider.refs !== "function") return null;
237
- try {
238
- const records = await provider.refs(root);
239
- return Array.isArray(records) ? records : null;
240
- } catch { return null; }
241
- };
242
- const capabilities = () => {
243
- const base = provider.capabilities?.() ?? { available: true, reason: null };
244
- return {
245
- contractVersion: "1.1.0", available: base.available !== false,
246
- reason: ["git-provider-unavailable", "workspace-registry-unavailable"].includes(base.reason) ? base.reason : null,
247
- readOnly: true, provider: provider === external ? "external" : "bundled",
248
- features: {
249
- repository: true, branches: true, graph: true, commit: true, worktree: true, preview: true,
250
- // Both flags are independent and additive: refsDetail can be
251
- // synthesized from legacy strings; fileHistory is true only when the
252
- // active provider implements the new methods (see fileHistoryFeature).
253
- refsDetail: true, fileHistory: fileHistoryFeature(),
254
- },
255
- };
256
- };
257
- /**
258
- * Normalize a client-supplied path to a repository-relative POSIX path.
259
- * Returns null for paths that escape the repository (reported as
260
- * `path-invalid`), and throws 400 for directories.
261
- */
262
- const normalizeHistoryPath = async (root, input) => {
263
- if (typeof input !== "string" || input === "" || input.includes("\0")) return null;
264
- // Windows-style absolute paths cannot be mapped on a POSIX host; report
265
- // them as invalid instead of treating them as a relative filename.
266
- if (/^(?:[A-Za-z]:[\\/]|\\\\)/.test(input) && !isAbsolute(input)) return null;
267
- let candidate = isAbsolute(input) ? resolve(input) : resolve(root, input);
268
- // Windows clients can send an 8.3 alias while the authorized repository
269
- // uses its canonical long name. Canonicalize the nearest existing parent,
270
- // preserving the final filename (a tracked symlink is itself a file).
271
- let parent = dirname(candidate);
272
- const tail = [basename(candidate)];
273
- for (;;) {
274
- try { candidate = resolve(await realpath(parent), ...tail); break; }
275
- catch {
276
- const next = dirname(parent);
277
- if (next === parent) break;
278
- tail.unshift(basename(parent)); parent = next;
279
- }
280
- }
281
- const rel = relative(root, candidate);
282
- if (rel === "") throw failure("path-invalid", 400);
283
- if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) return null;
284
- const normalized = sep === "/" ? rel : rel.split(sep).join("/");
285
- try {
286
- const info = await lstat(candidate);
287
- if (info.isDirectory()) throw failure("path-invalid", 400);
288
- } catch (error) {
289
- if (error?.code === "path-invalid") throw error;
290
- }
291
- return normalized;
292
- };
293
- const service = {
294
- capabilities,
295
- async capabilitiesForSession(sessionId) {
296
- const current = session(sessionId);
297
- const base = capabilities();
298
- if (!base.available) return base;
299
- try {
300
- await authorizedRoot(current?.header?.cwd);
301
- return base;
302
- } catch (error) {
303
- const reason = ["not-git-repository", "git-provider-unavailable"].includes(error?.code)
304
- ? error.code : "repository-not-authorized";
305
- return { ...base, available: false, reason };
306
- }
307
- },
308
- async repositoryForSession(sessionId) {
309
- const current = session(sessionId);
310
- const root = await authorizedRoot(current?.header?.cwd);
311
- const repositoryId = repositoryIdFor(sessionId, root);
312
- bindings.set(repositoryId, { sessionId, root });
313
- keepBounded(bindings, 256);
314
- const rawInfo = typeof provider.repositoryInfo === "function" ? await provider.repositoryInfo(root) : {};
315
- if (typeof provider.refSignature === "function") refSignatures.set(repositoryId, await provider.refSignature(root));
316
- return {
317
- repositoryId, name: basename(root) || "repository",
318
- ...(validOid(rawInfo.headOid) ? { headOid: rawInfo.headOid } : {}),
319
- ...(typeof rawInfo.currentBranch === "string" && rawInfo.currentBranch.startsWith("refs/heads/") && validRef(rawInfo.currentBranch) ? { currentBranch: rawInfo.currentBranch } : {}),
320
- detached: rawInfo.detached === true, empty: rawInfo.empty === true,
321
- };
322
- },
323
- async worktree(sessionId, repositoryId) {
324
- const authorized = await binding(sessionId, repositoryId);
325
- let reader = typeof provider.worktree === "function" ? provider : bundled;
326
- let raw = await reader.worktree(authorized.root);
327
- if (typeof raw?.signature !== "string" || raw.signature === "" || !Array.isArray(raw.entries)) {
328
- reader = bundled;
329
- raw = await reader.worktree(authorized.root);
330
- }
331
- const entries = (raw.entries ?? []).filter((entry) => safeFilePath(entry.path)).slice(0, 2000);
332
- const snapshotId = createHash("sha256").update(`${repositoryId}\0${raw.signature}\0${JSON.stringify(entries)}`).digest("base64url");
333
- worktreeSnapshots.set(snapshotId, { sessionId, repositoryId, root: authorized.root, signature: raw.signature, entries, reader, expiresAt: now() + snapshotTtlMs });
334
- keepBounded(worktreeSnapshots, 128);
335
- return { repositoryId, snapshotId, staged: entries.filter((e) => e.index).map(({ path, oldPath, status, conflicted }) => ({ path, ...(oldPath ? { oldPath } : {}), status, conflicted })), unstaged: entries.filter((e) => e.worktree).map(({ path, oldPath, status, conflicted }) => ({ path, ...(oldPath ? { oldPath } : {}), status, conflicted })), untracked: entries.filter((e) => e.status === "untracked").map(({ path, status, conflicted }) => ({ path, status, conflicted })), truncated: (raw.entries ?? []).length > 2000 };
336
- },
337
- async preview(sessionId, repositoryId, { kind, snapshotId, path, oid } = {}) {
338
- const authorized = await binding(sessionId, repositoryId);
339
- if (!safeFilePath(path) || !["staged", "unstaged", "untracked", "commit"].includes(kind)) throw failure("preview-invalid", 400);
340
- const reader = bundled;
341
- let raw;
342
- if (kind === "commit") {
343
- if (!validOid(oid)) throw failure("invalid-oid", 400);
344
- const commit = typeof provider.commit === "function"
345
- ? await provider.commit(authorized.root, oid)
346
- : await reader.commit(authorized.root, oid);
347
- const commitFile = (Array.isArray(commit?.files) ? commit.files : []).find((file) => file.path === path || file.oldPath === path);
348
- if (!commitFile) throw failure("preview-file-not-found", 404);
349
- raw = { ...await reader.commitPreview(authorized.root, oid, path), ...(commitFile.oldPath ? { oldPath: commitFile.oldPath } : {}) };
350
- } else {
351
- const snap = worktreeSnapshots.get(snapshotId);
352
- if (!snap || snap.sessionId !== sessionId || snap.repositoryId !== repositoryId || snap.root !== authorized.root || snap.expiresAt <= now()) throw stale();
353
- const current = await snap.reader.worktree(authorized.root);
354
- if (current.signature !== snap.signature) throw stale();
355
- const member = snap.entries.find((entry) => entry.path === path && (kind === "untracked" ? entry.status === "untracked" : kind === "staged" ? entry.index : entry.worktree));
356
- if (!member) throw failure("preview-file-not-found", 404);
357
- if (member.conflicted) raw = { diff: "", binary: false, notice: "merge conflict preview omitted" };
358
- else {
359
- const previewReader = typeof snap.reader.worktreePreview === "function" ? snap.reader : reader;
360
- const preview = await previewReader.worktreePreview(authorized.root, kind, path);
361
- const afterPreview = await snap.reader.worktree(authorized.root);
362
- if (afterPreview.signature !== snap.signature) throw stale();
363
- raw = { ...preview, ...(member.oldPath ? { oldPath: member.oldPath } : {}) };
364
- }
365
- }
366
- let diff = String(raw.diff ?? ""); const max = 512 * 1024; const truncated = raw.truncated === true || Buffer.byteLength(diff) > max;
367
- if (Buffer.byteLength(diff) > max) diff = Buffer.from(diff).subarray(0, max).toString("utf8");
368
- const binary = raw.binary === true || /Binary files? .* differ/.test(diff) || diff.includes("GIT binary patch");
369
- let notice = raw.notice;
370
- if (!notice && binary) { notice = "binary preview omitted"; diff = ""; }
371
- else if (!notice && /(?:new file mode|old mode|new mode) 120000/.test(diff)) { notice = "symlink text preview omitted"; diff = ""; }
372
- else if (!notice && /^\+(?:Subproject commit )|^-(?:Subproject commit )/m.test(diff)) { notice = "submodule preview omitted"; diff = ""; }
373
- else if (!notice && !/^@@/m.test(diff) && /^(?:old mode|new mode) /m.test(diff)) { notice = "file mode changed; no text changes"; diff = ""; }
374
- return { repositoryId, kind, path, ...(raw.oldPath ? { oldPath: raw.oldPath } : {}), diff, truncated, binary, additions: raw.additions ?? null, deletions: raw.deletions ?? null, ...(notice ? { notice } : {}) };
375
- },
376
- async branches(sessionId, repositoryId) {
377
- const authorized = await binding(sessionId, repositoryId);
378
- if (typeof provider.branches !== "function") throw failure("provider-incompatible", 503);
379
- const rows = await provider.branches(authorized.root);
380
- const branches = (Array.isArray(rows) ? rows : []).filter((row) => row && row.name !== "HEAD" && validRef(row.name) && validOid(row.oid)).map((row) => ({
381
- name: row.name, displayName: row.name.replace(/^refs\/(?:heads|remotes)\//, ""), oid: row.oid,
382
- kind: row.name.startsWith("refs/remotes/") ? "remote" : "local", current: row.current === true,
383
- tracking: typeof row.tracking === "string" && row.tracking.startsWith("refs/remotes/") && validRef(row.tracking) ? row.tracking : null,
384
- ahead: Math.max(0, Number(row.ahead) || 0), behind: Math.max(0, Number(row.behind) || 0),
385
- }));
386
- return { repositoryId, branches };
387
- },
388
- async commit(sessionId, repositoryId, oid, { filesCursor, filesLimit = 100 } = {}) {
389
- const authorized = await binding(sessionId, repositoryId);
390
- if (!validOid(oid)) throw failure("invalid-oid", 400);
391
- if (typeof provider.commit !== "function") throw failure("provider-incompatible", 503);
392
- const limit = Math.max(1, Math.min(200, Number(filesLimit) || 100));
393
- prune();
394
- let offset = 0;
395
- if (filesCursor) {
396
- const saved = fileCursors.get(filesCursor);
397
- if (!saved || saved.expiresAt <= now() || saved.sessionId !== sessionId || saved.repositoryId !== repositoryId || saved.oid !== String(oid).toLowerCase()) throw failure("invalid-files-cursor", 400);
398
- offset = saved.offset;
399
- }
400
- const value = await provider.commit(authorized.root, oid);
401
- const allFiles = (Array.isArray(value.files) ? value.files : []).filter((file) => safeFilePath(file?.path) && (file.oldPath == null || safeFilePath(file.oldPath))).map((file) => ({
402
- path: String(file.path ?? ""), ...(typeof file.oldPath === "string" ? { oldPath: file.oldPath } : {}),
403
- status: String(file.status ?? "modified"), binary: file.binary === true,
404
- additions: file.additions == null ? null : Math.max(0, Number(file.additions) || 0),
405
- deletions: file.deletions == null ? null : Math.max(0, Number(file.deletions) || 0),
406
- }));
407
- const items = allFiles.slice(offset, offset + limit);
408
- let nextCursor = null;
409
- if (offset + items.length < allFiles.length) {
410
- nextCursor = randomUUID();
411
- fileCursors.set(nextCursor, { sessionId, repositoryId, oid: value.oid.toLowerCase(), offset: offset + items.length, expiresAt: now() + snapshotTtlMs });
412
- keepBounded(fileCursors, 1024);
413
- }
414
- const stats = allFiles.reduce((sum, file) => ({ additions: sum.additions + (file.additions ?? 0), deletions: sum.deletions + (file.deletions ?? 0), files: sum.files + 1 }), { additions: 0, deletions: 0, files: 0 });
415
- const commitOid = String(value.oid ?? oid);
416
- const legacyRefs = Array.isArray(value.refs) ? value.refs.map(String) : [];
417
- const legacyTags = Array.isArray(value.tags) ? value.tags.map(String) : [];
418
- const records = await readRefRecords(authorized.root);
419
- const refDetails = mergeRefDetails(
420
- records ? refDetailsFromRecords(records, commitOid, { fullTags: true }) : emptyRefDetails(),
421
- refDetailsFromLegacyRefs(legacyRefs, commitOid, { tags: legacyTags }),
422
- );
423
- return {
424
- repositoryId, oid: commitOid, parents: Array.isArray(value.parents) ? value.parents.map(String) : [],
425
- author: String(value.author ?? ""), timestamp: Number(value.timestamp) || 0, message: String(value.message ?? ""),
426
- refs: legacyRefs, tags: legacyTags, refsDetail: refDetails.refsDetail, tagsDetail: refDetails.tagsDetail,
427
- stats, files: { items, total: allFiles.length, nextCursor },
428
- };
429
- },
430
- async graph(sessionId, repositoryId, { tips, snapshotId, cursor, limit = 100 } = {}) {
431
- const authorized = await binding(sessionId, repositoryId);
432
- prune();
433
- const pageSize = Math.max(1, Math.min(200, Number(limit) || 100));
434
- let snapshot, offset = 0;
435
- if (snapshotId !== undefined || cursor !== undefined) {
436
- if (!snapshotId || !cursor) throw stale();
437
- snapshot = snapshots.get(snapshotId);
438
- if (!snapshot || snapshot.sessionId !== sessionId || snapshot.repositoryId !== repositoryId || snapshot.root !== authorized.root || snapshot.expiresAt <= now()) throw stale();
439
- offset = snapshot.cursors.get(cursor);
440
- if (!Number.isInteger(offset)) throw stale();
441
- } else {
442
- const selected = tips === undefined ? [{ name: "HEAD", tipOid: null }] : tips;
443
- if (!Array.isArray(selected) || selected.length > MAX_GRAPH_TIPS) throw failure("graph-too-many-tips", 400);
444
- if (selected.length === 0) throw failure("graph-tip-invalid", 400);
445
- const names = selected.map((tip) => tip?.name);
446
- if (new Set(names).size !== names.length || names.some((name) => !validRef(name)) || selected.some((tip) => tip?.tipOid != null && !validOid(tip.tipOid))) throw failure("graph-tip-invalid", 400);
447
- const resolved = [];
448
- for (const tip of selected) {
449
- let oid;
450
- try { oid = await provider.resolveTip(authorized.root, tip.name); }
451
- catch (error) {
452
- if (tip.name === "HEAD" && error?.code === "git-command-failed") continue;
453
- throw failure("graph-tip-invalid", 409);
454
- }
455
- if (!validOid(oid)) throw failure("graph-tip-invalid", 409);
456
- if (tip.tipOid != null && tip.tipOid.toLowerCase() !== oid.toLowerCase()) throw failure("graph-tip-invalid", 409);
457
- resolved.push({ name: tip.name, tipOid: oid });
458
- }
459
- snapshot = { id: randomUUID(), sessionId, repositoryId, root: authorized.root, tips: resolved, expiresAt: now() + snapshotTtlMs, cursors: new Map() };
460
- snapshots.set(snapshot.id, snapshot);
461
- keepBounded(snapshots, 128);
462
- }
463
- for (const tip of snapshot.tips) {
464
- let current;
465
- try { current = await provider.resolveTip(authorized.root, tip.name); } catch { throw stale(); }
466
- if (current.toLowerCase() !== tip.tipOid.toLowerCase()) throw stale();
467
- }
468
- let rawCommits;
469
- try { rawCommits = await provider.graph(authorized.root, { refs: snapshot.tips.map((tip) => tip.tipOid), offset, limit: pageSize }); }
470
- catch (error) {
471
- for (const tip of snapshot.tips) {
472
- let current;
473
- try { current = await provider.resolveTip(authorized.root, tip.name); } catch { snapshots.delete(snapshot.id); throw stale(); }
474
- if (current.toLowerCase() !== tip.tipOid.toLowerCase()) { snapshots.delete(snapshot.id); throw stale(); }
475
- }
476
- throw error;
477
- }
478
- for (const tip of snapshot.tips) {
479
- let current;
480
- try { current = await provider.resolveTip(authorized.root, tip.name); } catch { snapshots.delete(snapshot.id); throw stale(); }
481
- if (current.toLowerCase() !== tip.tipOid.toLowerCase()) { snapshots.delete(snapshot.id); throw stale(); }
482
- }
483
- const records = await readRefRecords(authorized.root);
484
- const commits = (Array.isArray(rawCommits) ? rawCommits : []).map((row) => {
485
- const oid = String(row.oid ?? "");
486
- const legacy = Array.isArray(row.refs) ? row.refs.map(String) : [];
487
- // Graph rows only guarantee name-level refs plus `annotated`; full
488
- // tag metadata is reserved for commit details.
489
- const refDetails = mergeRefDetails(
490
- records ? refDetailsFromRecords(records, oid) : emptyRefDetails(),
491
- refDetailsFromLegacyRefs(legacy, oid),
492
- );
493
- return {
494
- oid, parents: Array.isArray(row.parents) ? row.parents.map(String) : [],
495
- author: String(row.author ?? ""), timestamp: Number(row.timestamp) || 0, subject: String(row.subject ?? ""),
496
- refs: legacy, refsDetail: refDetails.refsDetail, tagsDetail: refDetails.tagsDetail,
497
- };
498
- });
499
- let nextCursor = null;
500
- if (commits.length === pageSize) {
501
- nextCursor = randomUUID();
502
- snapshot.cursors.set(nextCursor, offset + commits.length);
503
- keepBounded(snapshot.cursors, 128);
504
- }
505
- return { repositoryId, snapshotId: snapshot.id, tips: snapshot.tips, commits, nextCursor };
506
- },
507
- async files(sessionId, repositoryId, { q, limit } = {}) {
508
- const authorized = await binding(sessionId, repositoryId);
509
- const pageSize = Math.max(1, Math.min(MAX_TRACKED_FILES, Number(limit) || MAX_TRACKED_FILES));
510
- const query = typeof q === "string" ? q : "";
511
- const raw = await fileReader().files(authorized.root, { q: query, limit: pageSize });
512
- const files = [...new Set((Array.isArray(raw?.files) ? raw.files : [])
513
- .map((path) => String(path ?? ""))
514
- .filter((path) => safeFilePath(path)))].sort(compareText).slice(0, pageSize);
515
- return { repositoryId, files, truncated: raw?.truncated === true };
516
- },
517
- async fileHistory(sessionId, repositoryId, { path, cursor, limit } = {}) {
518
- const authorized = await binding(sessionId, repositoryId);
519
- const pageSize = Math.max(1, Math.min(FILE_HISTORY_MAX_LIMIT, Number(limit) || FILE_HISTORY_DEFAULT_LIMIT));
520
- prune();
521
- const normalized = await normalizeHistoryPath(authorized.root, path);
522
- if (normalized === null) {
523
- return { repositoryId, path: String(path ?? ""), entries: [], nextCursor: null, truncated: false, reason: "path-invalid" };
524
- }
525
- let snapshot = null, offset = 0;
526
- if (cursor !== undefined && cursor !== null && cursor !== "") {
527
- const saved = historyCursors.get(String(cursor));
528
- if (!saved || saved.expiresAt <= now() || saved.sessionId !== sessionId || saved.repositoryId !== repositoryId || saved.path !== normalized) throw failure("invalid-history-cursor", 400);
529
- snapshot = historySnapshots.get(saved.snapshotId);
530
- if (!snapshot || snapshot.expiresAt <= now() || snapshot.root !== authorized.root) throw failure("invalid-history-cursor", 400);
531
- offset = saved.offset;
532
- }
533
- if (!snapshot) {
534
- const raw = await fileReader().fileHistory(authorized.root, normalized, {
535
- maxCommits: FILE_HISTORY_MAX_COMMITS,
536
- timeoutMs: FILE_HISTORY_TIMEOUT_MS,
537
- });
538
- const reason = FILE_HISTORY_REASONS.has(raw?.reason) ? raw.reason : null;
539
- const entries = (Array.isArray(raw?.entries) ? raw.entries : []).map((entry) => ({
540
- oid: String(entry?.oid ?? ""),
541
- shortOid: String(entry?.shortOid ?? String(entry?.oid ?? "").slice(0, 7)),
542
- author: String(entry?.author ?? ""),
543
- timestamp: Number(entry?.timestamp) || 0,
544
- subject: String(entry?.subject ?? ""),
545
- status: historyStatus(entry?.status),
546
- })).filter((entry) => validOid(entry.oid));
547
- if (reason && entries.length === 0) {
548
- return { repositoryId, path: normalized, entries: [], nextCursor: null, truncated: false, reason };
549
- }
550
- snapshot = {
551
- id: randomUUID(), sessionId, repositoryId, root: authorized.root, path: normalized,
552
- entries, truncated: raw?.truncated === true, expiresAt: now() + snapshotTtlMs,
553
- };
554
- historySnapshots.set(snapshot.id, snapshot);
555
- keepBounded(historySnapshots, MAX_FILE_HISTORY_SNAPSHOTS);
556
- }
557
- const items = snapshot.entries.slice(offset, offset + pageSize);
558
- let nextCursor = null;
559
- if (offset + items.length < snapshot.entries.length) {
560
- nextCursor = randomUUID();
561
- historyCursors.set(nextCursor, {
562
- sessionId, repositoryId, path: normalized, snapshotId: snapshot.id,
563
- offset: offset + items.length, expiresAt: now() + snapshotTtlMs,
564
- });
565
- keepBounded(historyCursors, 1024);
566
- }
567
- return { repositoryId, path: normalized, entries: items, nextCursor, truncated: snapshot.truncated };
568
- },
569
- _pollOnce() {
570
- if (pollInFlight) return pollInFlight;
571
- pollInFlight = (async () => {
572
- for (const [repositoryId, authorized] of bindings) {
573
- try {
574
- await binding(authorized.sessionId, repositoryId);
575
- if (typeof provider.refSignature === "function") {
576
- const signature = await provider.refSignature(authorized.root);
577
- const previous = refSignatures.get(repositoryId); refSignatures.set(repositoryId, signature);
578
- if (previous !== undefined && previous !== signature) onChanged?.(repositoryId, "refs");
579
- }
580
- } catch { bindings.delete(repositoryId); refSignatures.delete(repositoryId); }
581
- }
582
- })().finally(() => { pollInFlight = null; });
583
- return pollInFlight;
584
- },
585
- start() {
586
- if (unsubscribeProvider || pollTimer) return;
587
- if (typeof provider.subscribeChanges === "function") {
588
- try { unsubscribeProvider = provider.subscribeChanges((change) => {
589
- void (async () => {
590
- for (const [repositoryId, authorized] of bindings) {
591
- if (change?.root !== authorized.root) continue;
592
- try {
593
- await binding(authorized.sessionId, repositoryId);
594
- if (typeof provider.refSignature === "function") {
595
- const signature = await provider.refSignature(authorized.root);
596
- const previous = refSignatures.get(repositoryId);
597
- refSignatures.set(repositoryId, signature);
598
- if (previous === signature) continue;
599
- }
600
- onChanged?.(repositoryId);
601
- } catch { bindings.delete(repositoryId); refSignatures.delete(repositoryId); }
602
- }
603
- })();
604
- }); } catch { unsubscribeProvider = null; }
605
- if (typeof unsubscribeProvider !== "function") unsubscribeProvider = null;
606
- }
607
- // Ref polling is server-side; worktree polling stays scoped to an open mobile page.
608
- pollTimer = setInterval(() => { void service._pollOnce(); }, pollIntervalMs);
609
- pollTimer.unref?.();
610
- },
611
- stop() {
612
- if (pollTimer) clearInterval(pollTimer);
613
- pollTimer = null;
614
- try { unsubscribeProvider?.(); } catch { /* optional provider teardown must not break host shutdown */ }
615
- unsubscribeProvider = null;
616
- return pollInFlight ?? Promise.resolve();
617
- },
618
- };
619
- return service;
620
- }