spell 0.8.8 → 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 (92) hide show
  1. package/README-epics.md +60 -20
  2. package/app/package.json +1 -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/epic/cli/EpicProgram.js +15 -6
  12. package/dist/epic/cli/epicGroups.js +5 -0
  13. package/dist/epic/command/BaseBranch.js +1 -1
  14. package/dist/epic/command/PullRequest.d.ts +45 -0
  15. package/dist/epic/command/PullRequest.js +100 -0
  16. package/dist/epic/command/RepoInit.d.ts +96 -47
  17. package/dist/epic/command/RepoInit.js +222 -96
  18. package/dist/epic/command/Requests.js +2 -1
  19. package/dist/epic/command/Worktrees.d.ts +5 -3
  20. package/dist/epic/command/Worktrees.js +9 -8
  21. package/dist/epic/components/__pack/epics.entry.js +43 -43
  22. package/dist/epic/components/__pack/epics.pack.js +2 -2
  23. package/dist/epic/config/CodeHost.d.ts +96 -0
  24. package/dist/epic/config/CodeHost.js +89 -0
  25. package/dist/epic/config/EpicConfig.d.ts +9 -2
  26. package/dist/epic/config/EpicConfig.js +16 -0
  27. package/dist/epic/config/EpicRepo.js +1 -1
  28. package/dist/epic/config/GitHub.d.ts +34 -2
  29. package/dist/epic/config/GitHub.js +36 -7
  30. package/dist/epic/config/GitLab.d.ts +138 -0
  31. package/dist/epic/config/GitLab.js +297 -0
  32. package/dist/epic/tool/PlanCommits.d.ts +7 -4
  33. package/dist/epic/tool/PlanCommits.js +7 -5
  34. package/dist/epic/tool/PlanDocCommands.js +3 -4
  35. package/dist/epic/tool/PlanDocFiles.d.ts +3 -1
  36. package/dist/epic/tool/PlanDocFiles.js +10 -3
  37. package/dist/parser/core/classes/View.d.ts +20 -0
  38. package/dist/parser/core/classes/View.js +91 -17
  39. package/dist/parser/core/core.declarations.json5 +18 -0
  40. package/dist/parser/core/core.scopes.js +5 -0
  41. package/dist/parser/core/sites.d.ts +10 -0
  42. package/dist/parser/core/sites.js +12 -0
  43. package/dist/parser/parser/tokenizer/Tokenizer.d.ts +9 -1
  44. package/dist/parser/parser/tokenizer/Tokenizer.js +43 -5
  45. package/dist/parser/parser/tokenizer/Tokens.d.ts +4 -0
  46. package/dist/parser/parser/tokenizer/Tokens.js +4 -0
  47. package/dist/parser/parser/tokenizer/tokenizer.types.d.ts +5 -0
  48. package/dist/parser/parser/tokenizer/tokenizer.types.js +2 -0
  49. package/dist/parser/py/core/spell_core/apps.py +2 -0
  50. package/dist/parser/spell/PARSING.md +21 -0
  51. package/dist/parser/spell/SpellParser.d.ts +2 -0
  52. package/dist/parser/spell/SpellParser.js +58 -3
  53. package/dist/parser/spell/SpellxTokenizer.js +2 -1
  54. package/dist/parser/spell/SpellxTwin.d.ts +4 -1
  55. package/dist/parser/spell/SpellxTwin.js +10 -3
  56. package/dist/parser/spell/builtinTypes.js +24 -1
  57. package/dist/parser/spell/ingest/PlaceIngest.js +3 -1
  58. package/dist/parser/spell/languages/Language.d.ts +11 -2
  59. package/dist/parser/spell/languages/en/words.js +3 -2
  60. package/dist/parser/spell/languages/es/words.js +7 -4
  61. package/dist/parser/spell/rules/Statement.js +1 -1
  62. package/dist/parser/spell/rules/classes/DrawSlot.js +6 -1
  63. package/dist/parser/spell/rules/sites/SitePage.d.ts +3 -3
  64. package/dist/parser/spell/rules/sites/SitePage.js +2 -2
  65. package/dist/parser/spell/rules/sites/sites.en.js +1 -1
  66. package/dist/parser/spell/rules/sites/sites.es.js +1 -1
  67. package/dist/parser/spell/rules/sites/sites.shared.d.ts +2 -2
  68. package/dist/parser/spell/spell.types.d.ts +7 -0
  69. package/dist/parser/spell/spellSyntax.es.json +6 -6
  70. package/dist/parser/spell/spellSyntax.json +6 -6
  71. package/dist/parser/spellx/SpellxView.js +2 -1
  72. package/dist/ui/components/ui-parts/UIHeader.d.ts +12 -2
  73. package/dist/ui/components/ui-parts/UIHeader.en.d.ts +5 -2
  74. package/dist/ui/components/ui-parts/UIHeader.en.js +6 -3
  75. package/dist/ui/components/ui-parts/UIHeader.js +45 -5
  76. package/dist/ui/components/ui-parts/UIParts.css +18 -0
  77. package/dist/ui/components/ui-parts/UIParts.css.inline.js +1 -1
  78. package/dist/ui/jsx.d.ts +4 -4
  79. package/dist/ui/vocabulary/defaults.generated.js +1 -1
  80. package/dist/util/spell/constants.js +1 -1
  81. package/epic/.claude-plugin/plugin.json +1 -1
  82. package/epic/.codex-plugin/plugin.json +1 -1
  83. package/epic/package.json +1 -1
  84. package/epic/skills/epic/SKILL.md +2 -2
  85. package/epic/skills/epic/guide.md +2 -3
  86. package/epic/skills/isolate/SKILL.md +25 -27
  87. package/epic/src/AGENTS.md +5 -0
  88. package/epic/vscode/package.json +1 -1
  89. package/epic/vscode/spell-epic.vsix +0 -0
  90. package/package.json +1 -1
  91. package/parser/package.json +1 -1
  92. package/ui/package.json +1 -1
