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
@@ -1,28 +1,65 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/tools/_assets/goals-live.js
5
- (function() {
6
- const SERVER = window.GOALS_SERVER && window.SPELL_SERVER ? { ...window.GOALS_SERVER, token: window.SPELL_SERVER.token } : void 0;
7
- const body = document.body;
8
- const SET = body.dataset.set;
9
- const TOPIC = body.dataset.topic;
10
- const BASE = SET ? TOPIC ? `${SET}/${TOPIC}` : SET : "";
11
- const NAME = BASE || "the goals home page";
12
- const DEFAULT_PORT = 4747;
13
- if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start, { once: true });
14
- else start();
1
+ /*
2
+ * Live saga pages (parked goals): buttons to add thoughts and to start Claude sessions.
3
+ * - PARKED (epic `epic-workflow` P6, Owen 2026-10-11): the buttons stay, and each says "TODO: this will ..." when
4
+ * clicked (`parked()`). The routes, skills and CLI they called are in `packages/goals.zip`; epic `epic-goals`
5
+ * rebuilds them. What follows describes them as they were.
6
+ * Loaded after `spell-ui.js` by every saga page (`goals/**`, `templates/goals/**`). Rules: `goals/AGENTS.md`.
7
+ * - Served by the page server (`spell dev goals open`, `spell dev server`) with goals' route module
8
+ * (`src/tools/goals/goalsRoutes.ts`), a page has `window.GOALS_SERVER` (`{ api }`) and the server's own
9
+ * `window.SPELL_SERVER` (`{ token, ... }`):
10
+ * - thoughts save through `POST <api>/thought`; Claude sessions start through `POST <api>/run`, in a terminal
11
+ * - writes carry the server's token (`x-server-token`)
12
+ * - live reload is the page server's (`/api/server/live.js`), not ours
13
+ * - Opened from disk (`file://`): the same buttons explain how to start the server, and link to the page on it.
14
+ * - Classic script, no imports: `file://` pages can't load modules. `window.SpellUI.UI` is the bundle's `UI`.
15
+ * - The buttons follow the docs' rule: pills with an icon and text, or circles with an icon and an `aria-label`;
16
+ * each with the browser's own tooltip, a `title`, on the button the pointer lands on too (`titleInside()`)
17
+ * - `<ui-button>`s built as elements, never markup in strings (epic `epic-engine` P3); before it, a `<ui-popup>`
18
+ * after each was its tooltip, against the docs' rule (`src/AGENTS.md`, TOOLTIPS)
19
+ */
20
+ ;(function () {
21
+ /** goals' routes on this server, when it has them: `{ api, token }` */
22
+ const SERVER =
23
+ window.GOALS_SERVER && window.SPELL_SERVER
24
+ ? { ...window.GOALS_SERVER, token: window.SPELL_SERVER.token }
25
+ : undefined
26
+ const body = document.body
27
+ const SET = body.dataset.set
28
+ const TOPIC = body.dataset.topic
29
+ /** This page's target: `spell/motivation`, or `spell` on a set's contents page. */
30
+ const BASE = SET ? (TOPIC ? `${SET}/${TOPIC}` : SET) : ""
31
+ /** What the page calls itself in messages. */
32
+ const NAME = BASE || "the goals home page"
33
+ const DEFAULT_PORT = 4747
34
+
35
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start, { once: true })
36
+ else start()
37
+
38
+ ////////////////
39
+ // ## Start
40
+ ////////////////
41
+
42
+ /** Wire the page: the buttons. */
15
43
  function start() {
16
- if (!SET) return;
17
- addHeadingTools();
18
- addItemTools();
19
- addPageTools();
44
+ if (!SET) return
45
+ addHeadingTools()
46
+ addItemTools()
47
+ addPageTools()
20
48
  }
21
- __name(start, "start");
49
+
50
+ ////////////////
51
+ // ## Buttons
52
+ ////////////////
53
+
54
+ /**
55
+ * The page's goals buttons, a row at the end of its hero (the top card): Talk, Thought and Update, then a round
56
+ * VS Code button. They lived in the contents sidebar until it went (epic `epic-components`, 2026-10-08).
57
+ * - Update shows how many thoughts wait on the page
58
+ */
22
59
  function addPageTools() {
23
- const hero = document.querySelector("main header.goals-hero");
24
- if (!hero) return;
25
- const waiting = document.querySelectorAll('li.goals-thought[data-status="new"]').length;
60
+ const hero = document.querySelector("main header.goals-hero")
61
+ if (!hero) return
62
+ const waiting = document.querySelectorAll('li.goals-thought[data-status="new"]').length
26
63
  const tools = el(
27
64
  "div",
28
65
  { class: "goals-page-tools" },
@@ -36,79 +73,87 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
36
73
  ),
37
74
  el("span", { class: "goals-tool-gap" }),
38
75
  circle("vscode", "up right from square", "Open in VS Code", "Show this page in VS Code, beside your code")
39
- );
40
- hero.append(tools);
76
+ )
77
+ hero.append(tools)
41
78
  tools.addEventListener("click", (event) => {
42
- const button = event.target.closest("[data-goals]");
43
- if (!button) return;
44
- parked(button.dataset.goals, NAME);
45
- });
79
+ const button = event.target.closest("[data-goals]")
80
+ if (!button) return
81
+ parked(button.dataset.goals, NAME)
82
+ })
46
83
  }
