@brunosouzas/stackledger 0.0.0-stage → 0.4.1

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 (307) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +260 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +97 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/control.d.ts +2 -0
  7. package/dist/control.js +22 -0
  8. package/dist/control.js.map +1 -0
  9. package/dist/discover-command.d.ts +7 -0
  10. package/dist/discover-command.js +60 -0
  11. package/dist/discover-command.js.map +1 -0
  12. package/dist/discovery/annotations.d.ts +24 -0
  13. package/dist/discovery/annotations.js +37 -0
  14. package/dist/discovery/annotations.js.map +1 -0
  15. package/dist/discovery/host.d.ts +47 -0
  16. package/dist/discovery/host.js +56 -0
  17. package/dist/discovery/host.js.map +1 -0
  18. package/dist/discovery/index.d.ts +15 -0
  19. package/dist/discovery/index.js +30 -0
  20. package/dist/discovery/index.js.map +1 -0
  21. package/dist/discovery/machine.d.ts +14 -0
  22. package/dist/discovery/machine.js +17 -0
  23. package/dist/discovery/machine.js.map +1 -0
  24. package/dist/discovery/run.d.ts +39 -0
  25. package/dist/discovery/run.js +130 -0
  26. package/dist/discovery/run.js.map +1 -0
  27. package/dist/discovery/snapshot.d.ts +60 -0
  28. package/dist/discovery/snapshot.js +161 -0
  29. package/dist/discovery/snapshot.js.map +1 -0
  30. package/dist/discovery/sources/apps.d.ts +3 -0
  31. package/dist/discovery/sources/apps.js +136 -0
  32. package/dist/discovery/sources/apps.js.map +1 -0
  33. package/dist/discovery/sources/brew.d.ts +15 -0
  34. package/dist/discovery/sources/brew.js +69 -0
  35. package/dist/discovery/sources/brew.js.map +1 -0
  36. package/dist/discovery/sources/common.d.ts +39 -0
  37. package/dist/discovery/sources/common.js +70 -0
  38. package/dist/discovery/sources/common.js.map +1 -0
  39. package/dist/discovery/sources/index.d.ts +8 -0
  40. package/dist/discovery/sources/index.js +12 -0
  41. package/dist/discovery/sources/index.js.map +1 -0
  42. package/dist/discovery/sources/launchd.d.ts +3 -0
  43. package/dist/discovery/sources/launchd.js +65 -0
  44. package/dist/discovery/sources/launchd.js.map +1 -0
  45. package/dist/discovery/sources/mas.d.ts +9 -0
  46. package/dist/discovery/sources/mas.js +25 -0
  47. package/dist/discovery/sources/mas.js.map +1 -0
  48. package/dist/discovery/sources/mise.d.ts +5 -0
  49. package/dist/discovery/sources/mise.js +64 -0
  50. package/dist/discovery/sources/mise.js.map +1 -0
  51. package/dist/discovery/sources/npm.d.ts +12 -0
  52. package/dist/discovery/sources/npm.js +34 -0
  53. package/dist/discovery/sources/npm.js.map +1 -0
  54. package/dist/discovery/sources/pipx.d.ts +4 -0
  55. package/dist/discovery/sources/pipx.js +82 -0
  56. package/dist/discovery/sources/pipx.js.map +1 -0
  57. package/dist/discovery/types.d.ts +73 -0
  58. package/dist/discovery/types.js +10 -0
  59. package/dist/discovery/types.js.map +1 -0
  60. package/dist/discovery/write.d.ts +50 -0
  61. package/dist/discovery/write.js +196 -0
  62. package/dist/discovery/write.js.map +1 -0
  63. package/dist/drift-command.d.ts +62 -0
  64. package/dist/drift-command.js +375 -0
  65. package/dist/drift-command.js.map +1 -0
  66. package/dist/drift-formats.d.ts +3 -0
  67. package/dist/drift-formats.js +54 -0
  68. package/dist/drift-formats.js.map +1 -0
  69. package/dist/drift.d.ts +95 -0
  70. package/dist/drift.js +206 -0
  71. package/dist/drift.js.map +1 -0
  72. package/dist/errors.d.ts +15 -0
  73. package/dist/errors.js +26 -0
  74. package/dist/errors.js.map +1 -0
  75. package/dist/graph.d.ts +103 -0
  76. package/dist/graph.js +181 -0
  77. package/dist/graph.js.map +1 -0
  78. package/dist/ics.d.ts +18 -0
  79. package/dist/ics.js +103 -0
  80. package/dist/ics.js.map +1 -0
  81. package/dist/identity.d.ts +18 -0
  82. package/dist/identity.js +36 -0
  83. package/dist/identity.js.map +1 -0
  84. package/dist/index.d.ts +14 -0
  85. package/dist/index.js +9 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/map/badges.d.ts +20 -0
  88. package/dist/map/badges.js +95 -0
  89. package/dist/map/badges.js.map +1 -0
  90. package/dist/map/command.d.ts +8 -0
  91. package/dist/map/command.js +86 -0
  92. package/dist/map/command.js.map +1 -0
  93. package/dist/map/heap.d.ts +15 -0
  94. package/dist/map/heap.js +57 -0
  95. package/dist/map/heap.js.map +1 -0
  96. package/dist/map/ink.d.ts +11 -0
  97. package/dist/map/ink.js +10 -0
  98. package/dist/map/ink.js.map +1 -0
  99. package/dist/map/labels.d.ts +43 -0
  100. package/dist/map/labels.js +172 -0
  101. package/dist/map/labels.js.map +1 -0
  102. package/dist/map/layout.d.ts +59 -0
  103. package/dist/map/layout.js +197 -0
  104. package/dist/map/layout.js.map +1 -0
  105. package/dist/map/model.d.ts +46 -0
  106. package/dist/map/model.js +84 -0
  107. package/dist/map/model.js.map +1 -0
  108. package/dist/map/neighbourhood.d.ts +18 -0
  109. package/dist/map/neighbourhood.js +138 -0
  110. package/dist/map/neighbourhood.js.map +1 -0
  111. package/dist/map/parallel.d.ts +21 -0
  112. package/dist/map/parallel.js +174 -0
  113. package/dist/map/parallel.js.map +1 -0
  114. package/dist/map/relations.d.ts +39 -0
  115. package/dist/map/relations.js +127 -0
  116. package/dist/map/relations.js.map +1 -0
  117. package/dist/map/route.d.ts +25 -0
  118. package/dist/map/route.js +165 -0
  119. package/dist/map/route.js.map +1 -0
  120. package/dist/map/strip.d.ts +29 -0
  121. package/dist/map/strip.js +122 -0
  122. package/dist/map/strip.js.map +1 -0
  123. package/dist/map/suggest.d.ts +21 -0
  124. package/dist/map/suggest.js +97 -0
  125. package/dist/map/suggest.js.map +1 -0
  126. package/dist/map/svg.d.ts +22 -0
  127. package/dist/map/svg.js +232 -0
  128. package/dist/map/svg.js.map +1 -0
  129. package/dist/map/themes.d.ts +61 -0
  130. package/dist/map/themes.js +78 -0
  131. package/dist/map/themes.js.map +1 -0
  132. package/dist/map/xml.d.ts +8 -0
  133. package/dist/map/xml.js +68 -0
  134. package/dist/map/xml.js.map +1 -0
  135. package/dist/map/zones.d.ts +19 -0
  136. package/dist/map/zones.js +46 -0
  137. package/dist/map/zones.js.map +1 -0
  138. package/dist/mcp.d.ts +2 -0
  139. package/dist/mcp.js +145 -0
  140. package/dist/mcp.js.map +1 -0
  141. package/dist/money.d.ts +32 -0
  142. package/dist/money.js +91 -0
  143. package/dist/money.js.map +1 -0
  144. package/dist/report-command.d.ts +3 -0
  145. package/dist/report-command.js +85 -0
  146. package/dist/report-command.js.map +1 -0
  147. package/dist/report-formats.d.ts +11 -0
  148. package/dist/report-formats.js +157 -0
  149. package/dist/report-formats.js.map +1 -0
  150. package/dist/reports.d.ts +105 -0
  151. package/dist/reports.js +247 -0
  152. package/dist/reports.js.map +1 -0
  153. package/dist/scaffold.d.ts +30 -0
  154. package/dist/scaffold.js +140 -0
  155. package/dist/scaffold.js.map +1 -0
  156. package/dist/schema.d.ts +330 -0
  157. package/dist/schema.js +116 -0
  158. package/dist/schema.js.map +1 -0
  159. package/dist/secrets.d.ts +7 -0
  160. package/dist/secrets.js +68 -0
  161. package/dist/secrets.js.map +1 -0
  162. package/dist/site/build.d.ts +22 -0
  163. package/dist/site/build.js +196 -0
  164. package/dist/site/build.js.map +1 -0
  165. package/dist/site/command.d.ts +2 -0
  166. package/dist/site/command.js +221 -0
  167. package/dist/site/command.js.map +1 -0
  168. package/dist/site/data.d.ts +205 -0
  169. package/dist/site/data.js +241 -0
  170. package/dist/site/data.js.map +1 -0
  171. package/dist/site/fs-ops.d.ts +35 -0
  172. package/dist/site/fs-ops.js +26 -0
  173. package/dist/site/fs-ops.js.map +1 -0
  174. package/dist/site/owners.d.ts +5 -0
  175. package/dist/site/owners.js +50 -0
  176. package/dist/site/owners.js.map +1 -0
  177. package/dist/site/paths.d.ts +34 -0
  178. package/dist/site/paths.js +48 -0
  179. package/dist/site/paths.js.map +1 -0
  180. package/dist/site/policy.d.ts +17 -0
  181. package/dist/site/policy.js +26 -0
  182. package/dist/site/policy.js.map +1 -0
  183. package/dist/site/publish.d.ts +14 -0
  184. package/dist/site/publish.js +90 -0
  185. package/dist/site/publish.js.map +1 -0
  186. package/dist/site/relative.d.ts +14 -0
  187. package/dist/site/relative.js +265 -0
  188. package/dist/site/relative.js.map +1 -0
  189. package/dist/site/skills-build.d.ts +22 -0
  190. package/dist/site/skills-build.js +126 -0
  191. package/dist/site/skills-build.js.map +1 -0
  192. package/dist/site/skills-data.d.ts +89 -0
  193. package/dist/site/skills-data.js +94 -0
  194. package/dist/site/skills-data.js.map +1 -0
  195. package/dist/site/staging.d.ts +19 -0
  196. package/dist/site/staging.js +76 -0
  197. package/dist/site/staging.js.map +1 -0
  198. package/dist/skills/command.d.ts +8 -0
  199. package/dist/skills/command.js +64 -0
  200. package/dist/skills/command.js.map +1 -0
  201. package/dist/skills/frontmatter.d.ts +37 -0
  202. package/dist/skills/frontmatter.js +219 -0
  203. package/dist/skills/frontmatter.js.map +1 -0
  204. package/dist/skills/graph.d.ts +39 -0
  205. package/dist/skills/graph.js +100 -0
  206. package/dist/skills/graph.js.map +1 -0
  207. package/dist/skills/ignore.d.ts +34 -0
  208. package/dist/skills/ignore.js +138 -0
  209. package/dist/skills/ignore.js.map +1 -0
  210. package/dist/skills/lines.d.ts +53 -0
  211. package/dist/skills/lines.js +221 -0
  212. package/dist/skills/lines.js.map +1 -0
  213. package/dist/skills/map-command.d.ts +28 -0
  214. package/dist/skills/map-command.js +533 -0
  215. package/dist/skills/map-command.js.map +1 -0
  216. package/dist/skills/mermaid.d.ts +29 -0
  217. package/dist/skills/mermaid.js +261 -0
  218. package/dist/skills/mermaid.js.map +1 -0
  219. package/dist/skills/metro.d.ts +8 -0
  220. package/dist/skills/metro.js +93 -0
  221. package/dist/skills/metro.js.map +1 -0
  222. package/dist/skills/read.d.ts +17 -0
  223. package/dist/skills/read.js +54 -0
  224. package/dist/skills/read.js.map +1 -0
  225. package/dist/skills/rules.d.ts +28 -0
  226. package/dist/skills/rules.js +57 -0
  227. package/dist/skills/rules.js.map +1 -0
  228. package/dist/skills/source.d.ts +66 -0
  229. package/dist/skills/source.js +281 -0
  230. package/dist/skills/source.js.map +1 -0
  231. package/dist/skills/walk.d.ts +64 -0
  232. package/dist/skills/walk.js +281 -0
  233. package/dist/skills/walk.js.map +1 -0
  234. package/dist/source.d.ts +40 -0
  235. package/dist/source.js +199 -0
  236. package/dist/source.js.map +1 -0
  237. package/dist/stdout.d.ts +2 -0
  238. package/dist/stdout.js +24 -0
  239. package/dist/stdout.js.map +1 -0
  240. package/dist/validate.d.ts +45 -0
  241. package/dist/validate.js +321 -0
  242. package/dist/validate.js.map +1 -0
  243. package/dist/views.d.ts +25 -0
  244. package/dist/views.js +58 -0
  245. package/dist/views.js.map +1 -0
  246. package/examples/catalogue-repository/.github/workflows/stackledger.yml +122 -0
  247. package/examples/catalogue-repository/README.md +96 -0
  248. package/examples/catalogue-repository/catalog/catalog-info.yaml +12 -0
  249. package/examples/hosting/Caddyfile +69 -0
  250. package/examples/northwind/catalog-info.yaml +680 -0
  251. package/examples/northwind/stackledger.yaml +16 -0
  252. package/examples/northwind-machine/snapshot.json +309 -0
  253. package/examples/northwind-skills/agents/builder.md +10 -0
  254. package/examples/northwind-skills/agents/reviewer.md +10 -0
  255. package/examples/northwind-skills/designer/SKILL.md +8 -0
  256. package/examples/northwind-skills/editor/SKILL.md +8 -0
  257. package/examples/northwind-skills/engineering/SKILL.md +12 -0
  258. package/examples/northwind-skills/linter/SKILL.md +8 -0
  259. package/examples/northwind-skills/linter/rules.md +5 -0
  260. package/examples/northwind-skills/publishing/SKILL.md +12 -0
  261. package/examples/northwind-skills/publishing/rules.md +5 -0
  262. package/examples/northwind-skills/spec-writer/SKILL.md +8 -0
  263. package/examples/northwind-skills/stackledger-skills.yaml +51 -0
  264. package/examples/northwind-skills/tester/SKILL.md +10 -0
  265. package/examples/northwind-skills/writer/SKILL.md +8 -0
  266. package/examples/northwind-skills/writer/rules.md +6 -0
  267. package/npm-shrinkwrap.json +4995 -0
  268. package/package.json +51 -4
  269. package/site/LICENSE-astroplate +21 -0
  270. package/site/README.md +18 -0
  271. package/site/package.json +6 -0
  272. package/site/public/favicon.svg +1 -0
  273. package/site/src/components/Footer.astro +25 -0
  274. package/site/src/components/Header.astro +35 -0
  275. package/site/src/components/Impact.astro +55 -0
  276. package/site/src/components/LinkOrText.astro +12 -0
  277. package/site/src/components/SkillItem.astro +141 -0
  278. package/site/src/components/SubNav.astro +40 -0
  279. package/site/src/components/ThemeSwitch.astro +16 -0
  280. package/site/src/components/Themed.astro +14 -0
  281. package/site/src/layouts/Base.astro +52 -0
  282. package/site/src/lib/site.ts +25 -0
  283. package/site/src/pages/[reports].astro +222 -0
  284. package/site/src/pages/agents/[file].astro +14 -0
  285. package/site/src/pages/index.astro +71 -0
  286. package/site/src/pages/journeys/[name].astro +50 -0
  287. package/site/src/pages/journeys/index.astro +37 -0
  288. package/site/src/pages/licences/[name].astro +56 -0
  289. package/site/src/pages/map/index.astro +78 -0
  290. package/site/src/pages/playbooks/[file].astro +14 -0
  291. package/site/src/pages/rules/[...rules].astro +61 -0
  292. package/site/src/pages/skill-map/[...map].astro +101 -0
  293. package/site/src/pages/skills/[...list].astro +75 -0
  294. package/site/src/pages/skills/[file].astro +14 -0
  295. package/site/src/pages/software/[name].astro +155 -0
  296. package/site/src/pages/software/index.astro +71 -0
  297. package/site/src/scripts/diagram.ts +8 -0
  298. package/site/src/scripts/links.ts +31 -0
  299. package/site/src/scripts/map.ts +133 -0
  300. package/site/src/scripts/software.ts +32 -0
  301. package/site/src/scripts/theme.ts +52 -0
  302. package/site/src/styles/base.css +470 -0
  303. package/site/src/styles/fonts.css +60 -0
  304. package/site/src/styles/override.css +1 -0
  305. package/site/src/styles/pages.css +299 -0
  306. package/site/src/styles/tokens.css +71 -0
  307. package/skills/stackledger/SKILL.md +155 -0