@@ -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
+ };
@@ -1,8 +1,9 @@
1
+ import { type CodeHostKind } from "spell/epic/config/CodeHost";
1
2
  import type { ParsedCommit } from "./planDoc.types";
2
3
  /****************
3
4
  * ### `PlanCommits`
4
5
  * Commits as an epic page lists them: what a commit subject says it did (`P3: Name -- summary`, `Fix I3: ...`), the
5
- * repo's GitHub page, and finding a listed one (`<epic-commit sha>`).
6
+ * repo's page on its code host, and finding a listed one (`<epic-commit sha>`).
6
7
  * - STATIC and instance-free on purpose: pure functions of their arguments; never runs git (the command line does,
7
8
  * and hands the log in).
8
9
  * - From `src/tools/plan-doc.js` (epic `epic-components`, P7).
@@ -23,10 +24,12 @@ export declare class PlanCommits {
23
24
  */
24
25
  static titleNames(title: string, name: string): boolean;
25
26
  /**
26
- * The GitHub page of a repo, from its remote's URL (`git remote get-url origin`); `null` when it isn't GitHub.
27
- * - `https://github.com/o/r.git`, `git@github.com:o/r.git`, `ssh://git@github.com/o/r` -> `https://github.com/o/r`
27
+ * The page a repo's commit links go under, from its remote's URL (`git remote get-url origin`);
28
+ * `null` for an address that isn't that host's.
29
+ * - `<epic-commit>` adds `/commit/<sha>`: on GitLab this is `https://host/group/project/-`, giving GitLab's
30
+ * `/-/commit/<sha>`
28
31
  */