47
- __name(addPageTools, "addPageTools");
84
+
85
+ /**
86
+ * A thought bubble and a talk button on every section heading (`h2`, and the goal horizons' `h3`s), shown on
87
+ * hover or focus.
88
+ */
48
89
  function addHeadingTools() {
49
90
  for (const heading of document.querySelectorAll(
50
91
  "main ui-sticky.spell-h2 > h2[id], main ui-sticky.spell-h3 > h3[id]"
51
92
  )) {
52
- if (heading.id === "history") continue;
53
- const label = heading.textContent.replace(/^\s*\d+\.\s*/, "").trim();
54
- const target = `${BASE}/${heading.id}`;
93
+ if (heading.id === "history") continue
94
+ const label = heading.textContent.replace(/^\s*\d+\.\s*/, "").trim()
95
+ const target = `${BASE}/${heading.id}`
55
96
  const tools = el(
56
97
  "span",
57
98
  { class: "goals-heading-tools" },
58
99
  circle("thought", "comment dots", `Add a thought about ${label}`, `Add a thought about ${label}`),
59
100
  circle("talk", "comments", `Talk ${label} through`, `Talk ${label} through with Claude`)
60
- );
101
+ )
61
102
  tools.addEventListener("click", (event) => {
62
- const button = event.target.closest("[data-goals]");
63
- if (!button) return;
64
- event.preventDefault();
65
- event.stopPropagation();
66
- parked(button.dataset.goals, label);
67
- });
68
- heading.append(tools);
103
+ const button = event.target.closest("[data-goals]")
104
+ if (!button) return
105
+ event.preventDefault()
106
+ event.stopPropagation()
107
+ parked(button.dataset.goals, label)
108
+ })
109
+ heading.append(tools)
69
110
  }
70
111
  }
71
- __name(addHeadingTools, "addHeadingTools");
112
+
113
+ /** A thought bubble and a talk button on every item (`G1`, `Q3` ...), shown on hover or focus. */
72
114
  function addItemTools() {
73
115
  for (const item of document.querySelectorAll("ol.plan-items > li[id]")) {
74
- const id = item.id.toUpperCase();
75
- const title = item.querySelector(".plan-title")?.textContent.trim() ?? "";
76
- const label = `${id} · ${title}`;
77
- const target = `${BASE}/${id}`;
116
+ const id = item.id.toUpperCase()
117
+ const title = item.querySelector(".plan-title")?.textContent.trim() ?? ""
118
+ const label = `${id} · ${title}`
119
+ const target = `${BASE}/${id}`
78
120
  const tools = el(
79
121
  "span",
80
122
  { class: "goals-item-tools" },
81
123
  circle("thought", "comment dots", `Add a thought about ${id}`, `Add a thought about ${id}`),
82
124
  circle("talk", "comments", `Talk ${id} through`, `Talk ${id} through with Claude: /goals ${target}`)
83
- );
125
+ )
84
126
  tools.addEventListener("click", (event) => {
85
- const button = event.target.closest("[data-goals]");
86
- if (!button) return;
87
- parked(button.dataset.goals, label);
88
- });
89
- const after = item.querySelector(":scope > ul.goals-thoughts, :scope > ui-accordion");
90
- if (after) after.before(tools);
91
- else item.append(tools);
127
+ const button = event.target.closest("[data-goals]")
128
+ if (!button) return
129
+ parked(button.dataset.goals, label)
130
+ })
131
+ // after the item's line (title, tag, note), before its thoughts and folded details
132
+ const after = item.querySelector(":scope > ul.goals-thoughts, :scope > ui-accordion")
133
+ if (after) after.before(tools)
134
+ else item.append(tools)
92
135
  }
