spell 0.8.7 → 0.8.9

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 (304) hide show
  1. package/README-epics.md +149 -49
  2. package/app/package.json +25 -1
  3. package/app/spaces/@spell/guides/SpellUI/SpellUI.spellml +486 -486
  4. package/app/spaces/@spell/sites/SpellApp/SpellApp.spellml +50 -124
  5. package/dist/app/app/pages/SiteBoardView.css +5 -5
  6. package/dist/app/app/pages/SiteBoardView.js +1 -1
  7. package/dist/app/app/pages/SiteEditorPage.js +6 -3
  8. package/dist/app/app/pages/SiteEdits.js +27 -10
  9. package/dist/app/app/pages/SiteWrites.js +11 -0
  10. package/dist/app/app/runner/spellRuntime.js +1 -0
  11. package/dist/cli/publish/PublishedPackage.d.ts +2 -1
  12. package/dist/cli/publish/PublishedPackage.js +6 -3
  13. package/dist/cli/publish/ScratchInstall.d.ts +14 -3
  14. package/dist/cli/publish/ScratchInstall.js +69 -8
  15. package/dist/epic/cli/EpicProgram.js +20 -5
  16. package/dist/epic/cli/epicGroups.js +7 -1
  17. package/dist/epic/command/BaseBranch.d.ts +35 -0
  18. package/dist/epic/command/BaseBranch.js +58 -0
  19. package/dist/epic/command/EpicCheckout.d.ts +1 -1
  20. package/dist/epic/command/EpicCheckout.js +4 -4
  21. package/dist/epic/command/EpicGuide.js +3 -2
  22. package/dist/epic/command/EpicTools.d.ts +5 -0
  23. package/dist/epic/command/EpicTools.js +14 -3
  24. package/dist/epic/command/MainMerge.d.ts +26 -15
  25. package/dist/epic/command/MainMerge.js +60 -16
  26. package/dist/epic/command/PullRequest.d.ts +45 -0
  27. package/dist/epic/command/PullRequest.js +100 -0
  28. package/dist/epic/command/RepoInit.d.ts +196 -39
  29. package/dist/epic/command/RepoInit.js +481 -60
  30. package/dist/epic/command/Requests.d.ts +1 -0
  31. package/dist/epic/command/Requests.js +7 -1
  32. package/dist/epic/command/SessionMoves.js +2 -1
  33. package/dist/epic/command/SkillsCheck.js +3 -2
  34. package/dist/epic/command/Stock.js +3 -1
  35. package/dist/epic/command/TurnEnd.d.ts +1 -1
  36. package/dist/epic/command/TurnEnd.js +4 -3
  37. package/dist/epic/command/Worktrees.d.ts +20 -3
  38. package/dist/epic/command/Worktrees.js +39 -7
  39. package/dist/epic/command/command.types.d.ts +3 -0
  40. package/dist/epic/components/__pack/epics.entry.js +43 -43
  41. package/dist/epic/components/__pack/epics.pack.js +36 -12794
  42. package/dist/epic/config/CodeHost.d.ts +96 -0
  43. package/dist/epic/config/CodeHost.js +89 -0
  44. package/dist/epic/config/EngineFiles.mjs +60 -0
  45. package/dist/epic/config/EpicConfig.d.ts +20 -3
  46. package/dist/epic/config/EpicConfig.js +25 -1
  47. package/dist/epic/config/EpicRepo.js +1 -1
  48. package/dist/epic/config/GitHub.d.ts +75 -3
  49. package/dist/epic/config/GitHub.js +106 -5
  50. package/dist/epic/config/GitLab.d.ts +138 -0
  51. package/dist/epic/config/GitLab.js +297 -0
  52. package/dist/epic/config/LayeredSettings.js +3 -2
  53. package/dist/epic/server/EpicServer.d.ts +1 -1
  54. package/dist/epic/server/EpicServer.js +26 -12
  55. package/dist/epic/tool/InboxPoller.mjs +2 -1
  56. package/dist/epic/tool/MigrateCommands.js +6 -8
  57. package/dist/epic/tool/PlanCommits.d.ts +7 -4
  58. package/dist/epic/tool/PlanCommits.js +7 -5
  59. package/dist/epic/tool/PlanDocCommands.js +3 -4
  60. package/dist/epic/tool/PlanDocFiles.d.ts +3 -1
  61. package/dist/epic/tool/PlanDocFiles.js +13 -5
  62. package/dist/epic/tool/ServedFolders.d.ts +1 -1
  63. package/dist/epic/tool/ServedFolders.js +4 -4
  64. package/dist/epic/tools/PageInboxes.js +3 -3
  65. package/dist/epic/tools/_assets/commands.entry.js +149 -68
  66. package/dist/epic/tools/_assets/commands.js +20 -2073
  67. package/dist/epic/tools/_assets/core-reference.entry.js +244 -124
  68. package/dist/epic/tools/_assets/core-reference.js +20 -2142
  69. package/dist/epic/tools/_assets/emoji/cldr/0.js +2 -2
  70. package/dist/epic/tools/_assets/emoji/cldr/a.js +2 -2
  71. package/dist/epic/tools/_assets/emoji/cldr/b.js +2 -2
  72. package/dist/epic/tools/_assets/emoji/cldr/c.js +2 -2
  73. package/dist/epic/tools/_assets/emoji/cldr/d.js +2 -2
  74. package/dist/epic/tools/_assets/emoji/cldr/e.js +2 -2
  75. package/dist/epic/tools/_assets/emoji/cldr/f.js +2 -2
  76. package/dist/epic/tools/_assets/emoji/cldr/g.js +2 -2
  77. package/dist/epic/tools/_assets/emoji/cldr/h.js +2 -2
  78. package/dist/epic/tools/_assets/emoji/cldr/i.js +2 -2
  79. package/dist/epic/tools/_assets/emoji/cldr/j.js +2 -2
  80. package/dist/epic/tools/_assets/emoji/cldr/k.js +2 -2
  81. package/dist/epic/tools/_assets/emoji/cldr/l.js +2 -2
  82. package/dist/epic/tools/_assets/emoji/cldr/m.js +2 -2
  83. package/dist/epic/tools/_assets/emoji/cldr/n.js +2 -2
  84. package/dist/epic/tools/_assets/emoji/cldr/o.js +2 -2
  85. package/dist/epic/tools/_assets/emoji/cldr/p.js +2 -2
  86. package/dist/epic/tools/_assets/emoji/cldr/r.js +2 -2
  87. package/dist/epic/tools/_assets/emoji/cldr/s.js +2 -2
  88. package/dist/epic/tools/_assets/emoji/cldr/t.js +2 -2
  89. package/dist/epic/tools/_assets/emoji/cldr/u.js +2 -2
  90. package/dist/epic/tools/_assets/emoji/cldr/v.js +2 -2
  91. package/dist/epic/tools/_assets/emoji/cldr/w.js +2 -2
  92. package/dist/epic/tools/_assets/emoji/cldr/x.js +2 -2
  93. package/dist/epic/tools/_assets/emoji/cldr/y.js +2 -2
  94. package/dist/epic/tools/_assets/emoji/cldr/z.js +2 -2
  95. package/dist/epic/tools/_assets/emoji/fomantic/0.js +2 -2
  96. package/dist/epic/tools/_assets/emoji/fomantic/a.js +2 -2
  97. package/dist/epic/tools/_assets/emoji/fomantic/b.js +2 -2
  98. package/dist/epic/tools/_assets/emoji/fomantic/c.js +2 -2
  99. package/dist/epic/tools/_assets/emoji/fomantic/d.js +2 -2
  100. package/dist/epic/tools/_assets/emoji/fomantic/e.js +2 -2
  101. package/dist/epic/tools/_assets/emoji/fomantic/f.js +2 -2
  102. package/dist/epic/tools/_assets/emoji/fomantic/g.js +2 -2
  103. package/dist/epic/tools/_assets/emoji/fomantic/h.js +2 -2
  104. package/dist/epic/tools/_assets/emoji/fomantic/i.js +2 -2
  105. package/dist/epic/tools/_assets/emoji/fomantic/j.js +2 -2
  106. package/dist/epic/tools/_assets/emoji/fomantic/k.js +2 -2
  107. package/dist/epic/tools/_assets/emoji/fomantic/l.js +2 -2
  108. package/dist/epic/tools/_assets/emoji/fomantic/m.js +2 -2
  109. package/dist/epic/tools/_assets/emoji/fomantic/n.js +2 -2
  110. package/dist/epic/tools/_assets/emoji/fomantic/o.js +2 -2
  111. package/dist/epic/tools/_assets/emoji/fomantic/p.js +2 -2
  112. package/dist/epic/tools/_assets/emoji/fomantic/q.js +2 -2
  113. package/dist/epic/tools/_assets/emoji/fomantic/r.js +2 -2
  114. package/dist/epic/tools/_assets/emoji/fomantic/s.js +2 -2
  115. package/dist/epic/tools/_assets/emoji/fomantic/t.js +2 -2
  116. package/dist/epic/tools/_assets/emoji/fomantic/u.js +2 -2
  117. package/dist/epic/tools/_assets/emoji/fomantic/v.js +2 -2
  118. package/dist/epic/tools/_assets/emoji/fomantic/w.js +2 -2
  119. package/dist/epic/tools/_assets/emoji/fomantic/x.js +2 -2
  120. package/dist/epic/tools/_assets/emoji/fomantic/y.js +2 -2
  121. package/dist/epic/tools/_assets/emoji/fomantic/z.js +2 -2
  122. package/dist/epic/tools/_assets/goals-live.js +318 -210
  123. package/dist/epic/tools/_assets/highlight.min.js +5764 -5269
  124. package/dist/epic/tools/_assets/lazy/code-engine.js +5 -1270
  125. package/dist/epic/tools/_assets/lazy/markdown-engine.js +67 -1513
  126. package/dist/epic/tools/_assets/lazy/markdown-sanitizer.js +3 -753
  127. package/dist/epic/tools/_assets/spell-comments.entry.js +282 -159
  128. package/dist/epic/tools/_assets/spell-comments.js +24 -3716
  129. package/dist/epic/tools/_assets/spell-doc-comments.js +1243 -816
  130. package/dist/epic/tools/_assets/spell-doc-helpers.js +298 -165
  131. package/dist/epic/tools/_assets/spell-doc-runtime.js +2760 -1415
  132. package/dist/epic/tools/_assets/spell-doc-toolbar.js +396 -227
  133. package/dist/epic/tools/_assets/spell-syntax.entry.js +505 -285
  134. package/dist/epic/tools/_assets/spell-syntax.js +22 -2916
  135. package/dist/epic/tools/_assets/spell-ui-sources.js +102 -60
  136. package/dist/epic/tools/_assets/spell-ui.entry.js +108 -40
  137. package/dist/epic/tools/_assets/spell-ui.js +3131 -46465
  138. package/dist/epic/tools/pages.d.ts +5 -6
  139. package/dist/epic/tools/pages.js +7 -6
  140. package/dist/epic/window.mjs +2 -3
  141. package/dist/parser/core/classes/View.d.ts +20 -0
  142. package/dist/parser/core/classes/View.js +91 -17
  143. package/dist/parser/core/core.declarations.json5 +18 -0
  144. package/dist/parser/core/core.scopes.js +5 -0
  145. package/dist/parser/core/sites.d.ts +10 -0
  146. package/dist/parser/core/sites.js +12 -0
  147. package/dist/parser/parser/tokenizer/Tokenizer.d.ts +9 -1
  148. package/dist/parser/parser/tokenizer/Tokenizer.js +43 -5
  149. package/dist/parser/parser/tokenizer/Tokens.d.ts +4 -0
  150. package/dist/parser/parser/tokenizer/Tokens.js +4 -0
  151. package/dist/parser/parser/tokenizer/tokenizer.types.d.ts +5 -0
  152. package/dist/parser/parser/tokenizer/tokenizer.types.js +2 -0
  153. package/dist/parser/py/core/spell_core/apps.py +2 -0
  154. package/dist/parser/spell/PARSING.md +21 -0
  155. package/dist/parser/spell/SpellParser.d.ts +2 -0
  156. package/dist/parser/spell/SpellParser.js +58 -3
  157. package/dist/parser/spell/SpellxTokenizer.js +2 -1
  158. package/dist/parser/spell/SpellxTwin.d.ts +4 -1
  159. package/dist/parser/spell/SpellxTwin.js +10 -3
  160. package/dist/parser/spell/builtinTypes.js +24 -1
  161. package/dist/parser/spell/ingest/PlaceIngest.js +3 -1
  162. package/dist/parser/spell/languages/Language.d.ts +11 -2
  163. package/dist/parser/spell/languages/en/words.js +3 -2
  164. package/dist/parser/spell/languages/es/words.js +7 -4
  165. package/dist/parser/spell/rules/Statement.js +1 -1
  166. package/dist/parser/spell/rules/classes/DrawSlot.js +6 -1
  167. package/dist/parser/spell/rules/sites/SitePage.d.ts +3 -3
  168. package/dist/parser/spell/rules/sites/SitePage.js +2 -2
  169. package/dist/parser/spell/rules/sites/sites.en.js +1 -1
  170. package/dist/parser/spell/rules/sites/sites.es.js +1 -1
  171. package/dist/parser/spell/rules/sites/sites.shared.d.ts +2 -2
  172. package/dist/parser/spell/spell.types.d.ts +7 -0
  173. package/dist/parser/spell/spellSyntax.es.json +6 -6
  174. package/dist/parser/spell/spellSyntax.json +6 -6
  175. package/dist/parser/spellx/SpellxView.js +2 -1
  176. package/dist/ui/components/ui-accordion/UIAccordion.d.ts +1 -0
  177. package/dist/ui/components/ui-ad/UIAd.d.ts +1 -0
  178. package/dist/ui/components/ui-breadcrumbs/UIBreadcrumb.d.ts +1 -0
  179. package/dist/ui/components/ui-breadcrumbs/UIBreadcrumbs.d.ts +1 -0
  180. package/dist/ui/components/ui-button/UIButton.d.ts +8 -3
  181. package/dist/ui/components/ui-button/UIButton.fallback.d.ts +8 -3
  182. package/dist/ui/components/ui-button/UIButtons.d.ts +1 -0
  183. package/dist/ui/components/ui-button/UIOr.d.ts +1 -0
  184. package/dist/ui/components/ui-calendar/UICalendar.d.ts +6 -0
  185. package/dist/ui/components/ui-calendar/UICalendar.fallback.d.ts +6 -0
  186. package/dist/ui/components/ui-card/UICards.d.ts +31 -0
  187. package/dist/ui/components/ui-checkbox/UICheckbox.d.ts +7 -0
  188. package/dist/ui/components/ui-checkbox/UICheckbox.fallback.d.ts +7 -0
  189. package/dist/ui/components/ui-comment/UIComment.d.ts +1 -0
  190. package/dist/ui/components/ui-comment/UIComments.d.ts +1 -0
  191. package/dist/ui/components/ui-components/UIComponents.d.ts +1 -0
  192. package/dist/ui/components/ui-dimmer/UIDimmer.d.ts +1 -0
  193. package/dist/ui/components/ui-divider/UIDivider.d.ts +2 -0
  194. package/dist/ui/components/ui-dropdown/UIDropdown.d.ts +6 -0
  195. package/dist/ui/components/ui-dropdown/UIDropdown.fallback.d.ts +6 -0
  196. package/dist/ui/components/ui-embed/UIEmbed.d.ts +1 -0
  197. package/dist/ui/components/ui-emoji/UIEmoji.d.ts +1 -0
  198. package/dist/ui/components/ui-feed/UIFeed.d.ts +1 -0
  199. package/dist/ui/components/ui-feed/UIFeedEvent.d.ts +1 -0
  200. package/dist/ui/components/ui-flag/UIFlag.d.ts +1 -0
  201. package/dist/ui/components/ui-flyout/UIFlyout.d.ts +1 -0
  202. package/dist/ui/components/ui-form/UIFields.d.ts +1 -0
  203. package/dist/ui/components/ui-form/UIRepeat.d.ts +1 -0
  204. package/dist/ui/components/ui-grid/UIColumn.d.ts +1 -0
  205. package/dist/ui/components/ui-grid/UIGrid.d.ts +1 -0
  206. package/dist/ui/components/ui-grid/UIRow.d.ts +1 -0
  207. package/dist/ui/components/ui-icon/UIIcon.d.ts +3 -2
  208. package/dist/ui/components/ui-icon/UIIcons.d.ts +1 -0
  209. package/dist/ui/components/ui-icon-picker/UIIconPicker.d.ts +6 -0
  210. package/dist/ui/components/ui-icon-picker/UIIconPicker.fallback.d.ts +6 -0
  211. package/dist/ui/components/ui-image/UIImages.d.ts +1 -0
  212. package/dist/ui/components/ui-include/UIInclude.d.ts +1 -0
  213. package/dist/ui/components/ui-input/UIInput.fallback.d.ts +9 -2
  214. package/dist/ui/components/ui-items/UIItems.d.ts +1 -0
  215. package/dist/ui/components/ui-keys/UIKeys.d.ts +1 -0
  216. package/dist/ui/components/ui-label/UILabel.d.ts +2 -0
  217. package/dist/ui/components/ui-label/UILabels.d.ts +1 -0
  218. package/dist/ui/components/ui-list/UIList.d.ts +2 -0
  219. package/dist/ui/components/ui-loader/UILoader.d.ts +1 -0
  220. package/dist/ui/components/ui-message/UIMessage.d.ts +2 -0
  221. package/dist/ui/components/ui-modal/UIModal.d.ts +1 -0
  222. package/dist/ui/components/ui-nag/UINag.d.ts +1 -0
  223. package/dist/ui/components/ui-page/UIPage.d.ts +15 -0
  224. package/dist/ui/components/ui-page/UIPage.es.d.ts +1 -0
  225. package/dist/ui/components/ui-parts/UIActions.d.ts +1 -0
  226. package/dist/ui/components/ui-parts/UIAuthor.d.ts +1 -0
  227. package/dist/ui/components/ui-parts/UIAvatar.d.ts +1 -0
  228. package/dist/ui/components/ui-parts/UIContent.d.ts +1 -0
  229. package/dist/ui/components/ui-parts/UIDate.d.ts +1 -0
  230. package/dist/ui/components/ui-parts/UIDescription.d.ts +1 -0
  231. package/dist/ui/components/ui-parts/UIDetail.d.ts +1 -0
  232. package/dist/ui/components/ui-parts/UIExtra.d.ts +1 -0
  233. package/dist/ui/components/ui-parts/UIHeader.d.ts +15 -3
  234. package/dist/ui/components/ui-parts/UIHeader.en.d.ts +5 -2
  235. package/dist/ui/components/ui-parts/UIHeader.en.js +6 -3
  236. package/dist/ui/components/ui-parts/UIHeader.js +45 -5
  237. package/dist/ui/components/ui-parts/UIMeta.d.ts +1 -0
  238. package/dist/ui/components/ui-parts/UIParts.css +18 -0
  239. package/dist/ui/components/ui-parts/UIParts.css.inline.js +1 -1
  240. package/dist/ui/components/ui-parts/UIParts.types.d.ts +15 -1
  241. package/dist/ui/components/ui-parts/UISummary.d.ts +1 -0
  242. package/dist/ui/components/ui-parts/UITitle.d.ts +1 -0
  243. package/dist/ui/components/ui-parts/UIValue.d.ts +1 -0
  244. package/dist/ui/components/ui-placeholder/UIPlaceholder.d.ts +1 -0
  245. package/dist/ui/components/ui-placeholder/UIPlaceholderHeader.d.ts +1 -0
  246. package/dist/ui/components/ui-placeholder/UIPlaceholderImage.d.ts +1 -0
  247. package/dist/ui/components/ui-placeholder/UIPlaceholderLine.d.ts +1 -0
  248. package/dist/ui/components/ui-placeholder/UIPlaceholderParagraph.d.ts +1 -0
  249. package/dist/ui/components/ui-progress/UIProgress.d.ts +2 -0
  250. package/dist/ui/components/ui-quote/UIQuote.d.ts +1 -0
  251. package/dist/ui/components/ui-rail/UIRail.d.ts +1 -0
  252. package/dist/ui/components/ui-rating/UIRating.d.ts +6 -0
  253. package/dist/ui/components/ui-rating/UIRating.fallback.d.ts +6 -0
  254. package/dist/ui/components/ui-reveal/UIReveal.d.ts +1 -0
  255. package/dist/ui/components/ui-search/UISearch.fallback.d.ts +13 -1
  256. package/dist/ui/components/ui-section/UISections.d.ts +1 -0
  257. package/dist/ui/components/ui-segment/UISegment.d.ts +2 -0
  258. package/dist/ui/components/ui-segment/UISegments.d.ts +1 -0
  259. package/dist/ui/components/ui-select/UISelect.d.ts +6 -0
  260. package/dist/ui/components/ui-select/UISelect.fallback.d.ts +6 -0
  261. package/dist/ui/components/ui-shape/UISide.d.ts +4 -0
  262. package/dist/ui/components/ui-sidebar/UIPushable.d.ts +1 -0
  263. package/dist/ui/components/ui-sidebar/UIPusher.d.ts +1 -0
  264. package/dist/ui/components/ui-sidebar/UISidebar.d.ts +1 -0
  265. package/dist/ui/components/ui-sides/UISides.d.ts +6 -0
  266. package/dist/ui/components/ui-sides/UISides.fallback.d.ts +6 -0
  267. package/dist/ui/components/ui-slider/UISlider.d.ts +7 -0
  268. package/dist/ui/components/ui-slider/UISlider.fallback.d.ts +7 -0
  269. package/dist/ui/components/ui-space/UISpace.d.ts +1 -0
  270. package/dist/ui/components/ui-statistic/UIStatistic.d.ts +1 -0
  271. package/dist/ui/components/ui-statistic/UIStatistics.d.ts +1 -0
  272. package/dist/ui/components/ui-step/UIStep.d.ts +1 -0
  273. package/dist/ui/components/ui-step/UISteps.d.ts +1 -0
  274. package/dist/ui/components/ui-table/UICell.d.ts +1 -0
  275. package/dist/ui/components/ui-terms/UITerm.d.ts +1 -0
  276. package/dist/ui/components/ui-terms/UITerms.d.ts +1 -0
  277. package/dist/ui/components/ui-theme-editor/UIColorChip.d.ts +1 -0
  278. package/dist/ui/components/ui-theme-editor/UIThemeToken.d.ts +1 -0
  279. package/dist/ui/components/ui-toast/UIToast.d.ts +1 -0
  280. package/dist/ui/components/ui-toc/UIToc.d.ts +1 -0
  281. package/dist/ui/components/ui-transition/UITransition.d.ts +1 -0
  282. package/dist/ui/components/ui-video/UIAudio.d.ts +1 -0
  283. package/dist/ui/components/ui-video/UIVideo.d.ts +1 -0
  284. package/dist/ui/components/ui-visibility/UIVisibility.d.ts +1 -0
  285. package/dist/ui/components/ui-zoom/UIZoom.d.ts +1 -0
  286. package/dist/ui/jsx.d.ts +4 -4
  287. package/dist/ui/vocabulary/defaults.generated.js +1 -1
  288. package/dist/util/spell/constants.js +1 -1
  289. package/epic/.claude-plugin/plugin.json +1 -1
  290. package/epic/.codex-plugin/plugin.json +1 -1
  291. package/epic/hooks/handoff.mjs +4 -3
  292. package/epic/hooks/worktree.mjs +22 -3
  293. package/epic/package.json +41 -2
  294. package/epic/skills/details/SKILL.md +2 -1
  295. package/epic/skills/epic/SKILL.md +7 -1
  296. package/epic/skills/epic/guide.md +3 -0
  297. package/epic/skills/isolate/SKILL.md +53 -20
  298. package/epic/src/AGENTS.md +11 -2
  299. package/epic/templates/durable.html +1 -1
  300. package/epic/vscode/package.json +1 -1
  301. package/epic/vscode/spell-epic.vsix +0 -0
  302. package/package.json +1 -1
  303. package/parser/package.json +1 -1
  304. package/ui/package.json +15 -2
