@enbox/gitd 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (502) hide show
  1. package/LICENSE +177 -0
  2. package/README.md +134 -0
  3. package/dist/esm/ci.js +76 -0
  4. package/dist/esm/ci.js.map +1 -0
  5. package/dist/esm/cli/agent.js +86 -0
  6. package/dist/esm/cli/agent.js.map +1 -0
  7. package/dist/esm/cli/commands/ci.js +278 -0
  8. package/dist/esm/cli/commands/ci.js.map +1 -0
  9. package/dist/esm/cli/commands/clone.js +77 -0
  10. package/dist/esm/cli/commands/clone.js.map +1 -0
  11. package/dist/esm/cli/commands/daemon.js +132 -0
  12. package/dist/esm/cli/commands/daemon.js.map +1 -0
  13. package/dist/esm/cli/commands/github-api.js +36 -0
  14. package/dist/esm/cli/commands/github-api.js.map +1 -0
  15. package/dist/esm/cli/commands/init.js +69 -0
  16. package/dist/esm/cli/commands/init.js.map +1 -0
  17. package/dist/esm/cli/commands/issue.js +293 -0
  18. package/dist/esm/cli/commands/issue.js.map +1 -0
  19. package/dist/esm/cli/commands/log.js +90 -0
  20. package/dist/esm/cli/commands/log.js.map +1 -0
  21. package/dist/esm/cli/commands/migrate.js +444 -0
  22. package/dist/esm/cli/commands/migrate.js.map +1 -0
  23. package/dist/esm/cli/commands/notification.js +141 -0
  24. package/dist/esm/cli/commands/notification.js.map +1 -0
  25. package/dist/esm/cli/commands/org.js +353 -0
  26. package/dist/esm/cli/commands/org.js.map +1 -0
  27. package/dist/esm/cli/commands/patch.js +375 -0
  28. package/dist/esm/cli/commands/patch.js.map +1 -0
  29. package/dist/esm/cli/commands/registry.js +501 -0
  30. package/dist/esm/cli/commands/registry.js.map +1 -0
  31. package/dist/esm/cli/commands/release.js +197 -0
  32. package/dist/esm/cli/commands/release.js.map +1 -0
  33. package/dist/esm/cli/commands/repo.js +148 -0
  34. package/dist/esm/cli/commands/repo.js.map +1 -0
  35. package/dist/esm/cli/commands/serve.js +148 -0
  36. package/dist/esm/cli/commands/serve.js.map +1 -0
  37. package/dist/esm/cli/commands/setup.js +92 -0
  38. package/dist/esm/cli/commands/setup.js.map +1 -0
  39. package/dist/esm/cli/commands/shim.js +75 -0
  40. package/dist/esm/cli/commands/shim.js.map +1 -0
  41. package/dist/esm/cli/commands/social.js +206 -0
  42. package/dist/esm/cli/commands/social.js.map +1 -0
  43. package/dist/esm/cli/commands/web.js +36 -0
  44. package/dist/esm/cli/commands/web.js.map +1 -0
  45. package/dist/esm/cli/commands/wiki.js +185 -0
  46. package/dist/esm/cli/commands/wiki.js.map +1 -0
  47. package/dist/esm/cli/flags.js +29 -0
  48. package/dist/esm/cli/flags.js.map +1 -0
  49. package/dist/esm/cli/main.js +331 -0
  50. package/dist/esm/cli/main.js.map +1 -0
  51. package/dist/esm/cli/repo-context.js +53 -0
  52. package/dist/esm/cli/repo-context.js.map +1 -0
  53. package/dist/esm/daemon/adapter.js +18 -0
  54. package/dist/esm/daemon/adapter.js.map +1 -0
  55. package/dist/esm/daemon/adapters/github.js +112 -0
  56. package/dist/esm/daemon/adapters/github.js.map +1 -0
  57. package/dist/esm/daemon/adapters/go.js +51 -0
  58. package/dist/esm/daemon/adapters/go.js.map +1 -0
  59. package/dist/esm/daemon/adapters/index.js +32 -0
  60. package/dist/esm/daemon/adapters/index.js.map +1 -0
  61. package/dist/esm/daemon/adapters/npm.js +51 -0
  62. package/dist/esm/daemon/adapters/npm.js.map +1 -0
  63. package/dist/esm/daemon/adapters/oci.js +62 -0
  64. package/dist/esm/daemon/adapters/oci.js.map +1 -0
  65. package/dist/esm/daemon/index.js +12 -0
  66. package/dist/esm/daemon/index.js.map +1 -0
  67. package/dist/esm/daemon/server.js +167 -0
  68. package/dist/esm/daemon/server.js.map +1 -0
  69. package/dist/esm/git-remote/credential-helper.js +106 -0
  70. package/dist/esm/git-remote/credential-helper.js.map +1 -0
  71. package/dist/esm/git-remote/credential-main.js +109 -0
  72. package/dist/esm/git-remote/credential-main.js.map +1 -0
  73. package/dist/esm/git-remote/index.js +10 -0
  74. package/dist/esm/git-remote/index.js.map +1 -0
  75. package/dist/esm/git-remote/main.js +78 -0
  76. package/dist/esm/git-remote/main.js.map +1 -0
  77. package/dist/esm/git-remote/parse-url.js +60 -0
  78. package/dist/esm/git-remote/parse-url.js.map +1 -0
  79. package/dist/esm/git-remote/resolve.js +175 -0
  80. package/dist/esm/git-remote/resolve.js.map +1 -0
  81. package/dist/esm/git-remote/service.js +82 -0
  82. package/dist/esm/git-remote/service.js.map +1 -0
  83. package/dist/esm/git-server/auth.js +211 -0
  84. package/dist/esm/git-server/auth.js.map +1 -0
  85. package/dist/esm/git-server/bundle-restore.js +180 -0
  86. package/dist/esm/git-server/bundle-restore.js.map +1 -0
  87. package/dist/esm/git-server/bundle-sync.js +233 -0
  88. package/dist/esm/git-server/bundle-sync.js.map +1 -0
  89. package/dist/esm/git-server/did-service.js +73 -0
  90. package/dist/esm/git-server/did-service.js.map +1 -0
  91. package/dist/esm/git-server/git-backend.js +186 -0
  92. package/dist/esm/git-server/git-backend.js.map +1 -0
  93. package/dist/esm/git-server/http-handler.js +295 -0
  94. package/dist/esm/git-server/http-handler.js.map +1 -0
  95. package/dist/esm/git-server/index.js +16 -0
  96. package/dist/esm/git-server/index.js.map +1 -0
  97. package/dist/esm/git-server/push-authorizer.js +62 -0
  98. package/dist/esm/git-server/push-authorizer.js.map +1 -0
  99. package/dist/esm/git-server/ref-sync.js +132 -0
  100. package/dist/esm/git-server/ref-sync.js.map +1 -0
  101. package/dist/esm/git-server/server.js +185 -0
  102. package/dist/esm/git-server/server.js.map +1 -0
  103. package/dist/esm/git-server/verify.js +109 -0
  104. package/dist/esm/git-server/verify.js.map +1 -0
  105. package/dist/esm/github-shim/helpers.js +273 -0
  106. package/dist/esm/github-shim/helpers.js.map +1 -0
  107. package/dist/esm/github-shim/index.js +13 -0
  108. package/dist/esm/github-shim/index.js.map +1 -0
  109. package/dist/esm/github-shim/issues.js +318 -0
  110. package/dist/esm/github-shim/issues.js.map +1 -0
  111. package/dist/esm/github-shim/pulls.js +423 -0
  112. package/dist/esm/github-shim/pulls.js.map +1 -0
  113. package/dist/esm/github-shim/releases.js +154 -0
  114. package/dist/esm/github-shim/releases.js.map +1 -0
  115. package/dist/esm/github-shim/repos.js +86 -0
  116. package/dist/esm/github-shim/repos.js.map +1 -0
  117. package/dist/esm/github-shim/server.js +351 -0
  118. package/dist/esm/github-shim/server.js.map +1 -0
  119. package/dist/esm/github-shim/users.js +61 -0
  120. package/dist/esm/github-shim/users.js.map +1 -0
  121. package/dist/esm/index.js +26 -0
  122. package/dist/esm/index.js.map +1 -0
  123. package/dist/esm/indexer/api.js +132 -0
  124. package/dist/esm/indexer/api.js.map +1 -0
  125. package/dist/esm/indexer/crawler.js +256 -0
  126. package/dist/esm/indexer/crawler.js.map +1 -0
  127. package/dist/esm/indexer/index.js +9 -0
  128. package/dist/esm/indexer/index.js.map +1 -0
  129. package/dist/esm/indexer/main.js +76 -0
  130. package/dist/esm/indexer/main.js.map +1 -0
  131. package/dist/esm/indexer/store.js +334 -0
  132. package/dist/esm/indexer/store.js.map +1 -0
  133. package/dist/esm/issues.js +133 -0
  134. package/dist/esm/issues.js.map +1 -0
  135. package/dist/esm/notifications.js +47 -0
  136. package/dist/esm/notifications.js.map +1 -0
  137. package/dist/esm/org.js +90 -0
  138. package/dist/esm/org.js.map +1 -0
  139. package/dist/esm/patches.js +136 -0
  140. package/dist/esm/patches.js.map +1 -0
  141. package/dist/esm/refs.js +54 -0
  142. package/dist/esm/refs.js.map +1 -0
  143. package/dist/esm/registry.js +81 -0
  144. package/dist/esm/registry.js.map +1 -0
  145. package/dist/esm/releases.js +78 -0
  146. package/dist/esm/releases.js.map +1 -0
  147. package/dist/esm/repo.js +150 -0
  148. package/dist/esm/repo.js.map +1 -0
  149. package/dist/esm/resolver/index.js +10 -0
  150. package/dist/esm/resolver/index.js.map +1 -0
  151. package/dist/esm/resolver/resolve.js +189 -0
  152. package/dist/esm/resolver/resolve.js.map +1 -0
  153. package/dist/esm/resolver/trust-chain.js +155 -0
  154. package/dist/esm/resolver/trust-chain.js.map +1 -0
  155. package/dist/esm/resolver/verify.js +186 -0
  156. package/dist/esm/resolver/verify.js.map +1 -0
  157. package/dist/esm/shims/go/index.js +9 -0
  158. package/dist/esm/shims/go/index.js.map +1 -0
  159. package/dist/esm/shims/go/proxy.js +275 -0
  160. package/dist/esm/shims/go/proxy.js.map +1 -0
  161. package/dist/esm/shims/go/server.js +70 -0
  162. package/dist/esm/shims/go/server.js.map +1 -0
  163. package/dist/esm/shims/index.js +15 -0
  164. package/dist/esm/shims/index.js.map +1 -0
  165. package/dist/esm/shims/npm/index.js +9 -0
  166. package/dist/esm/shims/npm/index.js.map +1 -0
  167. package/dist/esm/shims/npm/registry.js +234 -0
  168. package/dist/esm/shims/npm/registry.js.map +1 -0
  169. package/dist/esm/shims/npm/server.js +72 -0
  170. package/dist/esm/shims/npm/server.js.map +1 -0
  171. package/dist/esm/shims/oci/index.js +9 -0
  172. package/dist/esm/shims/oci/index.js.map +1 -0
  173. package/dist/esm/shims/oci/registry.js +276 -0
  174. package/dist/esm/shims/oci/registry.js.map +1 -0
  175. package/dist/esm/shims/oci/server.js +82 -0
  176. package/dist/esm/shims/oci/server.js.map +1 -0
  177. package/dist/esm/social.js +70 -0
  178. package/dist/esm/social.js.map +1 -0
  179. package/dist/esm/web/html.js +123 -0
  180. package/dist/esm/web/html.js.map +1 -0
  181. package/dist/esm/web/index.js +7 -0
  182. package/dist/esm/web/index.js.map +1 -0
  183. package/dist/esm/web/routes.js +420 -0
  184. package/dist/esm/web/routes.js.map +1 -0
  185. package/dist/esm/web/server.js +225 -0
  186. package/dist/esm/web/server.js.map +1 -0
  187. package/dist/esm/wiki.js +63 -0
  188. package/dist/esm/wiki.js.map +1 -0
  189. package/dist/types/ci.d.ts +203 -0
  190. package/dist/types/ci.d.ts.map +1 -0
  191. package/dist/types/cli/agent.d.ts +59 -0
  192. package/dist/types/cli/agent.d.ts.map +1 -0
  193. package/dist/types/cli/commands/ci.d.ts +16 -0
  194. package/dist/types/cli/commands/ci.d.ts.map +1 -0
  195. package/dist/types/cli/commands/clone.d.ts +13 -0
  196. package/dist/types/cli/commands/clone.d.ts.map +1 -0
  197. package/dist/types/cli/commands/daemon.d.ts +29 -0
  198. package/dist/types/cli/commands/daemon.d.ts.map +1 -0
  199. package/dist/types/cli/commands/github-api.d.ts +14 -0
  200. package/dist/types/cli/commands/github-api.d.ts.map +1 -0
  201. package/dist/types/cli/commands/init.d.ts +11 -0
  202. package/dist/types/cli/commands/init.d.ts.map +1 -0
  203. package/dist/types/cli/commands/issue.d.ts +16 -0
  204. package/dist/types/cli/commands/issue.d.ts.map +1 -0
  205. package/dist/types/cli/commands/log.d.ts +13 -0
  206. package/dist/types/cli/commands/log.d.ts.map +1 -0
  207. package/dist/types/cli/commands/migrate.d.ts +19 -0
  208. package/dist/types/cli/commands/migrate.d.ts.map +1 -0
  209. package/dist/types/cli/commands/notification.d.ts +16 -0
  210. package/dist/types/cli/commands/notification.d.ts.map +1 -0
  211. package/dist/types/cli/commands/org.d.ts +19 -0
  212. package/dist/types/cli/commands/org.d.ts.map +1 -0
  213. package/dist/types/cli/commands/patch.d.ts +17 -0
  214. package/dist/types/cli/commands/patch.d.ts.map +1 -0
  215. package/dist/types/cli/commands/registry.d.ts +25 -0
  216. package/dist/types/cli/commands/registry.d.ts.map +1 -0
  217. package/dist/types/cli/commands/release.d.ts +13 -0
  218. package/dist/types/cli/commands/release.d.ts.map +1 -0
  219. package/dist/types/cli/commands/repo.d.ts +15 -0
  220. package/dist/types/cli/commands/repo.d.ts.map +1 -0
  221. package/dist/types/cli/commands/serve.d.ts +22 -0
  222. package/dist/types/cli/commands/serve.d.ts.map +1 -0
  223. package/dist/types/cli/commands/setup.d.ts +16 -0
  224. package/dist/types/cli/commands/setup.d.ts.map +1 -0
  225. package/dist/types/cli/commands/shim.d.ts +16 -0
  226. package/dist/types/cli/commands/shim.d.ts.map +1 -0
  227. package/dist/types/cli/commands/social.d.ts +19 -0
  228. package/dist/types/cli/commands/social.d.ts.map +1 -0
  229. package/dist/types/cli/commands/web.d.ts +14 -0
  230. package/dist/types/cli/commands/web.d.ts.map +1 -0
  231. package/dist/types/cli/commands/wiki.d.ts +14 -0
  232. package/dist/types/cli/commands/wiki.d.ts.map +1 -0
  233. package/dist/types/cli/flags.d.ts +16 -0
  234. package/dist/types/cli/flags.d.ts.map +1 -0
  235. package/dist/types/cli/main.d.ts +69 -0
  236. package/dist/types/cli/main.d.ts.map +1 -0
  237. package/dist/types/cli/repo-context.d.ts +30 -0
  238. package/dist/types/cli/repo-context.d.ts.map +1 -0
  239. package/dist/types/daemon/adapter.d.ts +74 -0
  240. package/dist/types/daemon/adapter.d.ts.map +1 -0
  241. package/dist/types/daemon/adapters/github.d.ts +10 -0
  242. package/dist/types/daemon/adapters/github.d.ts.map +1 -0
  243. package/dist/types/daemon/adapters/go.d.ts +10 -0
  244. package/dist/types/daemon/adapters/go.d.ts.map +1 -0
  245. package/dist/types/daemon/adapters/index.d.ts +22 -0
  246. package/dist/types/daemon/adapters/index.d.ts.map +1 -0
  247. package/dist/types/daemon/adapters/npm.d.ts +10 -0
  248. package/dist/types/daemon/adapters/npm.d.ts.map +1 -0
  249. package/dist/types/daemon/adapters/oci.d.ts +10 -0
  250. package/dist/types/daemon/adapters/oci.d.ts.map +1 -0
  251. package/dist/types/daemon/index.d.ts +14 -0
  252. package/dist/types/daemon/index.d.ts.map +1 -0
  253. package/dist/types/daemon/server.d.ts +55 -0
  254. package/dist/types/daemon/server.d.ts.map +1 -0
  255. package/dist/types/git-remote/credential-helper.d.ts +49 -0
  256. package/dist/types/git-remote/credential-helper.d.ts.map +1 -0
  257. package/dist/types/git-remote/credential-main.d.ts +24 -0
  258. package/dist/types/git-remote/credential-main.d.ts.map +1 -0
  259. package/dist/types/git-remote/index.d.ts +10 -0
  260. package/dist/types/git-remote/index.d.ts.map +1 -0
  261. package/dist/types/git-remote/main.d.ts +23 -0
  262. package/dist/types/git-remote/main.d.ts.map +1 -0
  263. package/dist/types/git-remote/parse-url.d.ts +32 -0
  264. package/dist/types/git-remote/parse-url.d.ts.map +1 -0
  265. package/dist/types/git-remote/resolve.d.ts +30 -0
  266. package/dist/types/git-remote/resolve.d.ts.map +1 -0
  267. package/dist/types/git-remote/service.d.ts +75 -0
  268. package/dist/types/git-remote/service.d.ts.map +1 -0
  269. package/dist/types/git-server/auth.d.ts +129 -0
  270. package/dist/types/git-server/auth.d.ts.map +1 -0
  271. package/dist/types/git-server/bundle-restore.d.ts +48 -0
  272. package/dist/types/git-server/bundle-restore.d.ts.map +1 -0
  273. package/dist/types/git-server/bundle-sync.d.ts +90 -0
  274. package/dist/types/git-server/bundle-sync.d.ts.map +1 -0
  275. package/dist/types/git-server/did-service.d.ts +26 -0
  276. package/dist/types/git-server/did-service.d.ts.map +1 -0
  277. package/dist/types/git-server/git-backend.d.ts +84 -0
  278. package/dist/types/git-server/git-backend.d.ts.map +1 -0
  279. package/dist/types/git-server/http-handler.d.ts +73 -0
  280. package/dist/types/git-server/http-handler.d.ts.map +1 -0
  281. package/dist/types/git-server/index.d.ts +16 -0
  282. package/dist/types/git-server/index.d.ts.map +1 -0
  283. package/dist/types/git-server/push-authorizer.d.ts +38 -0
  284. package/dist/types/git-server/push-authorizer.d.ts.map +1 -0
  285. package/dist/types/git-server/ref-sync.d.ts +52 -0
  286. package/dist/types/git-server/ref-sync.d.ts.map +1 -0
  287. package/dist/types/git-server/server.d.ts +70 -0
  288. package/dist/types/git-server/server.d.ts.map +1 -0
  289. package/dist/types/git-server/verify.d.ts +12 -0
  290. package/dist/types/git-server/verify.d.ts.map +1 -0
  291. package/dist/types/github-shim/helpers.d.ts +108 -0
  292. package/dist/types/github-shim/helpers.d.ts.map +1 -0
  293. package/dist/types/github-shim/index.d.ts +15 -0
  294. package/dist/types/github-shim/index.d.ts.map +1 -0
  295. package/dist/types/github-shim/issues.d.ts +24 -0
  296. package/dist/types/github-shim/issues.d.ts.map +1 -0
  297. package/dist/types/github-shim/pulls.d.ts +31 -0
  298. package/dist/types/github-shim/pulls.d.ts.map +1 -0
  299. package/dist/types/github-shim/releases.d.ts +18 -0
  300. package/dist/types/github-shim/releases.d.ts.map +1 -0
  301. package/dist/types/github-shim/repos.d.ts +21 -0
  302. package/dist/types/github-shim/repos.d.ts.map +1 -0
  303. package/dist/types/github-shim/server.d.ts +53 -0
  304. package/dist/types/github-shim/server.d.ts.map +1 -0
  305. package/dist/types/github-shim/users.d.ts +17 -0
  306. package/dist/types/github-shim/users.d.ts.map +1 -0
  307. package/dist/types/index.d.ts +26 -0
  308. package/dist/types/index.d.ts.map +1 -0
  309. package/dist/types/indexer/api.d.ts +32 -0
  310. package/dist/types/indexer/api.d.ts.map +1 -0
  311. package/dist/types/indexer/crawler.d.ts +72 -0
  312. package/dist/types/indexer/crawler.d.ts.map +1 -0
  313. package/dist/types/indexer/index.d.ts +12 -0
  314. package/dist/types/indexer/index.d.ts.map +1 -0
  315. package/dist/types/indexer/main.d.ts +21 -0
  316. package/dist/types/indexer/main.d.ts.map +1 -0
  317. package/dist/types/indexer/store.d.ts +168 -0
  318. package/dist/types/indexer/store.d.ts.map +1 -0
  319. package/dist/types/issues.d.ts +395 -0
  320. package/dist/types/issues.d.ts.map +1 -0
  321. package/dist/types/notifications.d.ts +93 -0
  322. package/dist/types/notifications.d.ts.map +1 -0
  323. package/dist/types/org.d.ts +232 -0
  324. package/dist/types/org.d.ts.map +1 -0
  325. package/dist/types/patches.d.ts +410 -0
  326. package/dist/types/patches.d.ts.map +1 -0
  327. package/dist/types/refs.d.ts +114 -0
  328. package/dist/types/refs.d.ts.map +1 -0
  329. package/dist/types/registry.d.ts +212 -0
  330. package/dist/types/registry.d.ts.map +1 -0
  331. package/dist/types/releases.d.ts +204 -0
  332. package/dist/types/releases.d.ts.map +1 -0
  333. package/dist/types/repo.d.ts +450 -0
  334. package/dist/types/repo.d.ts.map +1 -0
  335. package/dist/types/resolver/index.d.ts +13 -0
  336. package/dist/types/resolver/index.d.ts.map +1 -0
  337. package/dist/types/resolver/resolve.d.ts +80 -0
  338. package/dist/types/resolver/resolve.d.ts.map +1 -0
  339. package/dist/types/resolver/trust-chain.d.ts +54 -0
  340. package/dist/types/resolver/trust-chain.d.ts.map +1 -0
  341. package/dist/types/resolver/verify.d.ts +62 -0
  342. package/dist/types/resolver/verify.d.ts.map +1 -0
  343. package/dist/types/shims/go/index.d.ts +11 -0
  344. package/dist/types/shims/go/index.d.ts.map +1 -0
  345. package/dist/types/shims/go/proxy.d.ts +51 -0
  346. package/dist/types/shims/go/proxy.d.ts.map +1 -0
  347. package/dist/types/shims/go/server.d.ts +23 -0
  348. package/dist/types/shims/go/server.d.ts.map +1 -0
  349. package/dist/types/shims/index.d.ts +18 -0
  350. package/dist/types/shims/index.d.ts.map +1 -0
  351. package/dist/types/shims/npm/index.d.ts +11 -0
  352. package/dist/types/shims/npm/index.d.ts.map +1 -0
  353. package/dist/types/shims/npm/registry.d.ts +46 -0
  354. package/dist/types/shims/npm/registry.d.ts.map +1 -0
  355. package/dist/types/shims/npm/server.d.ts +23 -0
  356. package/dist/types/shims/npm/server.d.ts.map +1 -0
  357. package/dist/types/shims/oci/index.d.ts +11 -0
  358. package/dist/types/shims/oci/index.d.ts.map +1 -0
  359. package/dist/types/shims/oci/registry.d.ts +56 -0
  360. package/dist/types/shims/oci/registry.d.ts.map +1 -0
  361. package/dist/types/shims/oci/server.d.ts +23 -0
  362. package/dist/types/shims/oci/server.d.ts.map +1 -0
  363. package/dist/types/social.d.ts +162 -0
  364. package/dist/types/social.d.ts.map +1 -0
  365. package/dist/types/web/html.d.ts +23 -0
  366. package/dist/types/web/html.d.ts.map +1 -0
  367. package/dist/types/web/index.d.ts +8 -0
  368. package/dist/types/web/index.d.ts.map +1 -0
  369. package/dist/types/web/routes.d.ts +21 -0
  370. package/dist/types/web/routes.d.ts.map +1 -0
  371. package/dist/types/web/server.d.ts +38 -0
  372. package/dist/types/web/server.d.ts.map +1 -0
  373. package/dist/types/wiki.d.ts +143 -0
  374. package/dist/types/wiki.d.ts.map +1 -0
  375. package/package.json +108 -0
  376. package/schemas/ci/check-run.json +23 -0
  377. package/schemas/ci/check-suite.json +23 -0
  378. package/schemas/issues/assignment.json +17 -0
  379. package/schemas/issues/comment.json +14 -0
  380. package/schemas/issues/issue.json +20 -0
  381. package/schemas/issues/label.json +17 -0
  382. package/schemas/issues/reaction.json +14 -0
  383. package/schemas/issues/status-change.json +14 -0
  384. package/schemas/notifications/notification.json +20 -0
  385. package/schemas/org/org-member.json +17 -0
  386. package/schemas/org/org.json +26 -0
  387. package/schemas/org/team-member.json +17 -0
  388. package/schemas/org/team.json +17 -0
  389. package/schemas/patches/merge-result.json +14 -0
  390. package/schemas/patches/patch-status-change.json +14 -0
  391. package/schemas/patches/patch.json +20 -0
  392. package/schemas/patches/review-comment.json +17 -0
  393. package/schemas/patches/review.json +14 -0
  394. package/schemas/patches/revision.json +30 -0
  395. package/schemas/refs/git-ref.json +32 -0
  396. package/schemas/registry/attestation.json +23 -0
  397. package/schemas/registry/package-version.json +23 -0
  398. package/schemas/registry/package.json +32 -0
  399. package/schemas/releases/release.json +17 -0
  400. package/schemas/repo/collaborator.json +17 -0
  401. package/schemas/repo/repo.json +35 -0
  402. package/schemas/repo/settings.json +39 -0
  403. package/schemas/repo/topic.json +14 -0
  404. package/schemas/repo/webhook.json +26 -0
  405. package/schemas/social/activity.json +23 -0
  406. package/schemas/social/follow.json +17 -0
  407. package/schemas/social/star.json +20 -0
  408. package/schemas/wiki/wiki-history.json +20 -0
  409. package/schemas/wiki/wiki-page.json +17 -0
  410. package/src/ci.ts +118 -0
  411. package/src/cli/agent.ts +117 -0
  412. package/src/cli/commands/ci.ts +300 -0
  413. package/src/cli/commands/clone.ts +78 -0
  414. package/src/cli/commands/daemon.ts +129 -0
  415. package/src/cli/commands/github-api.ts +30 -0
  416. package/src/cli/commands/init.ts +69 -0
  417. package/src/cli/commands/issue.ts +321 -0
  418. package/src/cli/commands/log.ts +106 -0
  419. package/src/cli/commands/migrate.ts +525 -0
  420. package/src/cli/commands/notification.ts +148 -0
  421. package/src/cli/commands/org.ts +381 -0
  422. package/src/cli/commands/patch.ts +413 -0
  423. package/src/cli/commands/registry.ts +542 -0
  424. package/src/cli/commands/release.ts +189 -0
  425. package/src/cli/commands/repo.ts +160 -0
  426. package/src/cli/commands/serve.ts +153 -0
  427. package/src/cli/commands/setup.ts +97 -0
  428. package/src/cli/commands/shim.ts +79 -0
  429. package/src/cli/commands/social.ts +221 -0
  430. package/src/cli/commands/web.ts +30 -0
  431. package/src/cli/commands/wiki.ts +199 -0
  432. package/src/cli/flags.ts +28 -0
  433. package/src/cli/main.ts +350 -0
  434. package/src/cli/repo-context.ts +55 -0
  435. package/src/daemon/adapter.ts +95 -0
  436. package/src/daemon/adapters/github.ts +86 -0
  437. package/src/daemon/adapters/go.ts +47 -0
  438. package/src/daemon/adapters/index.ts +36 -0
  439. package/src/daemon/adapters/npm.ts +47 -0
  440. package/src/daemon/adapters/oci.ts +59 -0
  441. package/src/daemon/index.ts +16 -0
  442. package/src/daemon/server.ts +204 -0
  443. package/src/git-remote/credential-helper.ts +114 -0
  444. package/src/git-remote/credential-main.ts +118 -0
  445. package/src/git-remote/index.ts +10 -0
  446. package/src/git-remote/main.ts +74 -0
  447. package/src/git-remote/parse-url.ts +81 -0
  448. package/src/git-remote/resolve.ts +207 -0
  449. package/src/git-remote/service.ts +126 -0
  450. package/src/git-server/auth.ts +308 -0
  451. package/src/git-server/bundle-restore.ts +217 -0
  452. package/src/git-server/bundle-sync.ts +300 -0
  453. package/src/git-server/did-service.ts +77 -0
  454. package/src/git-server/git-backend.ts +222 -0
  455. package/src/git-server/http-handler.ts +386 -0
  456. package/src/git-server/index.ts +16 -0
  457. package/src/git-server/push-authorizer.ts +77 -0
  458. package/src/git-server/ref-sync.ts +166 -0
  459. package/src/git-server/server.ts +236 -0
  460. package/src/git-server/verify.ts +116 -0
  461. package/src/github-shim/helpers.ts +311 -0
  462. package/src/github-shim/index.ts +35 -0
  463. package/src/github-shim/issues.ts +389 -0
  464. package/src/github-shim/pulls.ts +500 -0
  465. package/src/github-shim/releases.ts +185 -0
  466. package/src/github-shim/repos.ts +95 -0
  467. package/src/github-shim/server.ts +334 -0
  468. package/src/github-shim/users.ts +63 -0
  469. package/src/index.ts +26 -0
  470. package/src/indexer/api.ts +162 -0
  471. package/src/indexer/crawler.ts +290 -0
  472. package/src/indexer/index.ts +22 -0
  473. package/src/indexer/main.ts +83 -0
  474. package/src/indexer/store.ts +408 -0
  475. package/src/issues.ts +200 -0
  476. package/src/notifications.ts +80 -0
  477. package/src/org.ts +147 -0
  478. package/src/patches.ts +203 -0
  479. package/src/refs.ts +94 -0
  480. package/src/registry.ts +132 -0
  481. package/src/releases.ts +124 -0
  482. package/src/repo.ts +234 -0
  483. package/src/resolver/index.ts +42 -0
  484. package/src/resolver/resolve.ts +244 -0
  485. package/src/resolver/trust-chain.ts +217 -0
  486. package/src/resolver/verify.ts +237 -0
  487. package/src/shims/go/index.ts +14 -0
  488. package/src/shims/go/proxy.ts +336 -0
  489. package/src/shims/go/server.ts +82 -0
  490. package/src/shims/index.ts +20 -0
  491. package/src/shims/npm/index.ts +14 -0
  492. package/src/shims/npm/registry.ts +288 -0
  493. package/src/shims/npm/server.ts +84 -0
  494. package/src/shims/oci/index.ts +14 -0
  495. package/src/shims/oci/registry.ts +334 -0
  496. package/src/shims/oci/server.ts +94 -0
  497. package/src/social.ts +116 -0
  498. package/src/web/html.ts +120 -0
  499. package/src/web/index.ts +8 -0
  500. package/src/web/routes.ts +449 -0
  501. package/src/web/server.ts +256 -0
  502. package/src/wiki.ts +102 -0