93
136
  }
94
- __name(addItemTools, "addItemTools");
137
+
138
+ /** A pill button: icon and `words` (text and elements), `tip` its tooltip. */
95
139
  function pill(action, icon, words, tip, primary = false) {
96
140
  const button = el(
97
141
  "ui-button",
98
142
  {
99
143
  "data-goals": action,
100
144
  appearance: primary ? "circular" : "circular basic",
101
- ...primary ? { color: "primary" } : {},
145
+ ...(primary ? { color: "primary" } : {}),
102
146
  size: "tiny",
103
147
  icon,
104
148
  title: tip
105
149
  },
106
150
  ...words
107
- );
108
- titleInside(button);
109
- return button;
151
+ )
152
+ titleInside(button)
153
+ return button
110
154
  }
111
- __name(pill, "pill");
155
+
156
+ /** A round, icon-only button: `label` what a screen reader hears, `tip` its tooltip. */
112
157
  function circle(action, icon, label, tip) {
113
158
  const button = el("ui-button", {
114
159
  "data-goals": action,
@@ -117,25 +162,32 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
117
162
  icon,
118
163
  title: tip,
119
164
  "aria-label": label
120
- });
121
- titleInside(button);
122
- return button;
165
+ })
166
+ titleInside(button)
167
+ return button
123
168
  }
124
- __name(circle, "circle");
169
+
170
+ ////////////////
171
+ // ## Thoughts
172
+ ////////////////
173
+
174
+ /** Ask for a thought about `target` (`label` for the reader), then save it. */
125
175
  function openThought(target, label) {
126
- if (!SERVER) return openNoServer();
127
- const modal = thoughtModal();
128
- modal.querySelector(".goals-modal-about").innerHTML = `About <b>${escape(label)}</b>, on <code>${escape(target.split("/").slice(0, 2).join("/"))}</code>`;
129
- const field = modal.querySelector("textarea");
130
- field.value = "";
131
- modal.dataset.target = target;
132
- show(modal);
133
- setTimeout(() => field.focus(), 60);
176
+ if (!SERVER) return openNoServer()
177
+ const modal = thoughtModal()
178
+ modal.querySelector(".goals-modal-about").innerHTML =
179
+ `About <b>${escape(label)}</b>, on <code>${escape(target.split("/").slice(0, 2).join("/"))}</code>`
180
+ const field = modal.querySelector("textarea")
181
+ field.value = ""
182
+ modal.dataset.target = target
183
+ show(modal)
184
+ setTimeout(() => field.focus(), 60)
134
185
  }
