@enspirit/opspicy 0.0.0-stage → 0.3.0
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.
- package/LICENSE +21 -0
- package/README.md +325 -2
- package/bin/entry.js +48 -0
- package/bin/help.js +115 -0
- package/bin/opspicy +27 -0
- package/dist/addresses.js +27 -0
- package/dist/behind.js +64 -0
- package/dist/citizens.js +71 -0
- package/dist/configuration.d.ts +56 -0
- package/dist/configuration.js +66 -0
- package/dist/explorer/afresh.js +43 -0
- package/dist/explorer/api.js +101 -0
- package/dist/explorer/asking.js +59 -0
- package/dist/explorer/build.js +11 -0
- package/dist/explorer/calls.js +42 -0
- package/dist/explorer/document.js +117 -0
- package/dist/explorer/elo-refs.js +153 -0
- package/dist/explorer/elo.js +95 -0
- package/dist/explorer/fonts/OFL.txt +93 -0
- package/dist/explorer/fonts/dm-sans-latin.woff2 +0 -0
- package/dist/explorer/html.js +104 -0
- package/dist/explorer/index.js +62 -0
- package/dist/explorer/json.js +33 -0
- package/dist/explorer/machine.js +34 -0
- package/dist/explorer/masking.js +57 -0
- package/dist/explorer/operation.js +97 -0
- package/dist/explorer/pages.js +159 -0
- package/dist/explorer/script/base.js +103 -0
- package/dist/explorer/script/call.js +161 -0
- package/dist/explorer/script/calling.js +103 -0
- package/dist/explorer/script/connection.js +83 -0
- package/dist/explorer/script/copying.js +75 -0
- package/dist/explorer/script/filter.js +56 -0
- package/dist/explorer/script/formaldef.js +37 -0
- package/dist/explorer/script/main.js +82 -0
- package/dist/explorer/script/markdown.js +143 -0
- package/dist/explorer/script/notes.js +184 -0
- package/dist/explorer/script/noting.js +38 -0
- package/dist/explorer/script/peek.js +62 -0
- package/dist/explorer/script/peeking.js +19 -0
- package/dist/explorer/script/ranking.js +91 -0
- package/dist/explorer/script/review.js +126 -0
- package/dist/explorer/script/rows.js +58 -0
- package/dist/explorer/script/run.js +168 -0
- package/dist/explorer/script/running.js +66 -0
- package/dist/explorer/script/search.js +122 -0
- package/dist/explorer/script/sending.js +64 -0
- package/dist/explorer/script/served.js +51 -0
- package/dist/explorer/serve.js +41 -0
- package/dist/explorer/server.js +143 -0
- package/dist/explorer/site.js +78 -0
- package/dist/explorer/style.css +247 -0
- package/dist/explorer/telling.js +30 -0
- package/dist/explorer/tests.js +78 -0
- package/dist/explorer/wiki.js +90 -0
- package/dist/files.js +178 -0
- package/dist/finding.js +17 -0
- package/dist/judging.js +99 -0
- package/dist/lines.js +30 -0
- package/dist/main.js +128 -0
- package/dist/meaning.js +100 -0
- package/dist/modelling.js +173 -0
- package/dist/naming.js +84 -0
- package/dist/notation.js +119 -0
- package/dist/planning.js +41 -0
- package/dist/reach.js +177 -0
- package/dist/reading.js +135 -0
- package/dist/report-file.js +42 -0
- package/dist/report.js +63 -0
- package/dist/running.js +105 -0
- package/dist/selecting.js +71 -0
- package/dist/starting.js +41 -0
- package/dist/suite.js +32 -0
- package/dist/upgrade.js +27 -0
- package/dist/upgrading.js +76 -0
- package/dist/words.js +103 -0
- package/dist/world.js +129 -0
- package/package.json +57 -4
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/* The style of the opspicy explorer: a quiet wiki. Off-white ground, off-black ink, DM Sans for
|
|
2
|
+
everything at one optical size, a system monospace for Elo, JSON and routes. Accents are small
|
|
3
|
+
fills: yellow for notes and matches, green for what passes, a warm tint for what fails, light
|
|
4
|
+
blue for what runs, orange for the half disc of a section title. Few rules: a table keeps one
|
|
5
|
+
hairline per row, everything else is space and tint.
|
|
6
|
+
Every colour, font and tint is a token of this first block, light and dark in one pair: the look
|
|
7
|
+
changes here and nowhere else. The font itself is put in front of this text by site.ts. */
|
|
8
|
+
:root{color-scheme:light dark;
|
|
9
|
+
--bg:light-dark(#fffaf0,#110e25);--side:light-dark(#fbf1de,#0b091b);--ink:light-dark(#110e25,#fff6e5);--muted:light-dark(#5d5a6c,#b3adb0);
|
|
10
|
+
--link:light-dark(#3348c0,#b4c7fd);--code:light-dark(rgba(17,14,37,.05),rgba(255,246,229,.07));--hover:light-dark(rgba(17,14,37,.07),rgba(255,246,229,.1));
|
|
11
|
+
--rule:light-dark(rgba(17,14,37,.1),rgba(255,246,229,.13));--panel:light-dark(#fff,#1a1731);
|
|
12
|
+
--ok:light-dark(#0b7a62,#18bf97);--ko:light-dark(#c2391e,#ff9b85);
|
|
13
|
+
--yellow:#ffee7f;--green:#18bf97;--orange:#f7a336;--blue:#728dee;--light-blue:#b4c7fd;--melon:#f5cab2;--on-accent:#110e25;
|
|
14
|
+
--shade:rgba(17,14,37,.26);--veil:rgba(17,14,37,.45);
|
|
15
|
+
--note:light-dark(#fff3a8,#3a3413);--run:light-dark(#e6ecff,#1d2347);--bad:light-dark(#fbe3d6,#3b1f1a);
|
|
16
|
+
--t-key:light-dark(#6a45c9,#c9b6ff);--t-type:light-dark(#0b7a62,#5fd9bb);--t-str:light-dark(#9a5200,#f7c27a);--t-num:light-dark(#9a5200,#f7c27a);
|
|
17
|
+
--sans:"DM Sans",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--opsz:"opsz" 14;--mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;--sign:Georgia,"Times New Roman",serif}
|
|
18
|
+
:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
|
|
19
|
+
|
|
20
|
+
*{box-sizing:border-box;min-width:0}[hidden]{display:none!important}
|
|
21
|
+
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.6 var(--sans);font-variation-settings:var(--opsz);overflow-x:clip;-webkit-font-smoothing:antialiased}
|
|
22
|
+
a{color:var(--link);text-decoration:none}a:hover{text-decoration:underline}
|
|
23
|
+
:focus-visible{outline:2px solid var(--link);outline-offset:2px;border-radius:4px}
|
|
24
|
+
code,pre,.mono,kbd{font-family:var(--mono);font-size:13.5px;font-variation-settings:normal}
|
|
25
|
+
button,input,select,textarea{font-family:var(--sans);font-variation-settings:var(--opsz);color:var(--ink)}
|
|
26
|
+
.m{color:var(--muted)}.s{font-size:13px}
|
|
27
|
+
kbd{font-size:11.5px;padding:1px 5px;border-radius:4px;background:var(--hover);color:var(--muted)}
|
|
28
|
+
mark{background:var(--yellow);color:var(--on-accent);border-radius:2px;padding:0 1px}
|
|
29
|
+
|
|
30
|
+
/* Pages: one section is shown, the one named by the address; the overview when none is. */
|
|
31
|
+
.page{display:none;scroll-margin-top:68px}
|
|
32
|
+
.page:target,.page:has(:target){display:block}
|
|
33
|
+
:root:not(:has(.page:target,.page :target)) #home{display:block}
|
|
34
|
+
body.searching .page{display:none!important}
|
|
35
|
+
/* Without the script, or with one that stopped while it loaded, nothing that needs it is shown, and every formaldef is. */
|
|
36
|
+
:root:not(.js) :is(.searchbox,.tools,#thm,.fd-toggle,.fold-all,.work,.rt){display:none}
|
|
37
|
+
:root:not(.js) main{padding-top:40px}
|
|
38
|
+
:root:not(.js) .formaldef{display:block}
|
|
39
|
+
#results{display:none}body.searching #results{display:block}
|
|
40
|
+
tr.citizen{scroll-margin-top:72px}
|
|
41
|
+
tr.citizen:target>td{background:color-mix(in srgb,var(--yellow) 38%,transparent)}
|
|
42
|
+
|
|
43
|
+
/* Sidebar */
|
|
44
|
+
.layout{display:grid;grid-template-columns:256px minmax(0,1fr);min-height:100vh}
|
|
45
|
+
.side{background:var(--side);padding:22px 16px 16px;position:sticky;top:0;height:100vh;overflow-y:auto;display:flex;flex-direction:column;gap:6px}
|
|
46
|
+
.brand{font:700 21px/1.1 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.025em;color:var(--ink);padding:0 8px 12px;display:flex;align-items:center;gap:10px}
|
|
47
|
+
.brand:hover{text-decoration:none}
|
|
48
|
+
.brand i{flex:none;width:9px;height:18px;border-radius:0 9px 9px 0;background:var(--orange)}
|
|
49
|
+
.searchbox{position:relative}
|
|
50
|
+
.find{width:100%;height:38px;padding:0 34px 0 14px;border:1px solid var(--rule);border-radius:999px;background:var(--panel);font-size:14.5px}
|
|
51
|
+
.find::placeholder{color:var(--muted)}
|
|
52
|
+
.searchbox kbd{position:absolute;right:10px;top:10px;pointer-events:none}
|
|
53
|
+
.chap{font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding:0 8px;margin:16px 0 2px}
|
|
54
|
+
.nav{display:grid;gap:1px}
|
|
55
|
+
.nav a,.nav button{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:5px 8px;border-radius:8px;color:var(--ink);font-size:15px;line-height:1.5;background:none;border:0;text-align:left;cursor:pointer;width:100%}
|
|
56
|
+
.nav a:hover,.nav button:hover{background:var(--hover);text-decoration:none}
|
|
57
|
+
.nav a[aria-current=page]{background:var(--ink);color:var(--bg)}
|
|
58
|
+
.nav a span,.nav button span{color:var(--muted);font-size:12.5px}
|
|
59
|
+
.nav a[aria-current=page] span{color:inherit;opacity:.75}
|
|
60
|
+
.nav a[aria-current=page] .count{color:var(--on-accent);opacity:1}
|
|
61
|
+
.nav .count{background:var(--yellow);color:var(--on-accent);border-radius:999px;padding:0 8px;font-weight:600}
|
|
62
|
+
.nav .count:empty{display:none}
|
|
63
|
+
.foot{margin:auto 0 0;padding:16px 8px 0}
|
|
64
|
+
.legend{display:flex;flex-direction:column;gap:3px;font-size:12.5px;color:var(--muted);margin:0}
|
|
65
|
+
.legend>span{display:flex;gap:8px;align-items:center}
|
|
66
|
+
.side select{font-size:12.5px;background:transparent;border:1px solid var(--rule);border-radius:6px;padding:2px 4px;margin-top:10px;color:var(--muted)}
|
|
67
|
+
|
|
68
|
+
/* Main, and the bar of tools that stays on top of every page */
|
|
69
|
+
main{padding:0 56px 112px}
|
|
70
|
+
.tools{position:sticky;top:0;z-index:15;display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;padding:12px 0;margin-bottom:22px;background:var(--bg)}
|
|
71
|
+
body.searching .tools{display:none}body.searching main{padding-top:40px}
|
|
72
|
+
.tools .sp{flex:1}
|
|
73
|
+
.filter{height:32px;width:230px;max-width:100%;padding:0 12px;border:1px solid var(--rule);border-radius:999px;background:var(--panel);font-size:14px}
|
|
74
|
+
.filter::placeholder{color:var(--muted)}
|
|
75
|
+
.tb{display:inline-flex;align-items:center;gap:7px;height:32px;padding:0 13px;border:1px solid var(--rule);border-radius:999px;background:transparent;font-size:14px;white-space:nowrap;cursor:pointer;color:var(--ink)}
|
|
76
|
+
.tb:hover{background:var(--hover)}
|
|
77
|
+
.tb[aria-pressed=true]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
|
|
78
|
+
.tb[aria-pressed=true] kbd{background:transparent;color:inherit;opacity:.7}
|
|
79
|
+
.tb b{font-family:var(--sign);font-weight:400;font-style:italic;font-size:17px;line-height:1}
|
|
80
|
+
.tb.primary{background:var(--ink);color:var(--bg);border-color:var(--ink)}
|
|
81
|
+
.tb.sm{height:26px;padding:0 10px;font-size:13px}
|
|
82
|
+
.tb[disabled]{opacity:.45;cursor:not-allowed}
|
|
83
|
+
|
|
84
|
+
.crumb{font-size:13px;color:var(--muted);margin:0 0 10px;display:flex;flex-wrap:wrap;gap:6px}
|
|
85
|
+
h1{font:700 38px/1.1 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.03em;margin:0;overflow-wrap:anywhere;text-wrap:balance}
|
|
86
|
+
.lead{font-size:18px;line-height:1.5;margin:14px 0 0;max-width:66ch}
|
|
87
|
+
h2{font:650 24px/1.2 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.02em;margin:44px 0 12px}
|
|
88
|
+
h3{font-size:15px;font-weight:600;margin:28px 0 8px}
|
|
89
|
+
.meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 22px;margin:22px 0 0;font-size:15px}
|
|
90
|
+
.meta dt{color:var(--muted)}.meta dd{margin:0;overflow-wrap:anywhere}
|
|
91
|
+
.sub{margin:8px 0 0;font-size:14px;color:var(--muted)}
|
|
92
|
+
.prose{max-width:66ch;margin:14px 0 0;line-height:1.6}
|
|
93
|
+
.prose p,.prose ul{margin:10px 0 0}.prose ul{padding-left:22px}.prose li{margin:4px 0}
|
|
94
|
+
.prose h3{margin:22px 0 0;font-size:16px}
|
|
95
|
+
.prose.lead p:first-child,.prose:not(.lead)>:first-child{margin-top:0}
|
|
96
|
+
.how{max-width:66ch;margin-top:14px}
|
|
97
|
+
.by{margin:12px 0 0;font-size:12px;color:var(--muted)}.by a{color:inherit}
|
|
98
|
+
.page-top{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
|
|
99
|
+
.fold-all{font-size:13px;color:var(--ink);background:none;border:1px solid var(--rule);border-radius:999px;padding:3px 12px;cursor:pointer;white-space:nowrap}
|
|
100
|
+
.fold-all:hover{background:var(--hover)}
|
|
101
|
+
.fold>summary.fold-title{cursor:pointer;list-style:none;font:650 24px/1.2 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.02em;margin:44px 0 12px;display:flex;align-items:center;gap:12px}
|
|
102
|
+
.fold>summary.fold-title::-webkit-details-marker{display:none}
|
|
103
|
+
.fold-title::before{content:"";flex:none;width:8px;height:16px;border-radius:0 8px 8px 0;background:var(--orange)}
|
|
104
|
+
.fold:not([open])>.fold-title::before{background:transparent;box-shadow:inset 0 0 0 1.5px var(--orange)}
|
|
105
|
+
.fold:not([open])>.fold-title{color:var(--muted)}
|
|
106
|
+
|
|
107
|
+
/* Elo and JSON */
|
|
108
|
+
pre.elo{margin:10px 0 0;padding:12px 16px;background:var(--code);border-radius:10px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere;tab-size:2}
|
|
109
|
+
code.elo,code{background:var(--code);border-radius:5px;padding:1px 5px;overflow-wrap:anywhere}
|
|
110
|
+
.e-keyword{color:var(--t-key);font-weight:600}
|
|
111
|
+
.e-literal,.e-number{color:var(--t-num)}
|
|
112
|
+
.e-builtin{color:var(--t-type);font-style:italic}
|
|
113
|
+
.e-type{color:var(--t-type);font-weight:600}
|
|
114
|
+
.e-fn{color:var(--t-key)}
|
|
115
|
+
.e-string{color:var(--t-str)}
|
|
116
|
+
.e-member{color:var(--t-type)}
|
|
117
|
+
.e-op,.e-comment,.j-p{color:var(--muted)}
|
|
118
|
+
.e-comment{font-style:italic}
|
|
119
|
+
.j-key{color:var(--t-key)}.j-str{color:var(--t-str)}.j-num,.j-lit{color:var(--t-num)}
|
|
120
|
+
pre.elo a.ref{text-decoration:underline dotted;text-underline-offset:3px}
|
|
121
|
+
pre.elo a.ref:hover{text-decoration-style:solid}
|
|
122
|
+
|
|
123
|
+
/* Tables of citizens */
|
|
124
|
+
.list{list-style:none;margin:0;padding:0;display:grid;gap:4px}
|
|
125
|
+
.list.code li{font-family:var(--mono);font-size:13.5px}
|
|
126
|
+
.sentence{margin:0}
|
|
127
|
+
.group{display:flex;justify-content:space-between;align-items:baseline;gap:16px;margin:30px 0 6px}
|
|
128
|
+
h2.group{margin-top:44px}
|
|
129
|
+
h3.group{font:600 13px/1.4 var(--sans);font-variation-settings:var(--opsz);letter-spacing:.08em;text-transform:uppercase}
|
|
130
|
+
.group .m.s{text-align:right;font:400 13px/1.4 var(--sans);font-variation-settings:var(--opsz);letter-spacing:0;text-transform:none}
|
|
131
|
+
.citizens.none{display:none}
|
|
132
|
+
/* A table reaches a little past its text on both sides: the tint of a row, hovered or named by the address, has air around what it holds, and the text stays in line with what is above it. */
|
|
133
|
+
.scroll{--bleed:10px;overflow-x:auto;margin:0 calc(-1*var(--bleed))}
|
|
134
|
+
table.t{width:100%;font-size:14.5px;line-height:1.45;border-collapse:collapse}
|
|
135
|
+
table.t th{font-size:12px;font-weight:600;color:var(--muted);padding:6px 14px 6px 0;white-space:nowrap;border-bottom:1px solid var(--rule);text-align:left;vertical-align:bottom}
|
|
136
|
+
table.t td{padding:8px 14px 8px 0;border-bottom:1px solid var(--rule);vertical-align:top;overflow-wrap:break-word}
|
|
137
|
+
table.t td:has(.j-p){overflow-wrap:anywhere}
|
|
138
|
+
table.t td .m.s{white-space:nowrap}
|
|
139
|
+
table.t th:first-child,table.t td:first-child{padding-left:var(--bleed)}
|
|
140
|
+
table.t th:last-child,table.t td:last-child{padding-right:var(--bleed)}
|
|
141
|
+
table.t tr.has-fd{cursor:pointer}
|
|
142
|
+
table.t tr.has-fd:hover>td{background:var(--hover)}
|
|
143
|
+
.mk{display:inline-grid;place-items:center;width:18px;height:18px;border-radius:50%;font-size:10.5px;line-height:1;cursor:help;color:var(--on-accent);background:var(--green)}
|
|
144
|
+
.mk.told{background:none;color:var(--muted);box-shadow:inset 0 0 0 1px var(--muted)}
|
|
145
|
+
.mk.complete{background:var(--light-blue)}
|
|
146
|
+
.legend .mk{cursor:default;flex:none}
|
|
147
|
+
.res{font-size:13px;white-space:nowrap}.res.ok{color:var(--ok)}.res.ko{color:var(--ko);font-weight:600}.res.nr{color:var(--muted)}
|
|
148
|
+
.fail,.prob{margin:10px 0 0;padding:10px 14px;border-radius:10px;background:var(--bad);font-size:14px}
|
|
149
|
+
.fail ul{margin:0;padding-left:18px}.prob p{margin:0 0 6px}.prob .list{font-family:var(--mono);font-size:13px}
|
|
150
|
+
|
|
151
|
+
/* Formaldef: one click on a row shows its own; the button of a table shows the table's; the bar shows them all. */
|
|
152
|
+
.formaldef{display:none;margin:0 0 12px}
|
|
153
|
+
tr.fd-on+tr.formal-row .formaldef,.citizens.fd-open .formaldef,body.formal-all .formaldef{display:block}
|
|
154
|
+
tr.formal-row td{padding:0;border:0}
|
|
155
|
+
tr.fd-on>td,.citizens.fd-open tr.has-fd>td,body.formal-all tr.has-fd>td{border-bottom-color:transparent}
|
|
156
|
+
.formaldef p{margin:8px 0 0}
|
|
157
|
+
table.t td pre.elo{margin:0;padding:8px 12px;font-size:13px}
|
|
158
|
+
.fd-toggle{font-size:12px;font-weight:500;letter-spacing:0;text-transform:none;color:var(--muted);background:none;border:1px solid var(--rule);border-radius:999px;padding:1px 10px;margin-left:10px;cursor:pointer;white-space:nowrap;vertical-align:middle}
|
|
159
|
+
.fd-toggle:hover{background:var(--hover)}
|
|
160
|
+
.citizens.fd-open .fd-toggle,body.formal-all .fd-toggle{background:var(--ink);color:var(--bg);border-color:var(--ink)}
|
|
161
|
+
td.rt,th.rt{width:1%;white-space:nowrap;padding-left:8px!important;text-align:right}
|
|
162
|
+
.rb{display:inline-grid;place-items:center;width:26px;height:26px;border:0;border-radius:50%;background:none;color:var(--muted);font-size:13px;line-height:1;cursor:pointer}
|
|
163
|
+
/* At rest a button of a row is quiet by its colour, the muted one, which reads on every ground here; it is never dimmed, which would take it under what a glyph needs to be read. */
|
|
164
|
+
tr:hover .rb,.rb:focus-visible,.rb[aria-expanded=true]{color:var(--ink)}
|
|
165
|
+
.rb:hover{background:var(--hover);color:var(--ink)}
|
|
166
|
+
.rb.fd{font:italic 400 17px/1 var(--sign)}
|
|
167
|
+
.rb.fd[aria-expanded=true],body.formal-all .rb.fd,.citizens.fd-open .rb.fd{background:var(--ink);color:var(--bg);opacity:1}
|
|
168
|
+
.rb.nt.on{background:var(--yellow);color:var(--on-accent)}
|
|
169
|
+
.rb.run{font-size:10px}
|
|
170
|
+
|
|
171
|
+
/* Notes */
|
|
172
|
+
tr.note-row td,tr.run-row td{padding:0 0 12px;border-bottom:1px solid var(--rule)}
|
|
173
|
+
.note{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:8px;align-items:start;background:var(--note);border-radius:10px;padding:8px 10px}
|
|
174
|
+
.note select{font-size:13px;border:0;background:transparent;padding:4px 2px;border-radius:6px;cursor:pointer}
|
|
175
|
+
.note textarea{width:100%;min-height:34px;border:0;background:transparent;resize:vertical;font-size:14.5px;line-height:1.5;padding:4px 2px;field-sizing:content}
|
|
176
|
+
.note textarea:focus{outline:none}
|
|
177
|
+
.pagenote{margin:16px 0 0;max-width:820px}
|
|
178
|
+
#review-list{margin-top:28px}
|
|
179
|
+
.review-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.review-bar .sp{flex:1}
|
|
180
|
+
.review-item{margin:0 0 18px}
|
|
181
|
+
.review-item .where{display:flex;flex-wrap:wrap;gap:4px 12px;align-items:baseline;margin-bottom:6px}
|
|
182
|
+
.review-item .quote{color:var(--muted);font-size:14px;margin:0 0 6px}
|
|
183
|
+
.review-item .now{margin:0 0 8px}
|
|
184
|
+
.export{width:100%;min-height:280px;margin-top:12px;padding:14px 16px;border:0;border-radius:10px;background:var(--code);font:13px/1.55 var(--mono);resize:vertical}
|
|
185
|
+
.empty{margin:22px 0 0;padding:16px 18px;border-radius:10px;background:var(--code);color:var(--muted);max-width:70ch}
|
|
186
|
+
|
|
187
|
+
/* Running a case, calling an operation */
|
|
188
|
+
.runbox,.callout{background:var(--run);border-radius:10px;padding:12px 14px;font-size:14px;display:grid;gap:8px}
|
|
189
|
+
.runbox .line{display:flex;flex-wrap:wrap;gap:6px 12px;align-items:center}
|
|
190
|
+
.runbox pre,.try pre.out{margin:0;padding:8px 12px;border-radius:8px;background:var(--panel);white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;max-height:320px;overflow:auto}
|
|
191
|
+
.runbox .line pre{flex:1 1 20ch;min-width:0}.runbox ul{margin:0;padding-left:20px}.runbox details pre{margin-top:6px}
|
|
192
|
+
.tag{display:inline-block;font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:1px 8px;border-radius:999px;background:var(--ink);color:var(--bg)}
|
|
193
|
+
.try .grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:18px 28px;margin-top:6px}
|
|
194
|
+
.try .json{display:grid;gap:4px;font-size:13px;color:var(--muted);align-content:start}
|
|
195
|
+
.try .json textarea,.try .bar select,dialog input,dialog textarea{width:100%;border:1px solid var(--rule);border-radius:8px;background:var(--panel);padding:7px 10px;font-size:14.5px}
|
|
196
|
+
.try .json textarea,dialog textarea{font:13px/1.5 var(--mono);min-height:120px;resize:vertical}
|
|
197
|
+
dialog textarea{min-height:0}
|
|
198
|
+
/* The form an operation is called with is elo-form's: it takes its colours and its type here, through its own tokens. */
|
|
199
|
+
.try .elo-form{--elo-text:var(--ink);--elo-muted:var(--muted);--elo-accent:var(--link);--elo-danger:var(--ko);--elo-font:var(--sans);--elo-font-mono:var(--mono);--elo-font-size:14.5px;--elo-control-bg:var(--panel);--elo-control-border:var(--rule);--elo-radius:8px}
|
|
200
|
+
.try .fields{display:grid;gap:10px;align-content:start}
|
|
201
|
+
.try .bar select{width:auto;max-width:340px}
|
|
202
|
+
.try .bar{display:flex;flex-wrap:wrap;gap:8px 10px;align-items:center;margin-top:14px}
|
|
203
|
+
.try .conf{font-size:13px;color:var(--muted)}
|
|
204
|
+
.err{color:var(--ko)}
|
|
205
|
+
.status{font:700 28px/1 var(--sans);font-variation-settings:var(--opsz)}
|
|
206
|
+
dialog{border:0;border-radius:14px;background:var(--panel);color:var(--ink);padding:24px;max-width:480px;width:calc(100% - 32px);box-shadow:0 24px 80px var(--shade)}
|
|
207
|
+
dialog::backdrop{background:var(--veil)}
|
|
208
|
+
dialog h2{margin:0 0 6px}
|
|
209
|
+
dialog label{display:grid;gap:4px;font-size:13px;color:var(--muted);margin-top:14px}
|
|
210
|
+
dialog .chk{display:flex;gap:8px;align-items:center;color:var(--ink);font-size:14px}
|
|
211
|
+
dialog .chk input{width:auto}
|
|
212
|
+
dialog .bar{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
|
|
213
|
+
|
|
214
|
+
/* Search results, and the card that shows what a link leads to */
|
|
215
|
+
.hit{display:block;padding:8px 10px;margin:0 -10px;border-radius:10px;color:var(--ink)}
|
|
216
|
+
.hit:hover,.hit.cur{background:var(--hover);text-decoration:none}
|
|
217
|
+
.hit .n{font-weight:600}.hit .n.mono{font-weight:500}
|
|
218
|
+
.hit .k{font-size:12px;color:var(--muted);margin-left:8px}
|
|
219
|
+
.hit .x{display:block;font-size:13.5px;color:var(--muted);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
|
220
|
+
.scopes{display:flex;flex-wrap:wrap;gap:6px;margin:16px 0 0}
|
|
221
|
+
.more{font-size:13px;color:var(--link);background:none;border:0;padding:4px 0;cursor:pointer}
|
|
222
|
+
#peek{position:absolute;z-index:40;max-width:440px;background:var(--panel);border-radius:12px;padding:12px 14px;box-shadow:0 12px 40px var(--shade),0 0 0 1px var(--rule);font-size:14px;pointer-events:none}
|
|
223
|
+
#peek b{display:block;font-family:var(--mono);font-weight:600;font-size:13.5px}
|
|
224
|
+
#peek .k{font-size:11.5px;color:var(--muted);letter-spacing:.08em;text-transform:uppercase}
|
|
225
|
+
#peek p{margin:4px 0 0}
|
|
226
|
+
#peek pre.elo{margin-top:8px;font-size:12.5px;max-height:220px;overflow:hidden}
|
|
227
|
+
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:26px 0 0}
|
|
228
|
+
.tile{background:var(--code);border-radius:12px;padding:16px 18px;color:var(--ink)}
|
|
229
|
+
.tile b{display:block;font:700 34px/1.15 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.03em;font-variant-numeric:tabular-nums}
|
|
230
|
+
.tile span{color:var(--muted);font-size:13px}
|
|
231
|
+
.tile.ko b{color:var(--ko)}.tile.ok b{color:var(--ok)}
|
|
232
|
+
.io{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);gap:16px;margin-top:4px}
|
|
233
|
+
.io .arrow{align-self:center;color:var(--muted);font-size:18px}
|
|
234
|
+
#toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:8px 16px;border-radius:999px;font-size:14px;z-index:60}
|
|
235
|
+
|
|
236
|
+
@media(max-width:900px){
|
|
237
|
+
.layout{grid-template-columns:minmax(0,1fr)}
|
|
238
|
+
.side{position:static;height:auto;padding:14px 12px}
|
|
239
|
+
.nav{display:flex;flex-wrap:wrap;gap:2px}.nav a,.nav button{width:auto}
|
|
240
|
+
.nav a span{display:none}.nav .count{display:inline}
|
|
241
|
+
.foot{display:none}
|
|
242
|
+
main{padding:0 20px 80px}
|
|
243
|
+
h1{font-size:32px}
|
|
244
|
+
.io,.try .grid{grid-template-columns:minmax(0,1fr)}.io .arrow{display:none}
|
|
245
|
+
.filter{width:160px}
|
|
246
|
+
tr.run-row .runbox{position:sticky;left:0;width:calc(100vw - 40px)}
|
|
247
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// What a run decided, as its page is told it: the result in a word, the call of the case and its
|
|
2
|
+
// answer, what did not hold, and the whole log. Pure: the outcome of a case is given, and nothing
|
|
3
|
+
// of what the world keeps to itself comes out (masking.ts).
|
|
4
|
+
import { operationLines } from '../report.js';
|
|
5
|
+
import { hidden, maskedWire } from './masking.js';
|
|
6
|
+
import { idOf } from './wiki.js';
|
|
7
|
+
/** A line of the log as a page reads it: without what colours it on a terminal. */
|
|
8
|
+
const plain = (line) => line.replace(/\u001b\[\d+m/g, '');
|
|
9
|
+
/** What did not hold, each with the anchor of the clause it is said of, when it is said of one: a clause of the operation, or what the example alone also shows. */
|
|
10
|
+
function failures(clauses, findings) {
|
|
11
|
+
return findings.map((says) => {
|
|
12
|
+
const clause = clauses.find((one) => says.startsWith(`${one.kind} "${one.description}"`));
|
|
13
|
+
return clause ? { ref: idOf('clause', clause.name), says } : { says };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const resultOf = (findings) => (!findings.length ? 'passed' : findings[0]?.startsWith('the case could not be run') ? 'error' : 'failed');
|
|
17
|
+
/**
|
|
18
|
+
* What a run decided, as the page is told it: nothing in it says what the world keeps to itself.
|
|
19
|
+
* What did not hold is told in the suite's own words, as a report keeps it (finding.ts): the
|
|
20
|
+
* clause, the status that was said. What was seen of the system that made it so is in the log,
|
|
21
|
+
* which is the runner's, line for line, beside what the system answered.
|
|
22
|
+
*/
|
|
23
|
+
export function ranOf(operation, outcome, mode, secrets) {
|
|
24
|
+
const [findings, kept] = [outcome.findings, outcome.kept].map((all) => all.map((one) => hidden(one, secrets)));
|
|
25
|
+
const told = { ...outcome, findings, kept, wire: maskedWire(outcome.wire, secrets) };
|
|
26
|
+
const call = told.wire.filter((one) => one.doing === 'calls').at(-1);
|
|
27
|
+
const request = call ? { actor: call.who, method: call.method, path: call.path, ...(call.sent === undefined ? {} : { sent: call.sent }) } : null;
|
|
28
|
+
const log = operationLines({ operation, outcomes: [told], gaps: [] }, 'trace').map((line) => hidden(plain(line), secrets)).filter((line, at) => at > 0 || line !== '');
|
|
29
|
+
return { result: resultOf(kept), mode, seconds: outcome.ms / 1000, background: outcome.kase.given.seed, request, answer: call ? { status: call.status, body: call.body } : null, failed: failures([...operation.clauses, ...outcome.kase.and], kept), log };
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { RESULT, citizens, esc, link, list, plural, table } from './html.js';
|
|
2
|
+
import { answeredOf, areaTitle, callerOf, crumbs, sentOf } from './operation.js';
|
|
3
|
+
import { idOf } from './wiki.js';
|
|
4
|
+
const tile = (value, label, cls = '') => `<div class="tile ${cls}"><b>${esc(value)}</b><span>${esc(label)}</span></div>`;
|
|
5
|
+
const seconds = (ms) => (ms === undefined ? '' : `<span class="m s">${(ms / 1000).toFixed(1)} s</span>`);
|
|
6
|
+
/** Of the cases of an operation, how many ran, passed, failed. */
|
|
7
|
+
function ledger(cases) {
|
|
8
|
+
const failed = cases.filter((one) => one.result === 'failed').length;
|
|
9
|
+
const passed = cases.filter((one) => one.result === 'passed').length;
|
|
10
|
+
return { ran: passed + failed, passed, failed, notRun: cases.length - passed - failed };
|
|
11
|
+
}
|
|
12
|
+
/** The result of an area: failed when one of its operations did, passed when one ran, not run otherwise. */
|
|
13
|
+
export function resultOfAll(results) {
|
|
14
|
+
if (results.includes('failed'))
|
|
15
|
+
return 'failed';
|
|
16
|
+
return results.includes('passed') ? 'passed' : 'notrun';
|
|
17
|
+
}
|
|
18
|
+
function overviewPage(wiki) {
|
|
19
|
+
const run = wiki.run;
|
|
20
|
+
if (!run) {
|
|
21
|
+
const body = `<h1>Tests</h1><p class="lead">No run of this specification is known. A run writes its report beside the console (<span class="mono">--report=</span>), and the explorer shows its results here.</p>`;
|
|
22
|
+
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
23
|
+
}
|
|
24
|
+
const failing = wiki.operations.filter((one) => one.cases.some((kase) => kase.result === 'failed'));
|
|
25
|
+
const failures = failing
|
|
26
|
+
.map((one) => `<h3>${link(`#${idOf('test', one.name)}`, one.name)}</h3>${list(one.cases.filter((kase) => kase.result === 'failed').map((kase) => `${esc(kase.description)}${kase.findings.length ? `<div class="fail">${list(kase.findings.map(esc))}</div>` : ''}`))}`)
|
|
27
|
+
.join('');
|
|
28
|
+
const rows = performing(wiki).map((area) => {
|
|
29
|
+
const of = ledger(area.operations.flatMap((one) => one.cases));
|
|
30
|
+
return [link(`#${idOf('test-area', area.name)}`, areaTitle(area.name)), String(of.passed), String(of.failed), String(of.notRun), RESULT[resultOfAll(area.operations.map((one) => one.result))]];
|
|
31
|
+
});
|
|
32
|
+
const narrowed = run.narrowed.length ? `Asked: <span class="mono">${esc(run.narrowed.join(' '))}</span>. The rest was not run.` : 'The whole suite.';
|
|
33
|
+
const body = `<h1>Tests</h1>
|
|
34
|
+
<p class="lead">Run ${esc(new Date(run.when).toLocaleString('en-GB'))}${run.fast ? ', the fast run' : ''}${run.stopped ? ', stopped at the first failure' : ''}.</p>
|
|
35
|
+
<div class="tiles">${tile(run.ran, 'cases run')}${tile(run.ran - run.failed, 'passing', 'ok')}${tile(run.failed, 'failing', run.failed ? 'ko' : 'ok')}${tile(run.notRun, 'not run')}</div>
|
|
36
|
+
<p class="sub">${narrowed}</p>
|
|
37
|
+
<h2>Failing</h2>${failures || '<p class="sub">Nothing fails.</p>'}
|
|
38
|
+
<h2>By area</h2>${table(['Area', 'Passed', 'Failed', 'Not run', 'Result'], rows)}`;
|
|
39
|
+
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The cases of an operation, as the run met them: the result, the case with what did not hold,
|
|
43
|
+
* who called, what was sent and answered, and how long it took. Each row names the case it tells
|
|
44
|
+
* the run of, whose own row is on the page of the operation.
|
|
45
|
+
*/
|
|
46
|
+
function casesOf(cases, refs) {
|
|
47
|
+
const rows = cases.map((kase) => {
|
|
48
|
+
const findings = kase.findings.length ? `<div class="fail">${list(kase.findings.map(esc))}</div>` : '';
|
|
49
|
+
const name = `${esc(kase.description)}<br><span class="m s">${kase.kind}${kase.generated ? ', from a condition' : ''}</span>${findings}`;
|
|
50
|
+
return { kase: idOf('case', kase.name), source: kase.source, name: RESULT[kase.result], description: name, more: [callerOf(kase), sentOf(kase, refs), answeredOf(kase), seconds(kase.ms)] };
|
|
51
|
+
});
|
|
52
|
+
return citizens('Cases', rows, { columns: ['Result', 'Case', 'Caller', 'Sends', 'Answers', 'Time'], note: plural(cases.length, 'case') });
|
|
53
|
+
}
|
|
54
|
+
function operationPage(operation, refs) {
|
|
55
|
+
const of = ledger(operation.cases);
|
|
56
|
+
const summary = operation.result === 'notrun' ? 'Not run.' : `${plural(of.passed, 'case')} passed${of.failed ? `, ${of.failed} failed` : ''}${of.notRun ? `, ${of.notRun} not run` : ''}.`;
|
|
57
|
+
const body = `${crumbs(link('#tests', 'Tests'), link(`#${idOf('test-area', operation.area)}`, areaTitle(operation.area)))}
|
|
58
|
+
<h1 class="code">${esc(operation.name)}</h1>
|
|
59
|
+
<p class="lead">${esc(summary)} ${RESULT[operation.result]}</p>
|
|
60
|
+
<p class="sub">${link(`#${idOf('op', operation.name)}`, 'Specification of this operation')}</p>
|
|
61
|
+
${casesOf(operation.cases, refs)}`;
|
|
62
|
+
return { id: idOf('test', operation.name), kind: 'Tests', title: `${operation.name} · tests`, nav: 'tests', body };
|
|
63
|
+
}
|
|
64
|
+
function areaPage(area) {
|
|
65
|
+
const rows = area.operations.map((one) => {
|
|
66
|
+
const of = ledger(one.cases);
|
|
67
|
+
return [link(`#${idOf('test', one.name)}`, one.name), String(of.passed), String(of.failed), String(of.notRun), RESULT[one.result]];
|
|
68
|
+
});
|
|
69
|
+
const body = `${crumbs(link('#tests', 'Tests'))}<h1>${esc(areaTitle(area.name))}</h1>
|
|
70
|
+
${table(['Operation', 'Passed', 'Failed', 'Not run', 'Result'], rows)}`;
|
|
71
|
+
return { id: idOf('test-area', area.name), kind: 'Tests', title: `${areaTitle(area.name)} · tests`, nav: 'tests', body };
|
|
72
|
+
}
|
|
73
|
+
/** The areas that have something to run: one that holds words only has no test. */
|
|
74
|
+
const performing = (wiki) => wiki.areas.filter((area) => area.operations.length > 0);
|
|
75
|
+
/** The test pages of a wiki: the overview, each area, and each operation's cases. */
|
|
76
|
+
export function testPagesOf(wiki) {
|
|
77
|
+
return [overviewPage(wiki), ...performing(wiki).map(areaPage), ...wiki.operations.map((one) => operationPage(one, wiki.refs))];
|
|
78
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// The wiki of a suite and of its last run, as data: the citizens each page shows, before it is
|
|
2
|
+
// written. Pure: a suite, and the report of a run when there is one, are given; nothing is read.
|
|
3
|
+
//
|
|
4
|
+
// A case of the specification is joined to the case the run reported for it, by its kind, its
|
|
5
|
+
// "when" and whether a condition gave it. A case the run did not reach is not run, and says so.
|
|
6
|
+
import { addressOf } from '../addresses.js';
|
|
7
|
+
import { casesOf, gapsOf } from '../planning.js';
|
|
8
|
+
import { named, sameSentence } from '../suite.js';
|
|
9
|
+
import { refsOf } from './elo.js';
|
|
10
|
+
/** A name, made safe for an anchor, as the suite is read to have no two at one (addresses.ts); and the anchor of a citizen of a kind: `predicate-seesBoard`. */
|
|
11
|
+
export const slug = addressOf;
|
|
12
|
+
export const idOf = (kind, name) => `${kind}-${slug(name)}`;
|
|
13
|
+
/** Each case of the specification, with the one the run reported for it: first unused, of the same kind, sentence and origin. */
|
|
14
|
+
function joined(cases, reported) {
|
|
15
|
+
const left = [...reported];
|
|
16
|
+
return cases.map((kase) => {
|
|
17
|
+
const at = left.findIndex((one) => one.kind === kase.kind && one.when === kase.description && one.generated === kase.generated);
|
|
18
|
+
return at < 0 ? undefined : left.splice(at, 1)[0];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const resultOf = (ran) => {
|
|
22
|
+
const done = ran.filter((one) => one !== undefined);
|
|
23
|
+
if (!done.length)
|
|
24
|
+
return 'notrun';
|
|
25
|
+
return done.some((one) => one.findings.length > 0) ? 'failed' : 'passed';
|
|
26
|
+
};
|
|
27
|
+
function operationView(operation, suite, report) {
|
|
28
|
+
const reported = report?.operations.find((one) => one.file === operation.file)?.cases ?? [];
|
|
29
|
+
const cases = casesOf(operation, suite.model);
|
|
30
|
+
const matched = joined(cases, reported);
|
|
31
|
+
const views = cases.map((kase, at) => ({ ...kase, result: resultOf([matched[at]]), findings: matched[at]?.findings ?? [], ms: matched[at]?.ms }));
|
|
32
|
+
return { ...operation, cases: views, gaps: gapsOf(operation, cases), result: resultOf(matched) };
|
|
33
|
+
}
|
|
34
|
+
function runOf(report, operations) {
|
|
35
|
+
const cases = operations.flatMap((one) => one.cases);
|
|
36
|
+
const ran = cases.filter((one) => one.result !== 'notrun');
|
|
37
|
+
return { when: report.when, narrowed: report.narrowed, fast: report.fast, stopped: report.stopped, ran: ran.length, failed: ran.filter((one) => one.result === 'failed').length, notRun: cases.length - ran.length };
|
|
38
|
+
}
|
|
39
|
+
/** The areas the suite describes, then those it only has: each with what is at home in it. */
|
|
40
|
+
function areasOf(suite, operations) {
|
|
41
|
+
const { model } = suite;
|
|
42
|
+
const homes = [...operations, ...model.definitions, ...model.conditions, ...model.types].map((one) => one.area);
|
|
43
|
+
const names = [...new Set([...model.areas.map((one) => one.name), ...homes])];
|
|
44
|
+
const of = (all, area) => all.filter((one) => one.area === area);
|
|
45
|
+
return names.map((name) => ({
|
|
46
|
+
name,
|
|
47
|
+
description: named(model.areas, name)?.description ?? '',
|
|
48
|
+
source: named(model.areas, name)?.source,
|
|
49
|
+
operations: of(operations, name),
|
|
50
|
+
predicates: of(model.definitions, name).filter((one) => one.kind === 'predicate'),
|
|
51
|
+
functions: of(model.definitions, name).filter((one) => one.kind === 'function'),
|
|
52
|
+
conditions: of(model.conditions, name),
|
|
53
|
+
types: of(model.types, name),
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The kind of each type, from what is written and nothing else: a type `state.yml` says a state
|
|
58
|
+
* tells, or the items of one that is a list (`Expense` of `Expenses = [Expense]`), is a state
|
|
59
|
+
* type; a type an operation names as its input or its output, and no state tells, is a message.
|
|
60
|
+
*/
|
|
61
|
+
function typeKindsOf(model, operations) {
|
|
62
|
+
const itemOf = (name) => /^\[\s*(\w+)\s*\]$/.exec(model.types.find((one) => one.name === name)?.formaldef.trim() ?? '')?.[1];
|
|
63
|
+
const told = new Set(model.state.flatMap((one) => (one.type ? [one.type, itemOf(one.type) ?? one.type] : [])));
|
|
64
|
+
const exchanged = new Set(operations.flatMap((one) => [one.input, one.output]).filter((one) => Boolean(one)));
|
|
65
|
+
return new Map(model.types.map((one) => [one.name, told.has(one.name) ? 'state' : exchanged.has(one.name) ? 'message' : 'data']));
|
|
66
|
+
}
|
|
67
|
+
/** The wiki of a suite, and of its last run when there is one. */
|
|
68
|
+
export function wikiOf(suite, report) {
|
|
69
|
+
const { model } = suite;
|
|
70
|
+
const operations = suite.operations.map((operation) => operationView(operation, suite, report)).sort((a, b) => a.area.localeCompare(b.area) || a.name.localeCompare(b.name));
|
|
71
|
+
return {
|
|
72
|
+
system: model.system,
|
|
73
|
+
descriptions: model.descriptions,
|
|
74
|
+
problems: suite.problems,
|
|
75
|
+
areas: areasOf(suite, operations),
|
|
76
|
+
operations,
|
|
77
|
+
agents: model.agents,
|
|
78
|
+
actors: model.actors.map(({ name, description, source, is, with: held }) => ({ name, description, source, is, signsIn: held !== null })),
|
|
79
|
+
backgrounds: model.backgrounds,
|
|
80
|
+
state: model.state,
|
|
81
|
+
relations: model.relations,
|
|
82
|
+
types: model.types,
|
|
83
|
+
worldKeys: Object.keys(model.world),
|
|
84
|
+
refs: refsOf(model),
|
|
85
|
+
run: report ? runOf(report, operations) : null,
|
|
86
|
+
typeKinds: typeKindsOf(model, suite.operations),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** The counterexamples that violate a precondition: those that are "for" its sentence. */
|
|
90
|
+
export const violating = (operation, sentence) => operation.cases.filter((kase) => kase.kind === 'counterexample' && sameSentence(kase.for ?? '', sentence));
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// The suite as it is on disk. What it says is in one directory, apart from how it is run, and
|
|
2
|
+
// by area: what an area says is in its directory, beside its operations and its observations, one
|
|
3
|
+
// file each. An observation is specified as an operation is, and only reads. Read
|
|
4
|
+
// whole, with everything that cannot be read told.
|
|
5
|
+
//
|
|
6
|
+
// config.ts how the suite meets the system (configuration.ts)
|
|
7
|
+
// specification/
|
|
8
|
+
// system.yml what the specified system is called, and is (optional)
|
|
9
|
+
// areas.yml, agents.yml, backgrounds.yml the areas, who performs operations, where a case starts
|
|
10
|
+
// state.yml what is observed: the routes that tell, the relations behind
|
|
11
|
+
// world.yml what the runner knows: who calls, and what they hold
|
|
12
|
+
// _shared/predicates.yml, functions.yml, conditions.yml, types.elo what every area says
|
|
13
|
+
// <area>/predicates.yml, functions.yml, conditions.yml, types.elo what one area says
|
|
14
|
+
// <area>/operations/<Operation>.yml what changes the state
|
|
15
|
+
// <area>/observations/<Observation>.yml what only reads it
|
|
16
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
import { parse } from 'yaml';
|
|
19
|
+
import { sharedAddresses } from './addresses.js';
|
|
20
|
+
import { linesOf } from './lines.js';
|
|
21
|
+
import { meaningOf, typesDeclared } from './meaning.js';
|
|
22
|
+
import { modelOf } from './modelling.js';
|
|
23
|
+
import { misnamed } from './naming.js';
|
|
24
|
+
import { crowded } from './notation.js';
|
|
25
|
+
import { operationOf } from './reading.js';
|
|
26
|
+
import { NOTHING_SAID, isPre } from './suite.js';
|
|
27
|
+
/**
|
|
28
|
+
* A YAML file as it was written, and where each thing is in it. What cannot be read is told, and
|
|
29
|
+
* is nothing: under the name the file is told by, which of an operation is its file from the
|
|
30
|
+
* specification, as every problem of it begins. A run narrowed to others tells them apart by it.
|
|
31
|
+
*/
|
|
32
|
+
function written(path, problems, as = path) {
|
|
33
|
+
try {
|
|
34
|
+
const text = readFileSync(path, 'utf8');
|
|
35
|
+
return { data: parse(text), lines: linesOf(text) };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
problems.push(`${as}: ${String(error instanceof Error ? error.message : error).split('\n')[0]}`);
|
|
39
|
+
return { data: {} };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const named = (directory, extension) => (existsSync(directory) ? readdirSync(directory, { recursive: true, encoding: 'utf8' }).filter((file) => file.endsWith(extension)).sort() : []);
|
|
43
|
+
/** What a suite names, that its formaldefs may read. */
|
|
44
|
+
export const namesOf = (model) => ({
|
|
45
|
+
states: model.state.map((one) => one.name),
|
|
46
|
+
relations: model.relations.map((one) => one.name),
|
|
47
|
+
actors: model.actors.map((one) => one.name),
|
|
48
|
+
definitions: model.definitions,
|
|
49
|
+
types: Object.fromEntries(model.state.flatMap((one) => (one.type ? [[one.name, one.type]] : []))),
|
|
50
|
+
columns: Object.fromEntries(model.relations.map((relation) => [relation.name, [...relation.key, ...relation.attributes]])),
|
|
51
|
+
});
|
|
52
|
+
/** Where a suite says what it specifies. */
|
|
53
|
+
export const SPECIFICATION = 'specification';
|
|
54
|
+
/** Where every area's words are. */
|
|
55
|
+
export const SHARED = '_shared';
|
|
56
|
+
/** Where an area files what changes the state, and what only reads it. */
|
|
57
|
+
const OPERATIONS = 'operations';
|
|
58
|
+
const OBSERVATIONS = 'observations';
|
|
59
|
+
const STATE = 'state.yml';
|
|
60
|
+
const WORLD = 'world.yml';
|
|
61
|
+
const AREAS = 'areas.yml';
|
|
62
|
+
const AGENTS = 'agents.yml';
|
|
63
|
+
const BACKGROUNDS = 'backgrounds.yml';
|
|
64
|
+
const SYSTEM = 'system.yml';
|
|
65
|
+
/** What a specification holds beside its areas. */
|
|
66
|
+
const HELD = [SYSTEM, AREAS, AGENTS, BACKGROUNDS, STATE, WORLD];
|
|
67
|
+
const SAID = ['predicates.yml', 'functions.yml', 'conditions.yml', 'types.elo', OPERATIONS, OBSERVATIONS];
|
|
68
|
+
/** What is filed with the operations or the observations of an area and is not a `.yml` file: it would be there, and not read. */
|
|
69
|
+
function strays(root, area, problems) {
|
|
70
|
+
for (const as of [OPERATIONS, OBSERVATIONS]) {
|
|
71
|
+
const filed = existsSync(join(root, area, as)) ? readdirSync(join(root, area, as), { recursive: true, encoding: 'utf8' }).sort() : [];
|
|
72
|
+
const others = filed.filter((file) => !file.endsWith('.yml') && !statSync(join(root, area, as, file)).isDirectory());
|
|
73
|
+
for (const file of others)
|
|
74
|
+
problems.push(`${join(area, as, file)} is not read: what is filed in ${as}/ is a file each, <Name>.yml`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** The areas of a suite: the directories of its specification, what every area says first. What is there and is not read is told. */
|
|
78
|
+
function areasOf(root, problems) {
|
|
79
|
+
const held = (directory) => readdirSync(join(root, directory), { withFileTypes: true }).map((entry) => entry.name).sort();
|
|
80
|
+
const areas = readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
81
|
+
for (const name of held(''))
|
|
82
|
+
if (!areas.includes(name) && !HELD.includes(name))
|
|
83
|
+
problems.push(`${name} is not read: a specification holds ${HELD.join(', ')} and its areas`);
|
|
84
|
+
for (const area of areas) {
|
|
85
|
+
const others = held(area).filter((name) => !SAID.includes(name));
|
|
86
|
+
if (others.length === held(area).length)
|
|
87
|
+
problems.push(`${area}/ says nothing: an area holds ${SAID.join(', ')}`);
|
|
88
|
+
else
|
|
89
|
+
for (const name of others)
|
|
90
|
+
problems.push(`${area}/${name} is not read: an area holds ${SAID.join(', ')}`);
|
|
91
|
+
strays(root, area, problems);
|
|
92
|
+
}
|
|
93
|
+
return [...areas.filter((area) => area === SHARED), ...areas.filter((area) => area !== SHARED)];
|
|
94
|
+
}
|
|
95
|
+
/** What one area says, as it is written: its three lists, and its types as a text. */
|
|
96
|
+
function saidBy(root, area, problems) {
|
|
97
|
+
const said = (name) => (existsSync(join(root, area, name)) ? written(join(root, area, name), problems) : {});
|
|
98
|
+
const [predicates, functions, conditions] = [said('predicates.yml'), said('functions.yml'), said('conditions.yml')];
|
|
99
|
+
const types = join(root, area, 'types.elo');
|
|
100
|
+
return { area, predicates: predicates.data, functions: functions.data, conditions: conditions.data, types: existsSync(types) ? readFileSync(types, 'utf8') : undefined, lines: { predicates: predicates.lines, functions: functions.lines, conditions: conditions.lines } };
|
|
101
|
+
}
|
|
102
|
+
/** What the suite says apart from its operations, as it is written: its own files, and the words of each area. */
|
|
103
|
+
function saidIn(root, areas, problems) {
|
|
104
|
+
const said = (name) => (existsSync(join(root, name)) ? written(join(root, name), problems) : {});
|
|
105
|
+
const [system, areasSaid, agents, backgrounds, state, world] = [SYSTEM, AREAS, AGENTS, BACKGROUNDS, STATE, WORLD].map(said);
|
|
106
|
+
const lines = { system: system?.lines, areas: areasSaid?.lines, agents: agents?.lines, backgrounds: backgrounds?.lines, state: state?.lines, world: world?.lines };
|
|
107
|
+
return { system: system?.data, areas: areasSaid?.data, agents: agents?.data, backgrounds: backgrounds?.data, state: state?.data, world: world?.data, lines, words: areas.map((area) => saidBy(root, area, problems)) };
|
|
108
|
+
}
|
|
109
|
+
/** The types of the suite as one text: what every area uses first, since a type is declared before it is used. */
|
|
110
|
+
const typesIn = (said) => (said.words ?? []).flatMap((one) => (one.types === undefined ? [] : [one.types])).join('\n');
|
|
111
|
+
/** The files of an area, each from the specification: `boards/operations/CreateBoard.yml`, then `boards/observations/ListBoards.yml`. */
|
|
112
|
+
const filed = (root, area, as) => named(join(root, area, as), '.yml').map((file) => join(area, as, file));
|
|
113
|
+
const specified = (root, areas) => areas.flatMap((area) => [...filed(root, area, OPERATIONS), ...filed(root, area, OBSERVATIONS)]);
|
|
114
|
+
const observes = (file) => file.split(/[\\/]/)[1] === OBSERVATIONS;
|
|
115
|
+
/**
|
|
116
|
+
* What Elo cannot read, or a type nobody declares, in an operation. A condition is read here
|
|
117
|
+
* too: where it is said decides the moment it speaks of.
|
|
118
|
+
*/
|
|
119
|
+
function unreadable(operation, meaning, types) {
|
|
120
|
+
const clauses = [...operation.clauses, ...operation.cases.flatMap((kase) => kase.and)].filter((clause) => clause.formaldef);
|
|
121
|
+
const declared = (type) => (type && types.includes(type) ? type : undefined);
|
|
122
|
+
const exchanged = { input: declared(operation.input), output: declared(operation.output) };
|
|
123
|
+
const said = clauses.map((clause) => [clause.description, meaning.unreadable(clause.formaldef ?? '', isPre(clause) ? 'pre' : 'post', exchanged)]);
|
|
124
|
+
const given = operation.cases.filter((kase) => typeof kase.input === 'string').map((kase) => [`the input of "${kase.description}"`, meaning.unreadable(kase.input, 'given')]);
|
|
125
|
+
const unknown = [operation.input, operation.output].filter((type) => type && !types.includes(type)).map((type) => `"${type}" is not a type of the suite`);
|
|
126
|
+
return [...unknown, ...[...said, ...given].flatMap(([says, problem]) => (problem ? [`"${says}": ${problem}`] : []))].map((problem) => `${operation.file}: ${problem}`);
|
|
127
|
+
}
|
|
128
|
+
/** A predicate is true or false, and a function gives something else: told where Elo knows better. */
|
|
129
|
+
function misfiled(one, meaning) {
|
|
130
|
+
const decides = meaning.decides(one.name);
|
|
131
|
+
if (one.kind === 'predicate' && decides === false)
|
|
132
|
+
return 'it gives something else than true or false: it is a function, said in functions.yml';
|
|
133
|
+
return one.kind === 'function' && decides === true ? 'it is true or false: it is a predicate, said in predicates.yml' : null;
|
|
134
|
+
}
|
|
135
|
+
/** A predicate or a function is read alone, by its name; a condition where everything is named, as a postcondition is. */
|
|
136
|
+
const unreadableWords = (model, meaning) => [
|
|
137
|
+
...model.definitions.map((one) => [`${one.kind} "${one.name}"`, misnamed(one.formaldef, namesOf(model)) ?? meaning.unreadable(one.name, 'post') ?? misfiled(one, meaning)]),
|
|
138
|
+
...model.conditions.map((condition) => [`condition "${condition.description}"`, meaning.unreadable(condition.formaldef, 'post')]),
|
|
139
|
+
].flatMap(([what, problem]) => (problem ? [`${what}: ${problem}`] : []));
|
|
140
|
+
/** The cases of a file that no empty line sets apart from the one before. */
|
|
141
|
+
const unaired = (root, file) => (existsSync(join(root, file)) ? crowded(readFileSync(join(root, file), 'utf8')) : []).map((line) => `${file}: line ${line}: an empty line sets a case apart from the one before`);
|
|
142
|
+
function duplicates(operations) {
|
|
143
|
+
const names = operations.map((operation) => operation.name);
|
|
144
|
+
return [...new Set(names.filter((name, at) => names.indexOf(name) !== at))].map((name) => `two files specify the operation "${name}"`);
|
|
145
|
+
}
|
|
146
|
+
/** The states whose type no area declares: told, and read as states of no type. */
|
|
147
|
+
function untyped(model, declared) {
|
|
148
|
+
const unknown = model.state.filter((one) => one.type && !declared.includes(one.type));
|
|
149
|
+
const problems = unknown.map((one) => `${STATE}: state "${one.name}": "${one.type}" is not a type of the suite`);
|
|
150
|
+
for (const one of unknown)
|
|
151
|
+
one.type = undefined;
|
|
152
|
+
return problems;
|
|
153
|
+
}
|
|
154
|
+
/** Reads the suite of a directory. */
|
|
155
|
+
export function readSuite(suite) {
|
|
156
|
+
const root = join(suite, SPECIFICATION);
|
|
157
|
+
const problems = [];
|
|
158
|
+
if (!existsSync(root))
|
|
159
|
+
return { model: NOTHING_SAID, types: '', operations: [], problems: [`${suite} holds no ${SPECIFICATION}/: nothing is specified`] };
|
|
160
|
+
const areas = areasOf(root, problems);
|
|
161
|
+
const said = saidIn(root, areas, problems);
|
|
162
|
+
const { model, problems: inModel } = modelOf(said);
|
|
163
|
+
const types = typesIn(said);
|
|
164
|
+
inModel.push(...untyped(model, typesDeclared(types)));
|
|
165
|
+
const meaning = meaningOf(types, namesOf(model));
|
|
166
|
+
const typesProblem = meaning.unreadable(`${types}\ntrue`);
|
|
167
|
+
const files = specified(root, areas);
|
|
168
|
+
const read = files.map((file) => {
|
|
169
|
+
const { data, lines } = written(join(root, file), problems, file);
|
|
170
|
+
return operationOf(file, data, model, observes(file), lines);
|
|
171
|
+
});
|
|
172
|
+
const operations = read.map(({ operation }) => operation);
|
|
173
|
+
const inWords = unreadableWords(model, meaning);
|
|
174
|
+
problems.push(...inModel, ...(typesProblem ? [`the types: ${typesProblem}`] : []), ...inWords, ...read.flatMap((one) => one.problems));
|
|
175
|
+
if (!typesProblem && !inWords.length)
|
|
176
|
+
problems.push(...operations.flatMap((operation) => unreadable(operation, meaning, typesDeclared(types))));
|
|
177
|
+
return { model, types, operations, problems: [...problems, ...duplicates(operations), ...sharedAddresses(operations, model), ...files.flatMap((file) => unaired(root, file))] };
|
|
178
|
+
}
|