29
- static githubBase(remote: string | null | undefined): string | null;
32
+ static commitBase(remote: string | null | undefined, kind: CodeHostKind): string | null;
30
33
  /**
31
34
  * The `<epic-commit>` for commit `sha` among `host`'s children (a phase, an item), if any: by its `sha`, either one
32
35
  * a prefix of the other (a short sha given, or listed).
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/tool/PlanCommits.ts
5
+ import { CodeHost } from "../config/CodeHost.js";
5
6
  var PlanCommits = class _PlanCommits {
6
7
  static {
7
8
  __name(this, "PlanCommits");
@@ -37,12 +38,13 @@ var PlanCommits = class _PlanCommits {
37
38
  return Boolean(name) && title.toLowerCase().includes(name.toLowerCase());
38
39
  }
39
40
  /**
40
- * The GitHub page of a repo, from its remote's URL (`git remote get-url origin`); `null` when it isn't GitHub.
41
- * - `https://github.com/o/r.git`, `git@github.com:o/r.git`, `ssh://git@github.com/o/r` -> `https://github.com/o/r`
41
+ * The page a repo's commit links go under, from its remote's URL (`git remote get-url origin`);
42
+ * `null` for an address that isn't that host's.
43
+ * - `<epic-commit>` adds `/commit/<sha>`: on GitLab this is `https://host/group/project/-`, giving GitLab's
44
+ * `/-/commit/<sha>`
42
45
  */
