oh-my-opencode 5.1.84 → 5.1.86

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 (405) hide show
  1. package/.agents/command/remove-deadcode.md +1 -1
  2. package/.agents/skills/remove-deadcode/SKILL.md +1 -1
  3. package/.agents/skills/work-with-pr/SKILL.md +2 -2
  4. package/.opencode/command/remove-deadcode.md +1 -1
  5. package/.opencode/skills/work-with-pr/SKILL.md +2 -2
  6. package/THIRD-PARTY-NOTICES.md +9 -3
  7. package/dist/cli/index.js +1022 -842
  8. package/dist/cli/service-auth/devices.d.ts +5 -2
  9. package/dist/cli-node/index.js +1022 -842
  10. package/dist/config/schema/agent-names.d.ts +1 -0
  11. package/dist/index.js +180 -205
  12. package/dist/skills/browser/SKILL.md +4 -1
  13. package/dist/skills/browser/references/commands.md +5 -2
  14. package/dist/skills/browser/references/desktop.md +1 -0
  15. package/dist/skills/browser/references/owned-engine/README.md +2 -0
  16. package/dist/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  17. package/dist/skills/browser/references/owned-engine/network.md +10 -5
  18. package/dist/skills/browser/references/recipes/1password.md +2 -0
  19. package/dist/skills/browser/runtime/omowright/index.js +11 -11
  20. package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
  21. package/dist/skills/debugging/SKILL.md +1 -1
  22. package/dist/skills/git/SKILL.md +62 -0
  23. package/dist/skills/git/agents/openai.yaml +13 -0
  24. package/dist/skills/github/SKILL.md +94 -0
  25. package/dist/skills/github/references/branch-rules.md +129 -0
  26. package/dist/skills/github/references/evidence-attachments.md +16 -0
  27. package/dist/skills/github/references/repo-setup.md +152 -0
  28. package/dist/skills/github/references/waiting.md +52 -0
  29. package/dist/skills/github/references/workflows.md +161 -0
  30. package/dist/skills/github/scripts/cli.ts +8 -0
  31. package/dist/skills/github/scripts/package.json +12 -0
  32. package/dist/skills/github/scripts/sdk.ts +11 -0
  33. package/dist/skills/github/scripts/src/account.ts +243 -0
  34. package/dist/skills/github/scripts/src/actions-write.ts +86 -0
  35. package/dist/skills/github/scripts/src/actions.ts +210 -0
  36. package/dist/skills/github/scripts/src/attestations.ts +136 -0
  37. package/dist/skills/github/scripts/src/blake2b.ts +102 -0
  38. package/dist/skills/github/scripts/src/branch-protection.ts +192 -0
  39. package/dist/skills/github/scripts/src/caches.ts +105 -0
  40. package/dist/skills/github/scripts/src/checks.ts +107 -0
  41. package/dist/skills/github/scripts/src/codespaces.ts +230 -0
  42. package/dist/skills/github/scripts/src/conversation-lock.ts +50 -0
  43. package/dist/skills/github/scripts/src/discussion-list.ts +126 -0
  44. package/dist/skills/github/scripts/src/discussion-lookup.ts +127 -0
  45. package/dist/skills/github/scripts/src/discussions.ts +234 -0
  46. package/dist/skills/github/scripts/src/env.ts +100 -0
  47. package/dist/skills/github/scripts/src/errors.ts +79 -0
  48. package/dist/skills/github/scripts/src/fields.ts +27 -0
  49. package/dist/skills/github/scripts/src/gist-shape.ts +58 -0
  50. package/dist/skills/github/scripts/src/gists-write.ts +130 -0
  51. package/dist/skills/github/scripts/src/gists.ts +118 -0
  52. package/dist/skills/github/scripts/src/git-auth.ts +46 -0
  53. package/dist/skills/github/scripts/src/http.ts +159 -0
  54. package/dist/skills/github/scripts/src/issue-develop.ts +118 -0
  55. package/dist/skills/github/scripts/src/issues-extra.ts +135 -0
  56. package/dist/skills/github/scripts/src/issues-write.ts +174 -0
  57. package/dist/skills/github/scripts/src/issues.ts +156 -0
  58. package/dist/skills/github/scripts/src/keys.ts +176 -0
  59. package/dist/skills/github/scripts/src/labels.ts +209 -0
  60. package/dist/skills/github/scripts/src/merge.ts +115 -0
  61. package/dist/skills/github/scripts/src/poly1305.ts +22 -0
  62. package/dist/skills/github/scripts/src/pr-checkout.ts +92 -0
  63. package/dist/skills/github/scripts/src/pr-view.ts +106 -0
  64. package/dist/skills/github/scripts/src/project-fields.ts +144 -0
  65. package/dist/skills/github/scripts/src/project-item-edit.ts +153 -0
  66. package/dist/skills/github/scripts/src/project-items.ts +191 -0
  67. package/dist/skills/github/scripts/src/project-links.ts +104 -0
  68. package/dist/skills/github/scripts/src/project-ref.ts +145 -0
  69. package/dist/skills/github/scripts/src/project-state.ts +99 -0
  70. package/dist/skills/github/scripts/src/projects.ts +158 -0
  71. package/dist/skills/github/scripts/src/pulls-extra.ts +165 -0
  72. package/dist/skills/github/scripts/src/pulls-read.ts +176 -0
  73. package/dist/skills/github/scripts/src/pulls-review.ts +206 -0
  74. package/dist/skills/github/scripts/src/pulls-write.ts +187 -0
  75. package/dist/skills/github/scripts/src/raw.ts +78 -0
  76. package/dist/skills/github/scripts/src/read.ts +77 -0
  77. package/dist/skills/github/scripts/src/release-assets.ts +111 -0
  78. package/dist/skills/github/scripts/src/release-download.ts +151 -0
  79. package/dist/skills/github/scripts/src/release-write.ts +197 -0
  80. package/dist/skills/github/scripts/src/repo-admin.ts +112 -0
  81. package/dist/skills/github/scripts/src/repo-content.ts +187 -0
  82. package/dist/skills/github/scripts/src/repo-create.ts +139 -0
  83. package/dist/skills/github/scripts/src/repo-extras.ts +217 -0
  84. package/dist/skills/github/scripts/src/repo-list.ts +143 -0
  85. package/dist/skills/github/scripts/src/repo-settings.ts +176 -0
  86. package/dist/skills/github/scripts/src/repo-sync.ts +81 -0
  87. package/dist/skills/github/scripts/src/repo-url.ts +104 -0
  88. package/dist/skills/github/scripts/src/repos.ts +87 -0
  89. package/dist/skills/github/scripts/src/ruleset-shape.ts +96 -0
  90. package/dist/skills/github/scripts/src/rulesets-write.ts +124 -0
  91. package/dist/skills/github/scripts/src/rulesets.ts +80 -0
  92. package/dist/skills/github/scripts/src/run-download.ts +88 -0
  93. package/dist/skills/github/scripts/src/salsa20.ts +97 -0
  94. package/dist/skills/github/scripts/src/scopes.ts +165 -0
  95. package/dist/skills/github/scripts/src/sealed-box.ts +75 -0
  96. package/dist/skills/github/scripts/src/search-commits.ts +114 -0
  97. package/dist/skills/github/scripts/src/search.ts +116 -0
  98. package/dist/skills/github/scripts/src/secrets.ts +131 -0
  99. package/dist/skills/github/scripts/src/snappy.ts +57 -0
  100. package/dist/skills/github/scripts/src/status-search.ts +55 -0
  101. package/dist/skills/github/scripts/src/transfer.ts +97 -0
  102. package/dist/skills/github/scripts/src/types.ts +75 -0
  103. package/dist/skills/github/scripts/src/variables.ts +86 -0
  104. package/dist/skills/github/scripts/src/wait.ts +164 -0
  105. package/dist/skills/github/scripts/src/wire.ts +159 -0
  106. package/dist/skills/github/scripts/src/workflows.ts +144 -0
  107. package/dist/skills/github/scripts/src/zip.ts +104 -0
  108. package/dist/skills/github/scripts/surface.ts +106 -0
  109. package/dist/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  110. package/dist/skills/github/scripts/vendor/surface/cli.ts +203 -0
  111. package/dist/skills/github/scripts/vendor/surface/flags.ts +195 -0
  112. package/dist/skills/github/scripts/vendor/surface/help.ts +89 -0
  113. package/dist/skills/github/scripts/vendor/surface/http.ts +180 -0
  114. package/dist/skills/github/scripts/vendor/surface/index.ts +44 -0
  115. package/dist/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  116. package/dist/skills/github/scripts/vendor/surface/schema.ts +200 -0
  117. package/dist/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  118. package/dist/skills/github/scripts/vendor/surface/surface.ts +250 -0
  119. package/dist/skills/github/scripts/vendor/surface/tools.ts +80 -0
  120. package/dist/skills/programming/SKILL.md +1 -1
  121. package/dist/skills/ulw-execute/SKILL.md +1 -1
  122. package/dist/tui.js +30 -27
  123. package/package.json +28 -26
  124. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  125. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  126. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  127. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  128. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  129. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  130. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  131. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  132. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  133. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
  134. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  135. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  136. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  137. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  138. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  139. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  140. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  141. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  142. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  143. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  144. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  145. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  146. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  147. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  148. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +1 -1
  149. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +3 -3
  150. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  151. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  152. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  153. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  154. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  155. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  156. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  157. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  158. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  159. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  160. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  161. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  162. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  163. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  164. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  165. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  166. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  167. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  168. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  169. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  170. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  171. package/packages/omo-codex/plugin/package-lock.json +12 -12
  172. package/packages/omo-codex/plugin/package.json +1 -1
  173. package/packages/omo-codex/plugin/skills/browser/SKILL.md +4 -1
  174. package/packages/omo-codex/plugin/skills/browser/references/commands.md +5 -2
  175. package/packages/omo-codex/plugin/skills/browser/references/desktop.md +1 -0
  176. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +2 -0
  177. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  178. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +10 -5
  179. package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +2 -0
  180. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +11 -11
  181. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
  182. package/packages/omo-codex/plugin/skills/debugging/SKILL.md +1 -1
  183. package/packages/omo-codex/plugin/skills/git/SKILL.md +62 -0
  184. package/packages/omo-codex/plugin/skills/git/agents/openai.yaml +13 -0
  185. package/packages/omo-codex/plugin/skills/github/SKILL.md +94 -0
  186. package/packages/omo-codex/plugin/skills/github/agents/openai.yaml +2 -0
  187. package/packages/omo-codex/plugin/skills/github/references/branch-rules.md +129 -0
  188. package/packages/omo-codex/plugin/skills/github/references/evidence-attachments.md +16 -0
  189. package/packages/omo-codex/plugin/skills/github/references/repo-setup.md +152 -0
  190. package/packages/omo-codex/plugin/skills/github/references/waiting.md +52 -0
  191. package/packages/omo-codex/plugin/skills/github/references/workflows.md +161 -0
  192. package/packages/omo-codex/plugin/skills/github/scripts/cli.ts +8 -0
  193. package/packages/omo-codex/plugin/skills/github/scripts/package.json +12 -0
  194. package/packages/omo-codex/plugin/skills/github/scripts/sdk.ts +11 -0
  195. package/packages/omo-codex/plugin/skills/github/scripts/src/account.ts +243 -0
  196. package/packages/omo-codex/plugin/skills/github/scripts/src/actions-write.ts +86 -0
  197. package/packages/omo-codex/plugin/skills/github/scripts/src/actions.ts +210 -0
  198. package/packages/omo-codex/plugin/skills/github/scripts/src/attestations.ts +136 -0
  199. package/packages/omo-codex/plugin/skills/github/scripts/src/blake2b.ts +102 -0
  200. package/packages/omo-codex/plugin/skills/github/scripts/src/branch-protection.ts +192 -0
  201. package/packages/omo-codex/plugin/skills/github/scripts/src/caches.ts +105 -0
  202. package/packages/omo-codex/plugin/skills/github/scripts/src/checks.ts +107 -0
  203. package/packages/omo-codex/plugin/skills/github/scripts/src/codespaces.ts +230 -0
  204. package/packages/omo-codex/plugin/skills/github/scripts/src/conversation-lock.ts +50 -0
  205. package/packages/omo-codex/plugin/skills/github/scripts/src/discussion-list.ts +126 -0
  206. package/packages/omo-codex/plugin/skills/github/scripts/src/discussion-lookup.ts +127 -0
  207. package/packages/omo-codex/plugin/skills/github/scripts/src/discussions.ts +234 -0
  208. package/packages/omo-codex/plugin/skills/github/scripts/src/env.ts +100 -0
  209. package/packages/omo-codex/plugin/skills/github/scripts/src/errors.ts +79 -0
  210. package/packages/omo-codex/plugin/skills/github/scripts/src/fields.ts +27 -0
  211. package/packages/omo-codex/plugin/skills/github/scripts/src/gist-shape.ts +58 -0
  212. package/packages/omo-codex/plugin/skills/github/scripts/src/gists-write.ts +130 -0
  213. package/packages/omo-codex/plugin/skills/github/scripts/src/gists.ts +118 -0
  214. package/packages/omo-codex/plugin/skills/github/scripts/src/git-auth.ts +46 -0
  215. package/packages/omo-codex/plugin/skills/github/scripts/src/http.ts +159 -0
  216. package/packages/omo-codex/plugin/skills/github/scripts/src/issue-develop.ts +118 -0
  217. package/packages/omo-codex/plugin/skills/github/scripts/src/issues-extra.ts +135 -0
  218. package/packages/omo-codex/plugin/skills/github/scripts/src/issues-write.ts +174 -0
  219. package/packages/omo-codex/plugin/skills/github/scripts/src/issues.ts +156 -0
  220. package/packages/omo-codex/plugin/skills/github/scripts/src/keys.ts +176 -0
  221. package/packages/omo-codex/plugin/skills/github/scripts/src/labels.ts +209 -0
  222. package/packages/omo-codex/plugin/skills/github/scripts/src/merge.ts +115 -0
  223. package/packages/omo-codex/plugin/skills/github/scripts/src/poly1305.ts +22 -0
  224. package/packages/omo-codex/plugin/skills/github/scripts/src/pr-checkout.ts +92 -0
  225. package/packages/omo-codex/plugin/skills/github/scripts/src/pr-view.ts +106 -0
  226. package/packages/omo-codex/plugin/skills/github/scripts/src/project-fields.ts +144 -0
  227. package/packages/omo-codex/plugin/skills/github/scripts/src/project-item-edit.ts +153 -0
  228. package/packages/omo-codex/plugin/skills/github/scripts/src/project-items.ts +191 -0
  229. package/packages/omo-codex/plugin/skills/github/scripts/src/project-links.ts +104 -0
  230. package/packages/omo-codex/plugin/skills/github/scripts/src/project-ref.ts +145 -0
  231. package/packages/omo-codex/plugin/skills/github/scripts/src/project-state.ts +99 -0
  232. package/packages/omo-codex/plugin/skills/github/scripts/src/projects.ts +158 -0
  233. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-extra.ts +165 -0
  234. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-read.ts +176 -0
  235. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-review.ts +206 -0
  236. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-write.ts +187 -0
  237. package/packages/omo-codex/plugin/skills/github/scripts/src/raw.ts +78 -0
  238. package/packages/omo-codex/plugin/skills/github/scripts/src/read.ts +77 -0
  239. package/packages/omo-codex/plugin/skills/github/scripts/src/release-assets.ts +111 -0
  240. package/packages/omo-codex/plugin/skills/github/scripts/src/release-download.ts +151 -0
  241. package/packages/omo-codex/plugin/skills/github/scripts/src/release-write.ts +197 -0
  242. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-admin.ts +112 -0
  243. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-content.ts +187 -0
  244. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-create.ts +139 -0
  245. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-extras.ts +217 -0
  246. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-list.ts +143 -0
  247. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-settings.ts +176 -0
  248. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-sync.ts +81 -0
  249. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-url.ts +104 -0
  250. package/packages/omo-codex/plugin/skills/github/scripts/src/repos.ts +87 -0
  251. package/packages/omo-codex/plugin/skills/github/scripts/src/ruleset-shape.ts +96 -0
  252. package/packages/omo-codex/plugin/skills/github/scripts/src/rulesets-write.ts +124 -0
  253. package/packages/omo-codex/plugin/skills/github/scripts/src/rulesets.ts +80 -0
  254. package/packages/omo-codex/plugin/skills/github/scripts/src/run-download.ts +88 -0
  255. package/packages/omo-codex/plugin/skills/github/scripts/src/salsa20.ts +97 -0
  256. package/packages/omo-codex/plugin/skills/github/scripts/src/scopes.ts +165 -0
  257. package/packages/omo-codex/plugin/skills/github/scripts/src/sealed-box.ts +75 -0
  258. package/packages/omo-codex/plugin/skills/github/scripts/src/search-commits.ts +114 -0
  259. package/packages/omo-codex/plugin/skills/github/scripts/src/search.ts +116 -0
  260. package/packages/omo-codex/plugin/skills/github/scripts/src/secrets.ts +131 -0
  261. package/packages/omo-codex/plugin/skills/github/scripts/src/snappy.ts +57 -0
  262. package/packages/omo-codex/plugin/skills/github/scripts/src/status-search.ts +55 -0
  263. package/packages/omo-codex/plugin/skills/github/scripts/src/transfer.ts +97 -0
  264. package/packages/omo-codex/plugin/skills/github/scripts/src/types.ts +75 -0
  265. package/packages/omo-codex/plugin/skills/github/scripts/src/variables.ts +86 -0
  266. package/packages/omo-codex/plugin/skills/github/scripts/src/wait.ts +164 -0
  267. package/packages/omo-codex/plugin/skills/github/scripts/src/wire.ts +159 -0
  268. package/packages/omo-codex/plugin/skills/github/scripts/src/workflows.ts +144 -0
  269. package/packages/omo-codex/plugin/skills/github/scripts/src/zip.ts +104 -0
  270. package/packages/omo-codex/plugin/skills/github/scripts/surface.ts +106 -0
  271. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  272. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/cli.ts +203 -0
  273. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/flags.ts +195 -0
  274. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/help.ts +89 -0
  275. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/http.ts +180 -0
  276. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/index.ts +44 -0
  277. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  278. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/schema.ts +200 -0
  279. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  280. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/surface.ts +250 -0
  281. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/tools.ts +80 -0
  282. package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -1
  283. package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +1 -1
  284. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +1 -1
  285. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +3 -3
  286. package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +1 -1
  287. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +2 -1
  288. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +5 -5
  289. package/packages/omo-codex/scripts/install-dist/install-local.mjs +20 -15
  290. package/packages/shared-skills/skills/browser/SKILL.md +4 -1
  291. package/packages/shared-skills/skills/browser/references/commands.md +5 -2
  292. package/packages/shared-skills/skills/browser/references/desktop.md +1 -0
  293. package/packages/shared-skills/skills/browser/references/owned-engine/README.md +2 -0
  294. package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  295. package/packages/shared-skills/skills/browser/references/owned-engine/network.md +10 -5
  296. package/packages/shared-skills/skills/browser/references/recipes/1password.md +2 -0
  297. package/packages/shared-skills/skills/browser/runtime/omowright/index.js +11 -11
  298. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
  299. package/packages/shared-skills/skills/debugging/SKILL.md +1 -1
  300. package/packages/shared-skills/skills/git/SKILL.md +62 -0
  301. package/packages/shared-skills/skills/git/agents/openai.yaml +13 -0
  302. package/packages/shared-skills/skills/github/SKILL.md +94 -0
  303. package/packages/shared-skills/skills/github/references/branch-rules.md +129 -0
  304. package/packages/shared-skills/skills/github/references/evidence-attachments.md +16 -0
  305. package/packages/shared-skills/skills/github/references/repo-setup.md +152 -0
  306. package/packages/shared-skills/skills/github/references/waiting.md +52 -0
  307. package/packages/shared-skills/skills/github/references/workflows.md +161 -0
  308. package/packages/shared-skills/skills/github/scripts/cli.ts +8 -0
  309. package/packages/shared-skills/skills/github/scripts/package.json +12 -0
  310. package/packages/shared-skills/skills/github/scripts/sdk.ts +11 -0
  311. package/packages/shared-skills/skills/github/scripts/src/account.ts +243 -0
  312. package/packages/shared-skills/skills/github/scripts/src/actions-write.ts +86 -0
  313. package/packages/shared-skills/skills/github/scripts/src/actions.ts +210 -0
  314. package/packages/shared-skills/skills/github/scripts/src/attestations.ts +136 -0
  315. package/packages/shared-skills/skills/github/scripts/src/blake2b.ts +102 -0
  316. package/packages/shared-skills/skills/github/scripts/src/branch-protection.ts +192 -0
  317. package/packages/shared-skills/skills/github/scripts/src/caches.ts +105 -0
  318. package/packages/shared-skills/skills/github/scripts/src/checks.ts +107 -0
  319. package/packages/shared-skills/skills/github/scripts/src/codespaces.ts +230 -0
  320. package/packages/shared-skills/skills/github/scripts/src/conversation-lock.ts +50 -0
  321. package/packages/shared-skills/skills/github/scripts/src/discussion-list.ts +126 -0
  322. package/packages/shared-skills/skills/github/scripts/src/discussion-lookup.ts +127 -0
  323. package/packages/shared-skills/skills/github/scripts/src/discussions.ts +234 -0
  324. package/packages/shared-skills/skills/github/scripts/src/env.ts +100 -0
  325. package/packages/shared-skills/skills/github/scripts/src/errors.ts +79 -0
  326. package/packages/shared-skills/skills/github/scripts/src/fields.ts +27 -0
  327. package/packages/shared-skills/skills/github/scripts/src/gist-shape.ts +58 -0
  328. package/packages/shared-skills/skills/github/scripts/src/gists-write.ts +130 -0
  329. package/packages/shared-skills/skills/github/scripts/src/gists.ts +118 -0
  330. package/packages/shared-skills/skills/github/scripts/src/git-auth.ts +46 -0
  331. package/packages/shared-skills/skills/github/scripts/src/http.ts +159 -0
  332. package/packages/shared-skills/skills/github/scripts/src/issue-develop.ts +118 -0
  333. package/packages/shared-skills/skills/github/scripts/src/issues-extra.ts +135 -0
  334. package/packages/shared-skills/skills/github/scripts/src/issues-write.ts +174 -0
  335. package/packages/shared-skills/skills/github/scripts/src/issues.ts +156 -0
  336. package/packages/shared-skills/skills/github/scripts/src/keys.ts +176 -0
  337. package/packages/shared-skills/skills/github/scripts/src/labels.ts +209 -0
  338. package/packages/shared-skills/skills/github/scripts/src/merge.ts +115 -0
  339. package/packages/shared-skills/skills/github/scripts/src/poly1305.ts +22 -0
  340. package/packages/shared-skills/skills/github/scripts/src/pr-checkout.ts +92 -0
  341. package/packages/shared-skills/skills/github/scripts/src/pr-view.ts +106 -0
  342. package/packages/shared-skills/skills/github/scripts/src/project-fields.ts +144 -0
  343. package/packages/shared-skills/skills/github/scripts/src/project-item-edit.ts +153 -0
  344. package/packages/shared-skills/skills/github/scripts/src/project-items.ts +191 -0
  345. package/packages/shared-skills/skills/github/scripts/src/project-links.ts +104 -0
  346. package/packages/shared-skills/skills/github/scripts/src/project-ref.ts +145 -0
  347. package/packages/shared-skills/skills/github/scripts/src/project-state.ts +99 -0
  348. package/packages/shared-skills/skills/github/scripts/src/projects.ts +158 -0
  349. package/packages/shared-skills/skills/github/scripts/src/pulls-extra.ts +165 -0
  350. package/packages/shared-skills/skills/github/scripts/src/pulls-read.ts +176 -0
  351. package/packages/shared-skills/skills/github/scripts/src/pulls-review.ts +206 -0
  352. package/packages/shared-skills/skills/github/scripts/src/pulls-write.ts +187 -0
  353. package/packages/shared-skills/skills/github/scripts/src/raw.ts +78 -0
  354. package/packages/shared-skills/skills/github/scripts/src/read.ts +77 -0
  355. package/packages/shared-skills/skills/github/scripts/src/release-assets.ts +111 -0
  356. package/packages/shared-skills/skills/github/scripts/src/release-download.ts +151 -0
  357. package/packages/shared-skills/skills/github/scripts/src/release-write.ts +197 -0
  358. package/packages/shared-skills/skills/github/scripts/src/repo-admin.ts +112 -0
  359. package/packages/shared-skills/skills/github/scripts/src/repo-content.ts +187 -0
  360. package/packages/shared-skills/skills/github/scripts/src/repo-create.ts +139 -0
  361. package/packages/shared-skills/skills/github/scripts/src/repo-extras.ts +217 -0
  362. package/packages/shared-skills/skills/github/scripts/src/repo-list.ts +143 -0
  363. package/packages/shared-skills/skills/github/scripts/src/repo-settings.ts +176 -0
  364. package/packages/shared-skills/skills/github/scripts/src/repo-sync.ts +81 -0
  365. package/packages/shared-skills/skills/github/scripts/src/repo-url.ts +104 -0
  366. package/packages/shared-skills/skills/github/scripts/src/repos.ts +87 -0
  367. package/packages/shared-skills/skills/github/scripts/src/ruleset-shape.ts +96 -0
  368. package/packages/shared-skills/skills/github/scripts/src/rulesets-write.ts +124 -0
  369. package/packages/shared-skills/skills/github/scripts/src/rulesets.ts +80 -0
  370. package/packages/shared-skills/skills/github/scripts/src/run-download.ts +88 -0
  371. package/packages/shared-skills/skills/github/scripts/src/salsa20.ts +97 -0
  372. package/packages/shared-skills/skills/github/scripts/src/scopes.ts +165 -0
  373. package/packages/shared-skills/skills/github/scripts/src/sealed-box.ts +75 -0
  374. package/packages/shared-skills/skills/github/scripts/src/search-commits.ts +114 -0
  375. package/packages/shared-skills/skills/github/scripts/src/search.ts +116 -0
  376. package/packages/shared-skills/skills/github/scripts/src/secrets.ts +131 -0
  377. package/packages/shared-skills/skills/github/scripts/src/snappy.ts +57 -0
  378. package/packages/shared-skills/skills/github/scripts/src/status-search.ts +55 -0
  379. package/packages/shared-skills/skills/github/scripts/src/transfer.ts +97 -0
  380. package/packages/shared-skills/skills/github/scripts/src/types.ts +75 -0
  381. package/packages/shared-skills/skills/github/scripts/src/variables.ts +86 -0
  382. package/packages/shared-skills/skills/github/scripts/src/wait.ts +164 -0
  383. package/packages/shared-skills/skills/github/scripts/src/wire.ts +159 -0
  384. package/packages/shared-skills/skills/github/scripts/src/workflows.ts +144 -0
  385. package/packages/shared-skills/skills/github/scripts/src/zip.ts +104 -0
  386. package/packages/shared-skills/skills/github/scripts/surface.ts +106 -0
  387. package/packages/shared-skills/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  388. package/packages/shared-skills/skills/github/scripts/vendor/surface/cli.ts +203 -0
  389. package/packages/shared-skills/skills/github/scripts/vendor/surface/flags.ts +195 -0
  390. package/packages/shared-skills/skills/github/scripts/vendor/surface/help.ts +89 -0
  391. package/packages/shared-skills/skills/github/scripts/vendor/surface/http.ts +180 -0
  392. package/packages/shared-skills/skills/github/scripts/vendor/surface/index.ts +44 -0
  393. package/packages/shared-skills/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  394. package/packages/shared-skills/skills/github/scripts/vendor/surface/schema.ts +200 -0
  395. package/packages/shared-skills/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  396. package/packages/shared-skills/skills/github/scripts/vendor/surface/surface.ts +250 -0
  397. package/packages/shared-skills/skills/github/scripts/vendor/surface/tools.ts +80 -0
  398. package/packages/shared-skills/skills/programming/SKILL.md +1 -1
  399. package/packages/shared-skills/skills/ulw-execute/SKILL.md +1 -1
  400. package/dist/skills/git-master/SKILL.md +0 -114
  401. package/dist/skills/git-master/agents/openai.yaml +0 -13
  402. package/packages/omo-codex/plugin/skills/git-master/SKILL.md +0 -114
  403. package/packages/omo-codex/plugin/skills/git-master/agents/openai.yaml +0 -13
  404. package/packages/shared-skills/skills/git-master/SKILL.md +0 -114
  405. package/packages/shared-skills/skills/git-master/agents/openai.yaml +0 -13