135
- __name(openThought, "openThought");
186
+
187
+ /** The thought dialog, made once. */
136
188
  function thoughtModal() {
137
- let modal = document.getElementById("goals-thought-modal");
138
- if (modal) return modal;
189
+ let modal = document.getElementById("goals-thought-modal")
190
+ if (modal) return modal
139
191
  modal = element(`<ui-modal id="goals-thought-modal" size="small" closable>
140
192
  <ui-header><ui-icon name="comment dots"></ui-icon> Add a thought</ui-header>
141
193
  <ui-content>
@@ -148,53 +200,66 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
148
200
  <ui-button class="deny" circular basic icon="xmark">Cancel</ui-button>
149
201
  <ui-button class="goals-save" circular primary icon="paper plane">Save thought</ui-button>
150
202
  </ui-actions>
151
- </ui-modal>`);
152
- const field = modal.querySelector("textarea");
153
- const save = modal.querySelector(".goals-save");
154
- const submit = /* @__PURE__ */ __name(async () => {
155
- const text = field.value.trim();
156
- if (!text) return field.focus();
157
- save.setAttribute("loading", "");
203
+ </ui-modal>`)
204
+ const field = modal.querySelector("textarea")
205
+ const save = modal.querySelector(".goals-save")
206
+ const submit = async () => {
207
+ const text = field.value.trim()
208
+ if (!text) return field.focus()
209
+ save.setAttribute("loading", "")
158
210
  try {
159
- const answer = await post(`${SERVER.api}/thought`, { target: modal.dataset.target, text });
160
- hide(modal);
161
- toast("Thought saved", `${answer.target} · ${answer.id}: the page reloads with it.`, "success");
211
+ const answer = await post(`${SERVER.api}/thought`, { target: modal.dataset.target, text })
212
+ hide(modal)
213
+ toast("Thought saved", `${answer.target} · ${answer.id}: the page reloads with it.`, "success")
162
214
  } catch (error) {
163
- toast("Couldn't save the thought", error.message, "error");
215
+ toast("Couldn't save the thought", error.message, "error")
164
216
  } finally {
165
- save.removeAttribute("loading");
217
+ save.removeAttribute("loading")
166
218
  }
167
- }, "submit");
168
- save.addEventListener("click", submit);
219
+ }
220
+ save.addEventListener("click", submit)
169
221
  field.addEventListener("keydown", (event) => {
170
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void submit();
171
- });
172
- document.body.append(modal);
173
- return modal;
222
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void submit()
223
+ })
224
+ document.body.append(modal)
225
+ return modal
174
226
  }
175
- __name(thoughtModal, "thoughtModal");
227
+
228
+ ////////////////
229
+ // ## Claude
230
+ ////////////////
231
+
232
+ /**
233
+ * Start Claude Code on `/<skill> <target>`, in a terminal window, through the server.
234
+ * - not installed or not logged in: the setup dialog, which retries once Claude is ready
235
+ */
176
236
  async function run(skill, target) {
177
- if (!SERVER) return openNoServer(`/${skill} ${target}`);
237
+ if (!SERVER) return openNoServer(`/${skill} ${target}`)
178
238
  try {
179
- const answer = await post(`${SERVER.api}/run`, { skill, target }, [409]);
180
- if (answer.needs) return openSetup(answer.needs, () => run(skill, target));
181
- toast("Claude is starting", `In ${answer.how}: /${skill} ${target}`, "success");
239
+ const answer = await post(`${SERVER.api}/run`, { skill, target }, [409])
240
+ if (answer.needs) return openSetup(answer.needs, () => run(skill, target))
241
+ toast("Claude is starting", `In ${answer.how}: /${skill} ${target}`, "success")
182
242
  } catch (error) {
183
- if (error.command) return openCommand(`Run this in a terminal`, error.message, error.command);
184
- toast("Couldn't start Claude", error.message, "error");
243
+ if (error.command) return openCommand(`Run this in a terminal`, error.message, error.command)
244
+ toast("Couldn't start Claude", error.message, "error")
185
245
  }
186
246
  }
187
- __name(run, "run");
247
+
248
+ /**
249
+ * The Claude setup dialog: what Claude Code is, then the step that's missing (`install` or `login`), with
250
+ * buttons; "Check again" runs `retry` once Claude is ready.
251
+ */
188
252
  function openSetup(needs, retry) {
189
- const modal = setupModal();
190
- modal.retry = retry;
191
- stepTo(modal, needs);
192
- show(modal);
253
+ const modal = setupModal()
254
+ modal.retry = retry
255
+ stepTo(modal, needs)
256
+ show(modal)
193
257
  }
194
- __name(openSetup, "openSetup");
258
+
259
+ /** The setup dialog, made once. */
195
260
  function setupModal() {
196
- let modal = document.getElementById("goals-claude-modal");
197
- if (modal) return modal;
261
+ let modal = document.getElementById("goals-claude-modal")
262
+ if (modal) return modal
198
263
  modal = element(`<ui-modal id="goals-claude-modal" size="small" closable>
199
264
  <ui-header><ui-icon name="wand magic sparkles"></ui-icon> Set up Claude</ui-header>
200
265
  <ui-content>
@@ -227,81 +292,97 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
227
292
  <ui-button class="deny" circular basic icon="xmark">Later</ui-button>
228
293
  <ui-button class="goals-recheck" circular primary icon="arrows rotate">Check again</ui-button>
229
294
  </ui-actions>
230
- </ui-modal>`);
231
- modal.querySelector(".goals-copy").addEventListener("click", () => copy(modal.querySelector(".goals-setup-install code").textContent));
295
+ </ui-modal>`)
296
+ modal
297
+ .querySelector(".goals-copy")
298
+ .addEventListener("click", () => copy(modal.querySelector(".goals-setup-install code").textContent))
232
299
  modal.querySelector(".goals-login").addEventListener("click", async () => {
233
300
  try {
234
- const answer = await post(`${SERVER.api}/claude/login`, {});
235
- toast("Logging in", `Finish in ${answer.how} and your browser, then press Check again.`, "info");
301
+ const answer = await post(`${SERVER.api}/claude/login`, {})
302
+ toast("Logging in", `Finish in ${answer.how} and your browser, then press Check again.`, "info")
236
303
  } catch (error) {
237
- if (error.command) return openCommand("Log in from a terminal", error.message, error.command);
238
- toast("Couldn't start the login", error.message, "error");
304
+ if (error.command) return openCommand("Log in from a terminal", error.message, error.command)
305
+ toast("Couldn't start the login", error.message, "error")
239
306
  }
240
- });
307
+ })
241
308
  modal.querySelector(".goals-recheck").addEventListener("click", async (event) => {
242
- const button = event.currentTarget;
243
- button.setAttribute("loading", "");
309
+ const button = event.currentTarget
310
+ button.setAttribute("loading", "")
244
311
  try {
245
- const status = await (await fetch(`${SERVER.api}/claude`)).json();
246
- if (!status.installed) return stepTo(modal, "install");
247
- if (!status.loggedIn) return stepTo(modal, "login");
248
- stepTo(modal, "talk");
249
- hide(modal);
250
- modal.retry?.();
312
+ const status = await (await fetch(`${SERVER.api}/claude`)).json()
313
+ if (!status.installed) return stepTo(modal, "install")
314
+ if (!status.loggedIn) return stepTo(modal, "login")
315
+ stepTo(modal, "talk")
316
+ hide(modal)
317
+ modal.retry?.()
251
318
  } finally {
252
- button.removeAttribute("loading");
319
+ button.removeAttribute("loading")
253
320
  }
254
- });
255
- document.body.append(modal);
256
- return modal;
321
+ })
322
+ document.body.append(modal)
323
+ return modal
257
324
  }
