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
@@ -7,18 +7,30 @@ var GitHub = class _GitHub {
7
7
  static {
8
8
  __name(this, "GitHub");
9
9
  }
10
+ /** Which code host this is: `CodeHost`'s word for it. */
11
+ static kind = "github";
12
+ /** What a person reads about this host: what work is proposed through, and how to get its command. */
13
+ static words = {
14
+ name: "GitHub",
15
+ command: "gh",
16
+ pullRequest: "pull request",
17
+ PullRequest: "Pull request",
18
+ number: /* @__PURE__ */ __name((id) => `#${id}`, "number"),
19
+ install: [" brew install gh (other systems: https://cli.github.com)", " gh auth login"],
20
+ openCommand: /* @__PURE__ */ __name((base, branch) => `gh pr create --base ${base} --head ${branch} --fill`, "openCommand")
21
+ };
10
22
  /** The `gh` to run: `$SPELL_EPIC_GH`, else `gh` on the `PATH`. Read on every call: a test sets it. */
11
23
  static command() {
12
24
  return process.env[GH_ENV] || "gh";
13
25
  }
14
26
  /**
15
27
  * Run `gh <args>`: `{ ok, out, err }`, `out` and `err` trimmed.
16
- * - `command`: the `gh` to run, default `command()`
17
- * - a missing `gh`, a timeout or a failing command is `ok: false`; NEVER throws
28
+ * - `command`: the command to run, default `command()`; `GitLab` passes its `glab` here
29
+ * - a missing command, a timeout or a failing command is `ok: false`; NEVER throws
18
30
  */
19
- static run(args, { command = _GitHub.command(), timeout = TIMEOUT_MS } = {}) {
31
+ static run(args, { command = _GitHub.command(), timeout = TIMEOUT_MS, cwd } = {}) {
20
32
  try {
21
- const run = spawnSync(command, args, { encoding: "utf8", timeout });
33
+ const run = spawnSync(command, args, { encoding: "utf8", timeout, cwd });
22
34
  return {
23
35
  ok: run.status === 0,
24
36
  out: (run.stdout ?? "").trim(),
@@ -45,6 +57,18 @@ var GitHub = class _GitHub {
45
57
  static isLogin(name) {
46
58
  return LOGIN.test(name);
47
59
  }
60
+ /**
61
+ * The repo page `<epic-commit>` links under, for git address `address`: `https://github.com/o/r`, which takes
62
+ * `/commit/<sha>`; `null` for an address that isn't GitHub's.
63
+ */
64
+ static commitBase(address) {
65
+ const repo = _GitHub.repoIn(String(address ?? "").trim());
66
+ return repo ? `https://github.com/${repo}` : null;
67
+ }
68
+ /** Nothing to do: a new GitHub repo's main takes pushes from everyone added to it. `CodeHost`'s other side. */
69
+ static letTeamPush() {
70
+ return void 0;
71
+ }
48
72
  /** Whether GitHub account `owner` is an organization, not a person; `false` when gh can't say. NEVER throws. */
49
73
  static isOrganization(owner) {
50
74
  return _GitHub.run(["api", `users/${owner}`, "-q", ".type"]).out === "Organization";
@@ -56,6 +80,81 @@ var GitHub = class _GitHub {
56
80
  static ownerIn(address) {
57
81
  return GITHUB_ADDRESS.exec(address)?.[1];
58
82
  }
83
+ /** The GitHub repo in git address `address`, `owner/name`; `undefined` for an address that isn't GitHub's. */
84
+ static repoIn(address) {
85
+ const match = GITHUB_ADDRESS.exec(address);
86
+ return match ? `${match[1]}/${match[2]}` : void 0;
87
+ }
88
+ /**
89
+ * Whether GitHub requires a pull request into `branch` of repo `fullName` (`owner/name`):
90
+ * a ruleset's `pull_request` rule, or, where this person may read it, classic branch protection's required reviews.
91
+ * - `false` for anything else: no rule, no right to read it, offline, `gh` missing. NEVER throws.
92
+ */
93
+ static requiresPullRequest(fullName, branch) {
94
+ const path = `repos/${fullName}`;
95
+ const name = encodeURIComponent(branch);
96
+ const rules = _GitHub.json(["api", `${path}/rules/branches/${name}`]);
97
+ if (Array.isArray(rules) && rules.some((rule) => rule.type === PULL_REQUEST_RULE)) return true;
98
+ const classic = _GitHub.json([
99
+ "api",
100
+ `${path}/branches/${name}/protection`
101
+ ]);
102
+ return Boolean(classic?.required_pull_request_reviews);
103
+ }
104
+ /**
105
+ * The pull request of branch `branch` into `base` that GitHub merged, as `gh` run in `cwd` reports it:
106
+ * `{ number, url, head }` (`head`: its last commit), the newest first; `[]` when `gh` can't say. NEVER throws.
107
+ */
108
+ static mergedPullRequests(branch, base, cwd) {
109
+ const args = [
110
+ "pr",
111
+ "list",
112
+ "--head",
113
+ branch,
114
+ "--base",
115
+ base,
116
+ "--state",
117
+ "merged",
118
+ "--json",
119
+ "number,url,headRefOid"
120
+ ];
121
+ const found = _GitHub.json(args, { cwd, timeout: NETWORK_MS });
122
+ return Array.isArray(found) ? found.map(({ number, url, headRefOid }) => ({ number, url, head: headRefOid })) : [];
123
+ }
124
+ /**
125
+ * Open a pull request of `branch` into `base`, from checkout `cwd`: its address.
126
+ * - one open already: that one's address
127
+ * - throws an `Error` with gh's own words when it can't
128
+ * - SIDE EFFECT: a pull request on GitHub
129
+ */
130
+ static openPullRequest({ branch, base, title, body, cwd }) {
131
+ const open = _GitHub.openPullRequestOf(branch, base, cwd);
132
+ if (open) return open;
133
+ const run = _GitHub.run(["pr", "create", "--base", base, "--head", branch, "--title", title, "--body", body], {
134
+ cwd,
135
+ timeout: CREATE_TIMEOUT_MS
136
+ });
137
+ if (!run.ok) throw new Error(`gh pr create failed: ${run.err || run.out || "no reason given"}`, { cause: run });
138
+ return run.out.split("\n").at(-1) ?? "";
139
+ }
140
+ /** The address of the pull request of `branch` into `base` that's open, from checkout `cwd`; none: `undefined`. NEVER throws. */
141
+ static openPullRequestOf(branch, base, cwd) {
142
+ const open = _GitHub.json(
143
+ ["pr", "list", "--head", branch, "--base", base, "--state", "open", "--json", "url"],
144
+ { cwd, timeout: NETWORK_MS }
145
+ );
146
+ return Array.isArray(open) ? open[0]?.url || void 0 : void 0;
147
+ }
148
+ /** `gh <args>`'s output as JSON; `undefined` when it failed or wasn't JSON. NEVER throws. */
149
+ static json(args, options) {
150
+ const run = _GitHub.run(args, options);
151
+ if (!run.ok) return void 0;
152
+ try {
153
+ return JSON.parse(run.out);
154
+ } catch {
155
+ return void 0;
156
+ }
157
+ }
59
158
  /**
60
159
  * Make GitHub repo `fullName` (`owner/name`), empty: private, unless `visibility` says `public`.
61
160
  * - throws an `Error` with gh's own words when it can't (a name taken, no right to make one there)
@@ -85,8 +184,10 @@ var GH_ENV = "SPELL_EPIC_GH";
85
184
  var HOST = "github.com";
86
185
  var TIMEOUT_MS = 5e3;
87
186
  var CREATE_TIMEOUT_MS = 3e4;
187
+ var NETWORK_MS = 15e3;
188
+ var PULL_REQUEST_RULE = "pull_request";
88
189
  var LOGIN = /^[A-Za-z\d](?:[A-Za-z\d]|-(?=[A-Za-z\d])){0,38}$/;
89
- var GITHUB_ADDRESS = /github\.com[:/]([^/]+)\/[^/]+?(?:\.git)?\/?$/;
190
+ var GITHUB_ADDRESS = /github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/;
90
191
  export {
91
192
  GitHub
92
193
  };
@@ -0,0 +1,138 @@
1
+ import { type CodeHostWords, type GhStatus, type MergedPullRequest, type OpenPullRequest, type RepoVisibility } from "./GitHub.ts";
2
+ /****************
3
+ * ### `GitLab`
4
+ * GitLab's command, `glab`, for the epic tools: the same operations as `GitHub`, on one GitLab instance.
5
+ *
6
+ * ```ts
7
+ * const lab = GitLab.ofAddress("git@git.acme.com:team/sub/app.git")
8
+ * lab.status() // => "ready", "missing" or "logged-out"
9
+ * lab.repoIn("https://git.acme.com/a/b/c") // => "a/b/c"
10
+ * lab.createRepo("team/sub/app.epics") // => the project made, private; throws with glab's words
11
+ * ```
12
+ *
13
+ * - One instance per repo, unlike `GitHub`'s statics: a repo's GitLab may be any host (`git.acme.com`).
14
+ * - Every call names that host, so a self-hosted address works from anywhere: `glab api --hostname`, `glab auth
15
+ * status --hostname`, `glab mr create --repo <its address>`.
16
+ * - Callers ask `CodeHost.of()`, never this class.
17
+ * - It leans on `glab api`, whose answers are GitLab's documented JSON, not `glab`'s printed tables;
18
+ * `glab mr create` is the one exception, and even so its address is read back from the API when it can't be parsed.
19
+ * - It makes a project through the API, never `glab repo create`, whose `--skipGitInit` still adds a local remote
20
+ * (https://gitlab.com/gitlab-org/cli/-/issues/8533).
21
+ * - NOT tried against a real GitLab yet: README-epics.md's "On GitLab" says so.
22
+ * - Its position: `GitHub` beside it (the one runner) and nothing else of ours, so plain `node` loads it;
23
+ * NEVER an alias, an `enum` or a parameter property.
24
+ ****************/
25
+ export declare class GitLab {
26
+ /** Which code host this is: `CodeHost`'s word for it. */
27
+ readonly kind = "gitlab";
28
+ /** the instance: `gitlab.com`, `git.acme.com`; none: `glab` picks */
29
+ readonly host: string | undefined;
30
+ /** the repo's path on it: `team/sub/app`; none for a repo with no GitLab address */
31
+ readonly repoPath: string | undefined;
32
+ /** whether the repo is reached over SSH: a project made for it is too */
33
+ readonly usesSsh: boolean;
34
+ /** - `host`, `repoPath`, `usesSsh`: as the fields; `ofAddress()` works them out from a git address */
35
+ constructor({ host, repoPath, usesSsh }?: {
36
+ host?: string;
37
+ repoPath?: string;
38
+ usesSsh?: boolean;
39
+ });
40
+ /**
41
+ * The `GitLab` of the repo at git address `address`: `git@host:group/sub/p.git`, `ssh://git@host/group/sub/p`,
42
+ * `https://host/group/sub/p.git`; self-hosted hosts too.
43
+ * - no address, or one naming no host (a local path): `glab` picks the host, and there's no repo path
44
+ */
45
+ static ofAddress(address: string | null | undefined): GitLab;
46
+ /**
47
+ * The host, the path and the protocol in git address `address`; `undefined` for a local path or anything else.
48
+ * - scp-like (`git@host:a/b.git`) and `ssh://` are SSH, an `ssh://` port dropped (`glab` knows the web host);
49
+ * `https://` keeps its port
50
+ */
51
+ static partsOf(address: string | null | undefined): {
52
+ host: string;
53
+ path: string;
54
+ ssh: boolean;
55
+ } | undefined;
56
+ /** The `glab` to run: `$SPELL_EPIC_GLAB`, else `glab` on the `PATH`. Read on every call: a test sets it. */
57
+ static command(): string;
58
+ /** What a person reads about this host. */
59
+ get words(): CodeHostWords;
60
+ /** What a person reads about GitLab at `host`: self-hosted, how to log in names it. */
61
+ static wordsOn(host?: string): CodeHostWords;
62
+ /** Run `glab <args>`: as `GitHub.run()`, `glab` by default. NEVER throws. */
63
+ private run;
64
+ /** Call GitLab's API on this repo's host. NEVER throws. */
65
+ private api;
66
+ /** `glab api <endpoint>`'s answer as JSON; `undefined` when it failed or wasn't JSON. NEVER throws. */
67
+ private json;
68
+ /** Whether `glab` can work: `ready`, `missing` (`glab version` doesn't run) or `logged-out`. NEVER throws. */
69
+ status(command?: string): GhStatus;
70
+ /** The GitLab username `glab` is logged in as; `undefined` for none (missing, logged out, offline). NEVER throws. */
71
+ login(): string | undefined;
72
+ /** Whether `name` is a GitLab username. */
73
+ isLogin(name: string): boolean;
74
+ /** Whether namespace `owner` is a GitLab group, subgroups too, not a person's; `false` when glab can't say. NEVER throws. */
75
+ isOrganization(owner: string): boolean;
76
+ /** The group or user in git address `address`, subgroups included: `team/sub`; `undefined` without one. */
77
+ ownerIn(address: string): string | undefined;
78
+ /** The project path in git address `address`, `team/sub/app`; `undefined` for an address naming no host. */
79
+ repoIn(address: string): string | undefined;
80
+ /**
81
+ * The repo page `<epic-commit>` links under, for git address `address`: `https://host/team/sub/app/-`, which takes
82
+ * `/commit/<sha>`; `null` for an address naming no host.
83
+ * - the `/-` is GitLab's own: a page's `repo` attribute carries it, so the element needs no rule for GitLab
84
+ */
85
+ commitBase(address: string | null | undefined): string | null;
86
+ /**
87
+ * Whether a merge request is the only way into `branch` of project `fullName`: its protected branches, any rule
88
+ * naming `branch` (`*-stable` too), with no push level the caller reaches.
89
+ * - nobody may push (level 0), or levels above the caller's: `true`; a level by user or group it can't check: counts
90
+ * as reachable
91
+ * - `false` for anything else: no rule, no right to read it, offline, `glab` missing. NEVER throws.
92
+ */
93
+ requiresPullRequest(fullName: string, branch: string): boolean;
94
+ /**
95
+ * The merge requests of `branch` into `base` that GitLab merged: `{ number, url, head }` (`head`: its last commit),
96
+ * newest first; `[]` when `glab` can't say. NEVER throws.
97
+ */
98
+ mergedPullRequests(branch: string, base: string, _cwd: string): MergedPullRequest[];
99
+ /** The address of the merge request of `branch` into `base` that's open; none: `undefined`. NEVER throws. */
100
+ openPullRequestOf(branch: string, base: string, _cwd: string): string | undefined;
101
+ /** This repo's merge requests of `branch` into `base`, by state; `[]` when `glab` can't say. */
102
+ private requestsOf;
103
+ /**
104
+ * Open a merge request of `branch` into `base`, from checkout `cwd`: its address.
105
+ * - one open already: that one's address
106
+ * - never asks anything: `--yes`, with title and description given
107
+ * - `body` empty: the title, `glab` otherwise asking for one
108
+ * - throws an `Error` with glab's own words when it can't
109
+ * - SIDE EFFECT: a merge request on GitLab
110
+ */
111
+ openPullRequest({ branch, base, title, body, cwd }: OpenPullRequest): string;
112
+ /** The repo's own address, for `--repo`: `https://host/team/sub/app`; none without a host and path. */
113
+ private get repoAddress();
114
+ /**
115
+ * Make GitLab project `fullName` (`team/sub/name`, or `username/name`), empty: private, unless `visibility` says.
116
+ * - through the API (the class's note): `POST projects`, under the group, or the person's own namespace
117
+ * - throws an `Error` with glab's own words when it can't (a name taken, no right to make one there)
118
+ * - SIDE EFFECT: a new project on GitLab
119
+ */
120
+ createRepo(fullName: string, { visibility, description }?: {
121
+ visibility?: RepoVisibility;
122
+ description?: string;
123
+ }): void;
124
+ /**
125
+ * GitLab project `fullName`'s address for git: SSH when this repo is reached over SSH, else HTTPS, so a push goes
126
+ * the way this person's already do.
127
+ * - throws an `Error` with glab's words when glab can't find it
128
+ */
129
+ addressOf(fullName: string): string;
130
+ /**
131
+ * Let every teammate push to `branch` of project `fullName`: run once the branch exists (its first push), which is
132
+ * when GitLab protects a new project's default branch, Developers kept out.
133
+ * - a line saying what to do by hand when it couldn't (no right to, offline); `undefined` when it's done
134
+ * - NEVER throws: a project it can't open up is still a project
135
+ * - SIDE EFFECT: the rule removed from the project
136
+ */
137
+ letTeamPush(fullName: string, branch: string): string | undefined;
138
+ }
@@ -0,0 +1,297 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/config/GitLab.ts
5
+ import {
6
+ GitHub
7
+ } from "./GitHub.js";
8
+ var GitLab = class _GitLab {
9
+ static {
10
+ __name(this, "GitLab");
11
+ }
12
+ /** Which code host this is: `CodeHost`'s word for it. */
13
+ kind = "gitlab";
14
+ /** the instance: `gitlab.com`, `git.acme.com`; none: `glab` picks */
15
+ host;
16
+ /** the repo's path on it: `team/sub/app`; none for a repo with no GitLab address */
17
+ repoPath;
18
+ /** whether the repo is reached over SSH: a project made for it is too */
19
+ usesSsh;
20
+ /** - `host`, `repoPath`, `usesSsh`: as the fields; `ofAddress()` works them out from a git address */
21
+ constructor({ host, repoPath, usesSsh = false } = {}) {
22
+ this.host = host;
23
+ this.repoPath = repoPath;
24
+ this.usesSsh = usesSsh;
25
+ }
26
+ /**
27
+ * The `GitLab` of the repo at git address `address`: `git@host:group/sub/p.git`, `ssh://git@host/group/sub/p`,
28
+ * `https://host/group/sub/p.git`; self-hosted hosts too.
29
+ * - no address, or one naming no host (a local path): `glab` picks the host, and there's no repo path
30
+ */
31
+ static ofAddress(address) {
32
+ const parts = _GitLab.partsOf(address);
33
+ return new _GitLab(parts ? { host: parts.host, repoPath: parts.path, usesSsh: parts.ssh } : {});
34
+ }
35
+ /**
36
+ * The host, the path and the protocol in git address `address`; `undefined` for a local path or anything else.
37
+ * - scp-like (`git@host:a/b.git`) and `ssh://` are SSH, an `ssh://` port dropped (`glab` knows the web host);
38
+ * `https://` keeps its port
39
+ */
40
+ static partsOf(address) {
41
+ const text = String(address ?? "").trim();
42
+ const web = /^https?:\/\/(?:[^/@]+@)?([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(text);
43
+ if (web) return { host: web[1], path: web[2], ssh: false };
44
+ const ssh = /^ssh:\/\/(?:[^/@]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(text);
45
+ if (ssh) return { host: ssh[1], path: ssh[2], ssh: true };
46
+ const scp = /^(?:[^/@]+@)?([^/:]+):(?!\/\/)(.+?)(?:\.git)?\/?$/.exec(text);
47
+ return scp ? { host: scp[1], path: scp[2], ssh: true } : void 0;
48
+ }
49
+ /** The `glab` to run: `$SPELL_EPIC_GLAB`, else `glab` on the `PATH`. Read on every call: a test sets it. */
50
+ static command() {
51
+ return process.env[GLAB_ENV] || "glab";
52
+ }
53
+ /** What a person reads about this host. */
54
+ get words() {
55
+ return _GitLab.wordsOn(this.host);
56
+ }
57
+ /** What a person reads about GitLab at `host`: self-hosted, how to log in names it. */
58
+ static wordsOn(host) {
59
+ const named = host && host !== DEFAULT_HOST ? ` --hostname ${host}` : "";
60
+ return {
61
+ name: "GitLab",
62
+ command: "glab",
63
+ pullRequest: "merge request",
64
+ PullRequest: "Merge request",
65
+ number: /* @__PURE__ */ __name((id) => `!${id}`, "number"),
66
+ install: [
67
+ " brew install glab (other systems: https://gitlab.com/gitlab-org/cli)",
68
+ ` glab auth login${named}`
69
+ ],
70
+ openCommand: /* @__PURE__ */ __name((base, branch) => `glab mr create --source-branch ${branch} --target-branch ${base} --fill --yes`, "openCommand")
71
+ };
72
+ }
73
+ /** Run `glab <args>`: as `GitHub.run()`, `glab` by default. NEVER throws. */
74
+ run(args, options = {}) {
75
+ return GitHub.run(args, { command: _GitLab.command(), timeout: READ_MS, ...options });
76
+ }
77
+ /** Call GitLab's API on this repo's host. NEVER throws. */
78
+ api(endpoint, options = {}) {
79
+ const { method, fields, ...run } = options;
80
+ return this.run(
81
+ [
82
+ "api",
83
+ ...this.host ? ["--hostname", this.host] : [],
84
+ ...method ? ["--method", method] : [],
85
+ endpoint,
86
+ ...Object.entries(fields ?? {}).flatMap(([name, value]) => ["--raw-field", `${name}=${value}`])
87
+ ],
88
+ run
89
+ );
90
+ }
91
+ /** `glab api <endpoint>`'s answer as JSON; `undefined` when it failed or wasn't JSON. NEVER throws. */
92
+ json(endpoint) {
93
+ return parsed(this.api(endpoint));
94
+ }
95
+ /** Whether `glab` can work: `ready`, `missing` (`glab version` doesn't run) or `logged-out`. NEVER throws. */
96
+ status(command = _GitLab.command()) {
97
+ if (!GitHub.run(["version"], { command, timeout: READ_MS }).ok) return "missing";
98
+ const auth = this.run(["auth", "status", ...this.host ? ["--hostname", this.host] : []], { command });
99
+ return auth.ok ? "ready" : "logged-out";
100
+ }
101
+ /** The GitLab username `glab` is logged in as; `undefined` for none (missing, logged out, offline). NEVER throws. */
102
+ login() {
103
+ const username = this.json("user")?.username;
104
+ return username && this.isLogin(username) ? username : void 0;
105
+ }
106
+ /** Whether `name` is a GitLab username. */
107
+ isLogin(name) {
108
+ return USERNAME.test(name);
109
+ }
110
+ /** Whether namespace `owner` is a GitLab group, subgroups too, not a person's; `false` when glab can't say. NEVER throws. */
111
+ isOrganization(owner) {
112
+ return this.json(`groups/${encoded(owner)}`)?.id !== void 0;
113
+ }
114
+ /** The group or user in git address `address`, subgroups included: `team/sub`; `undefined` without one. */
115
+ ownerIn(address) {
116
+ const repo = this.repoIn(address);
117
+ return repo?.includes("/") ? repo.slice(0, repo.lastIndexOf("/")) : void 0;
118
+ }
119
+ /** The project path in git address `address`, `team/sub/app`; `undefined` for an address naming no host. */
120
+ repoIn(address) {
121
+ return _GitLab.partsOf(address)?.path;
122
+ }
123
+ /**
124
+ * The repo page `<epic-commit>` links under, for git address `address`: `https://host/team/sub/app/-`, which takes
125
+ * `/commit/<sha>`; `null` for an address naming no host.
126
+ * - the `/-` is GitLab's own: a page's `repo` attribute carries it, so the element needs no rule for GitLab
127
+ */
128
+ commitBase(address) {
129
+ const parts = _GitLab.partsOf(address);
130
+ return parts ? `https://${parts.host}/${parts.path}/-` : null;
131
+ }
132
+ /**
133
+ * Whether a merge request is the only way into `branch` of project `fullName`: its protected branches, any rule
134
+ * naming `branch` (`*-stable` too), with no push level the caller reaches.
135
+ * - nobody may push (level 0), or levels above the caller's: `true`; a level by user or group it can't check: counts
136
+ * as reachable
137
+ * - `false` for anything else: no rule, no right to read it, offline, `glab` missing. NEVER throws.
138
+ */
139
+ requiresPullRequest(fullName, branch) {
140
+ const path = encoded(fullName);
141
+ const rules = this.json(`projects/${path}/protected_branches?per_page=100`);
142
+ if (!Array.isArray(rules)) return false;
143
+ const levels = rules.filter((rule) => branchMatches(rule.name, branch)).flatMap((rule) => rule.push_access_levels ?? []);
144
+ if (!levels.length) return false;
145
+ const me = this.json("user");
146
+ const project = this.json(`projects/${path}`);
147
+ const mine = [project?.permissions?.project_access?.access_level, project?.permissions?.group_access?.access_level].filter((level) => typeof level === "number").reduce((best, level) => Math.max(best ?? 0, level), void 0);
148
+ return !levels.some((level) => canPush(level, me?.id, mine));
149
+ }
150
+ /**
151
+ * The merge requests of `branch` into `base` that GitLab merged: `{ number, url, head }` (`head`: its last commit),
152
+ * newest first; `[]` when `glab` can't say. NEVER throws.
153
+ */
154
+ mergedPullRequests(branch, base, _cwd) {
155
+ const found = this.requestsOf(branch, base, "merged");
156
+ return found.map(({ iid, web_url, sha }) => ({ number: iid, url: web_url, head: sha }));
157
+ }
158
+ /** The address of the merge request of `branch` into `base` that's open; none: `undefined`. NEVER throws. */
159
+ openPullRequestOf(branch, base, _cwd) {
160
+ return this.requestsOf(branch, base, "opened")[0]?.web_url;
161
+ }
162
+ /** This repo's merge requests of `branch` into `base`, by state; `[]` when `glab` can't say. */
163
+ requestsOf(branch, base, state) {
164
+ if (!this.repoPath) return [];
165
+ const query = `state=${state}&source_branch=${encoded(branch)}&target_branch=${encoded(base)}&per_page=100`;
166
+ const found = this.json(`projects/${encoded(this.repoPath)}/merge_requests?${query}`);
167
+ return Array.isArray(found) ? found : [];
168
+ }
169
+ /**
170
+ * Open a merge request of `branch` into `base`, from checkout `cwd`: its address.
171
+ * - one open already: that one's address
172
+ * - never asks anything: `--yes`, with title and description given
173
+ * - `body` empty: the title, `glab` otherwise asking for one
174
+ * - throws an `Error` with glab's own words when it can't
175
+ * - SIDE EFFECT: a merge request on GitLab
176
+ */
177
+ openPullRequest({ branch, base, title, body, cwd }) {
178
+ const open = this.openPullRequestOf(branch, base, cwd);
179
+ if (open) return open;
180
+ const run = this.run(
181
+ [
182
+ "mr",
183
+ "create",
184
+ "--source-branch",
185
+ branch,
186
+ "--target-branch",
187
+ base,
188
+ "--title",
189
+ title,
190
+ "--description",
191
+ body || title,
192
+ "--yes",
193
+ ...this.repoAddress ? ["--repo", this.repoAddress] : []
194
+ ],
195
+ { cwd, timeout: CREATE_MS }
196
+ );
197
+ if (!run.ok) throw new Error(`glab mr create failed: ${run.err || run.out || "no reason given"}`, { cause: run });
198
+ return REQUEST_URL.exec(`${run.out}
199
+ ${run.err}`)?.[0] ?? this.openPullRequestOf(branch, base, cwd) ?? "";
200
+ }
201
+ /** The repo's own address, for `--repo`: `https://host/team/sub/app`; none without a host and path. */
202
+ get repoAddress() {
203
+ return this.host && this.repoPath ? `https://${this.host}/${this.repoPath}` : void 0;
204
+ }
205
+ /**
206
+ * Make GitLab project `fullName` (`team/sub/name`, or `username/name`), empty: private, unless `visibility` says.
207
+ * - through the API (the class's note): `POST projects`, under the group, or the person's own namespace
208
+ * - throws an `Error` with glab's own words when it can't (a name taken, no right to make one there)
209
+ * - SIDE EFFECT: a new project on GitLab
210
+ */
211
+ createRepo(fullName, { visibility = "private", description = "" } = {}) {
212
+ const name = fullName.slice(fullName.lastIndexOf("/") + 1);
213
+ const owner = fullName.slice(0, fullName.lastIndexOf("/"));
214
+ const group = owner && owner !== this.login() ? this.json(`groups/${encoded(owner)}`) : void 0;
215
+ if (owner && owner !== this.login() && group?.id === void 0)
216
+ throw new Error(`glab repo create ${fullName} failed: no group ${owner} that you can read`);
217
+ const run = this.api("projects", {
218
+ method: "POST",
219
+ timeout: CREATE_MS,
220
+ fields: {
221
+ name,
222
+ path: name,
223
+ visibility,
224
+ description,
225
+ ...group?.id !== void 0 && { namespace_id: String(group.id) }
226
+ }
227
+ });
228
+ if (!run.ok)
229
+ throw new Error(`glab api projects ${fullName} failed: ${run.err || run.out || "no reason given"}`, {
230
+ cause: run
231
+ });
232
+ }
233
+ /**
234
+ * GitLab project `fullName`'s address for git: SSH when this repo is reached over SSH, else HTTPS, so a push goes
235
+ * the way this person's already do.
236
+ * - throws an `Error` with glab's words when glab can't find it
237
+ */
238
+ addressOf(fullName) {
239
+ const run = this.api(`projects/${encoded(fullName)}`);
240
+ const project = parsed(run);
241
+ const address = this.usesSsh ? project?.ssh_url_to_repo : project?.http_url_to_repo;
242
+ if (!address)
243
+ throw new Error(`glab api projects/${fullName} failed: ${run.err || "no address in its answer"}`, { cause: run });
244
+ return address;
245
+ }
246
+ /**
247
+ * Let every teammate push to `branch` of project `fullName`: run once the branch exists (its first push), which is
248
+ * when GitLab protects a new project's default branch, Developers kept out.
249
+ * - a line saying what to do by hand when it couldn't (no right to, offline); `undefined` when it's done
250
+ * - NEVER throws: a project it can't open up is still a project
251
+ * - SIDE EFFECT: the rule removed from the project
252
+ */
253
+ letTeamPush(fullName, branch) {
254
+ const path = encoded(fullName);
255
+ const byHand = `in ${fullName}, Settings › Repository › Protected branches, unprotect ${branch}, or teammates can't sync`;
256
+ const rules = this.json(`projects/${path}/protected_branches?per_page=100`);
257
+ if (!Array.isArray(rules)) return `couldn't check whether ${branch} is protected: ${byHand}`;
258
+ if (!rules.some((rule) => rule.name === branch)) return void 0;
259
+ const run = this.api(`projects/${path}/protected_branches/${encoded(branch)}`, { method: "DELETE" });
260
+ return run.ok ? void 0 : `couldn't unprotect ${branch} (${run.err || "no reason given"}): ${byHand}`;
261
+ }
262
+ };
263
+ function parsed(run) {
264
+ if (!run.ok) return void 0;
265
+ try {
266
+ return JSON.parse(run.out);
267
+ } catch {
268
+ return void 0;
269
+ }
270
+ }
271
+ __name(parsed, "parsed");
272
+ function encoded(path) {
273
+ return encodeURIComponent(path);
274
+ }
275
+ __name(encoded, "encoded");
276
+ function branchMatches(name, branch) {
277
+ const pattern = name.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
278
+ return new RegExp(`^${pattern}$`).test(branch);
279
+ }
280
+ __name(branchMatches, "branchMatches");
281
+ function canPush(level, me, mine) {
282
+ if (typeof level.user_id === "number") return me === void 0 || level.user_id === me;
283
+ if (typeof level.group_id === "number") return true;
284
+ if (level.access_level === NO_ONE) return false;
285
+ return mine === void 0 || level.access_level === null || mine >= level.access_level;
286
+ }
287
+ __name(canPush, "canPush");
288
+ var GLAB_ENV = "SPELL_EPIC_GLAB";
289
+ var DEFAULT_HOST = "gitlab.com";
290
+ var READ_MS = 15e3;
291
+ var CREATE_MS = 3e4;
292
+ var NO_ONE = 0;
293
+ var USERNAME = /^[\w.-]+$/;
294
+ var REQUEST_URL = /https?:\/\/\S+\/-\/merge_requests\/\d+/;
295
+ export {
296
+ GitLab
297
+ };
@@ -3,8 +3,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3
3
 
4
4
  // src/config/LayeredSettings.ts
5
5
  import { homedir } from "node:os";
6
- import { join, resolve } from "node:path";
6
+ import { join } from "node:path";
7
7
  import { DataFile } from "spell/server/DataFile";
8
+ import { EngineFiles } from "./EngineFiles.mjs";
8
9
  var LayeredSettings = class _LayeredSettings {
9
10
  static {
10
11
  __name(this, "LayeredSettings");
@@ -15,7 +16,7 @@ var LayeredSettings = class _LayeredSettings {
15
16
  static BUILT_IN = { away: { finishedPhaseDays: 3 } };
16
17
  /** The kit's own file: worked out when read, as `EpicConfig.ENGINE_VOICES` is. */
17
18
  static get DEFAULT_FILE() {
18
- return resolve(import.meta.dirname ?? ".", "../..", _LayeredSettings.FILE);
19
+ return EngineFiles.path(_LayeredSettings.FILE);
19
20
  }
20
21
  /** The layers, lowest first. */
21
22
  layers;
@@ -283,7 +283,7 @@ export declare const ROUTE_MODULES: readonly string[];
283
283
  /**
284
284
  * Folders whose code, when newer than a running server, makes `ensure()` restart it
285
285
  * (`SRV.newestChange()`: every `.ts` / `.js` / `.mjs` file in them; `_assets/` and `node_modules/` skipped):
286
- * - ALL of spell-epic's code, `src/` (epic `epic-eject` I11): the route modules import far beyond their own folders
286
+ * - ALL of spell-epic's code, `src/`, or its built `dist/epic/` (epic `epic-eject` I11): the route modules import far beyond their own folders
287
287
  * (`config/`, `data/`, `links/`, `review/`, the elements' definitions ...), so watching only theirs and this one
288
288
  * missed a change to the rest
289
289
  * - the server package's, `spell/server` (the kit's `src/server/`), where Node's resolver finds it (`packageDir()`)