@marktrue/dsh-mobile-remote 3.2.4-alpha.12 → 3.2.4-alpha.13-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 -1665
  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 -1415
  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 -11496
  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,178 +0,0 @@
1
- // 端点登记表(ADR 0019「能力登记强制化」;评审 #32 note 1286 的 W2)。
2
- //
3
- // 三条判据里「能力能不能用」看的是**能力声明**;而声明要成立,前提是"新增端点时必须有人
4
- // 登记它"。此前这件事只写在 CONTRIBUTING 的文字要求里,没有机制兜底——于是必然漏。
5
- //
6
- // 这里把登记变成**可被测试检出**的东西:
7
- // - 从 `lib/index.js` 抽取所有正向分派(`rest === "..."`、`new Set([...]).has(rest)`),
8
- // 与登记表**双向**比对:漏登记、陈旧登记、**方法不符**都会失败;
9
- // - 抽取正则容忍引号与空白差异(`rest === '/x'`、`rest==="/x"` 同样会被抓到);
10
- // - 每条登记项都必须显式写出 `capability`(能力键或 `null`);写了键就必须真的在
11
- // bootstrap 的 capabilities 里声明过,否则失败。
12
- //
13
- // 已知边界(不假装更强):`methods` 由源码按分派段落推导,是**契约快照**而非运行期保证;
14
- // 端点自身仍靠 `requireGet`/`method` 检查在运行时兜底。
15
-
16
- /** 抽取正向分派所用的源码文件(相对仓库根)。 */
17
- export const ENDPOINT_DISPATCH_SOURCE = "lib/index.js";
18
-
19
- /** 从源码抽取"正向分派"及其方法(按分派段落判定,不看固定窗口)。 */
20
- export function extractEndpointDetails(source) {
21
- const lines = source.split("\n");
22
- const marks = [];
23
- lines.forEach((line, index) => {
24
- for (const m of line.matchAll(/rest\s*===\s*['"]([^'"]+)['"]/g)) marks.push({ index, path: m[1] });
25
- for (const group of line.matchAll(/new Set\(\[([^\]]+)\]\)\s*\.has\(rest\)/g)) {
26
- for (const m of group[1].matchAll(/['"]([^'"]+)['"]/g)) marks.push({ index, path: m[1] });
27
- }
28
- });
29
- marks.sort((a, b) => a.index - b.index);
30
- const markLines = [...new Set(marks.map((m) => m.index))].sort((a, b) => a - b);
31
- const out = new Map();
32
- for (const { index, path } of marks) {
33
- if (out.has(path)) continue;
34
- const next = markLines.find((l) => l > index);
35
- const segment = lines.slice(index, next ?? Math.min(lines.length, index + 400)).join("\n");
36
- // 路由**头部**(分派行 + 紧随其后的 2 行)才代表该端点的方法契约;块内更深处的
37
- // GET/HEAD 分支(如 /goal 内部图片/下载分支)不能把整个端点判成 GET/HEAD。
38
- const header = lines.slice(index, Math.min(lines.length, index + 3)).join("\n");
39
- let methods = "GET/POST";
40
- // issue #60 recheck-2(R02):头部显式 `(method === "GET" || method === "HEAD")`
41
- // 必须抽成 GET/HEAD——HEAD 是真实分派语义,不能被默认成 GET/POST。
42
- const allowsHead = /method\s*===\s*['"]GET['"]\s*\|\|\s*method\s*===\s*['"]HEAD['"]/.test(header);
43
- const allowsPost = /method\s*===\s*['"]POST['"]/.test(segment) || /requirePost\(method,\s*res\)/.test(segment);
44
- if (allowsHead && !allowsPost) methods = "GET/HEAD";
45
- else if (/requireGet\(method,\s*res\)/.test(segment) || /method\s*!==\s*['"]GET['"]/.test(segment)) methods = "GET";
46
- else if (/method\s*!==\s*['"]POST['"]/.test(segment)) methods = "POST";
47
- out.set(path, methods);
48
- }
49
- return out;
50
- }
51
-
52
- /**
53
- * 抽取 **bootstrap 响应**里实际声明的能力键(G2)。
54
- * 只认 `/bootstrap` 处理器里的那个 `capabilities: {...}` 块——SSE hello 里也有
55
- * `capabilities`,按"源码里第一个"抽取会误判(那样负向变异根本测不出来)。
56
- */
57
- export function extractDeclaredCapabilities(source) {
58
- const lines = source.split("\n");
59
- const bootstrapAt = lines.findIndex((l) => /rest\s*===\s*['"]\/bootstrap['"]/.test(l));
60
- const from = bootstrapAt >= 0 ? bootstrapAt : 0;
61
- const tail = lines.slice(from).join("\n");
62
- const m = /capabilities:\s*\{/.exec(tail);
63
- if (!m) return new Set();
64
- // 从 `{` 起做花括号配平,取出完整块
65
- const open = tail.indexOf("{", m.index);
66
- let depth = 0;
67
- let end = -1;
68
- for (let i = open; i < tail.length; i++) {
69
- if (tail[i] === "{") depth++;
70
- else if (tail[i] === "}") {
71
- depth--;
72
- if (depth === 0) {
73
- end = i;
74
- break;
75
- }
76
- }
77
- }
78
- if (end < 0) return new Set();
79
- const block = tail.slice(open + 1, end);
80
- return new Set([...block.matchAll(/([A-Za-z_][A-Za-z0-9_]*)\s*:/g)].map((x) => x[1]));
81
- }
82
-
83
- /** 未声明能力时的显式豁免理由(登记表要求二者必居其一)。 */
84
- export const NO_CAPABILITY_NEEDED = "端点级能力由 App 按 404/缺字段降级;能力声明机制覆盖的是帧/字段级特性";
85
-
86
- /**
87
- * 双向比对。返回 `missing`(源码有、表里没有)、`stale`(表里有、源码没有)、
88
- * `methodMismatch`(方法不符)与 `undeclaredCapabilities`(登记了未声明的能力键)。
89
- */
90
- export function diffRegisteredEndpoints(source, registered = REGISTERED_ENDPOINTS) {
91
- const dispatched = extractEndpointDetails(source);
92
- const known = new Map(registered.map((e) => [e.path, e]));
93
- const declared = extractDeclaredCapabilities(source);
94
- const missing = [...dispatched.keys()].filter((p) => !known.has(p)).sort();
95
- const stale = [...known.keys()].filter((p) => !dispatched.has(p)).sort();
96
- const methodMismatch = [...dispatched.entries()]
97
- .filter(([p, methods]) => known.has(p) && known.get(p).methods && known.get(p).methods !== methods)
98
- .map(([p, methods]) => ({ path: p, registered: known.get(p).methods, source: methods }))
99
- .sort((a, b) => a.path.localeCompare(b.path));
100
- const undeclaredCapabilities = [...new Set(
101
- registered.map((e) => e.capability).filter((c) => typeof c === "string" && c !== "" && !declared.has(c)),
102
- )].sort();
103
- const missingCapabilityField = registered.filter((e) => !("capability" in e)).map((e) => e.path).sort();
104
- // 没关联能力键的必须给出**显式豁免理由**(G2:不允许"忘了写"和"确实不需要"长得一样)
105
- const missingExemption = registered
106
- .filter((e) => (e.capability === null || e.capability === undefined) && !(typeof e.why === "string" && e.why.trim() !== ""))
107
- .map((e) => e.path)
108
- .sort();
109
- return { missing, stale, methodMismatch, undeclaredCapabilities, missingCapabilityField, missingExemption, dispatched, declared };
110
- }
111
-
112
- /** 已登记的 `/m/api/*` 端点(`path` 是去掉 `/m/api` 前缀后的部分)。 */
113
- export const REGISTERED_ENDPOINTS = Object.freeze([
114
- { path: "/account-usage", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
115
- { path: "/actions", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
116
- { path: "/attachment", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
117
- { path: "/balance", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
118
- { path: "/bootstrap", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
119
- { path: "/catalog", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
120
- { path: "/changes/diff", methods: "GET", capability: "turnTail" },
121
- { path: "/changes/summary", methods: "GET", capability: "turnTail" },
122
- { path: "/commands", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
123
- { path: "/defaults", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
124
- { path: "/dev/approval-test", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
125
- { path: "/diagnostics", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
126
- { path: "/directories", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
127
- { path: "/event-detail", methods: "GET", capability: "eventTimeline" },
128
- { path: "/events", methods: "GET", capability: "eventTimeline" },
129
- { path: "/feedback", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
130
- { path: "/files", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
131
- { path: "/files/upload", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
132
- { path: "/git/branches", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
133
- { path: "/git/capabilities", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
134
- { path: "/git/commit", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
135
- { path: "/git/file-history", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
136
- { path: "/git/files", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
137
- { path: "/git/graph", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
138
- { path: "/git/preview", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
139
- { path: "/git/repository", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
140
- { path: "/git/worktree", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
141
- { path: "/goal", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
142
- { path: "/history", methods: "GET", capability: "eventTimeline" },
143
- { path: "/jobs", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
144
- { path: "/jobs/kill", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
145
- { path: "/llm-providers", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
146
- { path: "/llm-providers/probe", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
147
- { path: "/messages", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
148
- { path: "/notifications", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
149
- { path: "/notifications/delete", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
150
- { path: "/notifications/read", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
151
- { path: "/plugin-update/check", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
152
- { path: "/plugin-update/prepare", methods: "POST", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
153
- { path: "/plugin-update/log", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
154
- { path: "/plugin-update", methods: "POST", capability: null, why: NO_CAPABILITY_NEEDED },
155
- { path: "/push-test", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
156
- { path: "/qr-config", methods: "GET", capability: null, auth: "local-privileged", why: NO_CAPABILITY_NEEDED },
157
- { path: "/queue", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
158
- { path: "/respond", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
159
- { path: "/send", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
160
- { path: "/send-receipt", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
161
- { path: "/session-config", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
162
- { path: "/sessions", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
163
- { path: "/sessions/archive", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
164
- { path: "/sessions/fork", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
165
- { path: "/sessions/stop", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
166
- { path: "/sessions/touch", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
167
- { path: "/sessions/unarchive", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
168
- { path: "/subagents", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
169
- { path: "/subagents/interrupt", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
170
- { path: "/todos", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
171
- { path: "/turn-file", methods: "GET/HEAD", capability: "turnTail" },
172
- { path: "/turn-outline", methods: "GET", capability: "turnOutline" },
173
- { path: "/update/apk", methods: "GET", capability: null, auth: "anonymous", why: NO_CAPABILITY_NEEDED },
174
- { path: "/update/manifest", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
175
- { path: "/update/plugin", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
176
- { path: "/usage", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
177
- { path: "/workspaces", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
178
- ]);
@@ -1,460 +0,0 @@
1
- import { constants as fsConstants } from "node:fs";
2
- import { realpath, open, lstat } from "node:fs/promises";
3
- import { isAbsolute, relative, resolve, sep } from "node:path";
4
- import { createHash } from "node:crypto";
5
-
6
- const UNTRACKED_PREVIEW_MAX = 512 * 1024;
7
- const SIGNATURE_SAMPLE_BYTES = 4096;
8
- const readOnlyNoFollow = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0);
9
- function sameRegularFile(expected, opened) {
10
- return expected.isFile() && opened.isFile() && expected.dev === opened.dev && expected.ino === opened.ino;
11
- }
12
- async function readPrefix(path, maximum, expected) {
13
- const handle = await open(path, readOnlyNoFollow);
14
- try {
15
- if (!sameRegularFile(expected, await handle.stat())) throw new Error("file changed while opening preview");
16
- const buffer = Buffer.alloc(maximum + 1);
17
- const { bytesRead } = await handle.read(buffer, 0, maximum + 1, 0);
18
- return { bytes: buffer.subarray(0, bytesRead), truncated: bytesRead > maximum };
19
- } finally { await handle.close(); }
20
- }
21
- async function sampledFileSignature(path, info) {
22
- const handle = await open(path, readOnlyNoFollow);
23
- try {
24
- if (!sameRegularFile(info, await handle.stat())) throw new Error("file changed while sampling worktree");
25
- const first = Buffer.alloc(Math.min(SIGNATURE_SAMPLE_BYTES, info.size));
26
- const firstRead = await handle.read(first, 0, first.length, 0);
27
- let last = Buffer.alloc(0);
28
- if (info.size > SIGNATURE_SAMPLE_BYTES) {
29
- last = Buffer.alloc(SIGNATURE_SAMPLE_BYTES);
30
- const read = await handle.read(last, 0, last.length, Math.max(0, info.size - last.length));
31
- last = last.subarray(0, read.bytesRead);
32
- }
33
- return createHash("sha256").update(`${info.dev}:${info.ino}:${info.size}:${info.mtimeMs}:${info.ctimeMs}:`).update(first.subarray(0, firstRead.bytesRead)).update(last).digest("hex");
34
- } finally { await handle.close(); }
35
- }
36
-
37
- function gitError(code, status, message = code) {
38
- const error = new Error(message);
39
- error.code = code;
40
- error.status = status;
41
- return error;
42
- }
43
-
44
- const refShortName = (name) => name === "HEAD" ? "HEAD" : String(name).replace(/^refs\/(?:heads|remotes|tags)\//, "");
45
- const HISTORY_STATUS_LETTER = { A: "A", M: "M", D: "D", R: "R", C: "C", T: "T" };
46
-
47
- /**
48
- * Parse `git log --format=%x00<meta> --name-status -M -z` output into file
49
- * history entries. Records are NUL-delimited: a `\x00` start marker, the
50
- * `\x1f`-separated metadata, then `\x00\n<status>` and its NUL-separated paths.
51
- * A deadline-aborted command may end mid-record; incomplete trailing records
52
- * are ignored while every fully parsed commit stays usable.
53
- */
54
- function parseFileHistory(stdout) {
55
- const tokens = String(stdout ?? "").split("\0");
56
- const entries = [];
57
- let index = 0;
58
- while (index < tokens.length) {
59
- const metadata = tokens[index++];
60
- if (!metadata || metadata.startsWith("\n")) continue;
61
- const fields = metadata.split("\x1f");
62
- if (fields.length < 5) continue;
63
- const oid = fields[0];
64
- if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(oid)) continue;
65
- let status = "M";
66
- if (index < tokens.length) {
67
- const marker = tokens[index];
68
- if (typeof marker === "string" && marker.startsWith("\n")) {
69
- index++;
70
- const code = marker.slice(1).trim();
71
- if (code) {
72
- status = HISTORY_STATUS_LETTER[code[0]] ?? "M";
73
- index += /^[RC]/.test(code) ? 2 : 1;
74
- }
75
- }
76
- }
77
- entries.push({
78
- oid,
79
- shortOid: fields[1] || oid.slice(0, 7),
80
- author: fields[2] ?? "",
81
- timestamp: Number(fields[3]) || 0,
82
- subject: fields.slice(4).join("\x1f"),
83
- status,
84
- });
85
- }
86
- return entries;
87
- }
88
-
89
- /** Bundled, read-only Git provider. Every command uses the host subprocess service. */
90
- export function createBundledGitReadProvider(ctx) {
91
- const get = (name) => {
92
- try { return ctx.get?.(name); } catch { return undefined; }
93
- };
94
- const subprocess = () => get("subprocess") ?? ctx.subprocess;
95
- const workspaces = () => (get("workspaceRegistry")?.list?.() ?? [])
96
- .map((entry) => entry?.path).filter((path) => typeof path === "string" && path !== "");
97
- const inside = (child, parent) => {
98
- const value = relative(resolve(parent), resolve(child));
99
- return value === "" || (value !== ".." && !value.startsWith(`..${sep}`) && !isAbsolute(value));
100
- };
101
- const assertWorkspace = async (path) => {
102
- if (typeof path !== "string" || path === "") throw gitError("workspace-not-allowed", 403);
103
- let canonical;
104
- try { canonical = await realpath(path); } catch { throw gitError("workspace-not-allowed", 403); }
105
- const roots = await Promise.all(workspaces().map((root) => realpath(root).catch(() => null)));
106
- if (!roots.some((root) => root && inside(canonical, root))) throw gitError("workspace-not-allowed", 403);
107
- return canonical;
108
- };
109
- const spawnGit = async (root, args, { disableFilters = false, allowNoMatches = false, timeoutMs = 0 } = {}) => {
110
- root = await assertWorkspace(root);
111
- const executor = subprocess();
112
- if (!executor?.spawn) throw gitError("git-provider-unavailable", 503);
113
- const noHooksPath = process.platform === "win32" ? "NUL" : "/dev/null";
114
- let filterOverrides = [];
115
- if (disableFilters) {
116
- const names = await run(root, ["config", "--null", "--name-only", "--get-regexp", "^filter\\..*\\.(clean|process)$"], false, true);
117
- filterOverrides = names.split("\0").filter(Boolean).flatMap((name) => ["-c", `${name}=`]);
118
- }
119
- // A soft deadline aborts the command and returns the output collected so far,
120
- // so file history can degrade to a partial, explicitly truncated page instead
121
- // of failing the request. Hardening below is shared with the batch helper.
122
- const controller = timeoutMs > 0 ? new AbortController() : null;
123
- const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
124
- try {
125
- const child = executor.spawn({
126
- argv: [
127
- process.platform === "win32" ? "git.exe" : "git",
128
- "-c", "core.fsmonitor=false",
129
- "-c", `core.hooksPath=${noHooksPath}`,
130
- ...filterOverrides,
131
- "-C", root,
132
- "--no-optional-locks",
133
- ...args,
134
- ],
135
- cwd: root,
136
- // Prevent ambient Git repository/config overrides from redirecting a
137
- // session-authorized read. Undefined values are seam tombstones.
138
- env: {
139
- GIT_TERMINAL_PROMPT: "0",
140
- GCM_INTERACTIVE: "never",
141
- GIT_DIR: undefined,
142
- GIT_WORK_TREE: undefined,
143
- GIT_INDEX_FILE: undefined,
144
- GIT_COMMON_DIR: undefined,
145
- GIT_OBJECT_DIRECTORY: undefined,
146
- GIT_ALTERNATE_OBJECT_DIRECTORIES: undefined,
147
- GIT_CONFIG: undefined,
148
- GIT_CONFIG_PARAMETERS: undefined,
149
- GIT_CONFIG_COUNT: "0",
150
- // Trace destinations open files even for otherwise read-only Git commands.
151
- ...Object.fromEntries(Object.keys(process.env).filter((key) => /^GIT_TRACE(?:2)?(?:_|$)/.test(key)).map((key) => [key, undefined])),
152
- GIT_TRACE: undefined,
153
- GIT_TRACE2: undefined,
154
- GIT_TRACE2_EVENT: undefined,
155
- GIT_TRACE2_PERF: undefined,
156
- },
157
- stdio: { stdin: "ignore", stdout: { maxBytes: 8 * 1024 * 1024 }, stderr: { maxBytes: 1024 * 1024 } },
158
- graceMs: 10_000,
159
- ...(controller ? { signal: controller.signal } : {}),
160
- });
161
- let done;
162
- try { done = await child.done; } catch (error) {
163
- if (!controller?.signal.aborted) throw error;
164
- done = { exitCode: null };
165
- }
166
- const stdoutResult = await child.collected?.stdout?.readFrom?.(0);
167
- const stderrResult = await child.collected?.stderr?.readFrom?.(0);
168
- if (stdoutResult?.lossy || stderrResult?.lossy) {
169
- throw gitError("git-output-too-large", 413);
170
- }
171
- const stdout = stdoutResult?.text ?? "";
172
- const stderr = stderrResult?.text ?? "";
173
- if (controller?.signal.aborted) return { stdout, stderr, timedOut: true };
174
- if (done?.exitCode !== 0) {
175
- if (allowNoMatches && done?.exitCode === 1) return { stdout: "", stderr, timedOut: false };
176
- if (/not a git repository/i.test(stderr)) throw gitError("not-git-repository", 404);
177
- throw gitError("git-command-failed", 400);
178
- }
179
- return { stdout, stderr, timedOut: false };
180
- } finally {
181
- if (timer) clearTimeout(timer);
182
- }
183
- };
184
- const run = async (root, args, disableFilters = false, allowNoMatches = false) =>
185
- (await spawnGit(root, args, { disableFilters, allowNoMatches })).stdout;
186
- const repositoryRoot = async (cwd) => {
187
- const allowed = await assertWorkspace(cwd);
188
- const root = (await run(allowed, ["rev-parse", "--show-toplevel"])).trim();
189
- return assertWorkspace(root);
190
- };
191
- return {
192
- contractVersion: "1.1.0",
193
- capabilities() {
194
- const available = Boolean(subprocess()?.spawn) && workspaces().length > 0;
195
- return { available, reason: available ? null : !subprocess()?.spawn ? "git-provider-unavailable" : "workspace-registry-unavailable" };
196
- },
197
- repositoryRoot,
198
- async refSignature(root) {
199
- let refs = "";
200
- try { refs = await run(root, ["show-ref", "--head", "--dereference"]); } catch (error) { if (error?.code !== "git-command-failed") throw error; }
201
- return createHash("sha256").update(refs).digest("hex");
202
- },
203
- async repositoryInfo(root) {
204
- let currentBranch = null, headOid = null;
205
- try { currentBranch = (await run(root, ["symbolic-ref", "--quiet", "HEAD"])).trim() || null; } catch (error) { if (error?.code !== "git-command-failed") throw error; }
206
- try { headOid = (await run(root, ["rev-parse", "--verify", "HEAD"])).trim() || null; } catch (error) { if (error?.code !== "git-command-failed") throw error; }
207
- return { ...(headOid ? { headOid } : {}), ...(currentBranch ? { currentBranch } : {}), detached: Boolean(headOid && !currentBranch), empty: !headOid };
208
- },
209
- async resolveTip(root, ref) {
210
- return (await run(root, ["rev-parse", "--verify", `${ref}^{commit}`])).trim();
211
- },
212
- async graph(root, { refs, offset, limit }) {
213
- if (refs.length === 0) return [];
214
- const text = await run(root, ["log", "--topo-order", "--date-order", `--skip=${offset}`, `--max-count=${limit}`, "--decorate=full", "--format=%H%x1f%P%x1f%an%x1f%at%x1f%s%x1f%D%x00", ...refs]);
215
- return text.split("\0").map((record) => record.replace(/^[\r\n]+|[\r\n]+$/g, "")).filter(Boolean).map((record) => {
216
- const [oid, parents, author, timestamp, subject, decorations] = record.split("\x1f");
217
- return { oid, parents: parents ? parents.split(" ") : [], author, timestamp: Number(timestamp) || 0, subject, refs: decorations ? decorations.split(",").map((value) => value.trim()).filter(Boolean) : [] };
218
- });
219
- },
220
- async commit(root, oid) {
221
- if (typeof oid !== "string" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(oid)) throw gitError("invalid-oid", 400);
222
- const metadata = (await run(root, ["show", "-s", "--decorate=full", "--format=%H%x1f%P%x1f%an%x1f%at%x1f%D%x1f%B%x00", oid])).split("\0")[0].split("\x1f");
223
- const [hash, parentText, author, timestamp, decorations, ...messageParts] = metadata;
224
- const diffBase = parentText ? [parentText.split(" ")[0], hash] : ["--root", hash];
225
- const statusParts = (await run(root, ["diff-tree", "--no-commit-id", "-r", "-M", "--name-status", "-z", ...diffBase])).split("\0");
226
- const files = [];
227
- for (let index = 0; index < statusParts.length;) {
228
- const code = statusParts[index++];
229
- if (!code) continue;
230
- const renamed = code.startsWith("R") || code.startsWith("C");
231
- const oldPath = renamed ? statusParts[index++] : undefined;
232
- const path = statusParts[index++];
233
- if (!path) break;
234
- const statuses = { A: "added", M: "modified", D: "deleted", R: "renamed", C: "copied", T: "type-changed" };
235
- files.push({ path, ...(oldPath ? { oldPath } : {}), status: statuses[code[0]] ?? "modified" });
236
- }
237
- const statParts = (await run(root, ["diff-tree", "--no-commit-id", "-r", "-M", "--numstat", "-z", ...diffBase])).split("\0");
238
- const stats = new Map();
239
- for (let index = 0; index < statParts.length;) {
240
- const record = statParts[index++];
241
- if (!record) continue;
242
- const firstTab = record.indexOf("\t");
243
- const secondTab = record.indexOf("\t", firstTab + 1);
244
- if (firstTab < 0 || secondTab < 0) continue;
245
- const added = record.slice(0, firstTab);
246
- const deleted = record.slice(firstTab + 1, secondTab);
247
- let path = record.slice(secondTab + 1);
248
- if (!path) { index++; path = statParts[index++] ?? ""; }
249
- stats.set(path, { binary: added === "-" || deleted === "-", additions: added === "-" ? null : Number(added), deletions: deleted === "-" ? null : Number(deleted) });
250
- }
251
- for (const file of files) Object.assign(file, stats.get(file.path) ?? { binary: false, additions: 0, deletions: 0 });
252
- return {
253
- oid: hash, parents: parentText ? parentText.split(" ") : [], author, timestamp: Number(timestamp) || 0,
254
- message: messageParts.join("\x1f").trim(),
255
- refs: decorations ? decorations.split(",").map((value) => value.trim()).filter(Boolean) : [],
256
- files,
257
- };
258
- },
259
- /**
260
- * All branch, remote, tag and HEAD refs with name-level facts plus
261
- * annotated-tag metadata. Non-commit and nested tag targets carry a hint
262
- * instead of failing the whole read.
263
- */
264
- async refs(root) {
265
- const records = [];
266
- // NUL/US-delimited fields keep tagger names and tag subjects that contain
267
- // tabs intact; a tab-delimited line format would corrupt such records.
268
- const text = await run(root, ["for-each-ref", "--format=%(refname)%1f%(objectname)%1f%(objecttype)%1f%(HEAD)%1f%(taggername)%1f%(taggerdate:unix)%1f%(subject)%1f%(*objectname)%1f%(*objecttype)%1f%(type)%00", "refs/heads", "refs/remotes", "refs/tags"]);
269
- for (const raw of text.split("\0")) {
270
- const record = raw.replace(/^[\r\n]+|[\r\n]+$/g, "");
271
- if (!record) continue;
272
- const fields = record.split("\x1f");
273
- if (fields.length < 10) continue;
274
- // Peeled fields are fixed at the tail so a subject containing the
275
- // unit separator cannot swallow them.
276
- const [name, oid, objectType, headFlag, taggerName, taggerDate] = fields;
277
- const targetType = fields.at(-1); // %(type) is the direct tag target, including on Git 2.52+.
278
- const peeledType = fields.at(-2);
279
- const peeledOid = fields.at(-3);
280
- const subject = fields.slice(6, -3).join("\x1f");
281
- if (!name || !oid) continue;
282
- if (name.startsWith("refs/remotes/") && name.endsWith("/HEAD")) continue;
283
- if (name.startsWith("refs/heads/") || name.startsWith("refs/remotes/")) {
284
- const commit = objectType === "commit";
285
- records.push({
286
- name, shortName: refShortName(name),
287
- kind: name.startsWith("refs/heads/") ? "localBranch" : "remoteBranch",
288
- oid, commitOid: commit ? oid : null, current: headFlag === "*", annotated: false,
289
- ...(commit ? {} : { hint: "non-commit-target" }),
290
- });
291
- continue;
292
- }
293
- if (!name.startsWith("refs/tags/")) continue;
294
- if (objectType !== "tag") {
295
- // Lightweight tag: the ref itself points at the target object.
296
- const commit = objectType === "commit";
297
- records.push({
298
- name, shortName: refShortName(name), kind: "tag",
299
- oid, commitOid: commit ? oid : null, current: false, annotated: false,
300
- ...(commit ? {} : { hint: "non-commit-target" }),
301
- });
302
- continue;
303
- }
304
- let commitOid = null, hint;
305
- if (targetType === "tag" && peeledType === "commit") {
306
- commitOid = peeledOid;
307
- hint = "nested-tag";
308
- } else if (peeledType === "commit") commitOid = peeledOid;
309
- else if (peeledType === "tag") {
310
- // Nested tag: peel recursively; when the chain ends outside a
311
- // commit we still keep the name and advertise the hint.
312
- try { commitOid = (await run(root, ["rev-parse", "--verify", `${name}^{commit}`])).trim() || null; } catch { commitOid = null; }
313
- hint = commitOid ? "nested-tag" : "non-commit-target";
314
- } else hint = "non-commit-target";
315
- const date = Number(taggerDate);
316
- records.push({
317
- name, shortName: refShortName(name), kind: "tag", oid, commitOid, current: false, annotated: true,
318
- ...(taggerName ? { tagger: taggerName } : {}),
319
- ...(Number.isFinite(date) && date > 0 ? { date } : {}),
320
- ...(subject ? { subject } : {}),
321
- ...(hint ? { hint } : {}),
322
- });
323
- }
324
- let headOid = null;
325
- try { headOid = (await run(root, ["rev-parse", "--verify", "HEAD"])).trim() || null; } catch (error) { if (error?.code !== "git-command-failed") throw error; }
326
- if (headOid) records.unshift({ name: "HEAD", shortName: "HEAD", kind: "head", oid: headOid, commitOid: headOid, current: true, annotated: false });
327
- return records;
328
- },
329
- /** Tracked files at HEAD, bounded and filtered by a case-insensitive path substring. */
330
- async files(root, { q = "", limit = 200 } = {}) {
331
- const pageSize = Math.max(1, Math.min(200, Number(limit) || 200));
332
- // The recursive HEAD path list is bounded by the subprocess stdout cap
333
- // (8 MiB, see spawnGit). Repositories above that cap fail closed with
334
- // `git-output-too-large` (413) instead of returning a partial list; the
335
- // bound is documented in docs/03-api.md §6.19.7.
336
- let text;
337
- try { text = await run(root, ["ls-tree", "-r", "-z", "--name-only", "HEAD"]); } catch (error) {
338
- if (error?.code !== "git-command-failed") throw error;
339
- // An unborn HEAD is an empty repository, not a failure: /git/files
340
- // must answer 200 with an empty list for it.
341
- try { await run(root, ["rev-parse", "--verify", "HEAD"]); } catch (inner) {
342
- if (inner?.code === "git-command-failed") return { files: [], truncated: false };
343
- throw inner;
344
- }
345
- throw error;
346
- }
347
- const query = typeof q === "string" ? q.toLowerCase() : "";
348
- let paths = text.split("\0").filter((path) => path !== "");
349
- if (query) paths = paths.filter((path) => path.toLowerCase().includes(query));
350
- paths.sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
351
- const truncated = paths.length > pageSize;
352
- return { files: paths.slice(0, pageSize), truncated };
353
- },
354
- /**
355
- * Commits touching one file, newest first, with the change status that
356
- * commit applied to the path. Bounded by `maxCommits` or the soft
357
- * deadline; both report an explicitly truncated (partial) list.
358
- */
359
- async fileHistory(root, path, { maxCommits = 5000, timeoutMs = 20000 } = {}) {
360
- if (typeof path !== "string" || path === "" || path.includes("\0")) throw gitError("git-command-failed", 400);
361
- const deadline = Date.now() + timeoutMs;
362
- const historyRun = (args) => spawnGit(root, args, { timeoutMs: Math.max(1, deadline - Date.now()) });
363
- try {
364
- const check = await historyRun(["rev-parse", "--verify", "HEAD"]);
365
- if (check.timedOut) return { entries: [], truncated: true };
366
- } catch (error) {
367
- if (error?.code === "git-command-failed") return { entries: [], truncated: false, reason: "no-history" };
368
- throw error;
369
- }
370
- let tracked = false;
371
- try {
372
- const tree = await historyRun(["ls-tree", "-z", "HEAD", "--", `:(literal)${path}`]);
373
- if (tree.timedOut) return { entries: [], truncated: true };
374
- for (const record of tree.stdout.split("\0")) {
375
- const separator = record.indexOf("\t");
376
- if (separator < 0) continue;
377
- const entryPath = record.slice(separator + 1);
378
- const entryType = record.slice(0, separator).split(" ")[1];
379
- // Directories, gitlinks and other tree entries are not file paths;
380
- // only blobs (regular files and symlinks) have a file history.
381
- if (entryPath === path && entryType === "blob") tracked = true;
382
- }
383
- } catch (error) {
384
- if (error?.code !== "git-command-failed") throw error;
385
- }
386
- if (!tracked) return { entries: [], truncated: false, reason: "not-tracked" };
387
- const cap = Math.max(1, Math.min(5000, Number(maxCommits) || 5000));
388
- const result = await historyRun(["--literal-pathspecs", "log", `--max-count=${cap + 1}`, "--format=%x00%H%x1f%h%x1f%an%x1f%at%x1f%s", "--name-status", "-M", "-z", "--", path]);
389
- let entries = parseFileHistory(result.stdout);
390
- let truncated = result.timedOut === true;
391
- if (entries.length > cap) {
392
- entries = entries.slice(0, cap);
393
- truncated = true;
394
- }
395
- return { entries, truncated };
396
- },
397
- async worktree(root) {
398
- const text = await run(root, ["status", "--porcelain=v1", "-z", "--untracked-files=all"], true);
399
- const parts = text.split("\0"); const entries = [];
400
- for (let i = 0; i < parts.length;) {
401
- const record = parts[i++]; if (!record) continue;
402
- const code = record.slice(0, 2); let path = record.slice(3); let oldPath;
403
- if (/[RC]/.test(code)) { oldPath = parts[i++] ?? ""; }
404
- const status = code.includes("U") || code === "AA" || code === "DD" ? "conflicted" : code === "??" ? "untracked" : "modified";
405
- entries.push({ path, ...(oldPath ? { oldPath } : {}), status, conflicted: status === "conflicted", index: code[0] !== " " && code !== "??", worktree: code[1] !== " " && code !== "??" });
406
- }
407
- let signatureMaterial = text;
408
- for (const entry of entries) {
409
- if (entry.status !== "untracked" && !entry.worktree) continue;
410
- try { const target = resolve(root, entry.path); const info = await lstat(target); signatureMaterial += `\\0${entry.path}:${info.isSymbolicLink() ? "symlink" : info.isFile() ? await sampledFileSignature(target, info) : "special"}`; } catch { signatureMaterial += `\\0${entry.path}:missing`; }
411
- }
412
- try { signatureMaterial += await run(root, ["--literal-pathspecs", "diff", "--raw", "-z", "--no-abbrev", "HEAD"], true); } catch (error) { if (error?.code !== "git-command-failed") throw error; }
413
- try { signatureMaterial += await run(root, ["--literal-pathspecs", "diff", "--raw", "-z", "--no-abbrev", "--cached"], true); } catch (error) { if (error?.code !== "git-command-failed") throw error; }
414
- const signature = createHash("sha256").update(signatureMaterial).digest("hex");
415
- return { entries, signature };
416
- },
417
- async worktreePreview(root, kind, path) {
418
- const args = ["--literal-pathspecs", "diff", "--unified=999999", "--no-ext-diff", "--no-textconv", "--no-color", "--binary"];
419
- if (kind === "staged") args.push("--cached");
420
- args.push("--", path);
421
- if (kind === "untracked") {
422
- try {
423
- const target = resolve(root, path); const info = await lstat(target);
424
- if (info.isSymbolicLink()) return { diff: "", binary: false, additions: null, deletions: null, notice: "symlink preview omitted" };
425
- if (!info.isFile()) return { diff: "", binary: false, additions: null, deletions: null, notice: "special file preview omitted" };
426
- const { bytes, truncated } = await readPrefix(target, UNTRACKED_PREVIEW_MAX, info);
427
- const binary = bytes.includes(0);
428
- return { diff: binary ? "" : bytes.toString("utf8"), binary, truncated, additions: null, deletions: null, ...(binary ? { notice: "binary preview omitted" } : {}) };
429
- } catch { return { diff: "", binary: false, additions: 0, deletions: 0, notice: "unavailable" }; }
430
- }
431
- return { diff: await run(root, args, true), binary: false, additions: null, deletions: null };
432
- },
433
- async commitPreview(root, oid, path) {
434
- const commit = await this.commit(root, oid);
435
- if (!commit.parents.length) return { diff: await run(root, ["--literal-pathspecs", "diff-tree", "--root", "--no-commit-id", "-p", "-r", "--unified=999999", "--no-ext-diff", "--no-textconv", "--no-color", "--binary", oid, "--", path]), binary: false };
436
- return { diff: await run(root, ["--literal-pathspecs", "diff", "--unified=999999", "--no-ext-diff", "--no-textconv", "--no-color", "--binary", `${oid}^1`, oid, "--", path]), binary: false };
437
- },
438
- async branches(root) {
439
- const text = await run(root, ["for-each-ref", "--format=%(HEAD)%09%(refname)%09%(objectname)%09%(upstream:short)%00", "refs/heads", "refs/remotes"]);
440
- const rows = text.split("\0").map((record) => record.replace(/^[\r\n]+|[\r\n]+$/g, "")).filter(Boolean);
441
- const branches = [];
442
- for (const row of rows) {
443
- const [head, ref, oid, upstream = ""] = row.split("\t");
444
- if (ref.endsWith("/HEAD")) continue;
445
- const local = ref.startsWith("refs/heads/");
446
- let ahead = 0, behind = 0;
447
- if (local && upstream) {
448
- const counts = (await run(root, ["rev-list", "--left-right", "--count", `${ref}...${upstream}`])).trim().split(/\s+/).map(Number);
449
- [ahead, behind] = counts;
450
- }
451
- branches.push({
452
- name: ref, displayName: ref.replace(/^refs\/(?:heads|remotes)\//, ""), oid,
453
- kind: local ? "local" : "remote", current: local && head === "*",
454
- tracking: local && upstream ? `refs/remotes/${upstream}` : null, ahead, behind,
455
- });
456
- }
457
- return branches;
458
- },
459
- };
460
- }