258
- __name(setupModal, "setupModal");
325
+
326
+ /** Show the setup step `name` (`install`, `login` or `talk`): earlier steps done, its own buttons shown. */
259
327
  function stepTo(modal, name) {
260
- const order = ["install", "login", "talk"];
328
+ const order = ["install", "login", "talk"]
261
329
  for (const step of modal.querySelectorAll("ui-step")) {
262
- const at = order.indexOf(step.dataset.step);
263
- step.toggleAttribute("completed", at < order.indexOf(name));
264
- step.toggleAttribute("selected", at === order.indexOf(name));
330
+ const at = order.indexOf(step.dataset.step)
331
+ step.toggleAttribute("completed", at < order.indexOf(name))
332
+ step.toggleAttribute("selected", at === order.indexOf(name))
265
333
  }
266
334
  for (const part of modal.querySelectorAll(".goals-setup"))
267
- part.hidden = !part.classList.contains(`goals-setup-${name}`);
335
+ part.hidden = !part.classList.contains(`goals-setup-${name}`)
268
336
  }
269
- __name(stepTo, "stepTo");
337
+
338
+ ////////////////
339
+ // ## VS Code, no server, plain commands
340
+ ////////////////
341
+
342
+ /** Show `target` in VS Code's Simple Browser, beside the editor. */
270
343
  async function openVSCode(target) {
271
- if (!SERVER) return openNoServer(`spell dev goals open-vs ${target}`);
344
+ if (!SERVER) return openNoServer(`spell dev goals open-vs ${target}`)
272
345
  try {
273
- await post(`${SERVER.api}/open-vscode`, { target });
274
- toast("Opening in VS Code", "Beside your editor, in Simple Browser.", "success");
346
+ await post(`${SERVER.api}/open-vscode`, { target })
347
+ toast("Opening in VS Code", "Beside your editor, in Simple Browser.", "success")
275
348
  } catch (error) {
276
- toast("Couldn't open VS Code", error.message, "error");
349
+ toast("Couldn't open VS Code", error.message, "error")
277
350
  }
278
351
  }
