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,241 @@
1
+ // The MCP server for a surface, independent of transport. It is dual-era: a request carrying
2
+ // `_meta["io.modelcontextprotocol/protocolVersion"]` is served statelessly under the 2026-07-28
3
+ // revision (no handshake, `server/discover`), and an `initialize` request opens the legacy,
4
+ // handshake-based revisions (2025-11-25 and earlier) for the rest of that connection.
5
+ import {
6
+ describeError,
7
+ internalError,
8
+ redactFields,
9
+ redactValue,
10
+ type SurfaceDefinition,
11
+ type Ops,
12
+ } from "./surface.ts";
13
+ import { servedEntries, toolName, toolOf, type McpOptions } from "./tools.ts";
14
+
15
+ export { toolName, type McpOptions, type Tool } from "./tools.ts";
16
+
17
+ export const MODERN_VERSIONS = ["2026-07-28"] as const;
18
+ export const LEGACY_VERSIONS = [
19
+ "2025-11-25",
20
+ "2025-06-18",
21
+ "2025-03-26",
22
+ "2024-11-05",
23
+ ] as const;
24
+ const META = "io.modelcontextprotocol/";
25
+
26
+ export const ERRORS = {
27
+ parse: -32700,
28
+ invalidRequest: -32600,
29
+ methodNotFound: -32601,
30
+ invalidParams: -32602,
31
+ internal: -32603,
32
+ headerMismatch: -32020,
33
+ unsupportedVersion: -32022,
34
+ } as const;
35
+
36
+ type Message = { readonly [key: string]: unknown };
37
+ export type Reply = { readonly jsonrpc: "2.0"; readonly id: unknown } & Message;
38
+ /** Per connection: stdio has one, each legacy HTTP request is its own. */
39
+ export type Connection = { legacy: string | undefined };
40
+
41
+ const isObject = (value: unknown): value is Message =>
42
+ typeof value === "object" && value !== null && !Array.isArray(value);
43
+
44
+ class Refusal {
45
+ readonly code: number;
46
+ readonly message: string;
47
+ constructor(code: number, message: string) {
48
+ this.code = code;
49
+ this.message = message;
50
+ }
51
+ }
52
+
53
+ const failure = (
54
+ id: unknown,
55
+ code: number,
56
+ message: string,
57
+ data?: unknown,
58
+ ): Reply => ({
59
+ jsonrpc: "2.0",
60
+ id: id ?? null,
61
+ error: { code, message, ...(data === undefined ? {} : { data }) },
62
+ });
63
+
64
+ export const mcpHandler = <O extends Ops>(
65
+ surface: SurfaceDefinition<O>,
66
+ options: McpOptions = {},
67
+ ) => {
68
+ const served = servedEntries(surface, options);
69
+ const byName = new Map(served.map((entry) => [toolName(entry.path), entry]));
70
+ const tools = served.map(toolOf);
71
+ const serverInfo = { name: surface.name, version: surface.version };
72
+ const instructions =
73
+ surface.instructions === undefined
74
+ ? {}
75
+ : { instructions: surface.instructions };
76
+
77
+ const call = async (params: Message): Promise<Message | Refusal> => {
78
+ const name = params["name"];
79
+ const entry = typeof name === "string" ? byName.get(name) : undefined;
80
+ if (entry === undefined)
81
+ return new Refusal(ERRORS.invalidParams, `Unknown tool: ${String(name)}`);
82
+ try {
83
+ // Redacted before it is serialized, so the text and the structured copy carry the same value.
84
+ const value = await redactValue(
85
+ surface.redact,
86
+ await entry.op.invoke(params["arguments"] ?? {}),
87
+ );
88
+ const text =
89
+ value === undefined ? "null" : JSON.stringify(value, null, 2);
90
+ return {
91
+ content: [{ type: "text", text }],
92
+ ...(isObject(value) ? { structuredContent: value } : {}),
93
+ isError: false,
94
+ };
95
+ } catch (error) {
96
+ // Any thrown value is wrapped, never rethrown, so its text still reaches the redactor; the
97
+ // instanceof check itself is guarded, because it throws for a revoked or trapped Proxy.
98
+ let reported: Error;
99
+ try {
100
+ reported = error instanceof Error ? error : internalError(error);
101
+ } catch {
102
+ reported = internalError(error);
103
+ }
104
+ const { kind, message, hint } = describeError(reported);
105
+ const said = `${kind}: ${message}${hint === undefined ? "" : `\nhint: ${hint}`}`;
106
+ return { content: [{ type: "text", text: said }], isError: true };
107
+ }
108
+ };
109
+
110
+ const serve = async (
111
+ method: string,
112
+ params: Message,
113
+ modern: boolean,
114
+ ): Promise<Message | Refusal> => {
115
+ switch (method) {
116
+ case "ping":
117
+ return {};
118
+ case "tools/list":
119
+ return modern
120
+ ? { tools, ttlMs: 300_000, cacheScope: "public" }
121
+ : { tools };
122
+ case "tools/call":
123
+ return call(params);
124
+ default:
125
+ return new Refusal(
126
+ ERRORS.methodNotFound,
127
+ `Method not found: ${method}`,
128
+ );
129
+ }
130
+ };
131
+
132
+ const respond = (
133
+ id: unknown,
134
+ result: Message | Refusal,
135
+ modern: boolean,
136
+ ): Reply => {
137
+ if (result instanceof Refusal)
138
+ return failure(id, result.code, result.message);
139
+ if (!modern) return { jsonrpc: "2.0", id, result };
140
+ return {
141
+ jsonrpc: "2.0",
142
+ id,
143
+ result: {
144
+ resultType: "complete",
145
+ ...result,
146
+ _meta: { [`${META}serverInfo`]: serverInfo },
147
+ },
148
+ };
149
+ };
150
+
151
+ const answer = async (
152
+ message: unknown,
153
+ connection: Connection,
154
+ ): Promise<Reply | undefined> => {
155
+ if (!isObject(message) || message["jsonrpc"] !== "2.0") {
156
+ return failure(
157
+ isObject(message) ? message["id"] : null,
158
+ ERRORS.invalidRequest,
159
+ "Invalid Request",
160
+ );
161
+ }
162
+ const { id, method } = message;
163
+ const params = isObject(message["params"]) ? message["params"] : {};
164
+ if (typeof method !== "string") return undefined;
165
+ if (!("id" in message)) return undefined;
166
+ if (method === "initialize") {
167
+ const asked = params["protocolVersion"];
168
+ const version =
169
+ LEGACY_VERSIONS.find((each) => each === asked) ?? LEGACY_VERSIONS[0];
170
+ connection.legacy = version;
171
+ return respond(
172
+ id,
173
+ {
174
+ protocolVersion: version,
175
+ capabilities: { tools: { listChanged: false } },
176
+ serverInfo,
177
+ ...instructions,
178
+ },
179
+ false,
180
+ );
181
+ }
182
+ const meta = isObject(params["_meta"]) ? params["_meta"] : {};
183
+ const version = meta[`${META}protocolVersion`];
184
+ if (version === undefined && connection.legacy !== undefined)
185
+ return respond(id, await serve(method, params, false), false);
186
+ if (
187
+ typeof version !== "string" ||
188
+ !isObject(meta[`${META}clientCapabilities`])
189
+ ) {
190
+ return failure(
191
+ id,
192
+ ERRORS.invalidParams,
193
+ `Invalid params: _meta must carry ${META}protocolVersion and ${META}clientCapabilities (or send initialize first; supported: ${[...MODERN_VERSIONS, ...LEGACY_VERSIONS].join(", ")})`,
194
+ );
195
+ }
196
+ if (!MODERN_VERSIONS.some((each) => each === version)) {
197
+ return failure(
198
+ id,
199
+ ERRORS.unsupportedVersion,
200
+ "Unsupported protocol version",
201
+ { supported: [...MODERN_VERSIONS], requested: version },
202
+ );
203
+ }
204
+ if (method === "server/discover") {
205
+ return respond(
206
+ id,
207
+ {
208
+ supportedVersions: [...MODERN_VERSIONS],
209
+ capabilities: { tools: {} },
210
+ ...instructions,
211
+ ttlMs: 300_000,
212
+ cacheScope: "public",
213
+ },
214
+ true,
215
+ );
216
+ }
217
+ return respond(id, await serve(method, params, true), true);
218
+ };
219
+
220
+ /** A reply with the surface's redactor applied; a transport uses it for the replies it builds itself. */
221
+ const redact = async (reply: Reply): Promise<Reply> => {
222
+ const cleaned = await redactFields(surface.redact, reply);
223
+ return { ...cleaned, jsonrpc: "2.0", id: cleaned["id"] };
224
+ };
225
+
226
+ /**
227
+ * One JSON-RPC message in; the reply out, or undefined for a notification or a response. Every
228
+ * reply passes the surface's redactor here, protocol errors that echo the caller's input included.
229
+ */
230
+ const handle = async (
231
+ message: unknown,
232
+ connection: Connection,
233
+ ): Promise<Reply | undefined> => {
234
+ const reply = await answer(message, connection);
235
+ return reply === undefined ? undefined : redact(reply);
236
+ };
237
+
238
+ return { tools, handle, redact };
239
+ };
240
+
241
+ export type McpHandler = ReturnType<typeof mcpHandler>;
@@ -0,0 +1,200 @@
1
+ // A small JSON Schema builder. Each builder returns the JSON Schema itself (what MCP tools/list
2
+ // and the CLI's --help show) plus a TypeScript type for it, so one definition types the SDK,
3
+ // validates CLI and MCP input, and documents every surface. `s.json<T>(schema)` wraps a schema
4
+ // written elsewhere (an OpenRPC document, say) under a type you name.
5
+
6
+ export type JsonSchema = { readonly [keyword: string]: unknown };
7
+
8
+ declare const carried: unique symbol;
9
+
10
+ /** A JSON Schema that carries the TypeScript type `T` of the values it accepts. */
11
+ export type Schema<T, Optional extends boolean = false> = {
12
+ readonly json: JsonSchema;
13
+ readonly optional: Optional;
14
+ readonly [carried]?: () => T;
15
+ };
16
+
17
+ export type Infer<S> = S extends Schema<infer T, boolean> ? T : never;
18
+
19
+ export type Shape = { readonly [property: string]: Schema<unknown, boolean> };
20
+
21
+ type OptionalKeys<P extends Shape> = {
22
+ [K in keyof P]: P[K] extends Schema<unknown, true> ? K : never;
23
+ }[keyof P];
24
+ type Simplify<T> = { [K in keyof T]: T[K] } & {};
25
+
26
+ export type ObjectOf<P extends Shape> = Simplify<
27
+ { readonly [K in Exclude<keyof P, OptionalKeys<P>>]: Infer<P[K]> } & {
28
+ readonly [K in OptionalKeys<P>]?: Infer<P[K]> | undefined;
29
+ }
30
+ >;
31
+
32
+ export type Doc = {
33
+ readonly description?: string;
34
+ readonly title?: string;
35
+ /** A secret value: emitted as `writeOnly`, and the CLI takes it only through `--input`, never as an argument. */
36
+ readonly secret?: boolean;
37
+ };
38
+
39
+ const described = (doc: Doc = {}): JsonSchema => ({
40
+ ...(doc.title === undefined ? {} : { title: doc.title }),
41
+ ...(doc.description === undefined ? {} : { description: doc.description }),
42
+ ...(doc.secret === true ? { writeOnly: true } : {}),
43
+ });
44
+
45
+ const make = <T>(json: JsonSchema): Schema<T> => ({ json, optional: false });
46
+
47
+ export const s = {
48
+ string: (doc?: Doc): Schema<string> =>
49
+ make({ type: "string", ...described(doc) }),
50
+ number: (doc?: Doc): Schema<number> =>
51
+ make({ type: "number", ...described(doc) }),
52
+ integer: (doc?: Doc): Schema<number> =>
53
+ make({ type: "integer", ...described(doc) }),
54
+ boolean: (doc?: Doc): Schema<boolean> =>
55
+ make({ type: "boolean", ...described(doc) }),
56
+ unknown: (doc?: Doc): Schema<unknown> => make(described(doc)),
57
+ enum: <const V extends readonly [string, ...string[]]>(
58
+ values: V,
59
+ doc?: Doc,
60
+ ): Schema<V[number]> =>
61
+ make({ type: "string", enum: values, ...described(doc) }),
62
+ array: <T>(items: Schema<T, boolean>, doc?: Doc): Schema<readonly T[]> =>
63
+ make({ type: "array", items: items.json, ...described(doc) }),
64
+ record: <T>(
65
+ values: Schema<T, boolean>,
66
+ doc?: Doc,
67
+ ): Schema<Readonly<Record<string, T>>> =>
68
+ make({
69
+ type: "object",
70
+ additionalProperties: values.json,
71
+ ...described(doc),
72
+ }),
73
+ object: <const P extends Shape>(
74
+ properties: P,
75
+ doc?: Doc,
76
+ ): Schema<ObjectOf<P>> => {
77
+ const entries = Object.entries(properties);
78
+ return make({
79
+ type: "object",
80
+ properties: Object.fromEntries(
81
+ entries.map(([name, value]) => [name, value.json]),
82
+ ),
83
+ required: entries
84
+ .filter(([, value]) => !value.optional)
85
+ .map(([name]) => name),
86
+ additionalProperties: false,
87
+ ...described(doc),
88
+ });
89
+ },
90
+ optional: <T>(inner: Schema<T, boolean>): Schema<T, true> => ({
91
+ json: inner.json,
92
+ optional: true,
93
+ }),
94
+ /** A schema written elsewhere, typed as `T`. Validation covers the keywords `problems` reads. */
95
+ json: <T>(json: JsonSchema): Schema<T> => make(json),
96
+ };
97
+
98
+ const isObject = (
99
+ value: unknown,
100
+ ): value is { readonly [key: string]: unknown } =>
101
+ typeof value === "object" && value !== null && !Array.isArray(value);
102
+
103
+ const typeOf = (value: unknown): string => {
104
+ if (value === null) return "null";
105
+ if (Array.isArray(value)) return "array";
106
+ if (typeof value === "number")
107
+ return Number.isInteger(value) ? "integer" : "number";
108
+ return typeof value;
109
+ };
110
+
111
+ const fits = (kind: unknown, value: unknown): boolean => {
112
+ const actual = typeOf(value);
113
+ return kind === actual || (kind === "number" && actual === "integer");
114
+ };
115
+
116
+ const listOf = (value: unknown): readonly unknown[] =>
117
+ Array.isArray(value) ? value : [];
118
+
119
+ const resolve = (schema: JsonSchema, root: JsonSchema): JsonSchema => {
120
+ const ref = schema["$ref"];
121
+ if (typeof ref !== "string" || !ref.startsWith("#/")) return schema;
122
+ let at: unknown = root;
123
+ for (const part of ref.slice(2).split("/"))
124
+ at = isObject(at) ? at[part] : undefined;
125
+ return isObject(at) ? resolve(at, root) : {};
126
+ };
127
+
128
+ const walk = (
129
+ schema: JsonSchema,
130
+ value: unknown,
131
+ path: string,
132
+ root: JsonSchema,
133
+ ): string[] => {
134
+ const here = resolve(schema, root);
135
+ const kind = here["type"];
136
+ if (kind !== undefined) {
137
+ const kinds = Array.isArray(kind) ? kind : [kind];
138
+ if (!kinds.some((each) => fits(each, value))) {
139
+ return [`${path}: expected ${kinds.join(" or ")}, got ${typeOf(value)}`];
140
+ }
141
+ }
142
+ if (Array.isArray(here["enum"]) && !here["enum"].includes(value)) {
143
+ return [
144
+ `${path}: expected one of ${here["enum"].map((v) => JSON.stringify(v)).join(", ")}`,
145
+ ];
146
+ }
147
+ if ("const" in here && here["const"] !== value) {
148
+ return [`${path}: expected ${JSON.stringify(here["const"])}`];
149
+ }
150
+ const anyOf = [...listOf(here["anyOf"]), ...listOf(here["oneOf"])].filter(
151
+ isObject,
152
+ );
153
+ if (
154
+ anyOf.length > 0 &&
155
+ anyOf.every((each) => walk(each, value, path, root).length > 0)
156
+ ) {
157
+ return [`${path}: matches none of the allowed shapes`];
158
+ }
159
+ const all = listOf(here["allOf"])
160
+ .filter(isObject)
161
+ .flatMap((each) => walk(each, value, path, root));
162
+ if (Array.isArray(value) && isObject(here["items"])) {
163
+ const items = here["items"];
164
+ return [
165
+ ...all,
166
+ ...value.flatMap((item, at) => walk(items, item, `${path}[${at}]`, root)),
167
+ ];
168
+ }
169
+ if (!isObject(value)) return all;
170
+ const properties = isObject(here["properties"]) ? here["properties"] : {};
171
+ const missing = listOf(here["required"])
172
+ .filter(
173
+ (name): name is string =>
174
+ typeof name === "string" && value[name] === undefined,
175
+ )
176
+ .map((name) => `${path}.${name}: required`);
177
+ const extra = here["additionalProperties"];
178
+ const fields = Object.entries(value).flatMap(([name, field]) => {
179
+ const declared = properties[name];
180
+ if (isObject(declared))
181
+ return field === undefined
182
+ ? []
183
+ : walk(declared, field, `${path}.${name}`, root);
184
+ if (extra === false) return [`${path}.${name}: not a known field`];
185
+ return isObject(extra) ? walk(extra, field, `${path}.${name}`, root) : [];
186
+ });
187
+ return [...all, ...missing, ...fields];
188
+ };
189
+
190
+ /** What is wrong with `value` against `schema`; empty when it fits. `$ref`s resolve in `root`. */
191
+ export const problems = (
192
+ schema: JsonSchema,
193
+ value: unknown,
194
+ root: JsonSchema = schema,
195
+ ): string[] => walk(schema, value, "input", root);
196
+
197
+ export const conforms = <T>(
198
+ schema: Schema<T, boolean>,
199
+ value: unknown,
200
+ ): value is T => problems(schema.json, value).length === 0;
@@ -0,0 +1,54 @@
1
+ // The stdio binding: one JSON-RPC message per line in, one per line out. Requests run
2
+ // concurrently and answer in the order they finish; the server ends when its input ends and
3
+ // every request in flight has answered. Nothing but MCP messages goes to `write`.
4
+ import { ERRORS, type Connection, type McpHandler } from "./mcp.ts";
5
+
6
+ export type StdioStreams = {
7
+ readonly input: ReadableStream<Uint8Array>;
8
+ readonly write: (line: string) => void;
9
+ };
10
+
11
+ export const serveStdio = async (
12
+ handler: McpHandler,
13
+ streams: StdioStreams,
14
+ ): Promise<void> => {
15
+ const connection: Connection = { legacy: undefined };
16
+ const inFlight = new Set<Promise<void>>();
17
+ const answer = async (line: string): Promise<void> => {
18
+ let message: unknown;
19
+ try {
20
+ message = JSON.parse(line);
21
+ } catch {
22
+ streams.write(
23
+ JSON.stringify({
24
+ jsonrpc: "2.0",
25
+ id: null,
26
+ error: { code: ERRORS.parse, message: "Parse error" },
27
+ }),
28
+ );
29
+ return;
30
+ }
31
+ const reply = await handler.handle(message, connection);
32
+ if (reply !== undefined) streams.write(JSON.stringify(reply));
33
+ };
34
+ const decoder = new TextDecoder();
35
+ let pending = "";
36
+ const take = (text: string): void => {
37
+ pending += text;
38
+ let end = pending.indexOf("\n");
39
+ while (end >= 0) {
40
+ const line = pending.slice(0, end).trim();
41
+ pending = pending.slice(end + 1);
42
+ if (line !== "") {
43
+ const work = answer(line);
44
+ inFlight.add(work);
45
+ void work.finally(() => inFlight.delete(work));
46
+ }
47
+ end = pending.indexOf("\n");
48
+ }
49
+ };
50
+ for await (const chunk of streams.input)
51
+ take(decoder.decode(chunk, { stream: true }));
52
+ take(`${decoder.decode()}\n`);
53
+ await Promise.all(inFlight);
54
+ };