@seasb/metafab 1.0.0 → 2.0.0-next.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.
- package/README.md +1 -1
- package/dist/cli.js +118 -16
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.d.ts +29 -0
- package/dist/commands/build.js +111 -25
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +13 -2
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/create.js +1 -0
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/env.d.ts +4 -0
- package/dist/commands/env.js +362 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/map.js +1 -2
- package/dist/commands/map.js.map +1 -1
- package/dist/commands/pipeline-add.js +1 -0
- package/dist/commands/pipeline-add.js.map +1 -1
- package/dist/commands/pipeline-remove.js +1 -0
- package/dist/commands/pipeline-remove.js.map +1 -1
- package/dist/commands/publish.js +8 -2
- package/dist/commands/publish.js.map +1 -1
- package/dist/core/build/agents.d.ts +7 -4
- package/dist/core/build/agents.js +16 -9
- package/dist/core/build/agents.js.map +1 -1
- package/dist/core/build/index.d.ts +1 -0
- package/dist/core/build/index.js +1 -0
- package/dist/core/build/index.js.map +1 -1
- package/dist/core/build/plan.d.ts +35 -1
- package/dist/core/build/plan.js +156 -36
- package/dist/core/build/plan.js.map +1 -1
- package/dist/core/build/preview.d.ts +39 -0
- package/dist/core/build/preview.js +344 -0
- package/dist/core/build/preview.js.map +1 -0
- package/dist/core/build/skill.d.ts +39 -0
- package/dist/core/build/skill.js +120 -41
- package/dist/core/build/skill.js.map +1 -1
- package/dist/core/check/index.d.ts +5 -1
- package/dist/core/check/index.js +8 -2
- package/dist/core/check/index.js.map +1 -1
- package/dist/core/config/parse.js +3 -0
- package/dist/core/config/parse.js.map +1 -1
- package/dist/core/config/source.d.ts +11 -0
- package/dist/core/config/source.js +23 -0
- package/dist/core/config/source.js.map +1 -1
- package/dist/core/config/validate.js +75 -37
- package/dist/core/config/validate.js.map +1 -1
- package/dist/core/config/writers.js +9 -1
- package/dist/core/config/writers.js.map +1 -1
- package/dist/core/edit/create.js +1 -1
- package/dist/core/edit/create.js.map +1 -1
- package/dist/core/edit/factory-yaml.js +4 -2
- package/dist/core/edit/factory-yaml.js.map +1 -1
- package/dist/core/edit/paths.js +8 -3
- package/dist/core/edit/paths.js.map +1 -1
- package/dist/core/edit/pipeline.js +12 -6
- package/dist/core/edit/pipeline.js.map +1 -1
- package/dist/core/env/condition.d.ts +40 -0
- package/dist/core/env/condition.js +283 -0
- package/dist/core/env/condition.js.map +1 -0
- package/dist/core/env/declarations.d.ts +16 -0
- package/dist/core/env/declarations.js +328 -0
- package/dist/core/env/declarations.js.map +1 -0
- package/dist/core/env/directives.d.ts +75 -0
- package/dist/core/env/directives.js +429 -0
- package/dist/core/env/directives.js.map +1 -0
- package/dist/core/env/git-config.d.ts +15 -0
- package/dist/core/env/git-config.js +110 -0
- package/dist/core/env/git-config.js.map +1 -0
- package/dist/core/env/imports.d.ts +60 -0
- package/dist/core/env/imports.js +217 -0
- package/dist/core/env/imports.js.map +1 -0
- package/dist/core/env/index.d.ts +6 -0
- package/dist/core/env/index.js +7 -0
- package/dist/core/env/index.js.map +1 -0
- package/dist/core/env/markdown.d.ts +22 -0
- package/dist/core/env/markdown.js +33 -0
- package/dist/core/env/markdown.js.map +1 -0
- package/dist/core/env/render.d.ts +13 -0
- package/dist/core/env/render.js +65 -0
- package/dist/core/env/render.js.map +1 -0
- package/dist/core/env/report.d.ts +29 -0
- package/dist/core/env/report.js +39 -0
- package/dist/core/env/report.js.map +1 -0
- package/dist/core/env/scenarios.d.ts +40 -0
- package/dist/core/env/scenarios.js +124 -0
- package/dist/core/env/scenarios.js.map +1 -0
- package/dist/core/env/select.d.ts +30 -0
- package/dist/core/env/select.js +191 -0
- package/dist/core/env/select.js.map +1 -0
- package/dist/core/env/types.d.ts +38 -0
- package/dist/core/env/types.js +2 -0
- package/dist/core/env/types.js.map +1 -0
- package/dist/core/env/validate.d.ts +25 -0
- package/dist/core/env/validate.js +212 -0
- package/dist/core/env/validate.js.map +1 -0
- package/dist/core/factory/factory-yaml.d.ts +14 -1
- package/dist/core/factory/factory-yaml.js +166 -3
- package/dist/core/factory/factory-yaml.js.map +1 -1
- package/dist/core/factory/load.js +2 -0
- package/dist/core/factory/load.js.map +1 -1
- package/dist/core/factory/types.d.ts +14 -1
- package/dist/core/factory/validate.d.ts +5 -2
- package/dist/core/factory/validate.js +30 -11
- package/dist/core/factory/validate.js.map +1 -1
- package/dist/core/import/run.js +17 -0
- package/dist/core/import/run.js.map +1 -1
- package/dist/core/publish/git-target.js +35 -22
- package/dist/core/publish/git-target.js.map +1 -1
- package/dist/core/publish/npm-target.js +11 -4
- package/dist/core/publish/npm-target.js.map +1 -1
- package/dist/core/publish/package-json.d.ts +1 -1
- package/dist/core/publish/prepare.d.ts +11 -0
- package/dist/core/publish/prepare.js +11 -2
- package/dist/core/publish/prepare.js.map +1 -1
- package/dist/core/publish/publish.js +15 -2
- package/dist/core/publish/publish.js.map +1 -1
- package/dist/core/publish/readme.js +1 -4
- package/dist/core/publish/readme.js.map +1 -1
- package/dist/core/sources/cache.js +108 -44
- package/dist/core/sources/cache.js.map +1 -1
- package/dist/core/sources/extract.js +35 -72
- package/dist/core/sources/extract.js.map +1 -1
- package/dist/core/sources/git.js +48 -34
- package/dist/core/sources/git.js.map +1 -1
- package/dist/core/sources/https.js +23 -13
- package/dist/core/sources/https.js.map +1 -1
- package/dist/core/sources/npm-cli.js +8 -0
- package/dist/core/sources/npm-cli.js.map +1 -1
- package/dist/core/sources/npm.js +59 -34
- package/dist/core/sources/npm.js.map +1 -1
- package/dist/core/sources/parse.d.ts +20 -6
- package/dist/core/sources/parse.js +75 -18
- package/dist/core/sources/parse.js.map +1 -1
- package/dist/core/sources/path.js +24 -9
- package/dist/core/sources/path.js.map +1 -1
- package/dist/core/sources/problems.d.ts +29 -0
- package/dist/core/sources/problems.js +36 -0
- package/dist/core/sources/problems.js.map +1 -0
- package/dist/core/sources/types.d.ts +1 -1
- package/dist/core/sources/validate.js +18 -13
- package/dist/core/sources/validate.js.map +1 -1
- package/dist/core/summary.d.ts +5 -3
- package/dist/core/summary.js +8 -2
- package/dist/core/summary.js.map +1 -1
- package/dist/core/update/run.js +15 -12
- package/dist/core/update/run.js.map +1 -1
- package/dist/errors.d.ts +14 -4
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/help.d.ts +7 -2
- package/dist/help.js +16 -2
- package/dist/help.js.map +1 -1
- package/dist/input.js +1 -0
- package/dist/input.js.map +1 -1
- package/dist/output.d.ts +1 -1
- package/dist/util/fs.d.ts +6 -0
- package/dist/util/fs.js +9 -0
- package/dist/util/fs.js.map +1 -1
- package/dist/util/yaml.d.ts +1 -1
- package/package.json +2 -1
- package/resources/metafab-skill/SKILL.md +76 -2
- package/dist/commands/not-implemented.d.ts +0 -2
- package/dist/commands/not-implemented.js +0 -19
- package/dist/commands/not-implemented.js.map +0 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readdirTyped } from "../../util/fs.js";
|
|
4
|
+
import { toLF } from "../../util/text.js";
|
|
5
|
+
import { isInside, textContent } from "../build/skill.js";
|
|
6
|
+
import { directiveLines } from "./directives.js";
|
|
7
|
+
import { markdownParts } from "./markdown.js";
|
|
8
|
+
const FRONTMATTER_MESSAGE = "Directives are not allowed in frontmatter";
|
|
9
|
+
const FRONTMATTER_FIX = "Move the directive below the closing ---; name and description stay the same in every environment";
|
|
10
|
+
const NEEDS_PATH_FIX = "Write <!-- factory:import <path> -->";
|
|
11
|
+
const RELATIVE_FIX = "Write a path relative to this file, such as ../partials/x.md";
|
|
12
|
+
const SLASH_FIX = "Write it with / instead of \\";
|
|
13
|
+
const MARKDOWN_FIX = "Import a .md file, such as ../partials/x.md";
|
|
14
|
+
const INSIDE_FIX = "Import a file inside .factory/";
|
|
15
|
+
const MISSING_FIX = "Add the file, or write the path of a file in .factory/";
|
|
16
|
+
const DIRECTORY_FIX = "Import a .md file inside it";
|
|
17
|
+
const READ_FIX = "Check its permissions";
|
|
18
|
+
const TEXT_FIX = "Replace it with a UTF-8 text file";
|
|
19
|
+
const UNTERMINATED_FIX = "Add a line that contains only --- after the frontmatter";
|
|
20
|
+
/**
|
|
21
|
+
* A cache of imported files for one build or one `loadFactory`. Every file is
|
|
22
|
+
* keyed by its realpath, so an edited partial is always reread by the next run.
|
|
23
|
+
*/
|
|
24
|
+
export function createImportCache(factoryDir) {
|
|
25
|
+
return { factoryDir, files: new Map() };
|
|
26
|
+
}
|
|
27
|
+
function failure(message, fix) {
|
|
28
|
+
return { ok: false, message, fix };
|
|
29
|
+
}
|
|
30
|
+
function missing(given) {
|
|
31
|
+
return failure(`Import "${given}" does not exist`, MISSING_FIX);
|
|
32
|
+
}
|
|
33
|
+
function cannotRead(given) {
|
|
34
|
+
return failure(`Import "${given}" cannot be read`, READ_FIX);
|
|
35
|
+
}
|
|
36
|
+
/** A read error that means the path is not there, rather than that it is unreadable. */
|
|
37
|
+
function isMissing(error) {
|
|
38
|
+
const code = error.code;
|
|
39
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Rules 1 to 5 for an import: the path is relative to the importing file, uses
|
|
43
|
+
* `/`, ends in `.md`, and stays inside `.factory/` once normalised. Pure: it
|
|
44
|
+
* works on factory-relative POSIX paths only, so a Windows-style path gives the
|
|
45
|
+
* same answer on every platform and nothing here touches the disk.
|
|
46
|
+
*/
|
|
47
|
+
export function importTarget(from, argument) {
|
|
48
|
+
const given = argument.trim();
|
|
49
|
+
if (given === "")
|
|
50
|
+
return failure("factory:import needs a path", NEEDS_PATH_FIX);
|
|
51
|
+
if (path.win32.isAbsolute(given)) {
|
|
52
|
+
return failure(`Import path "${given}" must be relative to this file`, RELATIVE_FIX);
|
|
53
|
+
}
|
|
54
|
+
if (given.includes("\\"))
|
|
55
|
+
return failure(`Import path "${given}" must use /`, SLASH_FIX);
|
|
56
|
+
if (path.posix.extname(given).toLowerCase() !== ".md") {
|
|
57
|
+
return failure(`Import path "${given}" must name a .md file`, MARKDOWN_FIX);
|
|
58
|
+
}
|
|
59
|
+
const target = path.posix.normalize(`${path.posix.dirname(from)}/${given}`);
|
|
60
|
+
if (target === ".." || target.startsWith("../")) {
|
|
61
|
+
return failure(`Import "${given}" leaves .factory/`, INSIDE_FIX);
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, target };
|
|
64
|
+
}
|
|
65
|
+
async function factoryRealPath(cache) {
|
|
66
|
+
if (cache.factoryReal !== undefined)
|
|
67
|
+
return cache.factoryReal;
|
|
68
|
+
try {
|
|
69
|
+
cache.factoryReal = await realpath(cache.factoryDir);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return cache.factoryReal;
|
|
75
|
+
}
|
|
76
|
+
/** `.factory/<path>`, the name a file's own problems carry, from its realpath. */
|
|
77
|
+
function realFile(factoryReal, real) {
|
|
78
|
+
const relative = path.relative(factoryReal, real).split(path.sep).join("/");
|
|
79
|
+
return `.factory/${relative}`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The repository-relative `.factory/<path>` name of a realpath, for messages
|
|
83
|
+
* such as an import loop's chain.
|
|
84
|
+
*/
|
|
85
|
+
export function realDisplayPath(cache, real) {
|
|
86
|
+
return realFile(cache.factoryReal ?? cache.factoryDir, real);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Resolves an import to the file's realpath and its loaded content, reporting
|
|
90
|
+
* every path rule of the spec on the directive's line. The walk reads directory
|
|
91
|
+
* listings and matches names exactly, so a wrong-case path fails the same way on
|
|
92
|
+
* a case-insensitive file system as on a case-sensitive one. Symbolic links, for
|
|
93
|
+
* the file and for any parent, must resolve inside the real `.factory/`.
|
|
94
|
+
*/
|
|
95
|
+
export async function resolveImport(from, argument, cache) {
|
|
96
|
+
const target = importTarget(from, argument);
|
|
97
|
+
if (!target.ok)
|
|
98
|
+
return target;
|
|
99
|
+
const given = argument.trim();
|
|
100
|
+
const segments = target.target.split("/");
|
|
101
|
+
let current = cache.factoryDir;
|
|
102
|
+
let file = "";
|
|
103
|
+
let real;
|
|
104
|
+
for (const [index, segment] of segments.entries()) {
|
|
105
|
+
const last = index === segments.length - 1;
|
|
106
|
+
let entries;
|
|
107
|
+
try {
|
|
108
|
+
entries = await readdirTyped(current);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return isMissing(error) ? missing(given) : cannotRead(given);
|
|
112
|
+
}
|
|
113
|
+
const exact = entries.find((entry) => entry.name === segment);
|
|
114
|
+
const found = exact ?? entries.find((entry) => entry.name.toLowerCase() === segment.toLowerCase());
|
|
115
|
+
if (found === undefined)
|
|
116
|
+
return missing(given);
|
|
117
|
+
if (exact === undefined) {
|
|
118
|
+
const actual = [...segments.slice(0, index), found.name, ...segments.slice(index + 1)];
|
|
119
|
+
return failure(`Import "${given}" differs in letter case from "${found.name}"`, `Write "${actual.join("/")}"`);
|
|
120
|
+
}
|
|
121
|
+
const full = path.join(current, found.name);
|
|
122
|
+
if (!found.isSymbolicLink()) {
|
|
123
|
+
if (found.isDirectory()) {
|
|
124
|
+
if (last)
|
|
125
|
+
return failure(`Import "${given}" is a directory`, DIRECTORY_FIX);
|
|
126
|
+
current = full;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (!found.isFile())
|
|
130
|
+
return cannotRead(given);
|
|
131
|
+
if (!last)
|
|
132
|
+
return missing(given);
|
|
133
|
+
file = full;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
// A link may point anywhere, so its target is checked against the real
|
|
137
|
+
// `.factory/` before the walk continues by listing what it points to.
|
|
138
|
+
let resolved;
|
|
139
|
+
try {
|
|
140
|
+
resolved = await realpath(full);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return isMissing(error) ? missing(given) : cannotRead(given);
|
|
144
|
+
}
|
|
145
|
+
const factoryReal = await factoryRealPath(cache);
|
|
146
|
+
if (factoryReal === undefined)
|
|
147
|
+
return cannotRead(given);
|
|
148
|
+
if (!isInside(factoryReal, resolved)) {
|
|
149
|
+
return failure(`Import "${given}" resolves outside .factory/`, INSIDE_FIX);
|
|
150
|
+
}
|
|
151
|
+
let info;
|
|
152
|
+
try {
|
|
153
|
+
info = await stat(resolved);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return isMissing(error) ? missing(given) : cannotRead(given);
|
|
157
|
+
}
|
|
158
|
+
if (last) {
|
|
159
|
+
if (info.isDirectory())
|
|
160
|
+
return failure(`Import "${given}" is a directory`, DIRECTORY_FIX);
|
|
161
|
+
if (!info.isFile())
|
|
162
|
+
return cannotRead(given);
|
|
163
|
+
file = resolved;
|
|
164
|
+
real = resolved;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
if (!info.isDirectory())
|
|
168
|
+
return missing(given);
|
|
169
|
+
current = resolved;
|
|
170
|
+
}
|
|
171
|
+
if (real === undefined) {
|
|
172
|
+
try {
|
|
173
|
+
real = await realpath(file);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return isMissing(error) ? missing(given) : cannotRead(given);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const cached = cache.files.get(real);
|
|
180
|
+
if (cached !== undefined)
|
|
181
|
+
return { ok: true, real, loaded: cached };
|
|
182
|
+
let data;
|
|
183
|
+
try {
|
|
184
|
+
data = await readFile(file);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return cannotRead(given);
|
|
188
|
+
}
|
|
189
|
+
const decoded = textContent(data);
|
|
190
|
+
if (decoded === undefined) {
|
|
191
|
+
return failure(`Import "${given}" is not a UTF-8 text file`, TEXT_FIX);
|
|
192
|
+
}
|
|
193
|
+
const text = toLF(decoded.startsWith("\uFEFF") ? decoded.slice(1) : decoded);
|
|
194
|
+
const parts = markdownParts(text);
|
|
195
|
+
if (!parts.closed) {
|
|
196
|
+
return failure(`Import "${given}" has unterminated frontmatter`, UNTERMINATED_FIX);
|
|
197
|
+
}
|
|
198
|
+
const factoryReal = await factoryRealPath(cache);
|
|
199
|
+
if (factoryReal === undefined)
|
|
200
|
+
return cannotRead(given);
|
|
201
|
+
const problems = [];
|
|
202
|
+
if (parts.frontmatter !== undefined) {
|
|
203
|
+
const file = realFile(factoryReal, real);
|
|
204
|
+
for (const line of directiveLines(parts.frontmatter, 2)) {
|
|
205
|
+
problems.push({ level: "error", file, line, message: FRONTMATTER_MESSAGE, fix: FRONTMATTER_FIX });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const loaded = {
|
|
209
|
+
file: realFile(factoryReal, real),
|
|
210
|
+
text: parts.body.endsWith("\n") ? parts.body.slice(0, -1) : parts.body,
|
|
211
|
+
firstLine: parts.firstLine,
|
|
212
|
+
problems,
|
|
213
|
+
};
|
|
214
|
+
cache.files.set(real, loaded);
|
|
215
|
+
return { ok: true, real, loaded };
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../../../src/core/env/imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa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E,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/env/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface MarkdownParts {
|
|
2
|
+
/** The frontmatter lines, without their `---` fences, when the file starts with one. */
|
|
3
|
+
frontmatter?: string;
|
|
4
|
+
/** False when a file that starts with `---` has no closing `---` line. */
|
|
5
|
+
closed: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Everything before `body`, byte for byte, including the newline that ends a
|
|
8
|
+
* frontmatter block; "" when the file has none. `prefix + body` is `text`.
|
|
9
|
+
*/
|
|
10
|
+
prefix: string;
|
|
11
|
+
body: string;
|
|
12
|
+
/** Line number of the body's first line in the file. */
|
|
13
|
+
firstLine: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Splits frontmatter from body the way `build` handles every Markdown file it
|
|
17
|
+
* renders: a file that starts with a `---` line has frontmatter up to the next
|
|
18
|
+
* `---` line. Without a closing `---` the rest of the file is frontmatter, so no
|
|
19
|
+
* directive in it is live. Validation and rendering split with this one
|
|
20
|
+
* function, so a fence in frontmatter cannot hide a directive in the body.
|
|
21
|
+
*/
|
|
22
|
+
export declare function markdownParts(text: string): MarkdownParts;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits frontmatter from body the way `build` handles every Markdown file it
|
|
3
|
+
* renders: a file that starts with a `---` line has frontmatter up to the next
|
|
4
|
+
* `---` line. Without a closing `---` the rest of the file is frontmatter, so no
|
|
5
|
+
* directive in it is live. Validation and rendering split with this one
|
|
6
|
+
* function, so a fence in frontmatter cannot hide a directive in the body.
|
|
7
|
+
*/
|
|
8
|
+
export function markdownParts(text) {
|
|
9
|
+
const lines = text.split("\n");
|
|
10
|
+
if (lines[0] !== "---")
|
|
11
|
+
return { closed: true, prefix: "", body: text, firstLine: 1 };
|
|
12
|
+
const closing = lines.indexOf("---", 1);
|
|
13
|
+
if (closing === -1) {
|
|
14
|
+
return {
|
|
15
|
+
frontmatter: lines.slice(1).join("\n"),
|
|
16
|
+
closed: false,
|
|
17
|
+
prefix: text,
|
|
18
|
+
body: "",
|
|
19
|
+
firstLine: lines.length + 1,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const fence = lines.slice(0, closing + 1).join("\n");
|
|
23
|
+
return {
|
|
24
|
+
frontmatter: lines.slice(1, closing).join("\n"),
|
|
25
|
+
closed: true,
|
|
26
|
+
// A file that ends at its closing `---` has no newline to keep, so the
|
|
27
|
+
// prefix is the whole text and the body is empty.
|
|
28
|
+
prefix: closing === lines.length - 1 ? fence : `${fence}\n`,
|
|
29
|
+
body: lines.slice(closing + 1).join("\n"),
|
|
30
|
+
firstLine: closing + 2,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../src/core/env/markdown.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAEtF,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO;YACL,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACtC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,EAAE;YACR,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;SAC5B,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC/C,MAAM,EAAE,IAAI;QACZ,uEAAuE;QACvE,kDAAkD;QAClD,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI;QAC3D,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACzC,SAAS,EAAE,OAAO,GAAG,CAAC;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MarkdownDocument } from "./directives.js";
|
|
2
|
+
import type { EnvSelection, EnvVariable } from "./types.js";
|
|
3
|
+
export interface RenderContext {
|
|
4
|
+
variables: readonly EnvVariable[];
|
|
5
|
+
selection: EnvSelection;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a parsed Markdown document for the selection: a block that applies to
|
|
9
|
+
* every scenario is kept unlabelled, one that applies to none is removed, and a
|
|
10
|
+
* partial match is kept after its label line. Directive lines are gone already,
|
|
11
|
+
* and text lines are written unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderDocument(document: MarkdownDocument, context: RenderContext): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { classify } from "./scenarios.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a parsed Markdown document for the selection: a block that applies to
|
|
4
|
+
* every scenario is kept unlabelled, one that applies to none is removed, and a
|
|
5
|
+
* partial match is kept after its label line. Directive lines are gone already,
|
|
6
|
+
* and text lines are written unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export function renderDocument(document, context) {
|
|
9
|
+
return renderNodes(document.nodes, [], context).join("\n");
|
|
10
|
+
}
|
|
11
|
+
function renderNodes(nodes, enclosing, context) {
|
|
12
|
+
const lines = [];
|
|
13
|
+
for (const node of nodes) {
|
|
14
|
+
if (node.kind === "text") {
|
|
15
|
+
lines.push(node.text);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
// An import has no text of its own: its children are rendered in place,
|
|
19
|
+
// classified with the conditions that enclose the import line.
|
|
20
|
+
if (node.kind === "import") {
|
|
21
|
+
lines.push(...renderNodes(node.children, enclosing, context));
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (node.kind === "when") {
|
|
25
|
+
const applies = classify(node.condition, enclosing, context.selection, context.variables);
|
|
26
|
+
if (applies.kind === "none")
|
|
27
|
+
continue;
|
|
28
|
+
const inner = renderNodes(node.children, [...enclosing, node.condition], context);
|
|
29
|
+
if (inner.length === 0)
|
|
30
|
+
continue;
|
|
31
|
+
if (applies.kind === "some")
|
|
32
|
+
lines.push(`${node.indent}**${applies.label}:**`);
|
|
33
|
+
lines.push(...inner);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
for (const branch of node.branches) {
|
|
37
|
+
const condition = branchCondition(node, branch);
|
|
38
|
+
const applies = classify(condition, enclosing, context.selection, context.variables);
|
|
39
|
+
if (applies.kind === "none")
|
|
40
|
+
continue;
|
|
41
|
+
const inner = renderNodes(branch.children, [...enclosing, condition], context);
|
|
42
|
+
if (inner.length === 0)
|
|
43
|
+
continue;
|
|
44
|
+
if (applies.kind === "some")
|
|
45
|
+
lines.push(`${branch.indent}**${applies.label}:**`);
|
|
46
|
+
lines.push(...inner);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return lines;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A branch as the condition it stands for: `env.<variable> in [<its values>]`,
|
|
53
|
+
* and for `default` the negation over every value the switch's cases name.
|
|
54
|
+
*/
|
|
55
|
+
function branchCondition(node, branch) {
|
|
56
|
+
return {
|
|
57
|
+
kind: "test",
|
|
58
|
+
variable: node.variable,
|
|
59
|
+
values: branch.kind === "case"
|
|
60
|
+
? [...branch.values]
|
|
61
|
+
: node.branches.flatMap((entry) => entry.values),
|
|
62
|
+
negate: branch.kind === "default",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/env/render.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU1C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAA0B,EAAE,OAAsB;IAC/E,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,WAAW,CAClB,KAAsB,EACtB,SAA+B,EAC/B,OAAsB;IAEtB,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,SAAS;QACX,CAAC;QAED,wEAAwE;QAC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AS,CAAC,EAAE,OAAO,CAAC,CAAC;YAC/E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YACjC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC;YACjF,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAgB,EAAE,MAAc;IACvD,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EACJ,MAAM,CAAC,IAAI,KAAK,MAAM;YACpB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;YACpB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,SAAS;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { EnvVariable, GitConfigScope, ResolvedSelection, SelectionSource } from "./types.js";
|
|
2
|
+
export interface EnvValueReport {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
/** One variable of `metafab env` and `build --json`'s `env`. */
|
|
7
|
+
export interface EnvVariableReport {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
values: EnvValueReport[];
|
|
11
|
+
/** Value names, in the order `values` declares them. */
|
|
12
|
+
selected: string[];
|
|
13
|
+
source: SelectionSource;
|
|
14
|
+
/** The Git config scope, for `git`. */
|
|
15
|
+
scope?: GitConfigScope;
|
|
16
|
+
/** The `FACTORY_ENV_<VAR>` variable that supplied the selection, for `environment`. */
|
|
17
|
+
from?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The `variables` list `env` reports and `build --json` adds, in declaration
|
|
21
|
+
* order, with each variable's values and where its selection came from.
|
|
22
|
+
*/
|
|
23
|
+
export declare function describeSelection(variables: readonly EnvVariable[], resolved: ResolvedSelection): EnvVariableReport[];
|
|
24
|
+
/** The source words `metafab env` prints in its last column. */
|
|
25
|
+
export declare function sourceWord(resolved: {
|
|
26
|
+
source: SelectionSource;
|
|
27
|
+
scope?: GitConfigScope;
|
|
28
|
+
from?: string;
|
|
29
|
+
}): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `variables` list `env` reports and `build --json` adds, in declaration
|
|
3
|
+
* order, with each variable's values and where its selection came from.
|
|
4
|
+
*/
|
|
5
|
+
export function describeSelection(variables, resolved) {
|
|
6
|
+
const byName = new Map(resolved.variables.map((variable) => [variable.variable, variable]));
|
|
7
|
+
const reports = [];
|
|
8
|
+
for (const variable of variables) {
|
|
9
|
+
const selection = byName.get(variable.name);
|
|
10
|
+
if (selection === undefined)
|
|
11
|
+
continue;
|
|
12
|
+
reports.push({
|
|
13
|
+
name: variable.name,
|
|
14
|
+
...(variable.description === undefined ? {} : { description: variable.description }),
|
|
15
|
+
values: variable.values.map((value) => ({ name: value.name, label: value.label })),
|
|
16
|
+
selected: [...selection.values],
|
|
17
|
+
source: selection.source,
|
|
18
|
+
...(selection.scope === undefined ? {} : { scope: selection.scope }),
|
|
19
|
+
...(selection.from === undefined ? {} : { from: selection.from }),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return reports;
|
|
23
|
+
}
|
|
24
|
+
/** The source words `metafab env` prints in its last column. */
|
|
25
|
+
export function sourceWord(resolved) {
|
|
26
|
+
switch (resolved.source) {
|
|
27
|
+
case "option":
|
|
28
|
+
return "--env";
|
|
29
|
+
case "environment":
|
|
30
|
+
return resolved.from ?? "process environment";
|
|
31
|
+
case "git":
|
|
32
|
+
return `Git config (${resolved.scope ?? "unknown"})`;
|
|
33
|
+
case "default":
|
|
34
|
+
return "default in factory.yaml";
|
|
35
|
+
case "all":
|
|
36
|
+
return "every value (nothing selected)";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/core/env/report.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAiC,EACjC,QAA2B;IAE3B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5F,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,SAAS,KAAK,SAAS;YAAE,SAAS;QAEtC,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,GAAG,CAAC,QAAQ,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;YACpF,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAClF,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;YAC/B,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,GAAG,CAAC,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC;YACpE,GAAG,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;SAClE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,UAAU,CAAC,QAI1B;IACC,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,QAAQ,CAAC,IAAI,IAAI,qBAAqB,CAAC;QAChD,KAAK,KAAK;YACR,OAAO,eAAe,QAAQ,CAAC,KAAK,IAAI,SAAS,GAAG,CAAC;QACvD,KAAK,SAAS;YACZ,OAAO,yBAAyB,CAAC;QACnC,KAAK,KAAK;YACR,OAAO,gCAAgC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Condition } from "./condition.js";
|
|
2
|
+
import type { EnvSelection, EnvVariable } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The most scenarios a block may span over the variables it and its enclosing
|
|
5
|
+
* conditions name. A document that needs more is an error, so rendering and the
|
|
6
|
+
* all-values root block stay cheap however many variables a factory declares.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_COMBINATIONS = 1024;
|
|
9
|
+
/** One selected value for each of a block's variables. */
|
|
10
|
+
export type Scenario = ReadonlyMap<string, string>;
|
|
11
|
+
/** How a block applies to the selection. */
|
|
12
|
+
export type Applies = {
|
|
13
|
+
kind: "all";
|
|
14
|
+
} | {
|
|
15
|
+
kind: "none";
|
|
16
|
+
} | {
|
|
17
|
+
kind: "some";
|
|
18
|
+
label: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Product of the declared value counts of `variables`: the all-values case,
|
|
22
|
+
* independent of the selection. A variable the factory does not declare has no
|
|
23
|
+
* declared values, so the product is 0.
|
|
24
|
+
*/
|
|
25
|
+
export declare function combinations(variables: Iterable<string>, declared: readonly EnvVariable[]): number;
|
|
26
|
+
/**
|
|
27
|
+
* Every scenario over `variables`, in declaration order: the product of the
|
|
28
|
+
* selected values, with the first variable varying slowest. A variable the
|
|
29
|
+
* selection does not give a value for contributes none.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scenarios(selection: EnvSelection, variables: Iterable<string>): Scenario[];
|
|
32
|
+
/**
|
|
33
|
+
* Classifies a condition in the scenarios where its enclosing conditions are
|
|
34
|
+
* true: `all` when it holds in every one, `none` when it holds in none, else
|
|
35
|
+
* `some` with the label its kept text takes. No other variable is enumerated,
|
|
36
|
+
* because no other variable can change the result.
|
|
37
|
+
*/
|
|
38
|
+
export declare function classify(condition: Condition, enclosing: readonly Condition[], selection: EnvSelection, variables: readonly EnvVariable[]): Applies;
|
|
39
|
+
/** The selection with every declared value of every variable: the root `AGENTS.md` render. */
|
|
40
|
+
export declare function allValues(variables: readonly EnvVariable[]): EnvSelection;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { conditionVariables, evaluate } from "./condition.js";
|
|
2
|
+
/**
|
|
3
|
+
* The most scenarios a block may span over the variables it and its enclosing
|
|
4
|
+
* conditions name. A document that needs more is an error, so rendering and the
|
|
5
|
+
* all-values root block stay cheap however many variables a factory declares.
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_COMBINATIONS = 1024;
|
|
8
|
+
/**
|
|
9
|
+
* Product of the declared value counts of `variables`: the all-values case,
|
|
10
|
+
* independent of the selection. A variable the factory does not declare has no
|
|
11
|
+
* declared values, so the product is 0.
|
|
12
|
+
*/
|
|
13
|
+
export function combinations(variables, declared) {
|
|
14
|
+
const counts = new Map(declared.map((variable) => [variable.name, variable.values.length]));
|
|
15
|
+
let total = 1;
|
|
16
|
+
for (const name of variables) {
|
|
17
|
+
const count = counts.get(name);
|
|
18
|
+
if (count === undefined)
|
|
19
|
+
return 0;
|
|
20
|
+
total *= count;
|
|
21
|
+
if (total > Number.MAX_SAFE_INTEGER)
|
|
22
|
+
return Number.MAX_SAFE_INTEGER;
|
|
23
|
+
}
|
|
24
|
+
return total;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every scenario over `variables`, in declaration order: the product of the
|
|
28
|
+
* selected values, with the first variable varying slowest. A variable the
|
|
29
|
+
* selection does not give a value for contributes none.
|
|
30
|
+
*/
|
|
31
|
+
export function scenarios(selection, variables) {
|
|
32
|
+
let result = [new Map()];
|
|
33
|
+
for (const name of variables) {
|
|
34
|
+
const values = selection.get(name) ?? [];
|
|
35
|
+
const next = [];
|
|
36
|
+
for (const scenario of result) {
|
|
37
|
+
for (const value of values) {
|
|
38
|
+
const extended = new Map(scenario);
|
|
39
|
+
extended.set(name, value);
|
|
40
|
+
next.push(extended);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
result = next;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Classifies a condition in the scenarios where its enclosing conditions are
|
|
49
|
+
* true: `all` when it holds in every one, `none` when it holds in none, else
|
|
50
|
+
* `some` with the label its kept text takes. No other variable is enumerated,
|
|
51
|
+
* because no other variable can change the result.
|
|
52
|
+
*/
|
|
53
|
+
export function classify(condition, enclosing, selection, variables) {
|
|
54
|
+
const named = conditionVariables(condition);
|
|
55
|
+
for (const outer of enclosing) {
|
|
56
|
+
for (const name of conditionVariables(outer))
|
|
57
|
+
named.add(name);
|
|
58
|
+
}
|
|
59
|
+
const context = scenarios(selection, declarationOrder(named, variables)).filter((scenario) => enclosing.every((outer) => evaluate(outer, scenario)));
|
|
60
|
+
if (context.length === 0)
|
|
61
|
+
return { kind: "none" };
|
|
62
|
+
const kept = context.filter((scenario) => evaluate(condition, scenario));
|
|
63
|
+
if (kept.length === context.length)
|
|
64
|
+
return { kind: "all" };
|
|
65
|
+
if (kept.length === 0)
|
|
66
|
+
return { kind: "none" };
|
|
67
|
+
return { kind: "some", label: labelFor(condition, context, kept, variables) };
|
|
68
|
+
}
|
|
69
|
+
/** The selection with every declared value of every variable: the root `AGENTS.md` render. */
|
|
70
|
+
export function allValues(variables) {
|
|
71
|
+
return new Map(variables.map((variable) => [variable.name, variable.values.map((value) => value.name)]));
|
|
72
|
+
}
|
|
73
|
+
/** The declared variables a set of names names, in `env` order. */
|
|
74
|
+
function declarationOrder(named, variables) {
|
|
75
|
+
return variables.map((variable) => variable.name).filter((name) => named.has(name));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The label a partially matching block takes, as the spec's Rendering section
|
|
79
|
+
* builds it: each of the condition's variables that takes more than one value
|
|
80
|
+
* in the context and is not true for every one of them contributes the labels
|
|
81
|
+
* of the values it can be true for, joined with ` or `. When that names no
|
|
82
|
+
* variable, every combination of the condition's variables for which it is true
|
|
83
|
+
* is listed instead.
|
|
84
|
+
*/
|
|
85
|
+
function labelFor(condition, context, kept, variables) {
|
|
86
|
+
const own = conditionVariables(condition);
|
|
87
|
+
const parts = [];
|
|
88
|
+
for (const variable of variables) {
|
|
89
|
+
if (!own.has(variable.name))
|
|
90
|
+
continue;
|
|
91
|
+
const possible = new Set(context.map((scenario) => scenario.get(variable.name)));
|
|
92
|
+
if (possible.size < 2)
|
|
93
|
+
continue;
|
|
94
|
+
const reachable = new Set(kept.map((scenario) => scenario.get(variable.name)));
|
|
95
|
+
if (reachable.size === possible.size)
|
|
96
|
+
continue;
|
|
97
|
+
const labels = variable.values
|
|
98
|
+
.filter((value) => reachable.has(value.name))
|
|
99
|
+
.map((value) => value.label);
|
|
100
|
+
if (labels.length > 0)
|
|
101
|
+
parts.push(labels.join(" or "));
|
|
102
|
+
}
|
|
103
|
+
if (parts.length > 0)
|
|
104
|
+
return parts.join(", and ");
|
|
105
|
+
const ownVariables = variables.filter((variable) => own.has(variable.name));
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const listed = [];
|
|
108
|
+
for (const scenario of kept) {
|
|
109
|
+
const names = ownVariables.map((variable) => scenario.get(variable.name) ?? "");
|
|
110
|
+
const key = names.join("\u0000");
|
|
111
|
+
if (seen.has(key))
|
|
112
|
+
continue;
|
|
113
|
+
seen.add(key);
|
|
114
|
+
listed.push(ownVariables
|
|
115
|
+
.map((variable, index) => {
|
|
116
|
+
const name = names[index] ?? "";
|
|
117
|
+
return (variable.values.find((value) => value.name === name)?.label ??
|
|
118
|
+
`When ${variable.name} is ${name}`);
|
|
119
|
+
})
|
|
120
|
+
.join(", and "));
|
|
121
|
+
}
|
|
122
|
+
return listed.join(" or ");
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../../src/core/env/scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAQrC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA2B,EAC3B,QAAgC;IAEhC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,I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