279
- __name(openVSCode, "openVSCode");
352
+
353
+ /**
354
+ * The page came from disk, so nothing can be saved or started: how to start the server, and a link to this
355
+ * page on it (if it's running).
356
+ */
280
357
  function openNoServer(what) {
281
- const command = `spell dev goals open ${BASE}`;
282
- const modal = commandModal();
283
- modal.querySelector("ui-header").textContent = "Start the page server";
284
- modal.querySelector(".goals-modal-about").innerHTML = `${what ? `<code>${escape(what)}</code> needs` : "Thoughts and Claude sessions need"} the page server: a small local web server that saves to these pages and starts Claude for you. Start it from the project:`;
285
- modal.querySelector("code.goals-command").textContent = command;
286
- const link = modal.querySelector(".goals-served");
287
- const served = servedURL();
288
- link.hidden = !served;
289
- if (served) link.setAttribute("href", served);
290
- show(modal);
358
+ const command = `spell dev goals open ${BASE}`
359
+ const modal = commandModal()
360
+ modal.querySelector("ui-header").textContent = "Start the page server"
361
+ modal.querySelector(".goals-modal-about").innerHTML =
362
+ `${what ? `<code>${escape(what)}</code> needs` : "Thoughts and Claude sessions need"} the page server: a small ` +
363
+ `local web server that saves to these pages and starts Claude for you. Start it from the project:`
364
+ modal.querySelector("code.goals-command").textContent = command
365
+ const link = modal.querySelector(".goals-served")
366
+ const served = servedURL()
367
+ link.hidden = !served
368
+ if (served) link.setAttribute("href", served)
369
+ show(modal)
291
370
  }
292
- __name(openNoServer, "openNoServer");
371
+
372
+ /** A command to run by hand: `title`, why, and the command with a copy button. */
293
373
  function openCommand(title, why, command) {
294
- const modal = commandModal();
295
- modal.querySelector("ui-header").textContent = title;
296
- modal.querySelector(".goals-modal-about").textContent = why;
297
- modal.querySelector("code.goals-command").textContent = command;
298
- modal.querySelector(".goals-served").hidden = true;
299
- show(modal);
374
+ const modal = commandModal()
375
+ modal.querySelector("ui-header").textContent = title
376
+ modal.querySelector(".goals-modal-about").textContent = why
377
+ modal.querySelector("code.goals-command").textContent = command
378
+ modal.querySelector(".goals-served").hidden = true
379
+ show(modal)
300
380
  }