@@ -0,0 +1,96 @@
1
+ import { type CodeHostWords, type GhStatus, type MergedPullRequest, type OpenPullRequest, type RepoVisibility } from "./GitHub.ts";
2
+ /****************
3
+ * ### `CodeHost`
4
+ * Which company's server a repo's code is on, and the ONE chooser of how to talk to it: `GitHub` or `GitLab`.
5
+ *
6
+ * ```ts
7
+ * const host = CodeHost.of(config) // an `EpicConfig`, or `{ main, codeHost }`
8
+ * host.status() // => "ready", "missing" or "logged-out"
9
+ * host.words.pullRequest // => "merge request" on GitLab
10
+ * host.openPullRequest({ ... }) // => its address
11
+ * CodeHost.kindOfAddress("git@gitlab.acme.com:a/b.git") // => "gitlab"
12
+ * ```
13
+ *
14
+ * - The setting is `codeHost` in `.epic/config.json5`; a key left out is worked out from the `origin` remote each
15
+ * time it's read: `kindOfAddress()`.
16
+ * - Every caller asks this class; no other code compares host names or kinds.
17
+ * - Its position: `GitHub`, `GitLab` and `EpicHome` beside it, so plain `node` loads it (`EpicConfig` does);
18
+ * NEVER an alias, an `enum` or a parameter property.
19
+ * - All `static`: no state.
20
+ ****************/
21
+ export declare class CodeHost {
22
+ /** The values `codeHost` can take. */
23
+ static readonly KINDS: readonly CodeHostKind[];
24
+ /** Whether `value` is one of `KINDS`. */
25
+ static isKind(value: unknown): value is CodeHostKind;
26
+ /**
27
+ * Whose address git address `address` is: a host naming `gitlab` is GitLab's, `github.com` GitHub's, anything else
28
+ * (no address, a local path, `git.acme.com`) GitHub's by default.
29
+ * - the HOST only, so `github.com:me/gitlab-tools.git` stays GitHub's
30
+ */
31
+ static kindOfAddress(address: string | null | undefined): CodeHostKind;
32
+ /**
33
+ * Whether git address `address` names a host that doesn't say whose it is (`git.acme.com`): `epic init`'s question.
34
+ * - no address, or a local path: `false`: no host to ask about
35
+ */
36
+ static isUnknownAddress(address: string | null | undefined): boolean;
37
+ /** The host of git address `address`, when it has one: `git.acme.com`. */
38
+ static hostOf(address: string | null | undefined): string | undefined;
39
+ /**
40
+ * How to talk to the code host of `config`: `GitHub`, or the `GitLab` of its `origin`.
41
+ * - `config`: an `EpicConfig`, or `{ main, codeHost }` for settings not written yet
42
+ * - reads `origin` from `.git/config`, only for GitLab: it needs the host
43
+ */
44
+ static of(config: CodeHostConfig): CodeHostClient;
45
+ /** The `origin` remote's address in main checkout `main`, as `.git/config` says it; none: `undefined`.
46
+ * - no `git` run: every `EpicConfig` without a `codeHost` asks, the page server's included
47
+ */
48
+ static originOf(main: string): string | undefined;
49
+ /** What a person reads about code host `kind` (a report's lines, with no client to hand); `host`: GitLab's. */
50
+ static wordsFor(kind: CodeHostKind | undefined, host?: string): CodeHostWords;
51
+ /** The repo page `<epic-commit>` links under, for `kind`'s git address `address`; `null` for one that isn't. */
52
+ static commitBase(kind: CodeHostKind, address: string | null | undefined): string | null;
53
+ /**
54
+ * This person's login on `host`, its command asked, for a name to suggest.
55
+ * - GitHub's is kept (`EpicHome.refreshGithub()`): pages show it, never running `gh`
56
+ */
57
+ static loginOn(host: CodeHostClient): string | undefined;
58
+ }
59
+ /** The code hosts `epic` works with. */
60
+ export type CodeHostKind = "github" | "gitlab";
61
+ /** What `CodeHost.of()` takes: an `EpicConfig`, or just the two values it needs. */
62
+ export type CodeHostConfig = {
63
+ main: string;
64
+ codeHost: CodeHostKind;
65
+ };
66
+ /**
67
+ * One code host's operations: `GitHub`'s statics and a `GitLab` both are one of these.
68
+ * - `status()`, `login()`, `isLogin()`: whether its command is there and logged in, and as whom
69
+ * - `isOrganization()`, `ownerIn()`, `repoIn()`: an owner's kind, and what a git address names
70
+ * - `requiresPullRequest()`, `mergedPullRequests()`, `openPullRequestOf()`, `openPullRequest()`: work proposed
71
+ * through a pull or merge request
72
+ * - `createRepo()`, `addressOf()`, `letTeamPush()`: a shared repo made and opened up for the team
73
+ * - `commitBase()`: the page commit links go under
74
+ * - `words`: what a person reads
75
+ */
76
+ export type CodeHostClient = {
77
+ kind: CodeHostKind;
78
+ words: CodeHostWords;
79
+ status(): GhStatus;
80
+ login(): string | undefined;
81
+ isLogin(name: string): boolean;
82
+ isOrganization(owner: string): boolean;
83
+ ownerIn(address: string): string | undefined;
84
+ repoIn(address: string): string | undefined;
85
+ commitBase(address: string | null | undefined): string | null;
86
+ requiresPullRequest(fullName: string, branch: string): boolean;
87
+ mergedPullRequests(branch: string, base: string, cwd: string): MergedPullRequest[];
88
+ openPullRequestOf(branch: string, base: string, cwd: string): string | undefined;
89
+ openPullRequest(request: OpenPullRequest): string;
90
+ createRepo(fullName: string, options?: {
91
+ visibility?: RepoVisibility;
92
+ description?: string;
93
+ }): void;
94
+ addressOf(fullName: string): string;
95
+ letTeamPush(fullName: string, branch: string): string | undefined;
96
+ };
@@ -0,0 +1,89 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/config/CodeHost.ts
5
+ import { readFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { EpicHome } from "./EpicHome.js";
8
+ import {
9
+ GitHub
10
+ } from "./GitHub.js";
11
+ import { GitLab } from "./GitLab.js";
12
+ var CodeHost = class _CodeHost {
13
+ static {
14
+ __name(this, "CodeHost");
15
+ }
16
+ /** The values `codeHost` can take. */
17
+ static KINDS = ["github", "gitlab"];
18
+ /** Whether `value` is one of `KINDS`. */
19
+ static isKind(value) {
20
+ return _CodeHost.KINDS.includes(value);
21
+ }
22
+ /**
23
+ * Whose address git address `address` is: a host naming `gitlab` is GitLab's, `github.com` GitHub's, anything else
24
+ * (no address, a local path, `git.acme.com`) GitHub's by default.
25
+ * - the HOST only, so `github.com:me/gitlab-tools.git` stays GitHub's
26
+ */
27
+ static kindOfAddress(address) {
28
+ return hostSays(address) ?? "github";
29
+ }
30
+ /**
31
+ * Whether git address `address` names a host that doesn't say whose it is (`git.acme.com`): `epic init`'s question.
32
+ * - no address, or a local path: `false`: no host to ask about
33
+ */
34
+ static isUnknownAddress(address) {
35
+ return Boolean(GitLab.partsOf(address)) && !hostSays(address);
36
+ }
37
+ /** The host of git address `address`, when it has one: `git.acme.com`. */
38
+ static hostOf(address) {
39
+ return GitLab.partsOf(address)?.host;
40
+ }
41
+ /**
42
+ * How to talk to the code host of `config`: `GitHub`, or the `GitLab` of its `origin`.
43
+ * - `config`: an `EpicConfig`, or `{ main, codeHost }` for settings not written yet
44
+ * - reads `origin` from `.git/config`, only for GitLab: it needs the host
45
+ */
46
+ static of(config) {
47
+ return config.codeHost === "gitlab" ? GitLab.ofAddress(_CodeHost.originOf(config.main)) : GitHub;
48
+ }
49
+ /** The `origin` remote's address in main checkout `main`, as `.git/config` says it; none: `undefined`.
50
+ * - no `git` run: every `EpicConfig` without a `codeHost` asks, the page server's included
51
+ */
52
+ static originOf(main) {
53
+ return REMOTE_ORIGIN.exec(readConfig(join(main, ".git", "config")))?.[1]?.trim() || void 0;
54
+ }
55
+ /** What a person reads about code host `kind` (a report's lines, with no client to hand); `host`: GitLab's. */
56
+ static wordsFor(kind, host) {
57
+ return kind === "gitlab" ? GitLab.wordsOn(host) : GitHub.words;
58
+ }
59
+ /** The repo page `<epic-commit>` links under, for `kind`'s git address `address`; `null` for one that isn't. */
60
+ static commitBase(kind, address) {
61
+ return kind === "gitlab" ? GitLab.ofAddress(address).commitBase(address) : GitHub.commitBase(address);
62
+ }
63
+ /**
64
+ * This person's login on `host`, its command asked, for a name to suggest.
65
+ * - GitHub's is kept (`EpicHome.refreshGithub()`): pages show it, never running `gh`
66
+ */
67
+ static loginOn(host) {
68
+ return host === GitHub ? EpicHome.refreshGithub() : host.login();
69
+ }
70
+ };
71
+ function hostSays(address) {
72
+ const host = CodeHost.hostOf(address);
73
+ if (!host) return void 0;
74
+ if (/gitlab/i.test(host)) return "gitlab";
75
+ return /(^|\.)github\.com$/i.test(host) ? "github" : void 0;
76
+ }
77
+ __name(hostSays, "hostSays");
78
+ function readConfig(file) {
79
+ try {
80
+ return readFileSync(file, "utf8");
81
+ } catch {
82
+ return "";
83
+ }
84
+ }
85
+ __name(readConfig, "readConfig");
86
+ var REMOTE_ORIGIN = /\[remote "origin"\][^[]*?\burl\s*=\s*(.+)/;
87
+ export {
88
+ CodeHost
89
+ };
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/config/EngineFiles.mjs
5
+ import { basename, dirname, join, resolve } from "node:path";
6
+ var EngineFiles = class _EngineFiles {
7
+ static {
8
+ __name(this, "EngineFiles");
9
+ }
10
+ /** The folder of the engine's code: `epic/src`, or `dist/epic` in an install. This file is in its `config/`. */
11
+ static get code() {
12
+ return resolve(import.meta.dirname ?? ".", "..");
13
+ }
14
+ /** Is this code the built package's (`spell`'s `dist/epic/`), not a checkout's? */
15
+ static get isBuilt() {
16
+ return basename(dirname(_EngineFiles.code)) === DIST;
17
+ }
18
+ /**
19
+ * The engine's folder: `epic/` of the checkout, or `epic/` of the `spell` package, beside its `dist/`:
20
+ * every `"spellPublish": { "files" }` of the engine, and its folder manifest.
21
+ */
22
+ static get root() {
23
+ const { code } = _EngineFiles;
24
+ return _EngineFiles.isBuilt ? join(dirname(dirname(code)), ENGINE_FOLDER) : dirname(code);
25
+ }
26
+ /** The `epic` command, to run under `node`: this copy's, in either layout. */
27
+ static get bin() {
28
+ return _EngineFiles.isBuilt ? join(_EngineFiles.code, "cli", "epicMain.js") : join(_EngineFiles.root, "bin", "epic");
29
+ }
30
+ /**
31
+ * Where `path` is in this layout, `path` as a checkout of the engine has it:
32
+ * - `src/tools/_assets` => `dist/epic/tools/_assets`, `src/tools/x.ts` => its built `.js`, in an install
33
+ * - anything else (`templates`, `skills/epic/guide.md`): from the engine's folder
34
+ * - `engine`: an engine's folder other than this one (a test's fake checkout): plainly from it
35
+ */
36
+ static path(path, engine = _EngineFiles.root) {
37
+ if (!_EngineFiles.isBuilt || resolve(engine) !== _EngineFiles.root || !path.startsWith(SOURCE))
38
+ return join(engine, path);
39
+ return join(_EngineFiles.code, path.slice(SOURCE.length).replace(/\.tsx?$/, ".js"));
40
+ }
41
+ /**
42
+ * How to run `script` (a file of the engine's code) as a child `node`, for `spawnSync(process.execPath, args, { env })`:
43
+ * - a checkout: under `tsx`, with the engine's `tsconfig.json`: every repo's files by their package names
44
+ * - an install: plain `node`, the code being built (no `tsconfig.json` ships)
45
+ * - `env`: what to start from, default this process's
46
+ */
47
+ static nodeRun(script, args = [], env = process.env) {
48
+ if (_EngineFiles.isBuilt) return { args: [script, ...args], env };
49
+ return {
50
+ args: ["--import", "tsx", script, ...args],
51
+ env: { ...env, TSX_TSCONFIG_PATH: join(_EngineFiles.root, "tsconfig.json") }
52
+ };
53
+ }
54
+ };
55
+ var DIST = "dist";
56
+ var ENGINE_FOLDER = "epic";
57
+ var SOURCE = "src/";
58
+ export {
59
+ EngineFiles
60
+ };
@@ -1,3 +1,4 @@
1
+ import { type CodeHostKind } from "./CodeHost.ts";
1
2
  import { Editor } from "./Editor.ts";
2
3
  /****************
3
4
  * ### `EpicConfig`
@@ -151,6 +152,10 @@ export declare class EpicConfig {
151
152
  get contentFolder(): string;
152
153
  /** the branch worktrees start from and merge into */
153
154
  get baseBranch(): string;
155
+ /** whether the base branch can't be pushed to: work reaches it only through a pull request */
156
+ get baseBranchProtected(): boolean;
157
+ /** where the code is hosted, `github` or `gitlab`: ask `CodeHost.of(config)` how to talk to it */
158
+ get codeHost(): CodeHostKind;
154
159
  /**
155
160
  * the folder NEW worktrees go in, `<worktreesFolder>/<name>`: `worktreesFolder`, from the main checkout
156
161
  * - existing ones may still be in the old place: `worktreesFolders`
@@ -563,17 +568,27 @@ export type EpicOldLayout = {
563
568
  * epic folder is missing
564
569
  * - `baseBranch`: the branch worktrees start from and merge into (the remote's default branch, from git):
565
570
  * the worktree hook, `epic worktree merge-main`, `epic merge`, the behind-main notice
571
+ * - `codeHost`: where the code is hosted, `"github"` or `"gitlab"`: `CodeHost.of()` picks `gh` or `glab` by it
572
+ * - left out, it's worked out from the `origin` remote each time it's read (`CodeHost.kindOfAddress()`):
573
+ * `epic init` writes the value it settled on, for an address that doesn't say (`--host`)
574
+ * - `baseBranchProtected`: the base branch can't be pushed to, and work reaches it only through a pull request
575
+ * (`false`, the default; `epic init` turns it on with `--protected-base`, or when the code host says so)
576
+ * - `epic init` opens a pull request instead of committing on it; `epic merge` refuses
577
+ * - the worktree hook and `epic worktree merge-main` fast-forward the local base branch from `origin` first
578
+ * (`BaseBranch`); `epic worktree remove --branches` counts a merged pull request as merged (a squash too)
579
+ * - the skills' finish reads it: a pull request in place of a merge
580
+ * - NOT the epic repo, whose own branch every turn pushes to: an org-wide rule must leave it out
566
581
  * - `worktreesFolder`: where NEW worktrees go, relative to the main checkout (`../my-app.worktrees`), one folder each:
567
582
  * the worktree hook, the window script, the epics list, the page server's `/worktrees/<w>/`
568
583
  * - outside the repo since epic `epic-eject` P8: the old place, `.claude/worktrees`, is still read for the
569
584
  * worktrees left there (`worktreesFolders`)
570
- * - `installCommand`: what makes a new worktree ready to run (what the repo's lock file names, `yarn install`):
585
+ * - `installCommand`: what makes a new worktree ready to run (what the repo's lock file names, `npm install`):
571
586
  * `/isolate`, `/epic`, the hook; `""` for none (a repo with no packages to install)
572
587
  * - `installOnCreate`: whether the worktree hook runs `installCommand` itself, before it hands a NEW worktree over
573
588
  * (off: the skills run it, after entering). On (the default when there's an install command), nothing opens the
574
589
  * worktree without its packages (I2)
575
590
  * - `installTimeout`: the seconds the hook's install may take (600)
576
- * - `extraInstalls`: folders of a new worktree that are yarn projects of their own, NOT workspaces of the one install
591
+ * - `extraInstalls`: folders of a new worktree that are projects of their own, NOT workspaces of the one install
577
592
  * (`["epic/vscode", "app/vscode"]`, the extensions; epic `epic-engine` I65), each a path from the
578
593
  * worktree's root (the top's, in a multi-repo top); `[]` (the default): none
579
594
  * - the worktree hook runs `installCommand` in each, after the one at the root, `installTimeout` seconds each
@@ -649,6 +664,8 @@ export type EpicSettings = {
649
664
  contentFolder: string;
650
665
  contentRemote: string;
651
666
  baseBranch: string;
667
+ baseBranchProtected: boolean;
668
+ codeHost: CodeHostKind;
652
669
  worktreesFolder: string;
653
670
  installCommand: string;
654
671
  installOnCreate: boolean;
@@ -673,7 +690,7 @@ export type EpicSettings = {
673
690
  oldLayout: EpicOldLayout;
674
691
  };
675
692
  /** The keys whose value comes from the repo itself, when a file leaves them out (`EpicConfig.defaultsFor()`). */
676
- type RepoKey = "contentFolder" | "baseBranch" | "worktreesFolder" | "installCommand" | "installOnCreate" | "windowsFolder";
693
+ type RepoKey = "contentFolder" | "codeHost" | "baseBranch" | "worktreesFolder" | "installCommand" | "installOnCreate" | "windowsFolder";
677
694
  /**
678
695
  * `EpicConfig.DEFAULTS`: every key of `EpicSettings` with no per-repo value, the same in any repo
679
696
  * - the window names are the repo's; only a window's layout and settings are here
@@ -8,8 +8,10 @@ import JSON5 from "json5";
8
8
  import { checkoutOf } from "spell/server/checkout";
9
9
  import { Git } from "spell/server/Git";
10
10
  import { RealPath } from "spell/server/RealPath";
11
+ import { EngineFiles } from "./EngineFiles.mjs";
11
12
  import { peerRepos } from "spell/server/page/settings";
12
13
  import { PeopleColors } from "./PeopleColors.js";
14
+ import { CodeHost } from "./CodeHost.js";
13
15
  import { Editor, EDITOR_IDS } from "./Editor.js";
14
16
  import { VoiceColor } from "./VoiceColor.js";
15
17
  var EpicConfig = class _EpicConfig {
@@ -25,6 +27,7 @@ var EpicConfig = class _EpicConfig {
25
27
  */
26
28
  static DEFAULTS = {
27
29
  contentRemote: "",
30
+ baseBranchProtected: false,
28
31
  installTimeout: 600,
29
32
  extraInstalls: [],
30
33
  windows: { worktreeOnly: true, settings: {} },
@@ -52,7 +55,7 @@ var EpicConfig = class _EpicConfig {
52
55
  * computed as the class loads stopped it starting (epic `epic-engine` I76)
53
56
  */
54
57
  static get ENGINE_VOICES() {
55
- return resolve(import.meta.dirname ?? ".", "../../voices");
58
+ return EngineFiles.path("voices");
56
59
  }
57
60
  /**
58
61
  * where the window files were before epic `epic-eject` P13, from the main checkout:
@@ -178,6 +181,14 @@ var EpicConfig = class _EpicConfig {
178
181
  get baseBranch() {
179
182
  return this.settings.baseBranch;
180
183
  }
184
+ /** whether the base branch can't be pushed to: work reaches it only through a pull request */
185
+ get baseBranchProtected() {
186
+ return this.settings.baseBranchProtected;
187
+ }
188
+ /** where the code is hosted, `github` or `gitlab`: ask `CodeHost.of(config)` how to talk to it */
189
+ get codeHost() {
190
+ return this.settings.codeHost;
191
+ }
181
192
  /**
182
193
  * the folder NEW worktrees go in, `<worktreesFolder>/<name>`: `worktreesFolder`, from the main checkout
183
194
  * - existing ones may still be in the old place: `worktreesFolders`
@@ -769,6 +780,8 @@ var EpicConfig = class _EpicConfig {
769
780
  contentFolder: this.contentFolder,
770
781
  contentRemote: this.contentRemote,
771
782
  baseBranch: this.baseBranch,
783
+ baseBranchProtected: this.baseBranchProtected,
784
+ codeHost: this.codeHost,
772
785
  worktreesFolder: this.worktreesFolder,
773
786
  installCommand: this.installCommand,
774
787
  installOnCreate: this.installOnCreate,
@@ -867,6 +880,7 @@ var EpicConfig = class _EpicConfig {
867
880
  return {
868
881
  ...defaults,
869
882
  contentFolder,
883
+ codeHost: CodeHost.kindOfAddress(CodeHost.originOf(main)),
870
884
  baseBranch: written.baseBranch === void 0 ? _EpicConfig.baseBranchOf(main) : "main",
871
885
  worktreesFolder: `../${repo}.worktrees`,
872
886
  installCommand,
@@ -929,6 +943,8 @@ var EpicConfig = class _EpicConfig {
929
943
  contentFolder: valueOf(given, "contentFolder", defaults.contentFolder, file),
930
944
  contentRemote: valueOf(given, "contentRemote", defaults.contentRemote, file, "", { empty: true }),
931
945
  baseBranch: valueOf(given, "baseBranch", defaults.baseBranch, file),
946
+ baseBranchProtected: valueOf(given, "baseBranchProtected", defaults.baseBranchProtected, file),
947
+ codeHost: codeHostOf(given, defaults.codeHost, file),
932
948
  worktreesFolder: valueOf(given, "worktreesFolder", defaults.worktreesFolder, file),
933
949
  installCommand: valueOf(given, "installCommand", defaults.installCommand, file, "", { empty: true }),
934
950
  installOnCreate: valueOf(given, "installOnCreate", defaults.installOnCreate, file),
@@ -1016,6 +1032,14 @@ function warnOnce(message) {
1016
1032
  `);
1017
1033
  }
1018
1034
  __name(warnOnce, "warnOnce");
1035
+ function codeHostOf(given, fallback, file) {
1036
+ const value = given.codeHost;
1037
+ if (value === void 0) return fallback;
1038
+ if (!CodeHost.isKind(value))
1039
+ throw new TypeError(`EpicConfig: ${file}'s "codeHost" must be "github" or "gitlab", not ${JSON.stringify(value)}`);
1040
+ return value;
1041
+ }
1042
+ __name(codeHostOf, "codeHostOf");
1019
1043
  function valueOf(given, key, fallback, file, prefix = "", { empty: emptyOk = false } = {}) {
1020
1044
  const value = given[key];
1021
1045
  if (value === void 0) return fallback;
@@ -169,7 +169,7 @@ function currentUrl(url, renames) {
169
169
  }
170
170
  __name(currentUrl, "currentUrl");
171
171
  function normalUrl(url) {
172
- return url.trim().toLowerCase().replace(/^[a-z+]+:\/\//, "").replace(/^[^@/]+@/, "").replace(/^([^/:]+):(?!\d)/, "$1/").replace(/\/+$/, "").replace(/\.git$/, "");
172
+ return url.trim().toLowerCase().replace(/^[a-z+]+:\/\//, "").replace(/^[^@/]+@/, "").replace(/^([^/:]+):(?!\d)/, "$1/").replace(/\/+$/, "").replace(/\/-$/, "").replace(/\.git$/, "");
173
173
  }
174
174
  __name(normalUrl, "normalUrl");
175
175
  function isFolder(path) {
@@ -13,21 +13,29 @@
13
13
  *
14
14
  * - Who runs it: `EpicHome.refreshGithub()` (the person's login), `epic init` (the epic repo).
15
15
  * Serving a page or running a hook never does: `gh` may take seconds, or be offline.
16
+ * And a repo whose base branch takes only pull requests: `epic init` opens one, `epic worktree remove --branches`
17
+ * asks whether a branch's was merged.
16
18
  * - `$SPELL_EPIC_GH` names another `gh` (`command()`): the tests' stand-ins, or a path to none.
17
19
  * - Git itself is the kit's `Git`, never this.
18
20
  * - STATIC: `gh` is the machine's.
19
21
  * - Its position: node's own modules only, so plain `node` loads it (beside `EpicHome`, which does);
20
22
  * NEVER an alias, an `enum` or a parameter property.
23
+ * - One of the two code hosts: callers ask `CodeHost.of()`, which hands back this class or a `GitLab`;
24
+ * nothing else tells them apart. `run()` runs `glab` for `GitLab` too: one runner.
21
25
  ****************/
22
26
  export declare class GitHub {
27
+ /** Which code host this is: `CodeHost`'s word for it. */
28
+ static readonly kind = "github";
29
+ /** What a person reads about this host: what work is proposed through, and how to get its command. */
30
+ static readonly words: CodeHostWords;
23
31
  /** The `gh` to run: `$SPELL_EPIC_GH`, else `gh` on the `PATH`. Read on every call: a test sets it. */
24
32
  static command(): string;
25
33
  /**
26
34
  * Run `gh <args>`: `{ ok, out, err }`, `out` and `err` trimmed.
27
- * - `command`: the `gh` to run, default `command()`
28
- * - a missing `gh`, a timeout or a failing command is `ok: false`; NEVER throws
35
+ * - `command`: the command to run, default `command()`; `GitLab` passes its `glab` here
36
+ * - a missing command, a timeout or a failing command is `ok: false`; NEVER throws
29
37
  */
30
- static run(args: string[], { command, timeout }?: GhRunOptions): GhResult;
38
+ static run(args: string[], { command, timeout, cwd }?: GhRunOptions): GhResult;
31
39
  /**
32
40
  * Whether `gh` can make a repo: `ready`, `missing` (not installed: `gh --version` doesn't run) or `logged-out`
33
41
  * (`gh auth status` says no, or can't reach GitHub). NEVER throws.
@@ -37,6 +45,13 @@ export declare class GitHub {
37
45
  static login(command?: string): string | undefined;
38
46
  /** Whether `name` is a GitHub login: letters, digits and single hyphens, at most 39. */
39
47
  static isLogin(name: string): boolean;
48
+ /**
49
+ * The repo page `<epic-commit>` links under, for git address `address`: `https://github.com/o/r`, which takes
50
+ * `/commit/<sha>`; `null` for an address that isn't GitHub's.
51
+ */
52
+ static commitBase(address: string | null | undefined): string | null;
53
+ /** Nothing to do: a new GitHub repo's main takes pushes from everyone added to it. `CodeHost`'s other side. */
54
+ static letTeamPush(): string | undefined;
40
55
  /** Whether GitHub account `owner` is an organization, not a person; `false` when gh can't say. NEVER throws. */
41
56
  static isOrganization(owner: string): boolean;
42
57
  /**
@@ -44,6 +59,30 @@ export declare class GitHub {
44
59
  * `undefined` for an address that isn't GitHub's.
45
60
  */
46
61
  static ownerIn(address: string): string | undefined;
62
+ /** The GitHub repo in git address `address`, `owner/name`; `undefined` for an address that isn't GitHub's. */
63
+ static repoIn(address: string): string | undefined;
64
+ /**
65
+ * Whether GitHub requires a pull request into `branch` of repo `fullName` (`owner/name`):
66
+ * a ruleset's `pull_request` rule, or, where this person may read it, classic branch protection's required reviews.
67
+ * - `false` for anything else: no rule, no right to read it, offline, `gh` missing. NEVER throws.
68
+ */
69
+ static requiresPullRequest(fullName: string, branch: string): boolean;
70
+ /**
71
+ * The pull request of branch `branch` into `base` that GitHub merged, as `gh` run in `cwd` reports it:
72
+ * `{ number, url, head }` (`head`: its last commit), the newest first; `[]` when `gh` can't say. NEVER throws.
73
+ */
74
+ static mergedPullRequests(branch: string, base: string, cwd: string): MergedPullRequest[];
75
+ /**
76
+ * Open a pull request of `branch` into `base`, from checkout `cwd`: its address.
77
+ * - one open already: that one's address
78
+ * - throws an `Error` with gh's own words when it can't
79
+ * - SIDE EFFECT: a pull request on GitHub
80
+ */
81
+ static openPullRequest({ branch, base, title, body, cwd }: OpenPullRequest): string;
82
+ /** The address of the pull request of `branch` into `base` that's open, from checkout `cwd`; none: `undefined`. NEVER throws. */
83
+ static openPullRequestOf(branch: string, base: string, cwd: string): string | undefined;
84
+ /** `gh <args>`'s output as JSON; `undefined` when it failed or wasn't JSON. NEVER throws. */
85
+ private static json;
47
86
  /**
48
87
  * Make GitHub repo `fullName` (`owner/name`), empty: private, unless `visibility` says `public`.
49
88
  * - throws an `Error` with gh's own words when it can't (a name taken, no right to make one there)
@@ -60,6 +99,23 @@ export declare class GitHub {
60
99
  */
61
100
  static addressOf(fullName: string): string;
62
101
  }
102
+ /** What a person reads about a code host: `GitHub.words`, `GitLab`'s; the ONE place that says "merge request". */
103
+ export type CodeHostWords = {
104
+ /** its name: GitHub, GitLab */
105
+ name: string;
106
+ /** its command: `gh`, `glab` */
107
+ command: string;
108
+ /** what work is proposed through, in a sentence: `pull request`, `merge request` */
109
+ pullRequest: string;
110
+ /** that, starting a sentence */
111
+ PullRequest: string;
112
+ /** one of them, as this host numbers it: `#12`, `!12` */
113
+ number: (id: number) => string;
114
+ /** the lines to run to get its command, logged in, two spaces in */
115
+ install: string[];
116
+ /** the line that opens one by hand, for a branch already pushed */
117
+ openCommand: (base: string, branch: string) => string;
118
+ };
63
119
  /** What `GitHub.run()` returns. */
64
120
  export type GhResult = {
65
121
  ok: boolean;
@@ -72,6 +128,22 @@ export type GhRunOptions = {
72
128
  command?: string;
73
129
  /** how long it may take, ms; default a few seconds: it may be offline */
74
130
  timeout?: number;
131
+ /** where it runs, for what asks about "this repo" (`gh pr ...`); default the current folder */
132
+ cwd?: string;
133
+ };
134
+ /** A pull request GitHub merged: `GitHub.mergedPullRequests()`; `head`: its last commit. */
135
+ export type MergedPullRequest = {
136
+ number: number;
137
+ url: string;
138
+ head: string;
139
+ };
140
+ /** What `GitHub.openPullRequest()` takes. */
141
+ export type OpenPullRequest = {
142
+ branch: string;
143
+ base: string;
144
+ title: string;
145
+ body: string;
146
+ cwd: string;
75
147
  };
76
148
  /** Whether `gh` can make a repo: `GitHub.status()`. */
77
149
  export type GhStatus = "ready" | "missing" | "logged-out";