@sublang/spex 4.1.0 → 5.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.
Files changed (98) hide show
  1. package/README.md +438 -54
  2. package/dist/cli.js +81 -31
  3. package/dist/commands/add.d.ts +12 -0
  4. package/dist/commands/add.js +138 -0
  5. package/dist/commands/auth-target.d.ts +11 -0
  6. package/dist/commands/auth-target.js +50 -0
  7. package/dist/commands/environment.d.ts +123 -0
  8. package/dist/commands/environment.js +411 -0
  9. package/dist/commands/export.d.ts +21 -0
  10. package/dist/commands/export.js +663 -0
  11. package/dist/commands/home.d.ts +56 -0
  12. package/dist/commands/home.js +215 -0
  13. package/dist/commands/install.d.ts +2 -0
  14. package/dist/commands/install.js +48 -0
  15. package/dist/commands/list.d.ts +2 -0
  16. package/dist/commands/list.js +87 -0
  17. package/dist/commands/login.d.ts +2 -0
  18. package/dist/commands/login.js +211 -0
  19. package/dist/commands/logout.d.ts +2 -0
  20. package/dist/commands/logout.js +74 -0
  21. package/dist/commands/publish.d.ts +2 -0
  22. package/dist/commands/publish.js +120 -0
  23. package/dist/commands/remove.d.ts +2 -0
  24. package/dist/commands/remove.js +34 -0
  25. package/dist/commands/run.d.ts +50 -0
  26. package/dist/commands/run.js +309 -0
  27. package/dist/commands/search.d.ts +2 -0
  28. package/dist/commands/search.js +34 -0
  29. package/dist/commands/settle.d.ts +124 -0
  30. package/dist/commands/settle.js +475 -0
  31. package/dist/commands/update.d.ts +2 -0
  32. package/dist/commands/update.js +37 -0
  33. package/dist/commands/whoami.d.ts +2 -0
  34. package/dist/commands/whoami.js +75 -0
  35. package/dist/lib/environment/agent-folders.d.ts +14 -0
  36. package/dist/lib/environment/agent-folders.js +11 -0
  37. package/dist/lib/environment/archive.d.ts +26 -0
  38. package/dist/lib/environment/archive.js +91 -0
  39. package/dist/lib/environment/builtins.d.ts +112 -0
  40. package/dist/lib/environment/builtins.js +539 -0
  41. package/dist/lib/environment/citations.d.ts +75 -0
  42. package/dist/lib/environment/citations.js +267 -0
  43. package/dist/lib/environment/exports.d.ts +190 -0
  44. package/dist/lib/environment/exports.js +1029 -0
  45. package/dist/lib/environment/format.d.ts +133 -0
  46. package/dist/lib/environment/format.js +651 -0
  47. package/dist/lib/environment/git-source.d.ts +41 -0
  48. package/dist/lib/environment/git-source.js +159 -0
  49. package/dist/lib/environment/index.d.ts +20 -0
  50. package/dist/lib/environment/index.js +27 -0
  51. package/dist/lib/environment/install.d.ts +140 -0
  52. package/dist/lib/environment/install.js +694 -0
  53. package/dist/lib/environment/layout.d.ts +15 -0
  54. package/dist/lib/environment/layout.js +50 -0
  55. package/dist/lib/environment/lock.d.ts +87 -0
  56. package/dist/lib/environment/lock.js +305 -0
  57. package/dist/lib/environment/marker.d.ts +15 -0
  58. package/dist/lib/environment/marker.js +31 -0
  59. package/dist/lib/environment/own-paths.d.ts +59 -0
  60. package/dist/lib/environment/own-paths.js +174 -0
  61. package/dist/lib/environment/placed-record.d.ts +32 -0
  62. package/dist/lib/environment/placed-record.js +72 -0
  63. package/dist/lib/environment/registries.d.ts +25 -0
  64. package/dist/lib/environment/registries.js +75 -0
  65. package/dist/lib/environment/registry.d.ts +173 -0
  66. package/dist/lib/environment/registry.js +390 -0
  67. package/dist/lib/environment/requests.d.ts +108 -0
  68. package/dist/lib/environment/requests.js +403 -0
  69. package/dist/lib/environment/resolve.d.ts +70 -0
  70. package/dist/lib/environment/resolve.js +451 -0
  71. package/dist/lib/environment/semver.d.ts +30 -0
  72. package/dist/lib/environment/semver.js +130 -0
  73. package/dist/lib/environment/store.d.ts +23 -0
  74. package/dist/lib/environment/store.js +123 -0
  75. package/dist/lib/environment/tar.d.ts +27 -0
  76. package/dist/lib/environment/tar.js +219 -0
  77. package/dist/lib/files.d.ts +66 -0
  78. package/dist/lib/files.js +233 -0
  79. package/dist/lib/git-host.d.ts +579 -0
  80. package/dist/lib/git-host.js +1363 -0
  81. package/dist/lib/home-file.d.ts +124 -0
  82. package/dist/lib/home-file.js +288 -0
  83. package/dist/lib/instance.d.ts +63 -0
  84. package/dist/lib/instance.js +130 -0
  85. package/dist/lib/words.d.ts +32 -0
  86. package/dist/lib/words.js +27 -0
  87. package/dist/lint.js +8 -0
  88. package/dist/testing/index.d.ts +1 -0
  89. package/dist/testing/index.js +7 -0
  90. package/dist/testing/standin-registry.d.ts +94 -0
  91. package/dist/testing/standin-registry.js +449 -0
  92. package/package.json +37 -3
  93. package/dist/attached-cli.d.ts +0 -13
  94. package/dist/attached-cli.js +0 -247
  95. package/dist/attached-client.d.ts +0 -36
  96. package/dist/attached-client.js +0 -189
  97. package/dist/generated-protocol.d.ts +0 -2
  98. package/dist/generated-protocol.js +0 -6