301
- __name(openCommand, "openCommand");
381
+
382
+ /** The command dialog, made once. */
302
383
  function commandModal() {
303
- let modal = document.getElementById("goals-command-modal");
304
- if (modal) return modal;
384
+ let modal = document.getElementById("goals-command-modal")
385
+ if (modal) return modal
305
386
  modal = element(`<ui-modal id="goals-command-modal" size="small" closable>
306
387
  <ui-header>Run a command</ui-header>
307
388
  <ui-content>
@@ -314,94 +395,121 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
314
395
  </div>
315
396
  </ui-content>
316
397
  <ui-actions><ui-button class="approve" circular primary icon="check">OK</ui-button></ui-actions>
317
- </ui-modal>`);
318
- modal.querySelector(".goals-copy").addEventListener("click", () => copy(modal.querySelector("code.goals-command").textContent));
319
- document.body.append(modal);
320
- return modal;
398
+ </ui-modal>`)
399
+ modal
400
+ .querySelector(".goals-copy")
401
+ .addEventListener("click", () => copy(modal.querySelector("code.goals-command").textContent))
402
+ document.body.append(modal)
403
+ return modal
321
404
  }
322
- __name(commandModal, "commandModal");
405
+
406
+ /**
407
+ * This page's URL on a page server at the default port (its real port is in `.spell-server.json`, which a
408
+ * `file://` page can't read), worked out from where the docs' assets are: the project root is the folder above
409
+ * `packages/epics/tools/_assets/`.
410
+ */
323
411
  function servedURL() {
324
- const sheet = document.querySelector('link[href$="_assets/spell-doc.css"]');
325
- if (!sheet || location.protocol !== "file:") return "";
326
- const assets = new URL(sheet.getAttribute("href"), location.href).pathname;
327
- const root = assets.replace(/packages\/docs\/_assets\/spell-doc\.css$/, "");
328
- if (root === assets || !location.pathname.startsWith(root)) return "";
329
- return `http://127.0.0.1:${DEFAULT_PORT}/${location.pathname.slice(root.length)}${location.hash}`;
412
+ const sheet = document.querySelector('link[href$="_assets/spell-doc.css"]')
413
+ if (!sheet || location.protocol !== "file:") return ""
414
+ const assets = new URL(sheet.getAttribute("href"), location.href).pathname
415
+ const root = assets.replace(/packages\/docs\/_assets\/spell-doc\.css$/, "")
416
+ if (root === assets || !location.pathname.startsWith(root)) return ""
417
+ return `http://127.0.0.1:${DEFAULT_PORT}/${location.pathname.slice(root.length)}${location.hash}`
330
418
  }
331
- __name(servedURL, "servedURL");
419
+
420
+ ////////////////
421
+ // ## Helpers
422
+ ////////////////
423
+
424
+ /** POST `data` as JSON to the server; resolves to its answer, or rejects with its error (`command` attached). */
332
425
  async function post(path, data, okStatuses = []) {
333
426
  const response = await fetch(path, {
334
427
  method: "POST",
335
428
  headers: { "Content-Type": "application/json", "X-Server-Token": SERVER.token },
336
429
  body: JSON.stringify(data)
337
- });
338
- const answer = await response.json().catch(() => ({}));
339
- if (response.status === 403 && /token/.test(answer.error ?? "")) location.reload();
340
- if (response.ok || okStatuses.includes(response.status)) return answer;
341
- const error = new Error(answer.error ?? `${response.status} ${response.statusText}`);
342
- error.command = answer.command;
343
- throw error;
430
+ })
431
+ const answer = await response.json().catch(() => ({}))
432
+ // a server restarted since: its new token comes with a reload
433
+ if (response.status === 403 && /token/.test(answer.error ?? "")) location.reload()
434
+ if (response.ok || okStatuses.includes(response.status)) return answer
435
+ const error = new Error(answer.error ?? `${response.status} ${response.statusText}`)
436
+ error.command = answer.command
437
+ throw error
344
438
  }
345
- __name(post, "post");
439
+
440
+ /** Show / hide a `<ui-modal>`. */
346
441
  function show(modal) {
347
- modal.visible = true;
442
+ modal.visible = true
348
443
  }
349
- __name(show, "show");
350
444
  function hide(modal) {
351
- modal.visible = false;
445
+ modal.visible = false
352
446
  }