43
- static githubBase(remote) {
44
- const match = String(remote ?? "").trim().match(/github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/);
45
- return match ? `https://github.com/${match[1]}/${match[2]}` : null;
46
+ static commitBase(remote, kind) {
47
+ return CodeHost.commitBase(kind, String(remote ?? "").trim());
46
48
  }
47
49
  /**
48
50
  * The `<epic-commit>` for commit `sha` among `host`'s children (a phase, an item), if any: by its `sha`, either one
@@ -29,7 +29,6 @@ import { ItemPicker } from "./ItemPicker.js";
29
29
  import { MigrateCommands } from "./MigrateCommands.js";
30
30
  import { OptionCommands } from "./OptionCommands.js";
31
31
  import { PlanDoc } from "./PlanDoc.js";
32
- import { PlanCommits } from "./PlanCommits.js";
33
32
  import { EPIC_STATUSES, PlanDocFiles } from "./PlanDocFiles.js";
34
33
  import { PlanItem } from "./PlanItem.js";
35
34
  import { PlanMarkup } from "./PlanMarkup.js";
@@ -558,7 +557,7 @@ var PlanDocCommands = class _PlanDocCommands {
558
557
  if (!found) throw new PlanDocError(`no commit "${sha}" in ${folders.join(", ")}`);
559
558
  const { folder, full } = found;
560
559
  const base = this.files.commitBase(file);
561
- const repo = PlanCommits.githubBase(PlanDocFiles.gitIn(folder, "remote", "get-url", "origin"));
560
+ const repo = PlanDocFiles.commitBaseOf(folder);
562
561
  const { done, where } = await this.edit(file, (plan) => {
563
562
  const target = phase !== void 0 ? { phase: plan.phasePlace(String(phase)) } : { item: String(item) };
564
563
  const where2 = target.phase !== void 0 ? plan.phaseLabel(target.phase) : target.item.toUpperCase();
@@ -608,8 +607,8 @@ var PlanDocCommands = class _PlanDocCommands {
608
607
  const repos = stringFlag(flags.repo)?.split(",").filter(Boolean) ?? [];
609
608
  if (!maps.length || !repos.length)
610
609
  throw new PlanDocError("commits remap <map> [<map> ...] --repo <old repo> [--to <repo>] [--dry-run]");
611
- const to = stringFlag(flags.to) ?? PlanCommits.githubBase(PlanDocFiles.gitIn(this.files.root, "remote", "get-url", "origin"));
612
- if (!to) throw new PlanDocError("commits remap: this checkout's remote isn't GitHub: --to <repo>");
610
+ const to = stringFlag(flags.to) ?? PlanDocFiles.commitBaseOf(this.files.root);
611
+ if (!to) throw new PlanDocError("commits remap: this checkout's remote has no web page: --to <repo>");
613
612
  const remap = new CommitRemap({
614
613
  ids: CommitRemap.readMap(maps.map((map) => resolve(map))),
615
614
  from: repos,
@@ -294,8 +294,10 @@ export declare class PlanDocFiles {
294
294
  * - so green means changed in this commit or the last: everything since the commit before those
295
295
  */
296
296
  recentSince(file: string): string | null;
297
- /** The GitHub page of the doc's repo (`PlanCommits.githubBase()` of `origin`), or `null`. */
297
+ /** The page the doc's repo's commit links go under (`PlanCommits.commitBase()` of `origin`), or `null`. */
298
298
  commitBase(file: string): string | null;
299
+ /** The page checkout `checkout`'s commit links go under, by its `origin` and its code host; `null` for none. */
300
+ static commitBaseOf(checkout: string): string | null;
299
301
  /**
300
302
  * The repos a doc's commits can be in, the doc's checkout first: it, then each of its child repos that's there
301
303
  * (`EpicConfig.repos`: a multi-repo top's, `spell-parser` ...; none for a single repo), then each of the kit's
@@ -609,9 +609,16 @@ ${run.stdout}${run.stderr}`);
609
609
  recentSince(file) {
610
610
  return _PlanDocFiles.gitIn(this.checkoutOf(file), "log", "-1", "--format=%cI", "HEAD~2") || null;
611
611
  }
612
- /** The GitHub page of the doc's repo (`PlanCommits.githubBase()` of `origin`), or `null`. */
612
+ /** The page the doc's repo's commit links go under (`PlanCommits.commitBase()` of `origin`), or `null`. */
613
613
  commitBase(file) {
614
- return PlanCommits.githubBase(_PlanDocFiles.gitIn(this.checkoutOf(file), "remote", "get-url", "origin"));
614
+ return _PlanDocFiles.commitBaseOf(this.checkoutOf(file));
615
+ }
616
+ /** The page checkout `checkout`'s commit links go under, by its `origin` and its code host; `null` for none. */
617
+ static commitBaseOf(checkout) {
618
+ return PlanCommits.commitBase(
619
+ _PlanDocFiles.gitIn(checkout, "remote", "get-url", "origin"),
620
+ EpicConfig.of(checkout).codeHost
621
+ );
615
622
  }
616
623
  /**
617
624
  * The repos a doc's commits can be in, the doc's checkout first: it, then each of its child repos that's there
@@ -667,7 +674,7 @@ ${run.stdout}${run.stderr}`);
667
674
  const phases = PlanDoc.parse(html).phases;
668
675
  const timed = [];
669
676
  for (const checkout of [checkouts].flat()) {
670
- const repo = PlanCommits.githubBase(_PlanDocFiles.gitIn(checkout, "remote", "get-url", "origin"));
677
+ const repo = _PlanDocFiles.commitBaseOf(checkout);
671
678
  const raw = _PlanDocFiles.gitIn(
672
679
  checkout,
673
680
  "log",
@@ -1,3 +1,4 @@
1
+ import type { Drawing } from "spell/parser/core/drawing";
1
2
  import { Thing } from "./Thing";
2
3
  /**
3
4
  * `View`: a `Thing` drawn as its own custom element -- what `a card is a view` extends.
@@ -8,9 +9,28 @@ import { Thing } from "./Thing";
8
9
  * - Its things may be dragged, clicked or selected on the page only when its type says so:
9
10
  * `<spell-view "card" draggable>`, `- it is clickable when it is face down`, or an event that implies it,
10
11
  * `- on click:` (`core.isAble()`).
12
+ * - A picture of it, its `thumbnail`, draws while it has no drawing of its own (epic `mockup` P16).
11
13
  * - Everything else as a `Thing`.
12
14
  */
13
15
  export declare class View extends Thing {
16
+ /**
17
+ * A picture of it, a file of its project: `snapshots/terms.jpg`.
18
+ * - `<spell-page "terms" thumbnail="snapshots/terms.jpg"/>`, or `- its thumbnail is "..."`.
19
+ * - A type may have data of its own called this, a thing as much as text: only text is a picture's file.
20
+ */
21
+ accessor thumbnail: string | undefined;
22
+ /**
23
+ * Draw our thumbnail: what a view with no drawing of its own shows.
24
+ * - Compiled spell's own `to draw it` replaces this, so writing any content replaces the picture.
25
+ * - throws: no thumbnail, as a thing with no `to draw` can't be drawn.
26
+ */
27
+ draw(): Drawing;
28
+ /**
29
+ * Our thumbnail, as an image: what `draw its thumbnail` places.
30
+ * - Nothing when we have none.
31
+ * - Its file is found from the running project's folder, so no page says where its project is.
32
+ */
33
+ drawThumbnail(): Drawing;
14
34
  /**
15
35
  * May a page let people drag our things? `- it is draggable` says yes (epic `outline-spell` P28, `debut` P27).
16
36
  * - Even then, only when the list holding one will give it up: its `can give up` rule.
@@ -1,33 +1,107 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
5
+ var __typeError = (msg) => {
6
+ throw TypeError(msg);
7
+ };
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2
9
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
11
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
12
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
13
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
14
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
15
+ var __runInitializers = (array, flags, self, value) => {
16
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
17
+ return value;
18
+ };
19
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
20
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
21
+ var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
22
+ var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
23
+ var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
24
+ return __privateGet(this, extra);
25
+ }, set [name](x) {
26
+ return __privateSet(this, extra, x);
27
+ } }, name));
28
+ k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
29
+ for (var i = decorators.length - 1; i >= 0; i--) {
30
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
31
+ if (k) {
32
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
33
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
34
+ if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
35
+ }
36
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
37
+ if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
38
+ else if (typeof it !== "object" || it === null) __typeError("Object expected");
39
+ else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
40
+ }
41
+ return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
42
+ };
43
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
44
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
45
+ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
46
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
48
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
49
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
3
50
 
4
51
  // src/core/classes/View.ts
52
+ import h from "@solidjs/h";
53
+ import { prop } from "spell/util";
5
54
  import { noAbilities } from "../abilities.js";
55
+ import { core } from "../core.js";
6
56
  import { Thing } from "./Thing.js";
7
- var View = class extends Thing {
8
- static {
9
- __name(this, "View");
57
+ var _thumbnail_dec, _a, _init, _thumbnail;
58
+ var _View = class _View extends (_a = Thing, _thumbnail_dec = [prop()], _a) {
59
+ constructor() {
60
+ super(...arguments);
61
+ __privateAdd(this, _thumbnail, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
10
62
  }
11
63
  /**
12
- * May a page let people drag our things? `- it is draggable` says yes (epic `outline-spell` P28, `debut` P27).
13
- * - Even then, only when the list holding one will give it up: its `can give up` rule.
14
- * - "No" until a type says, or its `- on drag:` implies it: see `core.isAble()`.
64
+ * Draw our thumbnail: what a view with no drawing of its own shows.
65
+ * - Compiled spell's own `to draw it` replaces this, so writing any content replaces the picture.
66
+ * - throws: no thumbnail, as a thing with no `to draw` can't be drawn.
15
67
  */
16
- static draggable = false;
17
- /**
18
- * May a page let people click our things? `- it is clickable` says yes, or its `- on click:` (epic `debut` P27).
19
- * - Clickable, it shows the pointer; `- clickable when it is face down` runs its click only then.
20
- */
21
- static clickable = false;
68
+ draw() {
69
+ return typeof this.thumbnail === "string" ? this.drawThumbnail() : super.draw();
70
+ }
22
71
  /**
23
- * May a page let people select our things? `- it is selectable` says yes (epic `outline-spell` P29).
24
- * - A click selects one in its list; shift and command (ctrl) select more: see `ViewableList.selection`.
72
+ * Our thumbnail, as an image: what `draw its thumbnail` places.
73
+ * - Nothing when we have none.
74
+ * - Its file is found from the running project's folder, so no page says where its project is.
25
75
  */
26
- static selectable = false;
27
- static {
28
- noAbilities(this);
76
+ drawThumbnail() {
77
+ const { thumbnail } = this;
78
+ if (typeof thumbnail !== "string") return null;
79
+ return h("img", { src: core.addressOfFile(thumbnail), alt: "", style: "max-width: 100%" });
29
80
  }
30
81
  };
82
+ _init = __decoratorStart(_a);
83
+ _thumbnail = new WeakMap();
84
+ __decorateElement(_init, 4, "thumbnail", _thumbnail_dec, _View, _thumbnail);
85
+ __decoratorMetadata(_init, _View);
86
+ __name(_View, "View");
87
+ /**
88
+ * May a page let people drag our things? `- it is draggable` says yes (epic `outline-spell` P28, `debut` P27).
89
+ * - Even then, only when the list holding one will give it up: its `can give up` rule.
90
+ * - "No" until a type says, or its `- on drag:` implies it: see `core.isAble()`.
91
+ */
92
+ __publicField(_View, "draggable", false);
93
+ /**
94
+ * May a page let people click our things? `- it is clickable` says yes, or its `- on click:` (epic `debut` P27).
95
+ * - Clickable, it shows the pointer; `- clickable when it is face down` runs its click only then.
96
+ */
97
+ __publicField(_View, "clickable", false);
98
+ /**
99
+ * May a page let people select our things? `- it is selectable` says yes (epic `outline-spell` P29).
100
+ * - A click selects one in its list; shift and command (ctrl) select more: see `ViewableList.selection`.
101
+ */
102
+ __publicField(_View, "selectable", false);
103
+ noAbilities(_View);
104
+ var View = _View;
31
105
  export {
32
106
  View
33
107
  };
@@ -3534,6 +3534,24 @@
3534
3534
  "module": "sites",
3535
3535
  "description": "Where a running site's address lives, as the host keeps it: `undefined` for none, and the site keeps its own."
3536
3536
  },
3537
+ {
3538
+ "property": "projectFolder",
3539
+ "of": "core",
3540
+ "module": "sites",
3541
+ "description": "The folder of the program running, as an address: `/spaces/@spell/sites/SpellApp`."
3542
+ },
3543
+ {
3544
+ "kind": "method",
3545
+ "name": "addressOfFile",
3546
+ "of": "core",
3547
+ "module": "sites",
3548
+ "params": [
3549
+ {
3550
+ "name": "file"
3551
+ }
3552
+ ],
3553
+ "description": "The address of `file`, a file of the running project: `snapshots/terms.jpg` => `/spaces/.../snapshots/terms.jpg`."
3554
+ },
3537
3555
  {
3538
3556
  "kind": "method",
3539
3557
  "name": "showSitePart",
@@ -270,6 +270,11 @@
270
270
  { name: "draw_it", syntax: "to draw its {slot:member_words} :? {statement_body}?" }
271
271
  ]
272
272
  },