@@ -0,0 +1,90 @@
1
+ /** Atomic publication of a prepared build into the output folder (build-command, Atomic replace and
2
+ * Interrupted publication; design D8). Called by src/site/command.ts.
3
+ *
4
+ * For each entry `staff`, `full`, `_headers`, `robots.txt`, `_redirects` and `.stackledger-build`, in
5
+ * that order, the existing entry (if any) is renamed into `<staging>/old/`, then the new one is renamed
6
+ * into place. A personal build (FULL_ONLY in the staging folder) has no new `staff`: an earlier one
7
+ * only moves into `old/`, so it is removed after the commit. `old/` is created just before the first rename, so a staging folder without it never held
8
+ * a published entry (staging.ts). The renames done are recorded in memory only. The rename of the
9
+ * marker is the commit point: a failure before it undoes the renames in reverse, so the output
10
+ * folder is byte for byte what it was. Renames stay on one filesystem because the staging folder is
11
+ * inside the output folder, and none goes through a symbolic link.
12
+ *
13
+ * The output folder's identity (paths.ts) is checked immediately before creating `old/` and before
14
+ * every rename, the undo's included. A mismatch (FolderChanged) stops at once: no further rename,
15
+ * not even to undo, because the paths may now lead somewhere else.
16
+ *
17
+ * What can go wrong: an undo rename can fail too (a folder made read-only meanwhile). The undo then
18
+ * stops and throws UndoFailed; the previous entries are in `<staging>/old/`, the command keeps the
19
+ * staging folder and the person running the build restores them by hand (RESTORE_GUIDE).
20
+ */
21
+ import { join } from 'node:path';
22
+ import { InternalError } from '../errors.js';
23
+ import { NODE_FS } from './fs-ops.js';
24
+ import { assertSameFolder, FolderChanged, lstatOrUndefined } from './paths.js';
25
+ import { MARKER_NAME } from './policy.js';
26
+ import { FULL_ONLY, OLD_NAME, RESTORE_GUIDE } from './staging.js';
27
+ /** Published entries, in publication order, with their place in the staging folder. The marker is last. */
28
+ export const ENTRIES = [
29
+ { name: 'staff', staged: 'site-staff' },
30
+ { name: 'full', staged: 'site-full' },
31
+ { name: '_headers', staged: join('root', '_headers') },
32
+ { name: 'robots.txt', staged: join('root', 'robots.txt') },
33
+ { name: '_redirects', staged: join('root', '_redirects') },
34
+ { name: MARKER_NAME, staged: join('root', MARKER_NAME) },
35
+ ];
36
+ /** A publication failed and its undo failed too: the staging folder must be kept. */
37
+ export class UndoFailed extends InternalError {
38
+ }
39
+ /** Publish the staged entries of `staging` into `out`. On a failure before the commit, undo every
40
+ * rename and rethrow; throws FolderChanged or UndoFailed when that is not possible. */
41
+ export function publish(out, staging, identity, ops = NODE_FS) {
42
+ const done = [];
43
+ const move = (from, to) => {
44
+ assertSameFolder(identity, ops);
45
+ ops.rename(from, to);
46
+ done.push({ from, to });
47
+ };
48
+ try {
49
+ assertSameFolder(identity, ops);
50
+ ops.mkdir(join(staging, OLD_NAME));
51
+ const fullOnly = lstatOrUndefined(join(staging, FULL_ONLY), ops) !== undefined;
52
+ for (const entry of ENTRIES) {
53
+ const target = join(out, entry.name);
54
+ const existing = lstatOrUndefined(target, ops);
55
+ // Never rename through a link (command.ts refuses them before the build; this is the last check).
56
+ if (existing?.isSymbolicLink())
57
+ throw new Error(`${target} is a symbolic link`);
58
+ if (existing)
59
+ move(target, join(staging, OLD_NAME, entry.name));
60
+ if (!(fullOnly && entry.name === 'staff'))
61
+ move(join(staging, entry.staged), target);
62
+ }
63
+ }
64
+ catch (error) {
65
+ if (error instanceof FolderChanged)
66
+ throw error;
67
+ undo(staging, done, identity, ops, error);
68
+ throw error;
69
+ }
70
+ }
71
+ /** Put back the renames in `done`, latest first. Stops at the first failure: the remaining entries
72
+ * stay where they are, which is the state the manual restore in docs/site.md starts from. */
73
+ function undo(staging, done, identity, ops, cause) {
74
+ for (const step of [...done].reverse()) {
75
+ assertSameFolder(identity, ops);
76
+ try {
77
+ ops.rename(step.to, step.from);
78
+ }
79
+ catch (error) {
80
+ throw new UndoFailed(undoFailedMessage(staging, cause, error));
81
+ }
82
+ }
83
+ }
84
+ function undoFailedMessage(staging, cause, error) {
85
+ const reason = (value) => (value instanceof Error ? value.message : String(value)).replace(/\s+/g, ' ').trim();
86
+ return `stackledger build: publication failed (${reason(cause)}) and could not be undone (${reason(error)}); `
87
+ + `the previous entries are in ${join(staging, OLD_NAME)}. The staging folder ${staging} was kept: `
88
+ + `restore by hand as ${RESTORE_GUIDE} explains; until that folder is removed, stackledger build refuses this output folder`;
89
+ }
90
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/site/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAc,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAuB,MAAM,YAAY,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElE,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAgD;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;IACvC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE;IACrC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;IACtD,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;IAC1D,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;IAC1D,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;CACzD,CAAC;AAEF,qFAAqF;AACrF,MAAM,OAAO,UAAW,SAAQ,aAAa;CAAG;AAIhD;uFACuF;AACvF,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,OAAe,EAAE,QAAwB,EAAE,MAAa,OAAO;IAClG,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string, base?: string): string[];
3
+ /** The text of an HTML attribute value as a browser reads it, and the named references in it that
4
+ * are not in NAMED_REFERENCES (left as they are; a URL holding one is refused). */
5
+ export declare function decodeAttribute(value: string): {
6
+ text: string;
7
+ unknown: string[];
8
+ };
9
+ /** Rewrite every root-absolute Astro asset URL in the site's HTML and CSS files, in place. */
10
+ export declare function relativise(siteDir: string): void;
11
+ /** Every problem in a built site; an empty list means it may be published. `buildPaths` are the
12
+ * build's own paths (the staging folder, the working copy): none may appear in an output file.
13
+ * Only these exact paths count, so catalogue text that mentions `.stackledger-tmp-*` is fine. */
14
+ export declare function scan(siteDir: string, buildPaths?: readonly string[], homeLinks?: readonly string[]): string[];
@@ -0,0 +1,265 @@
1
+ /** Relative URLs and the output scan of one built site (design D3 and D4).
2
+ *
3
+ * Why: Astro has no relative base and writes root-absolute `/_astro/...` URLs. relativise(siteDir)
4
+ * rewrites them in HTML URL attributes and in CSS `url()` and `@import`, relative to the file that
5
+ * holds them, so a site works under any path prefix (`/full/`, `/staff/`). scan(siteDir, buildPaths)
6
+ * then lists every URL form the rewrite does not handle, every relative URL that resolves outside
7
+ * the site folder (`../../../full/` from a `staff` page), every piece of inline code, any page whose
8
+ * CSP differs from POLICY and any build path left in a file; the build fails on any problem, before
9
+ * anything is published.
10
+ *
11
+ * HTML is read tag by tag: catalogue text is escaped by Astro and the SVG renderers, so `<` and `>`
12
+ * never appear inside text or attribute values, and a hostile title cannot look like an attribute.
13
+ * Deterministic: files are visited in sorted order and only rewritten, never renamed.
14
+ *
15
+ * URLs are checked as a browser reads them: attribute values are decoded with the HTML character
16
+ * reference rules (`&#47;`, `&#x2f;`, `&sol;`, `&Tab;`…), ASCII tab, line feed and carriage return
17
+ * are dropped as the URL parser drops them, and the result is resolved with WHATWG URL against a
18
+ * made-up origin. A URL with a scheme, a leading `/` or `\`, another origin or a path outside the
19
+ * site folder is refused. Named references outside a small table of the ones that can form URL
20
+ * syntax are refused too, so an unknown name can never hide a separator. CSS escapes are not
21
+ * decoded: a CSS URL holding a backslash is refused instead.
22
+ */
23
+ import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
24
+ import { join, posix, relative, sep } from 'node:path';
25
+ import { POLICY } from './policy.js';
26
+ const URL_ATTRIBUTES = new Set(['href', 'src', 'action', 'formaction', 'poster', 'data', 'xlink:href']);
27
+ // Quoted attribute values may hold `>` (Astro escapes only `&` and `"`), so they are matched whole.
28
+ const TAG = /<([A-Za-z][A-Za-z0-9:-]*)((?:\s(?:"[^"]*"|'[^']*'|[^<>"'])*?)?)(\/?)>/g;
29
+ const ATTRIBUTE = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
30
+ const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
31
+ const ASTRO_ASSET = /^\/_astro\//;
32
+ /** Named character references that can spell URL syntax, or that Astro writes. Any other name in a
33
+ * URL is refused rather than decoded (see decodeAttribute). */
34
+ const NAMED_REFERENCES = {
35
+ amp: '&', AMP: '&', lt: '<', LT: '<', gt: '>', GT: '>', quot: '"', QUOT: '"', apos: "'",
36
+ sol: '/', bsol: '\\', colon: ':', Tab: '\t', NewLine: '\n', period: '.', percnt: '%', quest: '?',
37
+ num: '#', commat: '@', excl: '!', dollar: '$', lpar: '(', rpar: ')', ast: '*', midast: '*', plus: '+',
38
+ comma: ',', semi: ';', equals: '=', lsqb: '[', lbrack: '[', rsqb: ']', rbrack: ']', lcub: '{',
39
+ lbrace: '{', rcub: '}', rbrace: '}', verbar: '|', vert: '|', VerticalLine: '|', lowbar: '_',
40
+ UnderBar: '_', Hat: '^', grave: '`', DiacriticalGrave: '`', nbsp: '\u00a0', NonBreakingSpace: '\u00a0',
41
+ };
42
+ /** Numeric references to 0x80-0x9F mean Windows-1252 characters in browsers (HTML standard). */
43
+ const WINDOWS_1252 = {
44
+ 0x80: 0x20ac, 0x82: 0x201a, 0x83: 0x0192, 0x84: 0x201e, 0x85: 0x2026, 0x86: 0x2020, 0x87: 0x2021,
45
+ 0x88: 0x02c6, 0x89: 0x2030, 0x8a: 0x0160, 0x8b: 0x2039, 0x8c: 0x0152, 0x8e: 0x017d, 0x91: 0x2018,
46
+ 0x92: 0x2019, 0x93: 0x201c, 0x94: 0x201d, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014, 0x98: 0x02dc,
47
+ 0x99: 0x2122, 0x9a: 0x0161, 0x9b: 0x203a, 0x9c: 0x0153, 0x9e: 0x017e, 0x9f: 0x0178,
48
+ };
49
+ /** A numeric reference (the semicolon is optional for browsers) or a named one with its semicolon. */
50
+ const CHARACTER_REFERENCE = /&#(\d+);?|&#[xX]([0-9A-Fa-f]+);?|&([A-Za-z][A-Za-z0-9]*);/g;
51
+ /** Every file under a folder, as sorted paths relative to it with forward slashes. */
52
+ export function listFiles(dir, base = dir) {
53
+ const files = [];
54
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
55
+ const full = join(dir, entry.name);
56
+ if (entry.isDirectory())
57
+ files.push(...listFiles(full, base));
58
+ else
59
+ files.push(relative(base, full).split(sep).join('/'));
60
+ }
61
+ return files.sort();
62
+ }
63
+ function attributes(text) {
64
+ return [...text.matchAll(ATTRIBUTE)].map(match => ({ name: match[1].toLowerCase(), value: match[2] ?? match[3] ?? match[4] }));
65
+ }
66
+ /** The text of an HTML attribute value as a browser reads it, and the named references in it that
67
+ * are not in NAMED_REFERENCES (left as they are; a URL holding one is refused). */
68
+ export function decodeAttribute(value) {
69
+ const unknown = [];
70
+ const text = value.replace(CHARACTER_REFERENCE, (whole, decimal, hex, name) => {
71
+ if (name !== undefined) {
72
+ const named = NAMED_REFERENCES[name];
73
+ if (named === undefined)
74
+ unknown.push(whole);
75
+ return named ?? whole;
76
+ }
77
+ return fromCodePoint(decimal !== undefined ? Number.parseInt(decimal, 10) : Number.parseInt(hex, 16));
78
+ });
79
+ return { text, unknown };
80
+ }
81
+ /** The character a numeric reference stands for, with the browser's replacements. */
82
+ function fromCodePoint(code) {
83
+ const invalid = code === 0 || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff) || Number.isNaN(code);
84
+ return invalid ? '\ufffd' : String.fromCodePoint(WINDOWS_1252[code] ?? code);
85
+ }
86
+ /** A made-up origin and folder for the site root; any URL resolving elsewhere leaves the site. */
87
+ const SITE_ORIGIN = 'https://site.invalid';
88
+ const SITE_FOLDER = '/root/';
89
+ /** Encoded `/` and `\`: a server that decodes them before resolving the path could climb out. */
90
+ const ENCODED_SEPARATOR = /%2f|%5c/i;
91
+ /** What the WHATWG URL parser removes before parsing: tab, line feed and carriage return anywhere,
92
+ * and C0 controls or spaces at either end. */
93
+ const URL_IGNORED = /[\t\n\r]/g;
94
+ const URL_TRIMMED = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
95
+ /** Why `url` (already decoded from HTML) is not a local URL of `file`, or undefined when it is.
96
+ * `file` is a path from the site root; the URL is resolved as a browser would resolve it there. */
97
+ function urlProblem(file, url) {
98
+ const cleaned = url.replace(URL_IGNORED, '').replace(URL_TRIMMED, '');
99
+ // Root-absolute, protocol-relative (a backslash counts as a slash) or with a scheme.
100
+ if (/^[\\/]/.test(cleaned) || SCHEME.test(cleaned))
101
+ return 'leaves the site';
102
+ let resolved;
103
+ try {
104
+ resolved = new URL(cleaned, `${SITE_ORIGIN}${SITE_FOLDER}${file}`);
105
+ }
106
+ catch {
107
+ return 'leaves the site';
108
+ }
109
+ if (resolved.origin !== SITE_ORIGIN)
110
+ return 'leaves the site';
111
+ if (!resolved.pathname.startsWith(SITE_FOLDER) || ENCODED_SEPARATOR.test(resolved.pathname))
112
+ return 'leaves the site folder';
113
+ return undefined;
114
+ }
115
+ /** Rewrite `/_astro/...` into a path relative to the folder of `file` (both relative to the site root). */
116
+ function toRelative(file, url) {
117
+ return posix.relative(posix.dirname(file), url.slice(1)) || './';
118
+ }
119
+ function relativiseHtml(file, html) {
120
+ return html.replace(TAG, (tag, name, attrs, close) => {
121
+ const rewritten = attrs.replace(/(\s)([A-Za-z:-]+)=(["'])([^"']*)\3/g, (whole, space, attr, quote, value) => {
122
+ const key = attr.toLowerCase();
123
+ if (URL_ATTRIBUTES.has(key) && ASTRO_ASSET.test(value))
124
+ return `${space}${attr}=${quote}${toRelative(file, value)}${quote}`;
125
+ if (key === 'srcset') {
126
+ const parts = value.split(',').map(part => part.trim().replace(/^\/_astro\/\S*/, url => toRelative(file, url)));
127
+ return `${space}${attr}=${quote}${parts.join(', ')}${quote}`;
128
+ }
129
+ return whole;
130
+ });
131
+ return `<${name}${rewritten}${close}>`;
132
+ });
133
+ }
134
+ function relativiseCss(file, css) {
135
+ return css
136
+ .replace(/url\(\s*(["']?)(\/_astro\/[^"')]*)\1\s*\)/g, (_, quote, url) => `url(${quote}${toRelative(file, url)}${quote})`)
137
+ .replace(/@import\s+(["'])(\/_astro\/[^"']*)\1/g, (_, quote, url) => `@import ${quote}${toRelative(file, url)}${quote}`);
138
+ }
139
+ /** Rewrite every root-absolute Astro asset URL in the site's HTML and CSS files, in place. */
140
+ export function relativise(siteDir) {
141
+ for (const file of listFiles(siteDir)) {
142
+ const path = join(siteDir, file);
143
+ if (file.endsWith('.html'))
144
+ writeFileSync(path, relativiseHtml(file, readFileSync(path, 'utf8')));
145
+ else if (file.endsWith('.css'))
146
+ writeFileSync(path, relativiseCss(file, readFileSync(path, 'utf8')));
147
+ }
148
+ }
149
+ /** `homeLinks`: the validated URLs of spec.site.home.links, allowed only as the href of an `a` element
150
+ * in the site's root index.html (site-security, No external requests). */
151
+ function scanHtml(file, html, homeLinks = []) {
152
+ const problems = [];
153
+ const policies = [];
154
+ for (const [, rawName, attrText] of html.matchAll(TAG)) {
155
+ const name = rawName.toLowerCase();
156
+ const attrs = attributes(attrText ?? '');
157
+ const has = (key) => attrs.some(attr => attr.name === key);
158
+ if (name === 'script' && !has('src'))
159
+ problems.push(`${file}: inline <script>`);
160
+ if (name === 'style')
161
+ problems.push(`${file}: <style> element`);
162
+ for (const attr of attrs) {
163
+ if (attr.name === 'style')
164
+ problems.push(`${file}: style attribute`);
165
+ if (attr.name.startsWith('on'))
166
+ problems.push(`${file}: event-handler attribute ${attr.name}`);
167
+ if (name === 'a' && attr.name === 'href' && file === 'index.html' && isHomeLink(attr, homeLinks))
168
+ continue;
169
+ if (URL_ATTRIBUTES.has(attr.name) || attr.name === 'srcset')
170
+ problems.push(...urlAttributeProblems(file, attr));
171
+ }
172
+ const equiv = attrs.find(attr => attr.name === 'http-equiv')?.value;
173
+ if (name === 'meta' && equiv?.toLowerCase() === 'content-security-policy') {
174
+ policies.push(decodeAttribute(attrs.find(attr => attr.name === 'content')?.value ?? '').text);
175
+ }
176
+ }
177
+ if (policies.length !== 1 || policies[0] !== POLICY)
178
+ problems.push(`${file}: CSP meta ${JSON.stringify(policies)}`);
179
+ return problems;
180
+ }
181
+ /** An anchor's href that is exactly one of the home links once decoded (no unknown references). */
182
+ function isHomeLink(attr, homeLinks) {
183
+ if (!homeLinks.length)
184
+ return false;
185
+ const { text, unknown } = decodeAttribute(attr.value ?? '');
186
+ return !unknown.length && homeLinks.includes(text);
187
+ }
188
+ /** The problems of one URL attribute (or each URL of a srcset), its value decoded first. */
189
+ function urlAttributeProblems(file, attr) {
190
+ const { text, unknown } = decodeAttribute(attr.value ?? '');
191
+ if (unknown.length)
192
+ return [`${file}: ${attr.name}="${attr.value}" has an unknown character reference ${unknown[0]}`];
193
+ if (attr.name !== 'srcset')
194
+ return urlProblems(file, `${attr.name}="${text}"`, text);
195
+ return text
196
+ .split(',')
197
+ .map(item => item.replace(ASCII_EDGE_SPACE, ''))
198
+ .flatMap(part => urlProblems(file, `srcset part "${part}"`, part.split(ASCII_SPACE)[0] ?? ''));
199
+ }
200
+ /** HTML's ASCII whitespace only: a no-break space (U+00A0) is part of a URL, not a separator. */
201
+ const ASCII_SPACE = /[\t\n\f\r ]+/;
202
+ const ASCII_EDGE_SPACE = /^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;
203
+ /** The problem with one URL of `file`, if any. `label` names the URL in the message. */
204
+ function urlProblems(file, label, url) {
205
+ const problem = urlProblem(file, url);
206
+ if (problem === 'leaves the site')
207
+ return [`${file}: ${label}`];
208
+ if (problem)
209
+ return [`${file}: ${label} ${problem}`];
210
+ return [];
211
+ }
212
+ function scanCss(file, css) {
213
+ const problems = [];
214
+ const check = (label, url) => {
215
+ // CSS escapes (`\2f`) are not decoded here: refuse any backslash instead.
216
+ if (url.includes('\\'))
217
+ problems.push(`${file}: ${label} has a CSS escape`);
218
+ else
219
+ problems.push(...urlProblems(file, label, url));
220
+ };
221
+ for (const match of css.matchAll(/url\(\s*(["']?)([^"')]*)\1\s*\)/g))
222
+ check(`url(${match[2]})`, match[2].trim());
223
+ for (const match of css.matchAll(/@import\s+(?:url\()?\s*(["']?)([^"')\s;]*)\1/g))
224
+ check(`@import ${match[2]}`, match[2]);
225
+ return problems;
226
+ }
227
+ function scanJs(file, js) {
228
+ const problems = [];
229
+ if (/\bimport\s*\(/.test(js))
230
+ problems.push(`${file}: dynamic import(`);
231
+ if (/import\.meta\.url/.test(js))
232
+ problems.push(`${file}: import.meta.url`);
233
+ if (/\/_astro\//.test(js))
234
+ problems.push(`${file}: /_astro/ string`);
235
+ for (const match of js.matchAll(/(?:\bimport|\bexport)\s*(?:[\w*{}\s,$]*?\bfrom\s*)?["']([^"']+)["']/g)) {
236
+ const specifier = match[1];
237
+ // String escapes (`\x2e`, `\u002e`) would change the specifier: refuse any backslash.
238
+ if (specifier.includes('\\'))
239
+ problems.push(`${file}: import specifier "${specifier}" has a string escape`);
240
+ else if (!specifier.startsWith('./') && !specifier.startsWith('../'))
241
+ problems.push(`${file}: import specifier "${specifier}"`);
242
+ else if (urlProblem(file, specifier))
243
+ problems.push(`${file}: import specifier "${specifier}" leaves the site folder`);
244
+ }
245
+ return problems;
246
+ }
247
+ /** Every problem in a built site; an empty list means it may be published. `buildPaths` are the
248
+ * build's own paths (the staging folder, the working copy): none may appear in an output file.
249
+ * Only these exact paths count, so catalogue text that mentions `.stackledger-tmp-*` is fine. */
250
+ export function scan(siteDir, buildPaths = [], homeLinks = []) {
251
+ const problems = [];
252
+ for (const file of listFiles(siteDir)) {
253
+ const text = readFileSync(join(siteDir, file), 'utf8');
254
+ if (file.endsWith('.html'))
255
+ problems.push(...scanHtml(file, text, homeLinks));
256
+ else if (file.endsWith('.css'))
257
+ problems.push(...scanCss(file, text));
258
+ else if (file.endsWith('.js') || file.endsWith('.mjs'))
259
+ problems.push(...scanJs(file, text));
260
+ if (buildPaths.some(path => text.includes(path)))
261
+ problems.push(`${file}: staging path in the output`);
262
+ }
263
+ return problems;
264
+ }
265
+ //# sourceMappingURL=relative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.js","sourceRoot":"","sources":["../../src/site/relative.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AACxG,oGAAoG;AACpG,MAAM,GAAG,GAAG,wEAAwE,CAAC;AACrF,MAAM,SAAS,GAAG,mEAAmE,CAAC;AACtF,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAC3C,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC;+DAC+D;AAC/D,MAAM,gBAAgB,GAAqC;IACzD,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EA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loaded } from '../source.js';
3
+ import type { Catalogue } from '../validate.js';
4
+ import { type SkillSet } from '../skills/source.js';
5
+ import type { FsOps } from './fs-ops.js';
6
+ export interface SkillsInUse {
7
+ set?: SkillSet;
8
+ /** Real paths of the folders in use. */
9
+ folders: string[];
10
+ /** A broken Settings holds a `spec.skills` key: exit 1 once the exit-2 checks have passed. */
11
+ brokenSettings: boolean;
12
+ /** Report lines known before the build (a Settings file that could not be parsed). */
13
+ notes: string[];
14
+ }
15
+ /** The folders in use and the set read from them; throws a usage error (exit 2) for a folder that cannot be read. */
16
+ export declare function skillsInUse(option: string[], loaded: Loaded, catalogue: Catalogue, catalogueFolder: string, ops: FsOps): Promise<SkillsInUse>;
17
+ /** Refuse an output folder (its real path `target`) that would touch the skill set (exit 2). */
18
+ export declare function refuseSkillsOutput(target: string, skills: SkillsInUse, ops: FsOps): void;
19
+ /** The exit-1 stops, after every exit-2 check and before anything is written. */
20
+ export declare function skillsStops(skills: SkillsInUse): void;
21
+ /** The report lines of the skill set: counts, problems, then the skills map's suggestions and unrouted hops. */
22
+ export declare function skillsReport(set: SkillSet, geometry: MapGeometry): string[];
@@ -0,0 +1,126 @@
1
+ /** The skill set of `stackledger build` (build-command spec: Skill folders, Skills settings with
2
+ * problems, Skill folder errors, One page per skill item, Output folder and the skill set, Skills
3
+ * build report). Used by src/site/command.ts; only reads.
4
+ *
5
+ * Why each step is where it is: the command runs every exit-2 check before any exit-1 check, and every
6
+ * check before anything is written, so a wrong folder never empties a published Skills section.
7
+ * - skillsInUse (exit 2): the folders in use, `--skills` first, else `spec.skills.folders` of a Settings
8
+ * without error, resolved from the catalogue folder; then the set is read. A folder that cannot be
9
+ * read is a usage error naming it as written (and `spec.skills.folders` when it comes from there).
10
+ * - refuseSkillsOutput (exit 2): an output folder that is or holds a folder in use or a file the set was
11
+ * read from, or is inside a skill folder or a folder's top-level `agents/`.
12
+ * - skillsStops (exit 1): a broken Settings with a `spec.skills` key, a folder with nothing found, two
13
+ * items of one kind with one page file name.
14
+ * Configured folders are read with the catalogue folder as the current folder, so problems and messages
15
+ * show the paths as written in the Settings; pages show only paths below each folder.
16
+ */
17
+ import { join, relative, resolve, sep } from 'node:path';
18
+ import { withoutControls } from '../control.js';
19
+ import { CommandStop } from '../errors.js';
20
+ import { settingsInError } from '../views.js';
21
+ import { pageFileName } from '../skills/mermaid.js';
22
+ import { NOTHING_FOUND, readSkillSet } from '../skills/source.js';
23
+ import { SkillsFolderError } from '../skills/walk.js';
24
+ import { within } from './paths.js';
25
+ const COMMAND = 'stackledger build';
26
+ const SETTINGS_KEY = 'spec.skills.folders';
27
+ const AGENTS_FOLDER = 'agents';
28
+ const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
29
+ /** The folders in use and the set read from them; throws a usage error (exit 2) for a folder that cannot be read. */
30
+ export async function skillsInUse(option, loaded, catalogue, catalogueFolder, ops) {
31
+ let folders, cwd, configured = false;
32
+ if (option.length) {
33
+ folders = option;
34
+ cwd = process.cwd();
35
+ }
36
+ else if (settingsInError(catalogue)) {
37
+ const keyed = loaded.sources.some(source => typeof source.value.kind === 'string' && source.value.kind.toLowerCase() === 'settings'
38
+ && Object.hasOwn(object(source.value.spec), 'skills'));
39
+ if (keyed)
40
+ return { folders: [], brokenSettings: true, notes: [] };
41
+ const notes = loaded.settingsUnread ? ['Skill folders could not be read from the settings: a file that may hold a Settings cannot be parsed; run stackledger validate'] : [];
42
+ return { folders: [], brokenSettings: false, notes };
43
+ }
44
+ else {
45
+ folders = catalogue.served.settings[0]?.spec.skills?.folders ?? [];
46
+ cwd = catalogueFolder;
47
+ configured = true;
48
+ }
49
+ if (!folders.length)
50
+ return { folders: [], brokenSettings: false, notes: [] };
51
+ let set;
52
+ try {
53
+ set = await readSkillSet(folders, { cwd });
54
+ }
55
+ catch (error) {
56
+ if (error instanceof SkillsFolderError)
57
+ throw new Error(configured ? `${error.message} (${SETTINGS_KEY})` : error.message);
58
+ throw error;
59
+ }
60
+ return { set, folders: folders.map(folder => ops.realpath(resolve(cwd, folder))), brokenSettings: false, notes: [] };
61
+ }
62
+ /** Refuse an output folder (its real path `target`) that would touch the skill set (exit 2). */
63
+ export function refuseSkillsOutput(target, skills, ops) {
64
+ if (!skills.set)
65
+ return;
66
+ for (const folder of skills.folders) {
67
+ if (within(folder, target))
68
+ throw new Error('Output folder must not be a skills folder or contain one');
69
+ let agents = join(folder, AGENTS_FOLDER);
70
+ try {
71
+ agents = ops.realpath(agents);
72
+ }
73
+ catch { /* No agents folder: its plain path is checked. */ }
74
+ // As `skills map`: the first folder below the skills folder, in any case (APFS and NTFS ignore case).
75
+ const first = within(target, folder) ? relative(folder, target).split(sep)[0] : undefined;
76
+ if (within(target, agents) || first?.toLowerCase() === AGENTS_FOLDER)
77
+ throw new Error('Output folder must not be the agents folder of a skills folder or inside it');
78
+ }
79
+ for (const found of skills.set.found) {
80
+ if (within(found, target))
81
+ throw new Error(`Output folder must not hold a skill folder, agent file or file of the skill set: ${found}`);
82
+ if (within(target, found))
83
+ throw new Error(`Output folder must not be inside a skill folder of the set: ${found}`);
84
+ }
85
+ }
86
+ /** The exit-1 stops, after every exit-2 check and before anything is written. */
87
+ export function skillsStops(skills) {
88
+ if (skills.brokenSettings) {
89
+ throw new CommandStop(`${COMMAND}: the Settings has an error and sets spec.skills; run stackledger validate. The published sites are not changed`);
90
+ }
91
+ if (!skills.set)
92
+ return;
93
+ const empty = skills.set.problems.find(problem => problem.message.startsWith(NOTHING_FOUND));
94
+ if (empty)
95
+ throw new CommandStop(`${COMMAND}: ${withoutControls(empty.path)}: ${NOTHING_FOUND}; the published sites are not changed`);
96
+ const pages = new Map();
97
+ const items = [...skills.set.skills.map(skill => [skill.kind, skill.name, skill.path]), ...skills.set.agents.map(agent => ['agent', agent.name, agent.path])];
98
+ for (const [kind, name, path] of items) {
99
+ const key = `${kind}:${pageFileName(name)}`, earlier = pages.get(key);
100
+ if (earlier !== undefined)
101
+ throw new CommandStop(`${COMMAND}: ${withoutControls(earlier)} and ${withoutControls(path)} give the same page name; rename one. The published sites are not changed`);
102
+ pages.set(key, path);
103
+ }
104
+ }
105
+ const plural = (count, word) => `${count} ${count === 1 ? word : `${word}s`}`;
106
+ /** The report lines of the skill set: counts, problems, then the skills map's suggestions and unrouted hops. */
107
+ export function skillsReport(set, geometry) {
108
+ const { skills, playbooks, agents, rules, errors, warnings } = set.summary;
109
+ const lines = [`Skills: ${plural(skills, 'skill')}, ${plural(playbooks, 'playbook')}, ${plural(agents, 'agent')}, ${plural(rules, 'rule')}`];
110
+ if (errors || warnings)
111
+ lines.push(`Skill set: ${plural(errors, 'error')}, ${plural(warnings, 'warning')}; run stackledger skills validate for details`);
112
+ // The map-file key the person pastes: kind and name, control characters removed.
113
+ const names = new Map(geometry.stations.map(station => [station.ref, station.name]));
114
+ const key = (ref) => withoutControls(`${ref.slice(0, ref.indexOf(':'))}:${names.get(ref) ?? ref.slice(ref.indexOf(':') + 1)}`);
115
+ if (geometry.suggestions.length) {
116
+ lines.push('Suggested positions for the skills map (MapLayout spec.stations in stackledger-skills.yaml):');
117
+ for (const suggestion of geometry.suggestions)
118
+ lines.push(` ${key(suggestion.ref)}: [${suggestion.point[0]}, ${suggestion.point[1]}]`);
119
+ }
120
+ for (const hop of geometry.unrouted) {
121
+ for (const line of hop.lines)
122
+ lines.push(`Unrouted hop on the skills map: ${line} ${key(hop.from)} -> ${key(hop.to)} (drawn straight)`);
123
+ }
124
+ return lines;
125
+ }
126
+ //# sourceMappingURL=skills-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-build.js","sourceRoot":"","sources":["../../src/site/skills-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3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