@@ -0,0 +1,267 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
3
+ // Citations across a release's boundary (environments-41,
4
+ // environments-42, DR-174). An address `spex:<org>/<pkg>#<id>` cites
5
+ // another release's spec item and stands only inside a release; a
6
+ // project's `specs/` holds plain relative links. Building a release's
7
+ // spec from a project's file turns a relative citation into that file
8
+ // into a same-file citation and one into a package's spec into that
9
+ // package's address, keeps one of `meta.md` at the specs root, which
10
+ // the scaffold puts in every tree, removes one into a spec of no
11
+ // package or into a file two packages claim, and reduces a decision
12
+ // record's link to its text, each removal and reduction reported as a
13
+ // warning naming the citing item. Placing a release's spec in a tree
14
+ // turns each address whose package's spec stands there into the
15
+ // relative link to it and removes the rest, counted per package they
16
+ // wait for, a plain link to one keeping its text, and removes alike a
17
+ // `spex:` link that is no address, so `specs/` holds no `spex:` link; a
18
+ // relative link, `meta.md`'s among them, stays. A removal takes the
19
+ // citation's brackets and one space beside them — the one before, or,
20
+ // where a citation follows directly or the citation opens its line, the
21
+ // one after where one stands — so the phrase keeps its own spacing; the
22
+ // text outside each edit is left byte for byte.
23
+ import { posix } from "node:path";
24
+ import { applyEdits, endOffset, parseMarkdown, plainHeadingText, startOffset, visit, } from "../../markdown.js";
25
+ import { isPackageName } from "./format.js";
26
+ const ADDRESS_SCHEME = "spex:";
27
+ // The spec of specs at the specs root, which the scaffold puts in every
28
+ // tree (meta-1).
29
+ const META_PATH = "meta.md";
30
+ // The folder under the specs root a placed spec stands in
31
+ // (environments-41), from which a release's link to `meta.md` is written.
32
+ const PLACED_FOLDER = "packages";
33
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
34
+ // Item headings: lowercase <pack>-<N> (meta-11).
35
+ const ITEM_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*-[1-9][0-9]*$/;
36
+ // A decision record's link: its id as text, its file under decisions/
37
+ // named <NNN>-<kebab-case>.md (meta-1, meta-16, meta-22).
38
+ const RECORD_TEXT_RE = /^DR-\d+$/;
39
+ const RECORD_PATH_RE = /(?:^|\/)decisions\/\d{3}-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/;
40
+ /** The package and anchor of a `spex:<org>/<pkg>#<anchor>` url, or null. */
41
+ export function parseAddress(url) {
42
+ if (!url.startsWith(ADDRESS_SCHEME))
43
+ return null;
44
+ const hash = url.indexOf("#");
45
+ if (hash < 0)
46
+ return null;
47
+ const name = url.slice(ADDRESS_SCHEME.length, hash);
48
+ const anchor = url.slice(hash + 1);
49
+ if (!isPackageName(name) || anchor === "")
50
+ return null;
51
+ return { name, anchor };
52
+ }
53
+ /** The address citing `anchor` in the spec `name` provides. */
54
+ export function formatAddress(name, anchor) {
55
+ return `${ADDRESS_SCHEME}${name}#${anchor}`;
56
+ }
57
+ /**
58
+ * A citation's url: `#<anchor>`, a relative `<path>#<anchor>`, or an
59
+ * address `spex:<org>/<pkg>#<anchor>`.
60
+ */
61
+ export function isCitationUrl(url) {
62
+ return parseAddress(url) !== null || relativeTarget(url) !== null;
63
+ }
64
+ /**
65
+ * Rewrite a project's spec file for a release (environments-42): a
66
+ * relative citation into `selfPath` becomes a same-file citation, one
67
+ * into a package's spec that package's address, and one into a spec of
68
+ * no package or into a file two packages claim is removed; a decision
69
+ * record's link keeps its text alone. A citation of `meta.md` at the
70
+ * specs root is kept as the link from `specs/packages/`, where the
71
+ * placed spec stands; a same-file citation, an address and every other
72
+ * link stay.
73
+ */
74
+ export function rewriteForRelease(text, ctx) {
75
+ const selfPath = posix.normalize(ctx.selfPath);
76
+ const folder = posix.dirname(selfPath);
77
+ const edits = [];
78
+ const warnings = [];
79
+ for (const site of linkSites(text)) {
80
+ if (!site.enclosed) {
81
+ if (!isRecordLink(site))
82
+ continue;
83
+ edits.push(labelOnly(text, site));
84
+ warnings.push({ kind: "record", item: site.item, target: site.text });
85
+ continue;
86
+ }
87
+ const target = relativeTarget(site.url);
88
+ if (target === null || target.path === "")
89
+ continue;
90
+ const resolved = posix.normalize(posix.join(folder, target.path));
91
+ if (resolved === selfPath) {
92
+ edits.push(destinationEdit(text, site, `#${target.anchor}`));
93
+ continue;
94
+ }
95
+ if (resolved === META_PATH) {
96
+ if (posix.normalize(posix.join(PLACED_FOLDER, target.path)) !== META_PATH) {
97
+ edits.push(destinationEdit(text, site, `${posix.relative(PLACED_FOLDER, META_PATH)}#${target.anchor}`));
98
+ }
99
+ continue;
100
+ }
101
+ const owner = ctx.packageOf(resolved);
102
+ if (typeof owner === "string") {
103
+ edits.push(destinationEdit(text, site, formatAddress(owner, target.anchor)));
104
+ continue;
105
+ }
106
+ edits.push(removal(text, site));
107
+ warnings.push({
108
+ kind: "citation",
109
+ item: site.item,
110
+ target: `${resolved}#${target.anchor}`,
111
+ ...(owner !== null ? { claims: owner.claims } : {}),
112
+ });
113
+ }
114
+ return { text: applyEdits(text, edits), warnings };
115
+ }
116
+ /**
117
+ * Rewrite a release's spec for the tree it is placed in
118
+ * (environments-41): an address whose package's spec stands there
119
+ * becomes the relative link to that file's anchor, and one whose
120
+ * package's does not is removed, counted under that package in
121
+ * `waiting`. So `specs/` holds no address, a plain link to one is
122
+ * treated alike, keeping its text where it waits, and a `spex:` link
123
+ * that is no address, which resolves nowhere, is removed alike, counted
124
+ * under no package. A same-file citation, a relative one — `meta.md`'s
125
+ * among them — and every other link stay.
126
+ */
127
+ export function rewriteForTree(text, ctx) {
128
+ const selfPath = posix.normalize(ctx.selfPath);
129
+ const folder = posix.dirname(selfPath);
130
+ const edits = [];
131
+ const waiting = {};
132
+ for (const site of linkSites(text)) {
133
+ if (!site.url.startsWith(ADDRESS_SCHEME))
134
+ continue;
135
+ const address = parseAddress(site.url);
136
+ if (address === null) {
137
+ edits.push(site.enclosed ? removal(text, site) : labelOnly(text, site));
138
+ continue;
139
+ }
140
+ const placed = ctx.placedPathOf(address.name);
141
+ if (placed === null) {
142
+ edits.push(site.enclosed ? removal(text, site) : labelOnly(text, site));
143
+ waiting[address.name] = (waiting[address.name] ?? 0) + 1;
144
+ continue;
145
+ }
146
+ const path = posix.normalize(placed);
147
+ const link = path === selfPath ? "" : posix.relative(folder, path);
148
+ edits.push(destinationEdit(text, site, `${link}#${address.anchor}`));
149
+ }
150
+ return { text: applyEdits(text, edits), waiting };
151
+ }
152
+ /** Every inline link of the text in document order, as the linter reads them. */
153
+ function linkSites(text) {
154
+ const tree = parseMarkdown(text);
155
+ // Only a root-level heading carries structure; one quoted in a
156
+ // blockquote or a list is content.
157
+ const rootHeadings = new Set(tree.children.filter((child) => child.type === "heading"));
158
+ const sites = [];
159
+ let item = "intent";
160
+ visit(tree, (node) => {
161
+ if (node.type === "heading" && rootHeadings.has(node)) {
162
+ const heading = node;
163
+ const id = plainHeadingText(text, heading).trim();
164
+ if ((heading.depth === 3 || heading.depth === 4) && ITEM_RE.test(id))
165
+ item = id;
166
+ return;
167
+ }
168
+ if (node.type !== "link")
169
+ return;
170
+ const link = node;
171
+ const start = startOffset(link);
172
+ const end = endOffset(link);
173
+ sites.push({
174
+ start,
175
+ end,
176
+ labelEnd: labelEndOf(text, link, start, end),
177
+ url: link.url,
178
+ title: link.title ?? null,
179
+ text: plainText(link).trim(),
180
+ enclosed: text.charAt(start - 1) === "[" && text.charAt(end) === "]",
181
+ item,
182
+ });
183
+ });
184
+ return sites;
185
+ }
186
+ function plainText(node) {
187
+ let plain = "";
188
+ visit(node, (child) => {
189
+ if (child.type === "text" || child.type === "inlineCode") {
190
+ plain += child.value;
191
+ }
192
+ });
193
+ return plain;
194
+ }
195
+ /** Offset of the `]` before the link's `(`: past its last label child. */
196
+ function labelEndOf(text, link, start, end) {
197
+ const last = link.children[link.children.length - 1];
198
+ const from = last === undefined ? start + 1 : endOffset(last);
199
+ const close = text.indexOf("](", from);
200
+ return close >= 0 && close < end ? close : from;
201
+ }
202
+ /** The path and anchor of a relative `<path>#<anchor>` or `#<anchor>` url, or null. */
203
+ function relativeTarget(url) {
204
+ const hash = url.indexOf("#");
205
+ if (hash < 0)
206
+ return null;
207
+ const path = url.slice(0, hash);
208
+ const anchor = url.slice(hash + 1);
209
+ if (anchor === "" || SCHEME_RE.test(path) || path.startsWith("/"))
210
+ return null;
211
+ return { path, anchor };
212
+ }
213
+ function isRecordLink(site) {
214
+ if (!RECORD_TEXT_RE.test(site.text))
215
+ return false;
216
+ const path = site.url.split("#")[0] ?? "";
217
+ if (SCHEME_RE.test(path) || path.startsWith("/"))
218
+ return false;
219
+ return RECORD_PATH_RE.test(path);
220
+ }
221
+ /** Reduce a plain link to its label as written. */
222
+ function labelOnly(text, site) {
223
+ return { start: site.start, end: site.end, replacement: text.slice(site.start + 1, site.labelEnd) };
224
+ }
225
+ /**
226
+ * Remove an enclosed citation's `[[…](…)]` with one space beside it, so
227
+ * the phrase keeps its own spacing: the space before it, unless another
228
+ * citation follows directly, which keeps that space; else, where the
229
+ * citation opens its line, the space after it.
230
+ */
231
+ function removal(text, site) {
232
+ const open = site.start - 1;
233
+ const close = site.end + 1;
234
+ const before = text.charAt(open - 1);
235
+ const after = text.charAt(close);
236
+ if (before === " " && after !== "[")
237
+ return { start: open - 1, end: close, replacement: "" };
238
+ const opensLine = open === 0 || before === "\n";
239
+ return { start: open, end: opensLine && after === " " ? close + 1 : close, replacement: "" };
240
+ }
241
+ /**
242
+ * Replace the link's destination alone, so its label and any title
243
+ * stay as written; a destination in `<…>` is replaced brackets and all.
244
+ */
245
+ function destinationEdit(text, site, url) {
246
+ const close = site.end - 1;
247
+ let from = site.labelEnd + 2;
248
+ while (from < close && /\s/.test(text.charAt(from)))
249
+ from += 1;
250
+ let to;
251
+ if (text.charAt(from) === "<") {
252
+ const gt = text.indexOf(">", from);
253
+ to = gt >= 0 && gt < close ? gt + 1 : close;
254
+ }
255
+ else if (site.title === null) {
256
+ to = close;
257
+ while (to > from && /\s/.test(text.charAt(to - 1)))
258
+ to -= 1;
259
+ }
260
+ else {
261
+ to = from;
262
+ while (to < close && !/\s/.test(text.charAt(to)))
263
+ to += 1;
264
+ }
265
+ return { start: from, end: to, replacement: url };
266
+ }
267
+ //# sourceMappingURL=citations.js.map
@@ -0,0 +1,190 @@
1
+ import { type Lock, type Resolution } from "./lock.js";
2
+ /** The built-in spec package's name (environments-11). */
3
+ export declare const BUILTIN_PACKAGE_NAME = "sublang/playbooks";
4
+ /** The manifest an export leaves in each agent folder it writes. */
5
+ export declare const EXPORTS_MANIFEST = ".spex-exports.json";
6
+ /** A managed block of a working folder's `info/exclude`: the exports,
7
+ * or the engine links a compile provisions (playbook-library-12). */
8
+ export type ExcludeBlock = "exports" | "engine links";
9
+ export interface ExportOptions {
10
+ /** The environment's root (environments-26): its `.spex/` holds the
11
+ * installed files and receives the generated skills. */
12
+ root: string;
13
+ lock: Lock;
14
+ /** The working folder exported to; null exports nowhere but the
15
+ * root's `.spex/` and the user's home. */
16
+ workingFolder: string | null;
17
+ /** The folder a path source's path is relative to (environments-2):
18
+ * your own group's clone; the working folder where omitted. */
19
+ pathRoot?: string | null;
20
+ /** The user's home, for your own group's environment; else null. */
21
+ userHome: string | null;
22
+ /** The agents this device has: only their user-level folders are
23
+ * written, while every project-level folder is (environments-16). */
24
+ agents: string[];
25
+ /** The rename a mirror swaps a changed skill in with; the file
26
+ * system's, unless a test injects a failure (environments-30). */
27
+ rename?: (from: string, to: string) => void;
28
+ }
29
+ /** Where a provided spec stands under a project's `specs/`
30
+ * (environments-41, environments-14): placed at its path; edited there,
31
+ * the package's copy by its marker line or the record, so left as the
32
+ * reader's — as is an edited copy its package no longer places, the
33
+ * project's own now; blocked by a file of its basename under `specs/`
34
+ * that is neither the derivation nor the package's copy; or waiting for
35
+ * `specs/` where the root holds none, placed nowhere. */
36
+ export type SpecState = "placed" | "edited" | "blocked" | "no-specs";
37
+ export interface SpecPlacement {
38
+ /** The spec package, `<org>/<pkg>`. */
39
+ name: string;
40
+ /** Its path from the root, `specs/packages/<pkg>.md`. */
41
+ path: string;
42
+ state: SpecState;
43
+ /** Each package the placed copy's links wait for, with their count,
44
+ * in name order (environments-41). */
45
+ waiting: {
46
+ name: string;
47
+ count: number;
48
+ }[];
49
+ /** For an edited copy, the release's version where its marker line
50
+ * names another: the newer release waiting under `.spex/`
51
+ * (environments-41). */
52
+ waitingVersion?: string;
53
+ }
54
+ export interface ExportReport {
55
+ /** Every exported skill name, as it stands in `<root>/.spex/skills/`. */
56
+ skills: string[];
57
+ /** Each agent folder written, with the agents that read it. */
58
+ folders: {
59
+ agents: string[];
60
+ level: "project" | "user";
61
+ dir: string;
62
+ }[];
63
+ /** Skill folders an earlier export wrote and this one removed. */
64
+ removed: string[];
65
+ /** Exports left out of an agent folder because a folder the reader
66
+ * placed there has the name: the folder as the agent table names it,
67
+ * once under each name where a link makes two folders one. */
68
+ skipped: {
69
+ name: string;
70
+ folder: string;
71
+ }[];
72
+ /** Spec packages an exported artifact of which is not here: not
73
+ * installed, or a path source missing where its path resolves. */
74
+ missing: string[];
75
+ /** Each provided spec of a project's root with where it stands, in
76
+ * name order (environments-41); none where the root is no working
77
+ * folder, as your own group's clone. */
78
+ specs: SpecPlacement[];
79
+ }
80
+ /** Where a spec package's files stand: its installed folder, or a path
81
+ * source's folder where its path resolves (environments-8). */
82
+ export declare function packageRoot(name: string, resolution: Resolution, packagesDir: string, pathRoot: string | null): string | null;
83
+ /** Rewrite the `name` of a SKILL.md's frontmatter (Agent Skills: the
84
+ * name matches the folder). */
85
+ export declare function rewriteSkillName(text: string, name: string): string;
86
+ /** The SKILL.md generated for an exported playbook (environments-16):
87
+ * for an agent a person runs in the working folder, never for a player
88
+ * Spex launches there, which sees the same skills. The description
89
+ * leaves the version to the body, so its bounded names keep it within
90
+ * the Agent Skills limit. */
91
+ export declare function playbookSkill(options: {
92
+ name: string;
93
+ id: string;
94
+ packageName: string;
95
+ version: string;
96
+ }): string;
97
+ /** The name a spec package's spec is exported under where no alias
98
+ * names it (environments-6): `<org>-<pkg>`, or `<pkg>` where that is
99
+ * longer than an Agent Skills name may be. */
100
+ export declare function specExportName(packageName: string): string;
101
+ /** The SKILL.md generated for an exported spec (environments-16): what
102
+ * spec package it is, and the spec file beside it. */
103
+ export declare function specSkill(options: {
104
+ name: string;
105
+ packageName: string;
106
+ version: string;
107
+ description?: string | undefined;
108
+ file: string;
109
+ }): string;
110
+ /** The `info/exclude` file of the Git work tree a working folder lies
111
+ * in, where it lies in one, with the folder's path below the work
112
+ * tree's top, `/`-separated, empty at the top itself. */
113
+ export declare function gitExclude(workingFolder: string): {
114
+ file: string;
115
+ prefix: string;
116
+ } | null;
117
+ /** The `info/exclude` file of a working folder's Git, where it lies in
118
+ * a work tree. */
119
+ export declare function gitExcludeFile(workingFolder: string): string | null;
120
+ /** Replace a managed block of a working folder's `info/exclude`, under
121
+ * the version read: the file changed meanwhile is refused as a conflict,
122
+ * never overwritten (DR-111). The file is the folder's, so its mode is
123
+ * kept; one made new is 0644. A folder below its work tree's top keeps
124
+ * a block of its own, its anchored entries placed under its path, so
125
+ * two such folders of one work tree never replace each other's. */
126
+ export declare function writeExcludeBlock(workingFolder: string, entries: string[], block?: ExcludeBlock): void;
127
+ /**
128
+ * Remove what exports wrote into a working folder (environments-8): each
129
+ * agent folder's exported skills and their manifest, and the exports'
130
+ * block of the folder's `info/exclude`; a skill the reader placed stays.
131
+ * Called when the folder stops being paired with the spex repository.
132
+ */
133
+ export declare function removeExports(workingFolder: string): string[];
134
+ /** The path from the root a spec `<pkg>` is placed at (environments-41). */
135
+ export declare function placedSpecPath(id: string): string;
136
+ /**
137
+ * Where each provided spec of a lock stands under a project's root, read
138
+ * from the files, their marker lines and the install record as a
139
+ * placement finds them, writing nothing (environments-14,
140
+ * environments-41), so `spex list` and an install agree: waiting for
141
+ * `specs/` where the root holds none; else placed, edited or blocked as
142
+ * an install reports it. A spec whose package's files are not here as
143
+ * the lock locks them is left out, its recorded copy holding its path,
144
+ * and so is one whose copy is not written yet.
145
+ */
146
+ export declare function readSpecPlacements(root: string, lock: Lock, pathRoot?: string | null): SpecPlacement[];
147
+ /** Export an installed environment (environments-8). */
148
+ export declare function exportEnvironment(options: ExportOptions): Promise<ExportReport>;
149
+ export interface ModuleLocation {
150
+ /** The playbook's registry module, absolute. */
151
+ module: string;
152
+ /** The spec package it came from, and its version. */
153
+ package: string;
154
+ version: string;
155
+ /** Whether it is the app's built-in spec package. */
156
+ builtin: boolean;
157
+ /** The playbook's own id (the key is its exported name). */
158
+ id: string;
159
+ /** Whether the module file is there. */
160
+ present: boolean;
161
+ }
162
+ /** The module candidates of a playbook artifact folder, preferred first. */
163
+ export declare function playbookModuleCandidates(folder: string, id: string): string[];
164
+ /** Each exported playbook's module location (environments-9): the
165
+ * installed artifact under the root's `.spex/packages/`, or a path
166
+ * source's where its path resolves, `pathRoot` being the folder its path
167
+ * is relative to. Keyed by the exported name. */
168
+ export declare function moduleLocations(lock: Lock, root: string, pathRoot: string | null): Map<string, ModuleLocation>;
169
+ export interface EnvironmentModules {
170
+ /** The spex repository's key. */
171
+ repository: string;
172
+ locations: Map<string, ModuleLocation>;
173
+ }
174
+ export type LaunchModules = {
175
+ ok: true;
176
+ modules: Map<string, ModuleLocation & {
177
+ repository: string;
178
+ }>;
179
+ } | {
180
+ ok: false;
181
+ errors: {
182
+ playbook: string;
183
+ repository: string;
184
+ }[];
185
+ };
186
+ /** The modules a session hands the launcher (environments-9): each
187
+ * enabled playbook from the project's environment, else your own
188
+ * group's; one no environment exports is a config error naming the
189
+ * playbook and the spex repository whose environment lacks it. */
190
+ export declare function launchModules(enabled: Iterable<string>, project: EnvironmentModules | null, own: EnvironmentModules): LaunchModules;