273
+ {
274
+ path: "type:View/property:thumbnail",
275
+ detail: "text",
276
+ description: 'A picture of it, a file of its project: `snapshots/terms.jpg`.\n- Drawn while it has no drawing of its own: writing one replaces it.\n- A drawing can place it too: `draw its thumbnail`.\n- A site\'s card shows it, unless the site\'s line names its own.\n- Say it on its tag, `<spell-page "terms" thumbnail="snapshots/terms.jpg"/>`, or in its body, `- its thumbnail is "..."`.'
277
+ },
273
278
  {
274
279
  path: "type:Page",
275
280
  super: "type:View",
@@ -6,6 +6,16 @@ export declare const siteMethods: {
6
6
  * - The editor's Run sets it for each run: `/run/<project>/films/4` shows `/films/4`, and back and forward work.
7
7
  */
8
8
  siteHost: SiteHost | undefined;
9
+ /**
10
+ * The folder of the program running, as an address: `/spaces/@spell/sites/SpellApp`.
11
+ * - Set by whatever runs it; none: a file's name is left as it is, relative to the page.
12
+ */
13
+ projectFolder: string | undefined;
14
+ /**
15
+ * The address of `file`, a file of the running project: `snapshots/terms.jpg` => `/spaces/.../snapshots/terms.jpg`.
16
+ * - An address of its own (`/x.jpg`, `https://...`, `data:...`) is left as it is.
17
+ */
18
+ addressOfFile(file: string): string;
9
19
  /**
10
20
  * Show the site's page `name`, its parameter filled with `thing`, or open its dialog or sidebar of that name:
11
21
  * what `go to the film page for this film` and `show the settings dialog` compile to.