353
- __name(hide, "hide");
447
+
448
+ /**
449
+ * What a button WILL do, once goals is rebuilt: goals is PARKED (epic `epic-workflow` P6; the plan to rebuild it:
450
+ * epic `epic-goals`). Its routes and skills are gone (`packages/goals.zip`), so every button says so, instead.
451
+ * - `action`: the button's `data-goals`; `what`: the page, heading or item it's on
452
+ * - `run()`, `openThought()`, `openVSCode()` and their modals below are kept for that rebuild, unused meanwhile
453
+ */
354
454
  function parked(action, what) {
355
455
  const will = {
356
456
  talk: `start a Claude session that talks ${what} through with you (/goals)`,
357
457
  thought: `save a thought about ${what}, for Claude to digest later (/goals-thought)`,
358
458
  update: `have Claude work the new thoughts into ${what} (/goals-update)`,
359
459
  vscode: `show this page in VS Code's side bar, beside your code`
360
- }[action];
361
- toast("TODO", `This will ${will ?? "do this"}, once goals is rebuilt (epic epic-goals).`, "info");
460
+ }[action]
461
+ toast("TODO", `This will ${will ?? "do this"}, once goals is rebuilt (epic epic-goals).`, "info")
362
462
  }
363
- __name(parked, "parked");
463
+
464
+ /** A toast, through `UI.toast()`; the console if toasts aren't there. */
364
465
  function toast(title, message, type) {
365
466
  try {
366
- window.SpellUI.UI.toast({ title, message, type, position: "bottom right", displayTime: 4e3, showIcon: true });
467
+ window.SpellUI.UI.toast({ title, message, type, position: "bottom right", displayTime: 4000, showIcon: true })
367
468
  } catch {
368
- console.info(`${title}: ${message}`);
469
+ console.info(`${title}: ${message}`)
369
470
  }
370
471
  }
371
- __name(toast, "toast");
472
+
473
+ /** Copy `text`, and say so. */
372
474
  async function copy(text) {
373
475
  try {
374
- await navigator.clipboard.writeText(text);
375
- toast("Copied", text, "success");
476
+ await navigator.clipboard.writeText(text)
477
+ toast("Copied", text, "success")
376
478
  } catch {
377
- toast("Couldn't copy", "Select the command and copy it yourself.", "warning");
479
+ toast("Couldn't copy", "Select the command and copy it yourself.", "warning")
378
480
  }
379
481
  }
380
- __name(copy, "copy");
482
+
483
+ /** A new `tag` with `attributes`, holding `children` (nodes or text): as `spell-syntax.js`'s. */
381
484
  function el(tag, attributes = {}, ...children) {
382
- const node = document.createElement(tag);
383
- for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value);
384
- node.append(...children);
385
- return node;
485
+ const node = document.createElement(tag)
486
+ for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value)
487
+ node.append(...children)
488
+ return node
386
489
  }
387
- __name(el, "el");
490
+
491
+ /**
492
+ * `host`'s `title` (a `<ui-button>`'s) on the button inside it too, once drawn: the element the pointer lands on
493
+ * carries the tooltip (VS Code's side bar shows only that one's), as `spell-doc-helpers.js`' `titleInside()` does.
494
+ */
388
495
  function titleInside(host) {
389
- void customElements.whenDefined(host.localName).then(
390
- () => requestAnimationFrame(() => {
391
- const inner = host.shadowRoot?.querySelector('[part~="button"]');
392
- if (inner) inner.title = host.title;
496
+ void customElements.whenDefined(host.localName).then(() =>
497
+ requestAnimationFrame(() => {
498
+ const inner = host.shadowRoot?.querySelector('[part~="button"]')
499
+ if (inner) inner.title = host.title
393
500
  })
394
- );
501
+ )
395
502
  }
396
- __name(titleInside, "titleInside");
503
+
504
+ /** One element from HTML: the parked dialogs' (`thoughtModal()` ...), unused until goals is rebuilt. */
397
505
  function element(html) {
398
- const template = document.createElement("template");
399
- template.innerHTML = html.trim();
400
- return template.content.firstElementChild;
506
+ const template = document.createElement("template")
507
+ template.innerHTML = html.trim()
508
+ return template.content.firstElementChild
401
509
  }
402
- __name(element, "element");
510
+
511
+ /** Escape for HTML text and attributes. */
403
512
  function escape(text) {
404
- return String(text).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
513
+ return String(text).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
405
514
  }
406
- __name(escape, "escape");
407
- })();
515
+ })()