@@ -0,0 +1,525 @@
1
+ /**
2
+ * `gitd migrate` — import repository data from GitHub.
3
+ *
4
+ * Fetches repo metadata, issues, pull requests, and releases from the
5
+ * GitHub REST API and creates corresponding DWN records. A `GITHUB_TOKEN`
6
+ * env var is recommended for authenticated requests (higher rate limits).
7
+ *
8
+ * Usage:
9
+ * gitd migrate all <owner/repo> Import everything
10
+ * gitd migrate repo <owner/repo> Import repo metadata only
11
+ * gitd migrate issues <owner/repo> Import issues + comments
12
+ * gitd migrate pulls <owner/repo> Import PRs as patches + reviews
13
+ * gitd migrate releases <owner/repo> Import releases
14
+ *
15
+ * @module
16
+ */
17
+
18
+ import type { AgentContext } from '../agent.js';
19
+
20
+ import { getRepoContextId } from '../repo-context.js';
21
+
22
+ // ---------------------------------------------------------------------------
23
+ // GitHub API helpers
24
+ // ---------------------------------------------------------------------------
25
+
26
+ const GITHUB_API = 'https://api.github.com';
27
+
28
+ /** Headers for GitHub API requests. */
29
+ function githubHeaders(): Record<string, string> {
30
+ const headers: Record<string, string> = {
31
+ 'Accept' : 'application/vnd.github+json',
32
+ 'User-Agent' : 'gitd-migrate/0.1',
33
+ };
34
+ const token = process.env.GITHUB_TOKEN;
35
+ if (token) { headers['Authorization'] = `Bearer ${token}`; }
36
+ return headers;
37
+ }
38
+
39
+ /** Fetch a single page from the GitHub API. Throws on non-2xx. */
40
+ async function ghFetch<T>(path: string): Promise<T> {
41
+ const url = `${GITHUB_API}${path}`;
42
+ const res = await fetch(url, { headers: githubHeaders() });
43
+ if (!res.ok) {
44
+ const body = await res.text();
45
+ throw new Error(`GitHub API ${res.status}: ${body.slice(0, 200)}`);
46
+ }
47
+ return res.json() as Promise<T>;
48
+ }
49
+
50
+ /**
51
+ * Fetch all pages of a paginated GitHub API endpoint.
52
+ * GitHub uses Link headers for pagination.
53
+ */
54
+ async function ghFetchAll<T>(path: string, perPage = 100): Promise<T[]> {
55
+ const all: T[] = [];
56
+ let url: string | null = `${GITHUB_API}${path}${path.includes('?') ? '&' : '?'}per_page=${perPage}`;
57
+
58
+ while (url) {
59
+ const res: Response = await fetch(url, { headers: githubHeaders() });
60
+ if (!res.ok) {
61
+ const body = await res.text();
62
+ throw new Error(`GitHub API ${res.status}: ${body.slice(0, 200)}`);
63
+ }
64
+
65
+ const items = await res.json() as T[];
66
+ all.push(...items);
67
+
68
+ // Parse Link header for next page.
69
+ const link: string | null = res.headers.get('link');
70
+ const next: string | undefined = link?.split(',').find((s: string) => s.includes('rel="next"'));
71
+ url = next ? next.match(/<([^>]+)>/)?.[1] ?? null : null;
72
+ }
73
+
74
+ return all;
75
+ }
76
+
77
+ // ---------------------------------------------------------------------------
78
+ // GitHub API types (minimal — only fields we use)
79
+ // ---------------------------------------------------------------------------
80
+
81
+ type GhRepo = {
82
+ name : string;
83
+ description : string | null;
84
+ default_branch : string;
85
+ private : boolean;
86
+ html_url : string;
87
+ topics : string[];
88
+ };
89
+
90
+ type GhIssue = {
91
+ number : number;
92
+ title : string;
93
+ body : string | null;
94
+ state : string;
95
+ user : { login: string } | null;
96
+ created_at : string;
97
+ pull_request?: unknown;
98
+ };
99
+
100
+ type GhComment = {
101
+ body : string | null;
102
+ user : { login: string } | null;
103
+ created_at : string;
104
+ };
105
+
106
+ type GhPull = {
107
+ number : number;
108
+ title : string;
109
+ body : string | null;
110
+ state : string;
111
+ merged : boolean;
112
+ user : { login: string } | null;
113
+ base : { ref: string };
114
+ head : { ref: string };
115
+ created_at : string;
116
+ };
117
+
118
+ type GhReview = {
119
+ body : string | null;
120
+ state : string;
121
+ user : { login: string } | null;
122
+ submitted_at : string;
123
+ };
124
+
125
+ type GhRelease = {
126
+ tag_name : string;
127
+ name : string | null;
128
+ body : string | null;
129
+ prerelease : boolean;
130
+ draft : boolean;
131
+ target_commitish : string;
132
+ created_at : string;
133
+ };
134
+
135
+ // ---------------------------------------------------------------------------
136
+ // Sub-command dispatch
137
+ // ---------------------------------------------------------------------------
138
+
139
+ export async function migrateCommand(ctx: AgentContext, args: string[]): Promise<void> {
140
+ const sub = args[0];
141
+ const rest = args.slice(1);
142
+
143
+ switch (sub) {
144
+ case 'all': return migrateAll(ctx, rest);
145
+ case 'repo': return migrateRepo(ctx, rest);
146
+ case 'issues': return migrateIssues(ctx, rest);
147
+ case 'pulls': return migratePulls(ctx, rest);
148
+ case 'releases': return migrateReleases(ctx, rest);
149
+ default:
150
+ console.error('Usage: gitd migrate <all|repo|issues|pulls|releases> <owner/repo>');
151
+ process.exit(1);
152
+ }
153
+ }
154
+
155
+ // ---------------------------------------------------------------------------
156
+ // Parse <owner/repo> argument
157
+ // ---------------------------------------------------------------------------
158
+
159
+ function parseGhRepo(args: string[]): { owner: string; repo: string } {
160
+ const target = args[0];
161
+ if (!target || !target.includes('/')) {
162
+ console.error('Usage: gitd migrate <subcommand> <owner/repo>');
163
+ process.exit(1);
164
+ }
165
+
166
+ const [owner, ...repoParts] = target.split('/');
167
+ const repo = repoParts.join('/');
168
+
169
+ if (!owner || !repo) {
170
+ console.error('Invalid repository format. Use: owner/repo');
171
+ process.exit(1);
172
+ }
173
+
174
+ return { owner, repo };
175
+ }
176
+
177
+ /**
178
+ * Prepend a GitHub author attribution line to the body text.
179
+ * This preserves provenance when migrating records whose protocols
180
+ * don't have an `author` tag.
181
+ */
182
+ function prependAuthor(body: string, ghLogin: string): string {
183
+ return `[migrated from GitHub — @${ghLogin}]\n\n${body}`;
184
+ }
185
+
186
+ // ---------------------------------------------------------------------------
187
+ // migrate all
188
+ // ---------------------------------------------------------------------------
189
+
190
+ async function migrateAll(ctx: AgentContext, args: string[]): Promise<void> {
191
+ const { owner, repo } = parseGhRepo(args);
192
+ const slug = `${owner}/${repo}`;
193
+
194
+ console.log(`Migrating ${slug} from GitHub...\n`);
195
+
196
+ try {
197
+ // Step 1: repo metadata.
198
+ await migrateRepoInner(ctx, owner, repo);
199
+
200
+ // Step 2: issues + comments.
201
+ const issueCount = await migrateIssuesInner(ctx, owner, repo);
202
+
203
+ // Step 3: pull requests + reviews.
204
+ const pullCount = await migratePullsInner(ctx, owner, repo);
205
+
206
+ // Step 4: releases.
207
+ const releaseCount = await migrateReleasesInner(ctx, owner, repo);
208
+
209
+ console.log(`\nMigration complete: ${slug}`);
210
+ console.log(` Issues: ${issueCount}`);
211
+ console.log(` Patches: ${pullCount}`);
212
+ console.log(` Releases: ${releaseCount}`);
213
+ } catch (err) {
214
+ console.error(`Migration failed: ${(err as Error).message}`);
215
+ process.exit(1);
216
+ }
217
+ }
218
+
219
+ // ---------------------------------------------------------------------------
220
+ // migrate repo
221
+ // ---------------------------------------------------------------------------
222
+
223
+ async function migrateRepo(ctx: AgentContext, args: string[]): Promise<void> {
224
+ const { owner, repo } = parseGhRepo(args);
225
+ try {
226
+ await migrateRepoInner(ctx, owner, repo);
227
+ } catch (err) {
228
+ console.error(`Failed to migrate repo: ${(err as Error).message}`);
229
+ process.exit(1);
230
+ }
231
+ }
232
+
233
+ async function migrateRepoInner(ctx: AgentContext, owner: string, repo: string): Promise<void> {
234
+ const slug = `${owner}/${repo}`;
235
+ console.log(`Importing repo metadata from ${slug}...`);
236
+
237
+ // Check if a repo record already exists.
238
+ const { records: existing } = await ctx.repo.records.query('repo');
239
+ if (existing.length > 0) {
240
+ const data = await existing[0].data.json();
241
+ console.log(` Repo record already exists: "${data.name}" — skipping.`);
242
+ return;
243
+ }
244
+
245
+ const gh = await ghFetch<GhRepo>(`/repos/${owner}/${repo}`);
246
+
247
+ const { status, record } = await ctx.repo.records.create('repo', {
248
+ data: {
249
+ name : gh.name,
250
+ description : gh.description ?? '',
251
+ defaultBranch : gh.default_branch,
252
+ dwnEndpoints : [],
253
+ },
254
+ tags: {
255
+ name : gh.name,
256
+ visibility : gh.private ? 'private' : 'public',
257
+ },
258
+ });
259
+
260
+ if (status.code >= 300) {
261
+ console.error(` Failed to create repo: ${status.code} ${status.detail}`);
262
+ process.exit(1);
263
+ }
264
+
265
+ console.log(` Created repo "${gh.name}" (${gh.private ? 'private' : 'public'})`);
266
+ console.log(` Record ID: ${record.id}`);
267
+ console.log(` Source: ${gh.html_url}`);
268
+ }
269
+
270
+ // ---------------------------------------------------------------------------
271
+ // migrate issues
272
+ // ---------------------------------------------------------------------------
273
+
274
+ async function migrateIssues(ctx: AgentContext, args: string[]): Promise<void> {
275
+ const { owner, repo } = parseGhRepo(args);
276
+ try {
277
+ const count = await migrateIssuesInner(ctx, owner, repo);
278
+ console.log(`\nImported ${count} issue${count !== 1 ? 's' : ''}.`);
279
+ } catch (err) {
280
+ console.error(`Failed to migrate issues: ${(err as Error).message}`);
281
+ process.exit(1);
282
+ }
283
+ }
284
+
285
+ async function migrateIssuesInner(ctx: AgentContext, owner: string, repo: string): Promise<number> {
286
+ const slug = `${owner}/${repo}`;
287
+ const importComments = !process.env.GITD_MIGRATE_SKIP_COMMENTS;
288
+ console.log(`Importing issues from ${slug}...`);
289
+
290
+ const repoContextId = await getRepoContextId(ctx);
291
+
292
+ // Fetch all issues (GitHub API returns PRs as issues too — filter them out).
293
+ const allIssues = await ghFetchAll<GhIssue>(`/repos/${owner}/${repo}/issues?state=all&sort=created&direction=asc`);
294
+ const issues = allIssues.filter((i) => !i.pull_request);
295
+
296
+ if (issues.length === 0) {
297
+ console.log(' No issues found.');
298
+ return 0;
299
+ }
300
+
301
+ let imported = 0;
302
+
303
+ for (const ghIssue of issues) {
304
+ const author = ghIssue.user?.login ?? 'unknown';
305
+ const body = prependAuthor(ghIssue.body ?? '', author);
306
+
307
+ const { status: issueStatus, record: issueRecord } = await ctx.issues.records.create('repo/issue', {
308
+ data : { title: ghIssue.title, body, number: ghIssue.number },
309
+ tags : { status: ghIssue.state === 'open' ? 'open' : 'closed', number: String(ghIssue.number) },
310
+ parentContextId : repoContextId,
311
+ });
312
+
313
+ if (issueStatus.code >= 300) {
314
+ console.error(` Failed to import issue #${ghIssue.number}: ${issueStatus.code} ${issueStatus.detail}`);
315
+ continue;
316
+ }
317
+
318
+ imported++;
319
+
320
+ // Import comments.
321
+ if (importComments) {
322
+ const comments = await ghFetchAll<GhComment>(`/repos/${owner}/${repo}/issues/${ghIssue.number}/comments`);
323
+ let commentCount = 0;
324
+
325
+ for (const ghComment of comments) {
326
+ const commentAuthor = ghComment.user?.login ?? 'unknown';
327
+ const commentBody = prependAuthor(ghComment.body ?? '', commentAuthor);
328
+
329
+ const { status: commentStatus } = await ctx.issues.records.create('repo/issue/comment' as any, {
330
+ data : { body: commentBody },
331
+ parentContextId : issueRecord.contextId,
332
+ } as any);
333
+
334
+ if (commentStatus.code >= 300) {
335
+ console.error(` Failed to import comment on issue #${ghIssue.number}: ${commentStatus.code}`);
336
+ continue;
337
+ }
338
+ commentCount++;
339
+ }
340
+
341
+ if (commentCount > 0) {
342
+ console.log(` #${ghIssue.number} "${ghIssue.title}" (${ghIssue.state}, ${commentCount} comment${commentCount !== 1 ? 's' : ''})`);
343
+ } else {
344
+ console.log(` #${ghIssue.number} "${ghIssue.title}" (${ghIssue.state})`);
345
+ }
346
+ } else {
347
+ console.log(` #${ghIssue.number} "${ghIssue.title}" (${ghIssue.state})`);
348
+ }
349
+ }
350
+
351
+ return imported;
352
+ }
353
+
354
+ // ---------------------------------------------------------------------------
355
+ // migrate pulls
356
+ // ---------------------------------------------------------------------------
357
+
358
+ async function migratePulls(ctx: AgentContext, args: string[]): Promise<void> {
359
+ const { owner, repo } = parseGhRepo(args);
360
+ try {
361
+ const count = await migratePullsInner(ctx, owner, repo);
362
+ console.log(`\nImported ${count} patch${count !== 1 ? 'es' : ''}.`);
363
+ } catch (err) {
364
+ console.error(`Failed to migrate pull requests: ${(err as Error).message}`);
365
+ process.exit(1);
366
+ }
367
+ }
368
+
369
+ async function migratePullsInner(ctx: AgentContext, owner: string, repo: string): Promise<number> {
370
+ const slug = `${owner}/${repo}`;
371
+ const importReviews = !process.env.GITD_MIGRATE_SKIP_COMMENTS;
372
+ console.log(`Importing pull requests from ${slug}...`);
373
+
374
+ const repoContextId = await getRepoContextId(ctx);
375
+
376
+ const pulls = await ghFetchAll<GhPull>(`/repos/${owner}/${repo}/pulls?state=all&sort=created&direction=asc`);
377
+
378
+ if (pulls.length === 0) {
379
+ console.log(' No pull requests found.');
380
+ return 0;
381
+ }
382
+
383
+ let imported = 0;
384
+
385
+ for (const ghPull of pulls) {
386
+ const author = ghPull.user?.login ?? 'unknown';
387
+ const body = prependAuthor(ghPull.body ?? '', author);
388
+
389
+ // Map GitHub PR state to gitd patch status.
390
+ let patchStatus: string;
391
+ if (ghPull.merged) {
392
+ patchStatus = 'merged';
393
+ } else if (ghPull.state === 'closed') {
394
+ patchStatus = 'closed';
395
+ } else {
396
+ patchStatus = 'open';
397
+ }
398
+
399
+ const tags: Record<string, string> = {
400
+ status : patchStatus,
401
+ baseBranch : ghPull.base.ref,
402
+ headBranch : ghPull.head.ref,
403
+ number : String(ghPull.number),
404
+ };
405
+
406
+ const { status: patchSt, record: patchRecord } = await ctx.patches.records.create('repo/patch', {
407
+ data : { title: ghPull.title, body, number: ghPull.number },
408
+ tags,
409
+ parentContextId : repoContextId,
410
+ });
411
+
412
+ if (patchSt.code >= 300) {
413
+ console.error(` Failed to import PR #${ghPull.number}: ${patchSt.code} ${patchSt.detail}`);
414
+ continue;
415
+ }
416
+
417
+ imported++;
418
+
419
+ // Import reviews.
420
+ if (importReviews) {
421
+ const reviews = await ghFetchAll<GhReview>(`/repos/${owner}/${repo}/pulls/${ghPull.number}/reviews`);
422
+ let reviewCount = 0;
423
+
424
+ for (const ghReview of reviews) {
425
+ // Skip empty reviews (GitHub creates these for "viewed" actions).
426
+ if (!ghReview.body && ghReview.state === 'COMMENTED') { continue; }
427
+
428
+ const reviewer = ghReview.user?.login ?? 'unknown';
429
+ const reviewBody = prependAuthor(ghReview.body ?? '', reviewer);
430
+
431
+ // Map GitHub review state to a verdict.
432
+ let verdict: string;
433
+ switch (ghReview.state) {
434
+ case 'APPROVED': verdict = 'approve'; break;
435
+ case 'CHANGES_REQUESTED': verdict = 'request_changes'; break;
436
+ default: verdict = 'comment'; break;
437
+ }
438
+
439
+ const { status: reviewSt } = await ctx.patches.records.create('repo/patch/review' as any, {
440
+ data : { body: reviewBody },
441
+ tags : { verdict },
442
+ parentContextId : patchRecord.contextId,
443
+ } as any);
444
+
445
+ if (reviewSt.code >= 300) {
446
+ console.error(` Failed to import review on PR #${ghPull.number}: ${reviewSt.code}`);
447
+ continue;
448
+ }
449
+ reviewCount++;
450
+ }
451
+
452
+ if (reviewCount > 0) {
453
+ console.log(` #${ghPull.number} "${ghPull.title}" (${patchStatus}, ${reviewCount} review${reviewCount !== 1 ? 's' : ''})`);
454
+ } else {
455
+ console.log(` #${ghPull.number} "${ghPull.title}" (${patchStatus})`);
456
+ }
457
+ } else {
458
+ console.log(` #${ghPull.number} "${ghPull.title}" (${patchStatus})`);
459
+ }
460
+ }
461
+
462
+ return imported;
463
+ }
464
+
465
+ // ---------------------------------------------------------------------------
466
+ // migrate releases
467
+ // ---------------------------------------------------------------------------
468
+
469
+ async function migrateReleases(ctx: AgentContext, args: string[]): Promise<void> {
470
+ const { owner, repo } = parseGhRepo(args);
471
+ try {
472
+ const count = await migrateReleasesInner(ctx, owner, repo);
473
+ console.log(`\nImported ${count} release${count !== 1 ? 's' : ''}.`);
474
+ } catch (err) {
475
+ console.error(`Failed to migrate releases: ${(err as Error).message}`);
476
+ process.exit(1);
477
+ }
478
+ }
479
+
480
+ async function migrateReleasesInner(ctx: AgentContext, owner: string, repo: string): Promise<number> {
481
+ const slug = `${owner}/${repo}`;
482
+ console.log(`Importing releases from ${slug}...`);
483
+
484
+ const repoContextId = await getRepoContextId(ctx);
485
+
486
+ const releases = await ghFetchAll<GhRelease>(`/repos/${owner}/${repo}/releases`);
487
+
488
+ if (releases.length === 0) {
489
+ console.log(' No releases found.');
490
+ return 0;
491
+ }
492
+
493
+ let imported = 0;
494
+
495
+ for (const ghRelease of releases) {
496
+ const name = ghRelease.name ?? ghRelease.tag_name;
497
+ const body = ghRelease.body ?? '';
498
+
499
+ const tags: Record<string, unknown> = { tagName: ghRelease.tag_name };
500
+ if (ghRelease.target_commitish) { tags.commitSha = ghRelease.target_commitish; }
501
+ if (ghRelease.prerelease) { tags.prerelease = true; }
502
+ if (ghRelease.draft) { tags.draft = true; }
503
+
504
+ const { status } = await ctx.releases.records.create('repo/release' as any, {
505
+ data : { name, body },
506
+ tags,
507
+ parentContextId : repoContextId,
508
+ } as any);
509
+
510
+ if (status.code >= 300) {
511
+ console.error(` Failed to import release ${ghRelease.tag_name}: ${status.code} ${status.detail}`);
512
+ continue;
513
+ }
514
+
515
+ const flags = [
516
+ ghRelease.prerelease ? 'pre-release' : '',
517
+ ghRelease.draft ? 'draft' : '',
518
+ ].filter(Boolean).join(', ');
519
+
520
+ console.log(` ${ghRelease.tag_name} "${name}"${flags ? ` (${flags})` : ''}`);
521
+ imported++;
522
+ }
523
+
524
+ return imported;
525
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * `gitd notification` — personal notification inbox.
3
+ *
4
+ * Notifications are private (`published: false`) and only the DWN owner
5
+ * can read, mark as read, or delete them.
6
+ *
7
+ * Usage:
8
+ * gitd notification list [--unread] List notifications
9
+ * gitd notification read <id> Mark a notification as read
10
+ * gitd notification clear Delete all read notifications
11
+ *
12
+ * @module
13
+ */
14
+
15
+ import type { AgentContext } from '../agent.js';
16
+
17
+ import { DateSort } from '@enbox/dwn-sdk-js';
18
+
19
+ import { flagValue } from '../flags.js';
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // Sub-command dispatch
23
+ // ---------------------------------------------------------------------------
24
+
25
+ export async function notificationCommand(ctx: AgentContext, args: string[]): Promise<void> {
26
+ const sub = args[0];
27
+ const rest = args.slice(1);
28
+
29
+ switch (sub) {
30
+ case 'list':
31
+ case 'ls': return notificationList(ctx, rest);
32
+ case 'read': return notificationRead(ctx, rest);
33
+ case 'clear': return notificationClear(ctx);
34
+ default:
35
+ console.error('Usage: gitd notification <list|read|clear>');
36
+ process.exit(1);
37
+ }
38
+ }
39
+
40
+ // ---------------------------------------------------------------------------
41
+ // notification list
42
+ // ---------------------------------------------------------------------------
43
+
44
+ async function notificationList(ctx: AgentContext, args: string[]): Promise<void> {
45
+ const unreadOnly = args.includes('--unread');
46
+ const limit = parseInt(flagValue(args, '--limit') ?? '20', 10);
47
+
48
+ const filter: Record<string, unknown> = {};
49
+ if (unreadOnly) {
50
+ filter.tags = { read: false };
51
+ }
52
+
53
+ const { records } = await ctx.notifications.records.query('notification', {
54
+ filter,
55
+ dateSort : DateSort.CreatedDescending,
56
+ pagination : { limit },
57
+ });
58
+
59
+ if (records.length === 0) {
60
+ console.log(unreadOnly ? 'No unread notifications.' : 'No notifications.');
61
+ return;
62
+ }
63
+
64
+ const unreadCount = records.filter((r) => {
65
+ const tags = r.tags as Record<string, unknown> | undefined;
66
+ return tags?.read === false;
67
+ }).length;
68
+
69
+ console.log(`Notifications (${records.length}${unreadCount > 0 ? `, ${unreadCount} unread` : ''}):\n`);
70
+ for (const rec of records) {
71
+ const data = await rec.data.json();
72
+ const tags = rec.tags as Record<string, unknown> | undefined;
73
+ const isRead = tags?.read === true;
74
+ const type = tags?.type ?? data.type ?? 'unknown';
75
+ const date = rec.dateCreated?.slice(0, 19)?.replace('T', ' ') ?? '';
76
+ const marker = isRead ? ' ' : '*';
77
+ console.log(` ${marker} [${String(type).padEnd(16)}] ${data.title ?? ''} ${date}`);
78
+ if (data.body) {
79
+ console.log(` ${data.body}`);
80
+ }
81
+ console.log(` id: ${rec.id}`);
82
+ }
83
+ }
84
+
85
+ // ---------------------------------------------------------------------------
86
+ // notification read
87
+ // ---------------------------------------------------------------------------
88
+
89
+ async function notificationRead(ctx: AgentContext, args: string[]): Promise<void> {
90
+ const id = args[0];
91
+ if (!id) {
92
+ console.error('Usage: gitd notification read <id>');
93
+ process.exit(1);
94
+ }
95
+
96
+ const { records } = await ctx.notifications.records.query('notification', {
97
+ filter: { recordId: id },
98
+ });
99
+
100
+ if (records.length === 0) {
101
+ console.error(`Notification ${id} not found.`);
102
+ process.exit(1);
103
+ }
104
+
105
+ const rec = records[0];
106
+ const data = await rec.data.json();
107
+ const tags = rec.tags as Record<string, unknown> | undefined;
108
+
109
+ if (tags?.read === true) {
110
+ console.log('Notification is already marked as read.');
111
+ return;
112
+ }
113
+
114
+ const { status } = await rec.update({
115
+ data : data,
116
+ tags : { ...tags, read: true },
117
+ });
118
+
119
+ if (status.code >= 300) {
120
+ console.error(`Failed to mark as read: ${status.code} ${status.detail}`);
121
+ process.exit(1);
122
+ }
123
+
124
+ console.log('Marked notification as read.');
125
+ }
126
+
127
+ // ---------------------------------------------------------------------------
128
+ // notification clear
129
+ // ---------------------------------------------------------------------------
130
+
131
+ async function notificationClear(ctx: AgentContext): Promise<void> {
132
+ const { records } = await ctx.notifications.records.query('notification', {
133
+ filter: { tags: { read: true } },
134
+ });
135
+
136
+ if (records.length === 0) {
137
+ console.log('No read notifications to clear.');
138
+ return;
139
+ }
140
+
141
+ let deleted = 0;
142
+ for (const rec of records) {
143
+ const { status } = await rec.delete();
144
+ if (status.code < 300) { deleted++; }
145
+ }
146
+
147
+ console.log(`Cleared ${deleted} read notification${deleted !== 1 ? 's' : ''}.`);
148
+ }