@sublang/spex 4.2.0 → 6.0.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/README.md +438 -89
- package/dist/cli.js +80 -42
- package/dist/commands/add.d.ts +12 -0
- package/dist/commands/add.js +138 -0
- package/dist/commands/auth-target.d.ts +12 -0
- package/dist/commands/auth-target.js +52 -0
- package/dist/commands/environment.d.ts +117 -0
- package/dist/commands/environment.js +399 -0
- package/dist/commands/export.d.ts +21 -0
- package/dist/commands/export.js +663 -0
- package/dist/commands/home.d.ts +56 -0
- package/dist/commands/home.js +215 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +48 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +87 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +211 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +74 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +120 -0
- package/dist/commands/remove.d.ts +2 -0
- package/dist/commands/remove.js +34 -0
- package/dist/commands/run.d.ts +50 -0
- package/dist/commands/run.js +312 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.js +34 -0
- package/dist/commands/settle.d.ts +124 -0
- package/dist/commands/settle.js +475 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +37 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.js +71 -0
- package/dist/lib/environment/agent-folders.d.ts +14 -0
- package/dist/lib/environment/agent-folders.js +11 -0
- package/dist/lib/environment/archive.d.ts +39 -0
- package/dist/lib/environment/archive.js +122 -0
- package/dist/lib/environment/builtins.d.ts +112 -0
- package/dist/lib/environment/builtins.js +539 -0
- package/dist/lib/environment/citations.d.ts +75 -0
- package/dist/lib/environment/citations.js +267 -0
- package/dist/lib/environment/exports.d.ts +190 -0
- package/dist/lib/environment/exports.js +1029 -0
- package/dist/lib/environment/format.d.ts +133 -0
- package/dist/lib/environment/format.js +651 -0
- package/dist/lib/environment/git-source.d.ts +41 -0
- package/dist/lib/environment/git-source.js +159 -0
- package/dist/lib/environment/index.d.ts +20 -0
- package/dist/lib/environment/index.js +27 -0
- package/dist/lib/environment/install.d.ts +140 -0
- package/dist/lib/environment/install.js +694 -0
- package/dist/lib/environment/layout.d.ts +15 -0
- package/dist/lib/environment/layout.js +50 -0
- package/dist/lib/environment/lock.d.ts +87 -0
- package/dist/lib/environment/lock.js +305 -0
- package/dist/lib/environment/marker.d.ts +15 -0
- package/dist/lib/environment/marker.js +31 -0
- package/dist/lib/environment/own-paths.d.ts +59 -0
- package/dist/lib/environment/own-paths.js +174 -0
- package/dist/lib/environment/placed-record.d.ts +32 -0
- package/dist/lib/environment/placed-record.js +72 -0
- package/dist/lib/environment/registries.d.ts +23 -0
- package/dist/lib/environment/registries.js +48 -0
- package/dist/lib/environment/registry.d.ts +172 -0
- package/dist/lib/environment/registry.js +390 -0
- package/dist/lib/environment/requests.d.ts +109 -0
- package/dist/lib/environment/requests.js +401 -0
- package/dist/lib/environment/resolve.d.ts +70 -0
- package/dist/lib/environment/resolve.js +451 -0
- package/dist/lib/environment/semver.d.ts +30 -0
- package/dist/lib/environment/semver.js +130 -0
- package/dist/lib/environment/store.d.ts +23 -0
- package/dist/lib/environment/store.js +123 -0
- package/dist/lib/environment/tar.d.ts +27 -0
- package/dist/lib/environment/tar.js +219 -0
- package/dist/lib/files.d.ts +66 -0
- package/dist/lib/files.js +233 -0
- package/dist/lib/git-host.d.ts +579 -0
- package/dist/lib/git-host.js +1363 -0
- package/dist/lib/home-file.d.ts +124 -0
- package/dist/lib/home-file.js +288 -0
- package/dist/lib/instance.d.ts +63 -0
- package/dist/lib/instance.js +130 -0
- package/dist/lib/words.d.ts +32 -0
- package/dist/lib/words.js +27 -0
- package/dist/lint.js +8 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/standin-registry.d.ts +94 -0
- package/dist/testing/standin-registry.js +449 -0
- package/package.json +37 -3
- package/dist/attached-cli.d.ts +0 -13
- package/dist/attached-cli.js +0 -249
- package/dist/attached-client.d.ts +0 -53
- package/dist/attached-client.js +0 -237
- package/dist/generated-protocol.d.ts +0 -2
- package/dist/generated-protocol.js +0 -6
- package/dist/package-init.d.ts +0 -21
- package/dist/package-init.js +0 -442
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
// The spec package format (environments-1, DR-104): a release is a
|
|
4
|
+
// folder with a `meta.yaml` manifest of `format: 2`, the three root
|
|
5
|
+
// files, and one folder per artifact — `sources/`, `specs/`, `skills/`
|
|
6
|
+
// and `playbooks/` by language, `applets/` without one. The core reads
|
|
7
|
+
// a release from the registry, a Git commit, a path inside a working
|
|
8
|
+
// folder or the app's built-in spec package through these checks, and
|
|
9
|
+
// refuses any other with every reason it finds. The manifest's
|
|
10
|
+
// `provides` says which of its artifacts the release offers the project
|
|
11
|
+
// (DR-174).
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { lstat, readdir, readFile } from "node:fs/promises";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { parseDocument, stringify } from "yaml";
|
|
17
|
+
import { isRequirement, isVersion } from "./semver.js";
|
|
18
|
+
export const ARTIFACT_KINDS = ["source", "spec", "skill", "playbook", "applet"];
|
|
19
|
+
export class FormatError extends Error {
|
|
20
|
+
issues;
|
|
21
|
+
constructor(issues, subject = "release") {
|
|
22
|
+
super(`${subject} refused: ${issues.map((issue) => (issue.path ? `${issue.path}: ${issue.message}` : issue.message)).join("; ")}`);
|
|
23
|
+
this.issues = issues;
|
|
24
|
+
this.name = "FormatError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export const ROOT_FILES = ["meta.yaml", "README.md", "LICENSE"];
|
|
28
|
+
export const KIND_FOLDERS = {
|
|
29
|
+
source: "sources",
|
|
30
|
+
spec: "specs",
|
|
31
|
+
skill: "skills",
|
|
32
|
+
playbook: "playbooks",
|
|
33
|
+
applet: "applets",
|
|
34
|
+
};
|
|
35
|
+
const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
36
|
+
/** A lowercase kebab-case name of at most 64 characters: an org, a
|
|
37
|
+
* package, and — by the same rule — an Agent Skills name. */
|
|
38
|
+
export function isKebabName(value) {
|
|
39
|
+
return typeof value === "string" && value.length <= 64 && NAME_RE.test(value);
|
|
40
|
+
}
|
|
41
|
+
/** An Agent Skills name: a skill's or a playbook's id, or an alias. */
|
|
42
|
+
export const isSkillName = isKebabName;
|
|
43
|
+
export function isPackageName(value) {
|
|
44
|
+
if (typeof value !== "string")
|
|
45
|
+
return false;
|
|
46
|
+
const parts = value.split("/");
|
|
47
|
+
return parts.length === 2 && isKebabName(parts[0]) && isKebabName(parts[1]);
|
|
48
|
+
}
|
|
49
|
+
export function parsePackageName(name) {
|
|
50
|
+
if (!isPackageName(name))
|
|
51
|
+
throw new FormatError([{ rule: "name", message: `"${name}" is not a <org>/<pkg> name` }], "name");
|
|
52
|
+
const [org, pkg] = name.split("/");
|
|
53
|
+
return { org, pkg };
|
|
54
|
+
}
|
|
55
|
+
// BCP 47's langtag in its common form, or a private-use tag (RFC 5646
|
|
56
|
+
// §2.1); grandfathered tags are not taken.
|
|
57
|
+
const LANGTAG_RE = new RegExp("^(?:" +
|
|
58
|
+
"(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})" +
|
|
59
|
+
"(?:-[a-z]{4})?" +
|
|
60
|
+
"(?:-(?:[a-z]{2}|\\d{3}))?" +
|
|
61
|
+
"(?:-(?:[a-z\\d]{5,8}|\\d[a-z\\d]{3}))*" +
|
|
62
|
+
"(?:-[\\da-wyz](?:-[a-z\\d]{2,8})+)*" +
|
|
63
|
+
"(?:-x(?:-[a-z\\d]{1,8})+)?" +
|
|
64
|
+
"|x(?:-[a-z\\d]{1,8})+" +
|
|
65
|
+
")$", "i");
|
|
66
|
+
/** A well-formed BCP 47 tag, such as `en` or `zh-Hans`. */
|
|
67
|
+
export function isLanguageTag(value) {
|
|
68
|
+
return typeof value === "string" && value.length <= 64 && LANGTAG_RE.test(value);
|
|
69
|
+
}
|
|
70
|
+
const DEVICE_RE = /^(?:con|prn|aux|nul|com[0-9\u00b9\u00b2\u00b3]|lpt[0-9\u00b9\u00b2\u00b3])(?:\..*)?$/i;
|
|
71
|
+
// eslint-disable-next-line no-control-regex
|
|
72
|
+
const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/;
|
|
73
|
+
const RESERVED_RE = /[\\:*?"<>|]/;
|
|
74
|
+
/** Compare key for "unique after NFC and case folding". */
|
|
75
|
+
export function foldPath(path) {
|
|
76
|
+
return path.normalize("NFC").toUpperCase().toLowerCase().normalize("NFC");
|
|
77
|
+
}
|
|
78
|
+
/** Every portable-path rule a list of release paths breaks. */
|
|
79
|
+
export function portablePathIssues(paths) {
|
|
80
|
+
const issues = [];
|
|
81
|
+
const files = new Map();
|
|
82
|
+
const directories = new Map();
|
|
83
|
+
for (const path of paths) {
|
|
84
|
+
if (path === "" || path.startsWith("/") || path.endsWith("/")) {
|
|
85
|
+
issues.push({ path, rule: "path", message: "not a relative file path" });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const components = path.split("/");
|
|
89
|
+
let bad = false;
|
|
90
|
+
for (const component of components) {
|
|
91
|
+
const reason = component === "" ? "has an empty component"
|
|
92
|
+
: Buffer.byteLength(component, "utf8") > 255 ? "has a component over 255 bytes"
|
|
93
|
+
: CONTROL_RE.test(component) ? "has a control character"
|
|
94
|
+
: RESERVED_RE.test(component) ? "has one of \\ : * ? \" < > |"
|
|
95
|
+
: /[. ]$/.test(component) ? "has a component ending in a dot or space"
|
|
96
|
+
: DEVICE_RE.test(component) ? `has the Windows device name "${component}"`
|
|
97
|
+
: undefined;
|
|
98
|
+
if (reason) {
|
|
99
|
+
issues.push({ path, rule: "path", message: `is not portable: ${reason}` });
|
|
100
|
+
bad = true;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (bad)
|
|
105
|
+
continue;
|
|
106
|
+
const key = foldPath(path);
|
|
107
|
+
const clash = files.get(key) ?? directories.get(key);
|
|
108
|
+
if (clash !== undefined) {
|
|
109
|
+
issues.push({ path, rule: "path", message: `is not unique after NFC and case folding: it collides with ${clash}` });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
files.set(key, path);
|
|
113
|
+
for (let i = 1; i < components.length; i += 1) {
|
|
114
|
+
const directory = components.slice(0, i).join("/");
|
|
115
|
+
const directoryKey = foldPath(directory);
|
|
116
|
+
const fileClash = files.get(directoryKey);
|
|
117
|
+
if (fileClash !== undefined) {
|
|
118
|
+
issues.push({ path, rule: "path", message: `is not unique after NFC and case folding: its folder collides with ${fileClash}` });
|
|
119
|
+
}
|
|
120
|
+
if (!directories.has(directoryKey))
|
|
121
|
+
directories.set(directoryKey, directory);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return issues;
|
|
125
|
+
}
|
|
126
|
+
function isPlainObject(value) {
|
|
127
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
128
|
+
}
|
|
129
|
+
const MANIFEST_FIELDS = new Set(["format", "org", "name", "version", "description", "license", "repository", "dependencies", "provides", "artifacts"]);
|
|
130
|
+
const ARTIFACT_FIELDS = new Set(["kind", "language", "from", "requires", "generated-by"]);
|
|
131
|
+
function isExtension(key) {
|
|
132
|
+
return key.startsWith("x-");
|
|
133
|
+
}
|
|
134
|
+
/** Read a parsed `meta.yaml` value as a manifest of `format: 2`. */
|
|
135
|
+
export function parseManifest(raw) {
|
|
136
|
+
const at = "meta.yaml";
|
|
137
|
+
const issues = [];
|
|
138
|
+
if (!isPlainObject(raw))
|
|
139
|
+
return { manifest: null, issues: [{ path: at, rule: "manifest", message: "meta.yaml is not a mapping" }] };
|
|
140
|
+
if (raw.format !== 2) {
|
|
141
|
+
return { manifest: null, issues: [{ path: at, rule: "format", message: `format ${JSON.stringify(raw.format ?? null)} is not the known format 2` }] };
|
|
142
|
+
}
|
|
143
|
+
for (const key of Object.keys(raw)) {
|
|
144
|
+
if (!MANIFEST_FIELDS.has(key) && !isExtension(key))
|
|
145
|
+
issues.push({ path: at, rule: "field", message: `unknown field "${key}"` });
|
|
146
|
+
}
|
|
147
|
+
for (const key of ["org", "name"]) {
|
|
148
|
+
if (!isKebabName(raw[key]))
|
|
149
|
+
issues.push({ path: at, rule: "name", message: `${key} ${JSON.stringify(raw[key] ?? null)} is not a lowercase kebab-case name of at most 64 characters` });
|
|
150
|
+
}
|
|
151
|
+
if (!isVersion(raw.version))
|
|
152
|
+
issues.push({ path: at, rule: "version", message: `version ${JSON.stringify(raw.version ?? null)} is not a Semantic Versioning 2.0.0 version` });
|
|
153
|
+
for (const key of ["description", "license", "repository"]) {
|
|
154
|
+
if (raw[key] !== undefined && typeof raw[key] !== "string")
|
|
155
|
+
issues.push({ path: at, rule: "field", message: `${key} is not a string` });
|
|
156
|
+
}
|
|
157
|
+
const dependencies = {};
|
|
158
|
+
if (raw.dependencies !== undefined && raw.dependencies !== null) {
|
|
159
|
+
if (!isPlainObject(raw.dependencies)) {
|
|
160
|
+
issues.push({ path: at, rule: "dependency", message: "dependencies is not a mapping" });
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
for (const [name, requirement] of Object.entries(raw.dependencies)) {
|
|
164
|
+
if (!isPackageName(name))
|
|
165
|
+
issues.push({ path: at, rule: "dependency", message: `dependency "${name}" is not a <org>/<pkg> name` });
|
|
166
|
+
else if (name === `${String(raw.org)}/${String(raw.name)}`)
|
|
167
|
+
issues.push({ path: at, rule: "dependency", message: `${name} depends on itself` });
|
|
168
|
+
if (isPlainObject(requirement) && "mode" in requirement) {
|
|
169
|
+
issues.push({ path: at, rule: "dependency", message: `dependency ${name} carries mode, which DR-104 retired: give a version requirement` });
|
|
170
|
+
}
|
|
171
|
+
else if (!isRequirement(requirement)) {
|
|
172
|
+
issues.push({ path: at, rule: "dependency", message: `dependency ${name} requirement ${JSON.stringify(requirement)} is not 1.2.3, ^1.2.3 or ~1.2.3` });
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
dependencies[name] = requirement;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const artifacts = {};
|
|
181
|
+
if (!isPlainObject(raw.artifacts) || Object.keys(raw.artifacts).length === 0) {
|
|
182
|
+
issues.push({ path: at, rule: "artifact", message: "artifacts must name at least one artifact" });
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
for (const [id, entry] of Object.entries(raw.artifacts)) {
|
|
186
|
+
if (id === "" || id.includes("/") || id === "." || id === "..") {
|
|
187
|
+
issues.push({ path: at, rule: "artifact", message: `artifact id "${id}" is not a folder name` });
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (!isPlainObject(entry)) {
|
|
191
|
+
issues.push({ path: at, rule: "artifact", message: `artifact ${id} is not a mapping` });
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const key of Object.keys(entry)) {
|
|
195
|
+
if (!ARTIFACT_FIELDS.has(key) && !isExtension(key))
|
|
196
|
+
issues.push({ path: at, rule: "field", message: `artifact ${id} has unknown field "${key}"` });
|
|
197
|
+
}
|
|
198
|
+
const kind = entry.kind;
|
|
199
|
+
if (typeof kind !== "string" || !ARTIFACT_KINDS.includes(kind)) {
|
|
200
|
+
issues.push({ path: at, rule: "kind", message: `artifact ${id} kind ${JSON.stringify(kind ?? null)} is not one of ${ARTIFACT_KINDS.join(", ")}` });
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (entry.language !== undefined && typeof entry.language !== "string")
|
|
204
|
+
issues.push({ path: at, rule: "language", message: `artifact ${id} language is not a string` });
|
|
205
|
+
if (entry.from !== undefined && typeof entry.from !== "string")
|
|
206
|
+
issues.push({ path: at, rule: "from", message: `artifact ${id} from is not an artifact id` });
|
|
207
|
+
const requires = entry.requires ?? [];
|
|
208
|
+
if (!Array.isArray(requires) || !requires.every((item) => typeof item === "string")) {
|
|
209
|
+
issues.push({ path: at, rule: "requires", message: `artifact ${id} requires is not a list of artifact ids` });
|
|
210
|
+
}
|
|
211
|
+
const generated = entry["generated-by"];
|
|
212
|
+
if (generated !== undefined && !(isPlainObject(generated) && typeof generated.agent === "string" && typeof generated.model === "string"
|
|
213
|
+
&& Object.keys(generated).every((key) => key === "agent" || key === "model" || isExtension(key)))) {
|
|
214
|
+
issues.push({ path: at, rule: "field", message: `artifact ${id} generated-by is not {agent, model}` });
|
|
215
|
+
}
|
|
216
|
+
artifacts[id] = {
|
|
217
|
+
kind: kind,
|
|
218
|
+
...(typeof entry.language === "string" ? { language: entry.language } : {}),
|
|
219
|
+
...(typeof entry.from === "string" ? { from: entry.from } : {}),
|
|
220
|
+
requires: Array.isArray(requires) ? requires.filter((item) => typeof item === "string") : [],
|
|
221
|
+
...(isPlainObject(generated) && typeof generated.agent === "string" && typeof generated.model === "string"
|
|
222
|
+
? { generatedBy: { agent: generated.agent, model: generated.model } } : {}),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// The kinds the project is offered (environments-1, DR-174): a
|
|
227
|
+
// nonempty list of the five kinds, a kind listed twice read once.
|
|
228
|
+
let provides;
|
|
229
|
+
if (raw.provides !== undefined) {
|
|
230
|
+
if (!Array.isArray(raw.provides)) {
|
|
231
|
+
issues.push({ path: at, rule: "provides", message: "provides is not a list of artifact kinds" });
|
|
232
|
+
}
|
|
233
|
+
else if (raw.provides.length === 0) {
|
|
234
|
+
issues.push({ path: at, rule: "provides", message: "provides is an empty list — list the kinds the package provides, or leave it out" });
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
provides = [];
|
|
238
|
+
for (const kind of raw.provides) {
|
|
239
|
+
if (typeof kind !== "string" || !ARTIFACT_KINDS.includes(kind)) {
|
|
240
|
+
issues.push({ path: at, rule: "provides", message: `provides kind ${JSON.stringify(kind ?? null)} is not one of ${ARTIFACT_KINDS.join(", ")}` });
|
|
241
|
+
}
|
|
242
|
+
else if (!provides.includes(kind)) {
|
|
243
|
+
provides.push(kind);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (issues.length > 0)
|
|
249
|
+
return { manifest: null, issues };
|
|
250
|
+
return {
|
|
251
|
+
manifest: {
|
|
252
|
+
format: 2,
|
|
253
|
+
org: raw.org,
|
|
254
|
+
name: raw.name,
|
|
255
|
+
version: raw.version,
|
|
256
|
+
...(typeof raw.description === "string" ? { description: raw.description } : {}),
|
|
257
|
+
...(typeof raw.license === "string" ? { license: raw.license } : {}),
|
|
258
|
+
...(typeof raw.repository === "string" ? { repository: raw.repository } : {}),
|
|
259
|
+
dependencies,
|
|
260
|
+
...(provides !== undefined ? { provides } : {}),
|
|
261
|
+
artifacts,
|
|
262
|
+
},
|
|
263
|
+
issues,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** Parse `meta.yaml` text, YAML errors reported as issues. */
|
|
267
|
+
export function parseManifestText(text) {
|
|
268
|
+
const doc = parseDocument(text, { prettyErrors: false, uniqueKeys: true });
|
|
269
|
+
if (doc.errors.length > 0) {
|
|
270
|
+
return { manifest: null, issues: doc.errors.map((error) => ({ path: "meta.yaml", rule: "manifest", message: error.message })) };
|
|
271
|
+
}
|
|
272
|
+
return parseManifest(doc.toJS());
|
|
273
|
+
}
|
|
274
|
+
/** The manifest as `meta.yaml` text, fields in the format's order. */
|
|
275
|
+
export function serializeManifest(manifest) {
|
|
276
|
+
const artifacts = {};
|
|
277
|
+
for (const [id, artifact] of Object.entries(manifest.artifacts)) {
|
|
278
|
+
artifacts[id] = {
|
|
279
|
+
kind: artifact.kind,
|
|
280
|
+
...(artifact.language !== undefined ? { language: artifact.language } : {}),
|
|
281
|
+
...(artifact.from !== undefined ? { from: artifact.from } : {}),
|
|
282
|
+
...(artifact.requires.length > 0 ? { requires: artifact.requires } : {}),
|
|
283
|
+
...(artifact.generatedBy ? { "generated-by": artifact.generatedBy } : {}),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return stringify({
|
|
287
|
+
format: 2,
|
|
288
|
+
org: manifest.org,
|
|
289
|
+
name: manifest.name,
|
|
290
|
+
version: manifest.version,
|
|
291
|
+
...(manifest.description !== undefined ? { description: manifest.description } : {}),
|
|
292
|
+
...(manifest.license !== undefined ? { license: manifest.license } : {}),
|
|
293
|
+
...(manifest.repository !== undefined ? { repository: manifest.repository } : {}),
|
|
294
|
+
...(Object.keys(manifest.dependencies).length > 0 ? { dependencies: manifest.dependencies } : {}),
|
|
295
|
+
...(manifest.provides !== undefined ? { provides: manifest.provides } : {}),
|
|
296
|
+
artifacts,
|
|
297
|
+
}, { lineWidth: 0 });
|
|
298
|
+
}
|
|
299
|
+
/** The ids of the artifacts a release provides (environments-1,
|
|
300
|
+
* DR-174): each whose kind `provides` lists — every kind where it is
|
|
301
|
+
* absent — save a sibling's support, whatever `provides` lists. An
|
|
302
|
+
* artifact a sibling names in `from` is that sibling's support, and so
|
|
303
|
+
* is one a sibling of another kind names in `requires`: a playbook's
|
|
304
|
+
* skill, a skill's spec. A playbook a playbook requires, or a skill a
|
|
305
|
+
* skill requires, is a peer and stays provided. */
|
|
306
|
+
export function providedArtifacts(manifest) {
|
|
307
|
+
const kinds = manifest.provides !== undefined ? new Set(manifest.provides) : null;
|
|
308
|
+
const support = new Set();
|
|
309
|
+
for (const [id, artifact] of Object.entries(manifest.artifacts)) {
|
|
310
|
+
if (artifact.from !== undefined && artifact.from !== id)
|
|
311
|
+
support.add(artifact.from);
|
|
312
|
+
for (const required of artifact.requires) {
|
|
313
|
+
const kind = manifest.artifacts[required]?.kind;
|
|
314
|
+
if (required !== id && kind !== undefined && kind !== artifact.kind)
|
|
315
|
+
support.add(required);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const provided = new Set();
|
|
319
|
+
for (const [id, artifact] of Object.entries(manifest.artifacts)) {
|
|
320
|
+
if ((kinds === null || kinds.has(artifact.kind)) && !support.has(id))
|
|
321
|
+
provided.add(id);
|
|
322
|
+
}
|
|
323
|
+
return provided;
|
|
324
|
+
}
|
|
325
|
+
export function placeOf(path, pkg) {
|
|
326
|
+
const parts = path.split("/");
|
|
327
|
+
if (parts.length === 1)
|
|
328
|
+
return ROOT_FILES.includes(path) ? { root: true } : null;
|
|
329
|
+
const head = parts[0];
|
|
330
|
+
if (head === "sources" || head === "skills" || head === "playbooks") {
|
|
331
|
+
if (parts.length < 4)
|
|
332
|
+
return null;
|
|
333
|
+
const kind = head === "sources" ? "source" : head === "skills" ? "skill" : "playbook";
|
|
334
|
+
return { root: false, kind, language: parts[1], id: parts[2], folder: parts.slice(0, 3).join("/") };
|
|
335
|
+
}
|
|
336
|
+
if (head === "specs") {
|
|
337
|
+
if (parts.length < 3)
|
|
338
|
+
return null;
|
|
339
|
+
const ok = parts.length === 3 && parts[2] === `${pkg}.md`;
|
|
340
|
+
return {
|
|
341
|
+
root: false, kind: "spec", language: parts[1], id: pkg, folder: parts.slice(0, 2).join("/"),
|
|
342
|
+
...(ok ? {} : { misplaced: `a spec folder holds only ${pkg}.md` }),
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (head === "applets") {
|
|
346
|
+
if (parts.length < 3)
|
|
347
|
+
return null;
|
|
348
|
+
return { root: false, kind: "applet", id: parts[1], folder: parts.slice(0, 2).join("/") };
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
/** The folder prefix of an artifact in a language (none for an applet). */
|
|
353
|
+
export function artifactFolder(kind, id, language) {
|
|
354
|
+
if (kind === "applet")
|
|
355
|
+
return `applets/${id}/`;
|
|
356
|
+
if (kind === "spec")
|
|
357
|
+
return `specs/${language}/`;
|
|
358
|
+
return `${KIND_FOLDERS[kind]}/${language}/${id}/`;
|
|
359
|
+
}
|
|
360
|
+
/** Whether a release path belongs to an artifact in a language. */
|
|
361
|
+
export function inArtifact(path, kind, id, language, pkg) {
|
|
362
|
+
if (kind === "spec")
|
|
363
|
+
return path === `specs/${language}/${pkg}.md`;
|
|
364
|
+
return path.startsWith(artifactFolder(kind, id, language));
|
|
365
|
+
}
|
|
366
|
+
/** Each artifact's language folders, read from the files. */
|
|
367
|
+
export function artifactLanguages(manifest, files) {
|
|
368
|
+
const languages = {};
|
|
369
|
+
for (const file of files) {
|
|
370
|
+
const place = placeOf(file.path, manifest.name);
|
|
371
|
+
if (!place || place.root || place.language === undefined)
|
|
372
|
+
continue;
|
|
373
|
+
const artifact = manifest.artifacts[place.id];
|
|
374
|
+
if (!artifact || artifact.kind !== place.kind)
|
|
375
|
+
continue;
|
|
376
|
+
(languages[place.id] ??= new Set()).add(place.language);
|
|
377
|
+
}
|
|
378
|
+
const out = {};
|
|
379
|
+
for (const id of Object.keys(manifest.artifacts))
|
|
380
|
+
out[id] = [...(languages[id] ?? [])].sort();
|
|
381
|
+
return out;
|
|
382
|
+
}
|
|
383
|
+
const ITEM_HEADING = (pkg) => new RegExp(`^#{3,4}[ \\t]+(${pkg.replace(/[-]/g, "\\-")}-([1-9]\\d*))[ \\t]*$`, "gm");
|
|
384
|
+
/** A spec file's item ids, in order, from its `### <pkg>-<N>` and
|
|
385
|
+
* `#### <pkg>-<N>` headings. */
|
|
386
|
+
export function specItemIds(text, pkg) {
|
|
387
|
+
return [...text.matchAll(ITEM_HEADING(pkg))].map((match) => match[1]);
|
|
388
|
+
}
|
|
389
|
+
/** The `name` of a SKILL.md's YAML frontmatter, if it has one. */
|
|
390
|
+
export function skillFrontmatterName(text) {
|
|
391
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text);
|
|
392
|
+
if (!match)
|
|
393
|
+
return undefined;
|
|
394
|
+
try {
|
|
395
|
+
const value = parseDocument(match[1]).toJS();
|
|
396
|
+
return isPlainObject(value) && typeof value.name === "string" ? value.name : undefined;
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/** Every layout rule of environments-1 the release breaks. */
|
|
403
|
+
export function checkRelease(dir, manifest, files) {
|
|
404
|
+
const read = typeof dir === "string"
|
|
405
|
+
? (path) => { const file = join(dir, ...path.split("/")); return existsSync(file) ? readFileSync(file) : undefined; }
|
|
406
|
+
: dir;
|
|
407
|
+
const issues = [];
|
|
408
|
+
const pkg = manifest.name;
|
|
409
|
+
const paths = new Set(files.map((file) => file.path));
|
|
410
|
+
// folder key -> place
|
|
411
|
+
const folders = new Map();
|
|
412
|
+
for (const file of files) {
|
|
413
|
+
const place = placeOf(file.path, pkg);
|
|
414
|
+
if (place === null) {
|
|
415
|
+
issues.push({ path: file.path, rule: "layout", message: "lies under no artifact and is not meta.yaml, README.md or LICENSE" });
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (place.root)
|
|
419
|
+
continue;
|
|
420
|
+
if (place.misplaced)
|
|
421
|
+
issues.push({ path: file.path, rule: "spec", message: place.misplaced });
|
|
422
|
+
if (place.language !== undefined && !isLanguageTag(place.language)) {
|
|
423
|
+
issues.push({ path: file.path, rule: "language", message: `language folder "${place.language}" is not a well-formed BCP 47 tag` });
|
|
424
|
+
}
|
|
425
|
+
folders.set(`${place.kind}\u0000${place.id}\u0000${place.language ?? ""}`, place);
|
|
426
|
+
}
|
|
427
|
+
const shared = new Set();
|
|
428
|
+
for (const place of folders.values()) {
|
|
429
|
+
if (place.kind === "skill" || place.kind === "playbook") {
|
|
430
|
+
const other = place.kind === "skill" ? "playbooks" : "skills";
|
|
431
|
+
if ([...folders.values()].some((p) => p.id === place.id && KIND_FOLDERS[p.kind] === other))
|
|
432
|
+
shared.add(place.id);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
for (const id of shared)
|
|
436
|
+
issues.push({ path: `skills/*/${id}`, rule: "shared-id", message: `a skill and a playbook share the id ${id}` });
|
|
437
|
+
const seenFolders = new Set();
|
|
438
|
+
for (const place of folders.values()) {
|
|
439
|
+
if (seenFolders.has(place.folder))
|
|
440
|
+
continue;
|
|
441
|
+
seenFolders.add(place.folder);
|
|
442
|
+
if (shared.has(place.id))
|
|
443
|
+
continue;
|
|
444
|
+
const artifact = manifest.artifacts[place.id];
|
|
445
|
+
if (!artifact) {
|
|
446
|
+
issues.push({ path: place.folder, rule: "folder", message: `meta.yaml lists no artifact ${place.id} for this folder` });
|
|
447
|
+
}
|
|
448
|
+
else if (artifact.kind !== place.kind) {
|
|
449
|
+
issues.push({ path: place.folder, rule: "folder", message: `folder is a ${place.kind} folder but ${place.id} is a ${artifact.kind}` });
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const languagesOf = (kind, id) => [...folders.values()].filter((p) => p.kind === kind && p.id === id && p.language !== undefined).map((p) => p.language)
|
|
453
|
+
.filter((language, index, all) => all.indexOf(language) === index);
|
|
454
|
+
let specs = 0;
|
|
455
|
+
for (const [id, artifact] of Object.entries(manifest.artifacts)) {
|
|
456
|
+
const at = "meta.yaml";
|
|
457
|
+
if (artifact.kind === "applet") {
|
|
458
|
+
if (artifact.language !== undefined)
|
|
459
|
+
issues.push({ path: at, rule: "language", message: `applet ${id} has a language; an applet has none` });
|
|
460
|
+
if (![...folders.values()].some((p) => p.kind === "applet" && p.id === id)) {
|
|
461
|
+
issues.push({ path: `applets/${id}`, rule: "folder", message: `applet ${id} has no folder` });
|
|
462
|
+
}
|
|
463
|
+
else if (!paths.has(`applets/${id}/index.html`)) {
|
|
464
|
+
// A static web application entered at `index.html`, a regular
|
|
465
|
+
// file at the folder's root (environments-1, DR-161): the list
|
|
466
|
+
// holds regular files alone, so a link or a folder there is no
|
|
467
|
+
// entry.
|
|
468
|
+
issues.push({ path: `applets/${id}/index.html`, rule: "applet-entry", message: `applet ${id} has no index.html at its folder's root` });
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
const languages = languagesOf(artifact.kind, id);
|
|
473
|
+
if (artifact.language === undefined) {
|
|
474
|
+
issues.push({ path: at, rule: "language", message: `${artifact.kind} ${id} names no language` });
|
|
475
|
+
}
|
|
476
|
+
else if (!isLanguageTag(artifact.language)) {
|
|
477
|
+
issues.push({ path: at, rule: "language", message: `${artifact.kind} ${id} language "${artifact.language}" is not a well-formed BCP 47 tag` });
|
|
478
|
+
}
|
|
479
|
+
else if (!languages.includes(artifact.language)) {
|
|
480
|
+
issues.push({ path: artifactFolder(artifact.kind, id, artifact.language).replace(/\/$/, ""), rule: "folder", message: `${artifact.kind} ${id} has no folder in its language ${artifact.language}` });
|
|
481
|
+
}
|
|
482
|
+
if (artifact.kind === "spec") {
|
|
483
|
+
specs += 1;
|
|
484
|
+
if (id !== pkg)
|
|
485
|
+
issues.push({ path: at, rule: "spec", message: `the spec's id is ${id}, not the package name ${pkg}` });
|
|
486
|
+
const original = artifact.language;
|
|
487
|
+
const originalText = original ? read(`specs/${original}/${pkg}.md`) : undefined;
|
|
488
|
+
if (originalText) {
|
|
489
|
+
const ids = specItemIds(Buffer.from(originalText).toString("utf8"), pkg);
|
|
490
|
+
const duplicates = ids.filter((item, index) => ids.indexOf(item) !== index);
|
|
491
|
+
if (duplicates.length > 0)
|
|
492
|
+
issues.push({ path: `specs/${original}/${pkg}.md`, rule: "item-ids", message: `item ids repeat: ${[...new Set(duplicates)].join(", ")}` });
|
|
493
|
+
const expected = [...new Set(ids)].sort().join(",");
|
|
494
|
+
for (const language of languages) {
|
|
495
|
+
if (language === original)
|
|
496
|
+
continue;
|
|
497
|
+
const translated = read(`specs/${language}/${pkg}.md`);
|
|
498
|
+
if (!translated)
|
|
499
|
+
continue;
|
|
500
|
+
const translatedIds = specItemIds(Buffer.from(translated).toString("utf8"), pkg);
|
|
501
|
+
if ([...new Set(translatedIds)].sort().join(",") !== expected || translatedIds.length !== ids.length) {
|
|
502
|
+
issues.push({ path: `specs/${language}/${pkg}.md`, rule: "translation", message: `a translation must keep the original's item ids` });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (artifact.kind === "skill" || artifact.kind === "playbook") {
|
|
508
|
+
if (!isSkillName(id))
|
|
509
|
+
issues.push({ path: at, rule: "skill-name", message: `${artifact.kind} id "${id}" is not an Agent Skills name` });
|
|
510
|
+
}
|
|
511
|
+
if (artifact.kind === "skill") {
|
|
512
|
+
for (const language of languages) {
|
|
513
|
+
const skillPath = `skills/${language}/${id}/SKILL.md`;
|
|
514
|
+
const text = paths.has(skillPath) ? read(skillPath) : undefined;
|
|
515
|
+
if (!text) {
|
|
516
|
+
issues.push({ path: skillPath, rule: "skill-md", message: `skill ${id} has no SKILL.md` });
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
const name = skillFrontmatterName(Buffer.from(text).toString("utf8"));
|
|
520
|
+
if (name !== id)
|
|
521
|
+
issues.push({ path: skillPath, rule: "skill-md", message: `SKILL.md name ${JSON.stringify(name ?? null)} differs from the skill's id ${id}` });
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (artifact.kind === "source") {
|
|
525
|
+
for (const language of languages) {
|
|
526
|
+
const sourcePath = `sources/${language}/${id}/SOURCE.md`;
|
|
527
|
+
if (!paths.has(sourcePath))
|
|
528
|
+
issues.push({ path: sourcePath, rule: "source-md", message: `source ${id} has no SOURCE.md` });
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (artifact.from !== undefined && (artifact.from === id || !manifest.artifacts[artifact.from])) {
|
|
533
|
+
issues.push({ path: at, rule: "from", message: `artifact ${id} from ${artifact.from} names no other artifact of this release` });
|
|
534
|
+
}
|
|
535
|
+
for (const required of artifact.requires) {
|
|
536
|
+
if (required === id || !manifest.artifacts[required]) {
|
|
537
|
+
issues.push({ path: at, rule: "requires", message: `artifact ${id} requires ${required}, which names no other artifact of this release` });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (specs > 1)
|
|
542
|
+
issues.push({ path: "meta.yaml", rule: "spec", message: "a release has at most one spec" });
|
|
543
|
+
issues.push(...portablePathIssues([...paths]));
|
|
544
|
+
return issues;
|
|
545
|
+
}
|
|
546
|
+
/** Folders and files a reader of a working folder or a Git tree skips:
|
|
547
|
+
* they are never release files. */
|
|
548
|
+
const SKIPPED_DIRECTORIES = new Set([".git", "node_modules"]);
|
|
549
|
+
const SKIPPED_FILES = new Set([".DS_Store"]);
|
|
550
|
+
/** The compile pipeline's history, verifier support, generated checks
|
|
551
|
+
* and introspection bundle are no folder release files (environments-1).
|
|
552
|
+
* File exclusions match the native output names and locations, leaving
|
|
553
|
+
* the author's other tests and editable intermediates intact. */
|
|
554
|
+
const COMPILER_OWN = new Set([".slc", ".slc-verify"]);
|
|
555
|
+
const COMPILER_CHECKS = ["fsm.coverage", "fsm.introspect", "gears-fsm", "prompt-contract"];
|
|
556
|
+
function compilerOwn(path) {
|
|
557
|
+
const parts = path.split("/");
|
|
558
|
+
// Under `playbooks/<language>/<id>/`.
|
|
559
|
+
if (parts[0] !== "playbooks" || parts.length < 4)
|
|
560
|
+
return false;
|
|
561
|
+
if (parts.slice(3).some((part) => COMPILER_OWN.has(part)))
|
|
562
|
+
return true;
|
|
563
|
+
const id = parts[2];
|
|
564
|
+
return (parts.length === 4 && parts[3] === `${id}.fsm.bundle.mjs`)
|
|
565
|
+
|| (parts.length === 5 && parts[3] === `${id}.playbook`
|
|
566
|
+
&& COMPILER_CHECKS.some((check) => parts[4] === `${id}.${check}.test.ts`));
|
|
567
|
+
}
|
|
568
|
+
export function sha256Hex(bytes) {
|
|
569
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
570
|
+
}
|
|
571
|
+
/** Every file of a folder with its digest and executable bit, but what
|
|
572
|
+
* the compiler keeps for itself beside a playbook; a link or a special
|
|
573
|
+
* file is an issue, never followed. */
|
|
574
|
+
export async function listReleaseFiles(dir) {
|
|
575
|
+
const files = [];
|
|
576
|
+
const issues = [];
|
|
577
|
+
const walk = async (relative) => {
|
|
578
|
+
const absolute = relative ? join(dir, ...relative.split("/")) : dir;
|
|
579
|
+
const entries = (await readdir(absolute)).sort();
|
|
580
|
+
for (const name of entries) {
|
|
581
|
+
const path = relative ? `${relative}/${name}` : name;
|
|
582
|
+
if (compilerOwn(path))
|
|
583
|
+
continue;
|
|
584
|
+
const stat = await lstat(join(absolute, name));
|
|
585
|
+
if (stat.isDirectory()) {
|
|
586
|
+
if (SKIPPED_DIRECTORIES.has(name))
|
|
587
|
+
continue;
|
|
588
|
+
await walk(path);
|
|
589
|
+
}
|
|
590
|
+
else if (stat.isSymbolicLink()) {
|
|
591
|
+
issues.push({ path, rule: "link", message: "is a link; a release holds files only" });
|
|
592
|
+
}
|
|
593
|
+
else if (stat.isFile()) {
|
|
594
|
+
if (SKIPPED_FILES.has(name))
|
|
595
|
+
continue;
|
|
596
|
+
const bytes = await readFile(join(absolute, name));
|
|
597
|
+
files.push({ path, size: bytes.length, sha256: sha256Hex(bytes), executable: (stat.mode & 0o100) !== 0 });
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
issues.push({ path, rule: "special", message: "is a special file; a release holds files only" });
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
await walk("");
|
|
605
|
+
files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
606
|
+
return { files, issues };
|
|
607
|
+
}
|
|
608
|
+
/** Read the manifest of a folder, refusing a missing or unknown one. */
|
|
609
|
+
export function readManifest(dir) {
|
|
610
|
+
const file = join(dir, "meta.yaml");
|
|
611
|
+
if (!existsSync(file))
|
|
612
|
+
throw new FormatError([{ path: "meta.yaml", rule: "manifest", message: "the folder has no meta.yaml" }]);
|
|
613
|
+
const { manifest, issues } = parseManifestText(readFileSync(file, "utf8"));
|
|
614
|
+
if (!manifest)
|
|
615
|
+
throw new FormatError(issues);
|
|
616
|
+
return manifest;
|
|
617
|
+
}
|
|
618
|
+
/** Read and check a release folder (environments-1). */
|
|
619
|
+
export async function readRelease(dir) {
|
|
620
|
+
const file = join(dir, "meta.yaml");
|
|
621
|
+
if (!existsSync(file))
|
|
622
|
+
throw new FormatError([{ path: "meta.yaml", rule: "manifest", message: "the folder has no meta.yaml" }]);
|
|
623
|
+
const { manifest, issues } = parseManifestText(readFileSync(file, "utf8"));
|
|
624
|
+
const listed = await listReleaseFiles(dir);
|
|
625
|
+
issues.push(...listed.issues);
|
|
626
|
+
if (manifest)
|
|
627
|
+
issues.push(...checkRelease(dir, manifest, listed.files));
|
|
628
|
+
if (!manifest || issues.length > 0)
|
|
629
|
+
throw new FormatError(issues);
|
|
630
|
+
return { manifest, files: listed.files };
|
|
631
|
+
}
|
|
632
|
+
/** The manifest fields the registry requires of a release it takes,
|
|
633
|
+
* which reading a release leaves optional (environments-10). */
|
|
634
|
+
const PUBLISH_FIELDS = ["description", "license"];
|
|
635
|
+
/** Every field the registry requires to publish that the manifest
|
|
636
|
+
* lacks, named as the registry names it (environments-10). */
|
|
637
|
+
export function publishIssues(manifest) {
|
|
638
|
+
return PUBLISH_FIELDS
|
|
639
|
+
.filter((field) => manifest[field] === undefined)
|
|
640
|
+
.map((field) => ({ path: "meta.yaml", rule: "field", message: `missing required field "${field}"` }));
|
|
641
|
+
}
|
|
642
|
+
/** Read a release folder as publishing takes it (environments-10):
|
|
643
|
+
* every release check, then the fields the registry requires. */
|
|
644
|
+
export async function readPublishableRelease(dir) {
|
|
645
|
+
const release = await readRelease(dir);
|
|
646
|
+
const issues = publishIssues(release.manifest);
|
|
647
|
+
if (issues.length > 0)
|
|
648
|
+
throw new FormatError(issues, "publishing");
|
|
649
|
+
return release;
|
|
650
|
+
}
|
|
651
|
+
//# sourceMappingURL=format.js.map
|