@@ -0,0 +1,130 @@
1
+ // Gist writes: create, edit, rename, delete and clone.
2
+ import { op, s, SurfaceError } from "../vendor/surface/index.ts";
3
+ import { enc, irreversible, writes } from "./fields.ts";
4
+ import {
5
+ contentsOf,
6
+ gistField,
7
+ gistId,
8
+ gistWritten,
9
+ readPaths,
10
+ } from "./gist-shape.ts";
11
+ import type { GitHub } from "./http.ts";
12
+
13
+ export const gistWriteOps = (gh: GitHub) => ({
14
+ create: op({
15
+ description:
16
+ "Create a gist from inline contents and/or local files; secret unless `public`. Replaces `gh gist create`.",
17
+ input: s.object({
18
+ files: s.optional(
19
+ s.record(s.string(), { description: "filename -> content." }),
20
+ ),
21
+ paths: s.optional(
22
+ s.array(s.string(), {
23
+ description: "Local files to upload under their base names.",
24
+ }),
25
+ ),
26
+ description: s.optional(s.string()),
27
+ public: s.optional(s.boolean()),
28
+ }),
29
+ annotations: writes,
30
+ run: async ({ files, paths, description, public: isPublic }) => {
31
+ const contents = {
32
+ ...contentsOf(files ?? {}),
33
+ ...(await readPaths(paths ?? [])),
34
+ };
35
+ if (Object.keys(contents).length === 0)
36
+ throw new SurfaceError(
37
+ "usage",
38
+ "a gist needs at least one file",
39
+ "pass files or paths",
40
+ );
41
+ return gistWritten(
42
+ await gh.rest("POST", "gists", {
43
+ body: {
44
+ files: contents,
45
+ public: isPublic ?? false,
46
+ ...(description === undefined ? {} : { description }),
47
+ },
48
+ }),
49
+ );
50
+ },
51
+ }),
52
+ edit: op({
53
+ description:
54
+ "Change a gist's description, replace or add file contents, add local files, or remove files. Replaces `gh gist edit`.",
55
+ input: s.object({
56
+ id: gistField,
57
+ description: s.optional(s.string()),
58
+ set: s.optional(
59
+ s.record(s.string(), {
60
+ description: "filename -> new content (adds the file if missing).",
61
+ }),
62
+ ),
63
+ add: s.optional(
64
+ s.array(s.string(), {
65
+ description: "Local files to add under their base names.",
66
+ }),
67
+ ),
68
+ remove: s.optional(s.array(s.string(), { description: "Filenames." })),
69
+ }),
70
+ annotations: writes,
71
+ run: async ({ id, description, set, add, remove }) => {
72
+ const gist = gistId(id);
73
+ const files = {
74
+ ...contentsOf(set ?? {}),
75
+ ...(await readPaths(add ?? [])),
76
+ ...Object.fromEntries((remove ?? []).map((name) => [name, null])),
77
+ };
78
+ if (description === undefined && Object.keys(files).length === 0)
79
+ throw new SurfaceError(
80
+ "usage",
81
+ "nothing to change",
82
+ "pass description, set, add or remove",
83
+ );
84
+ return gistWritten(
85
+ await gh.rest("PATCH", `gists/${enc(gist)}`, {
86
+ body: {
87
+ ...(description === undefined ? {} : { description }),
88
+ ...(Object.keys(files).length === 0 ? {} : { files }),
89
+ },
90
+ }),
91
+ );
92
+ },
93
+ }),
94
+ rename: op({
95
+ description:
96
+ "Rename one file in a gist, keeping its content. Replaces `gh gist rename`.",
97
+ input: s.object({ id: gistField, from: s.string(), to: s.string() }),
98
+ annotations: writes,
99
+ run: async ({ id, from, to }) =>
100
+ gistWritten(
101
+ await gh.rest("PATCH", `gists/${enc(gistId(id))}`, {
102
+ body: { files: { [from]: { filename: to } } },
103
+ }),
104
+ ),
105
+ }),
106
+ delete: op({
107
+ description: "Delete a gist and its history. Replaces `gh gist delete`.",
108
+ input: s.object({ id: gistField }),
109
+ annotations: irreversible,
110
+ run: async ({ id }) => {
111
+ const gist = gistId(id);
112
+ await gh.rest("DELETE", `gists/${enc(gist)}`);
113
+ return { id: gist, deleted: true };
114
+ },
115
+ }),
116
+ clone: op({
117
+ description:
118
+ "Clone a gist's git repository into a local directory. Replaces `gh gist clone`.",
119
+ input: s.object({
120
+ id: gistField,
121
+ dir: s.string({ description: "Directory to clone into." }),
122
+ }),
123
+ annotations: writes,
124
+ run: async ({ id, dir }) => {
125
+ const gist = gistId(id);
126
+ await gh.git(["clone", `https://gist.github.com/${gist}.git`, dir], ".");
127
+ return { id: gist, dir };
128
+ },
129
+ }),
130
+ });
@@ -0,0 +1,118 @@
1
+ // Gists of the authenticated user: list and view here, writes in gists-write.ts.
2
+ import { op, s, SurfaceError } from "../vendor/surface/index.ts";
3
+ import { enc, limitField, reads } from "./fields.ts";
4
+ import { fileList, gistField, gistId, gistSummary } from "./gist-shape.ts";
5
+ import { gistWriteOps } from "./gists-write.ts";
6
+ import type { GitHub } from "./http.ts";
7
+ import { arr, at, bool, nodes, num, optStr, str } from "./read.ts";
8
+
9
+ const LIST = `query($n: Int!, $after: String, $privacy: GistPrivacy!, $content: Boolean!) {
10
+ viewer { gists(first: $n, after: $after, privacy: $privacy, orderBy: { field: CREATED_AT, direction: DESC }) {
11
+ nodes { name description isPublic updatedAt url files(limit: 300) { name text @include(if: $content) } }
12
+ pageInfo { hasNextPage endCursor }
13
+ } }
14
+ }`;
15
+
16
+ export const gistOps = (gh: GitHub) => ({
17
+ list: op({
18
+ description:
19
+ "Your gists, newest first, optionally only public or secret ones and only those whose description or file names match a regex. Replaces `gh gist list`.",
20
+ input: s.object({
21
+ visibility: s.optional(s.enum(["all", "public", "secret"])),
22
+ filter: s.optional(
23
+ s.string({
24
+ description: "Regex matched against the description and file names.",
25
+ }),
26
+ ),
27
+ includeContent: s.optional(
28
+ s.boolean({ description: "Also match the filter against file text." }),
29
+ ),
30
+ limit: limitField(10),
31
+ }),
32
+ annotations: reads,
33
+ run: async ({ visibility, filter, includeContent, limit }) => {
34
+ const max = limit ?? 10;
35
+ const pattern = filter === undefined ? undefined : new RegExp(filter);
36
+ const content = pattern !== undefined && includeContent === true;
37
+ const items = [];
38
+ let after: string | null = null;
39
+ do {
40
+ const page: unknown = at(
41
+ await gh.graphql(LIST, {
42
+ n: pattern === undefined ? Math.min(100, max) : 100,
43
+ after,
44
+ privacy: (visibility ?? "all").toUpperCase(),
45
+ content,
46
+ }),
47
+ "viewer",
48
+ "gists",
49
+ );
50
+ for (const g of nodes(page)) {
51
+ const files = arr(at(g, "files") ?? [], "files");
52
+ const fields = [
53
+ optStr(g, "description") ?? "",
54
+ ...files.map((f) => str(f, "name")),
55
+ ...(content ? files.map((f) => optStr(f, "text") ?? "") : []),
56
+ ];
57
+ if (pattern !== undefined && !fields.some((t) => pattern.test(t)))
58
+ continue;
59
+ items.push({
60
+ id: str(g, "name"),
61
+ description: optStr(g, "description"),
62
+ public: bool(g, "isPublic"),
63
+ files: files.map((f) => str(f, "name")),
64
+ updatedAt: str(g, "updatedAt"),
65
+ url: str(g, "url"),
66
+ });
67
+ if (items.length >= max) break;
68
+ }
69
+ after =
70
+ at(page, "pageInfo", "hasNextPage") === true
71
+ ? optStr(page, "pageInfo", "endCursor")
72
+ : null;
73
+ } while (after !== null && items.length < max);
74
+ return { items };
75
+ },
76
+ }),
77
+ view: op({
78
+ description:
79
+ "A gist's description, visibility and files with name, size and full content (a file over 1 MB is fetched from its raw URL; one over 10 MB needs `gist clone`). Replaces `gh gist view`.",
80
+ input: s.object({
81
+ id: gistField,
82
+ filename: s.optional(s.string({ description: "Return only this file." })),
83
+ files: s.optional(
84
+ s.boolean({ description: "Return file names and sizes only." }),
85
+ ),
86
+ }),
87
+ annotations: reads,
88
+ run: async ({ id, filename, files }) => {
89
+ const g = await gh.rest("GET", `gists/${enc(gistId(id))}`);
90
+ const all = fileList(g).filter(
91
+ (f) => filename === undefined || str(f, "filename") === filename,
92
+ );
93
+ if (filename !== undefined && all.length === 0)
94
+ throw new SurfaceError(
95
+ "not_found",
96
+ `gist has no file named ${filename}`,
97
+ "list its files with `files: true`",
98
+ );
99
+ const content = async (f: unknown): Promise<string> =>
100
+ bool(f, "truncated")
101
+ ? new TextDecoder().decode(await gh.content(str(f, "raw_url")))
102
+ : (optStr(f, "content") ?? "");
103
+ return {
104
+ ...gistSummary(g),
105
+ files: await Promise.all(
106
+ all.map(async (f) => ({
107
+ name: str(f, "filename"),
108
+ size: num(f, "size"),
109
+ ...(files === true
110
+ ? {}
111
+ : { content: await content(f), rawUrl: str(f, "raw_url") }),
112
+ })),
113
+ ),
114
+ };
115
+ },
116
+ }),
117
+ ...gistWriteOps(gh),
118
+ });
@@ -0,0 +1,46 @@
1
+ // How a git child process authenticates to GitHub with this SDK's token, so clone and fetch need no gh login
2
+ // and no credential helper of the user's. The token travels only in the child's environment: never in argv,
3
+ // the remote URL or .git/config.
4
+ const TOKEN_VAR = "GITHUB_SDK_GIT_TOKEN";
5
+ const HOSTS = ["github.com", "gist.github.com"] as const;
6
+ const HELPER = `!f() { test "$1" = get && printf 'username=x-access-token\\npassword=%s\\n' "$${TOKEN_VAR}"; }; f`;
7
+
8
+ // Git reads GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n after its config files. An empty helper value clears the
9
+ // helpers configured for that host, so only ours answers and no stored credential is read or rewritten.
10
+ const TOKEN_VARS: ReadonlySet<string> = new Set([
11
+ "GH_TOKEN",
12
+ "GITHUB_TOKEN",
13
+ TOKEN_VAR,
14
+ ]);
15
+
16
+ // A checkout's hooks, filters and aliases run inside git children, so no git child inherits the
17
+ // token variables this process may hold. `auth` is added back only for a command that reaches the remote.
18
+ export const gitChildEnv = (
19
+ base: Readonly<Record<string, string | undefined>>,
20
+ auth: Readonly<Record<string, string>>,
21
+ ): Record<string, string> => ({
22
+ ...Object.fromEntries(
23
+ Object.entries(base).flatMap(([name, value]) =>
24
+ value === undefined || TOKEN_VARS.has(name) ? [] : [[name, value]],
25
+ ),
26
+ ),
27
+ ...auth,
28
+ });
29
+
30
+ export const gitAuthEnv = (token: string): Record<string, string> => {
31
+ const pairs = HOSTS.flatMap((host) => [
32
+ [`credential.https://${host}.helper`, ""],
33
+ [`credential.https://${host}.helper`, HELPER],
34
+ ]);
35
+ return {
36
+ [TOKEN_VAR]: token,
37
+ GIT_TERMINAL_PROMPT: "0",
38
+ GIT_CONFIG_COUNT: String(pairs.length),
39
+ ...Object.fromEntries(
40
+ pairs.flatMap(([key, value], i) => [
41
+ [`GIT_CONFIG_KEY_${i}`, key],
42
+ [`GIT_CONFIG_VALUE_${i}`, value],
43
+ ]),
44
+ ),
45
+ };
46
+ };
@@ -0,0 +1,159 @@
1
+ // One GitHub transport for every operation: JSON calls, pagination, GraphQL, downloads, uploads and local git.
2
+ import { SurfaceError } from "../vendor/surface/index.ts";
3
+ import { parseRepo } from "./env.ts";
4
+ import { gitAuthEnv, gitChildEnv } from "./git-auth.ts";
5
+ import { at, isObj, optStr } from "./read.ts";
6
+ import { createTransfer } from "./transfer.ts";
7
+ import type { Deps, GitHub } from "./types.ts";
8
+ import { createWire } from "./wire.ts";
9
+
10
+ export type {
11
+ Deps,
12
+ Fetch,
13
+ GitHub,
14
+ GitResult,
15
+ Method,
16
+ Repo,
17
+ Request,
18
+ } from "./types.ts";
19
+
20
+ // Only these git commands talk to the remote. Every other one (checkout, merge, config) can run the
21
+ // checkout's hooks and filter drivers, so it gets no token.
22
+ const REMOTE_COMMANDS: ReadonlySet<string> = new Set(["clone", "fetch"]);
23
+
24
+ const nextLink = (link: string | null): string | undefined =>
25
+ link
26
+ ?.split(",")
27
+ .find((part) => /rel="next"/.test(part))
28
+ ?.match(/<([^>]+)>/)?.[1];
29
+
30
+ export const createGitHub = (deps: Deps): GitHub => {
31
+ const wire = createWire(deps);
32
+ const { url, send, fail, decode, redact } = wire;
33
+
34
+ const rest: GitHub["rest"] = async (method, path, req = {}) => {
35
+ const target = url(path, req.query);
36
+ const res = await send(method, target, req);
37
+ if (!res.ok) return fail(method, target, res);
38
+ return decode(res);
39
+ };
40
+
41
+ const list: GitHub["list"] = async (path, limit, req = {}) => {
42
+ const out: unknown[] = [];
43
+ let target: URL | undefined = url(path, {
44
+ ...req.query,
45
+ per_page: Math.min(100, Math.max(1, limit)),
46
+ });
47
+ while (target && out.length < limit) {
48
+ const res = await send("GET", target, req);
49
+ if (!res.ok) return fail("GET", target, res);
50
+ const body = await decode(res);
51
+ const page = req.key === undefined ? body : at(body, req.key);
52
+ if (!Array.isArray(page))
53
+ throw new SurfaceError(
54
+ "invalid_response",
55
+ `${target.pathname} did not return a list`,
56
+ "inspect it with `api rest`",
57
+ );
58
+ out.push(...page);
59
+ const next = nextLink(res.headers.get("link"));
60
+ target =
61
+ next === undefined || page.length === 0 ? undefined : new URL(next);
62
+ }
63
+ return out.slice(0, limit);
64
+ };
65
+
66
+ const text: GitHub["text"] = async (path, accept) => {
67
+ const target = url(path, undefined);
68
+ const res = await send("GET", target, { accept });
69
+ if (!res.ok) return fail("GET", target, res);
70
+ return res.text();
71
+ };
72
+
73
+ const headers: GitHub["headers"] = async (path) => {
74
+ const target = url(path, undefined);
75
+ const res = await send("GET", target, {});
76
+ if (!res.ok) return fail("GET", target, res);
77
+ return res.headers;
78
+ };
79
+
80
+ const graphql: GitHub["graphql"] = async (query, variables) => {
81
+ const body = await rest("POST", "graphql", { body: { query, variables } });
82
+ const errors = at(body, "errors");
83
+ if (Array.isArray(errors) && errors.length > 0) {
84
+ const first = errors[0];
85
+ const type = optStr(first, "type") ?? "";
86
+ const message = errors.map((e) => optStr(e, "message") ?? "").join("; ");
87
+ const kind =
88
+ type === "NOT_FOUND"
89
+ ? "not_found"
90
+ : type === "FORBIDDEN"
91
+ ? "forbidden"
92
+ : "graphql";
93
+ throw new SurfaceError(
94
+ kind,
95
+ await redact(message),
96
+ kind === "not_found"
97
+ ? "check owner/name and number"
98
+ : "fix the query or its variables",
99
+ );
100
+ }
101
+ const data = at(body, "data");
102
+ if (!isObj(data))
103
+ throw new SurfaceError(
104
+ "invalid_response",
105
+ "GraphQL response had no data",
106
+ "inspect it with `api graphql`",
107
+ );
108
+ return data;
109
+ };
110
+
111
+ const repo: GitHub["repo"] = async (given) => {
112
+ const source = given ?? (await deps.originRepo());
113
+ const parsed = source === undefined ? undefined : parseRepo(source);
114
+ if (parsed) return parsed;
115
+ throw new SurfaceError(
116
+ "usage",
117
+ given === undefined
118
+ ? "no repo given and the current directory has no GitHub origin"
119
+ : `not a GitHub repo: ${given}`,
120
+ "pass repo as owner/name",
121
+ );
122
+ };
123
+
124
+ const git: GitHub["git"] = async (args, cwd) => {
125
+ const res = await deps.git(
126
+ args,
127
+ cwd,
128
+ gitChildEnv(
129
+ deps.env(),
130
+ REMOTE_COMMANDS.has(args[0] ?? "")
131
+ ? gitAuthEnv(await deps.token())
132
+ : {},
133
+ ),
134
+ );
135
+ if (res.code !== 0)
136
+ throw new SurfaceError(
137
+ "git",
138
+ await redact(
139
+ `git ${args[0] ?? ""} exited ${res.code}: ${res.stderr.trim().slice(-400)}`,
140
+ ),
141
+ "run the same git command in that directory to see the cause",
142
+ );
143
+ return res.stdout;
144
+ };
145
+
146
+ return {
147
+ rest,
148
+ list,
149
+ text,
150
+ headers,
151
+ graphql,
152
+ repo,
153
+ git,
154
+ redact,
155
+ ...createTransfer(deps, wire),
156
+ now: deps.now,
157
+ sleep: deps.sleep,
158
+ };
159
+ };
@@ -0,0 +1,118 @@
1
+ // Branches linked to an issue: listing them and creating one on GitHub.
2
+ import { op, s, SurfaceError } from "../vendor/surface/index.ts";
3
+ import { numberField, repoField, writes } from "./fields.ts";
4
+ import type { GitHub, Repo } from "./http.ts";
5
+ import { at, nodes, str } from "./read.ts";
6
+
7
+ const LINKED = `query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){issue(number:$number){
8
+ linkedBranches(first:100){nodes{ref{name target{oid} repository{nameWithOwner}}}}}}}`;
9
+
10
+ const TARGET = `query($owner:String!,$name:String!,$number:Int!,$bOwner:String!,$bName:String!,$base:String!,$hasBase:Boolean!){
11
+ repository(owner:$owner,name:$name){issue(number:$number){id}}
12
+ target:repository(owner:$bOwner,name:$bName){id defaultBranchRef{name target{oid}} ref(qualifiedName:$base) @include(if:$hasBase){name target{oid}}}}`;
13
+
14
+ const CREATE = `mutation($issue:ID!,$oid:GitObjectID!,$name:String,$repo:ID!){createLinkedBranch(input:{issueId:$issue,oid:$oid,name:$name,repositoryId:$repo}){
15
+ linkedBranch{ref{name target{oid} repository{nameWithOwner}}}}}`;
16
+
17
+ const branchOf = (ref: unknown) => {
18
+ const repo = str(ref, "repository", "nameWithOwner");
19
+ const name = str(ref, "name");
20
+ return {
21
+ name,
22
+ repo,
23
+ headSha: str(ref, "target", "oid"),
24
+ url: `https://github.com/${repo}/tree/${name}`,
25
+ };
26
+ };
27
+
28
+ const issueMissing = (r: Repo, number: number) =>
29
+ new SurfaceError(
30
+ "not_found",
31
+ `no issue #${number} in ${r.full}`,
32
+ "check the number",
33
+ );
34
+
35
+ export const developOp = (gh: GitHub) =>
36
+ op({
37
+ description:
38
+ "With list, the branches linked to an issue; otherwise create a branch on GitHub linked to the issue, from `base` (default: the branch repo's default branch) in `branchRepo` (default: the issue's repo). Nothing is checked out locally; use git or `pr checkout` for that. Replaces `gh issue develop`.",
39
+ input: s.object({
40
+ repo: repoField,
41
+ number: numberField,
42
+ list: s.optional(s.boolean()),
43
+ name: s.optional(
44
+ s.string({ description: "Branch name (GitHub picks one if omitted)." }),
45
+ ),
46
+ base: s.optional(s.string({ description: "Branch to start from." })),
47
+ branchRepo: s.optional(
48
+ s.string({ description: "owner/name to create the branch in." }),
49
+ ),
50
+ }),
51
+ annotations: writes,
52
+ run: async ({ repo, number, list, name, base, branchRepo }) => {
53
+ if (
54
+ list === true &&
55
+ (name !== undefined || base !== undefined || branchRepo !== undefined)
56
+ )
57
+ throw new SurfaceError(
58
+ "usage",
59
+ "list cannot be combined with name, base or branchRepo",
60
+ "drop list to create a branch",
61
+ );
62
+ const r = await gh.repo(repo);
63
+ if (list === true) {
64
+ const data = await gh.graphql(LINKED, {
65
+ owner: r.owner,
66
+ name: r.name,
67
+ number,
68
+ });
69
+ const issue = at(data, "repository", "issue");
70
+ if (issue === null || issue === undefined)
71
+ throw issueMissing(r, number);
72
+ return {
73
+ repo: r.full,
74
+ number,
75
+ items: nodes(issue, "linkedBranches").map((n) =>
76
+ branchOf(at(n, "ref")),
77
+ ),
78
+ };
79
+ }
80
+ const b = branchRepo === undefined ? r : await gh.repo(branchRepo);
81
+ const data = await gh.graphql(TARGET, {
82
+ owner: r.owner,
83
+ name: r.name,
84
+ number,
85
+ bOwner: b.owner,
86
+ bName: b.name,
87
+ base: `refs/heads/${base ?? ""}`,
88
+ hasBase: base !== undefined,
89
+ });
90
+ const issueId = at(data, "repository", "issue", "id");
91
+ if (typeof issueId !== "string") throw issueMissing(r, number);
92
+ const from = at(
93
+ data,
94
+ "target",
95
+ base === undefined ? "defaultBranchRef" : "ref",
96
+ );
97
+ if (from === null || from === undefined)
98
+ throw new SurfaceError(
99
+ "not_found",
100
+ `no branch ${base ?? "(default)"} in ${b.full}`,
101
+ "check base and branchRepo",
102
+ );
103
+ const created = await gh.graphql(CREATE, {
104
+ issue: issueId,
105
+ oid: str(from, "target", "oid"),
106
+ repo: str(data, "target", "id"),
107
+ ...(name === undefined ? {} : { name }),
108
+ });
109
+ return {
110
+ repo: r.full,
111
+ number,
112
+ base: str(from, "name"),
113
+ branch: branchOf(
114
+ at(created, "createLinkedBranch", "linkedBranch", "ref"),
115
+ ),
116
+ };
117
+ },
118
+ });