@miadi/inquiry-weave 0.16.6 → 0.17.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/dist/artefact-dsl.d.ts +60 -0
- package/dist/artefact-dsl.d.ts.map +1 -0
- package/dist/artefact-dsl.js +138 -0
- package/dist/artefact-dsl.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/markdown-directives.d.ts +2 -0
- package/dist/markdown-directives.d.ts.map +1 -1
- package/dist/markdown-directives.js +23 -1
- package/dist/markdown-directives.js.map +1 -1
- package/dist/mcp-server.js +213 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/mint.d.ts +261 -1
- package/dist/mint.d.ts.map +1 -1
- package/dist/mint.js +565 -0
- package/dist/mint.js.map +1 -1
- package/dist/notebook.d.ts +88 -0
- package/dist/notebook.d.ts.map +1 -0
- package/dist/notebook.js +258 -0
- package/dist/notebook.js.map +1 -0
- package/dist/pde.d.ts +54 -0
- package/dist/pde.d.ts.map +1 -0
- package/dist/pde.js +165 -0
- package/dist/pde.js.map +1 -0
- package/dist/prototype.d.ts +90 -0
- package/dist/prototype.d.ts.map +1 -0
- package/dist/prototype.js +286 -0
- package/dist/prototype.js.map +1 -0
- package/dist/references.d.ts +2 -0
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +2 -0
- package/dist/references.js.map +1 -1
- package/dist/rise-dsl.d.ts +44 -0
- package/dist/rise-dsl.d.ts.map +1 -0
- package/dist/rise-dsl.js +99 -0
- package/dist/rise-dsl.js.map +1 -0
- package/dist/rise-workspaces.d.ts +34 -0
- package/dist/rise-workspaces.d.ts.map +1 -0
- package/dist/rise-workspaces.js +73 -0
- package/dist/rise-workspaces.js.map +1 -0
- package/dist/rispec.d.ts +72 -0
- package/dist/rispec.d.ts.map +1 -0
- package/dist/rispec.js +227 -0
- package/dist/rispec.js.map +1 -0
- package/dist/text-references.d.ts +3 -2
- package/dist/text-references.d.ts.map +1 -1
- package/dist/text-references.js +29 -3
- package/dist/text-references.js.map +1 -1
- package/dist/tracing.d.ts +95 -0
- package/dist/tracing.d.ts.map +1 -0
- package/dist/tracing.js +302 -0
- package/dist/tracing.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prototype seam — a prototype entering an episode, in the shape the
|
|
3
|
+
* review (jgwill/Miadi#630) and foundation (#713) seams set: one reusable
|
|
4
|
+
* `prototype:<slug>` node on the wheel, one `chronicle:<episode>` →
|
|
5
|
+
* `prototype:<slug>` edge whose relationship type names what the episode does
|
|
6
|
+
* with it (`is-prototyped-in` when nobody said), and an entry in
|
|
7
|
+
* `episode.yaml`'s `prototypes:` list.
|
|
8
|
+
*
|
|
9
|
+
* Two addresses, two reaches. The published address goes in the manifest
|
|
10
|
+
* and on the node (`public_url`). The editing address (a v0 chat, say) goes
|
|
11
|
+
* in the node's metadata only (`editor_url`) and is handed out by the door to
|
|
12
|
+
* a viewer who may edit the episode; it is never written in `episode.yaml`,
|
|
13
|
+
* which is served to every reader of the episode. Rules kept from the other
|
|
14
|
+
* seams: the manifest entry is written once and never overwritten, one
|
|
15
|
+
* ordered node pair is one edge, and the wheel projection never throws.
|
|
16
|
+
* Ref: jgwill/Miadi#769 (A2), jgwill/miadi-orchestration-kit#80.
|
|
17
|
+
*/
|
|
18
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import { dirname } from "node:path";
|
|
21
|
+
import { Scalar, isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
22
|
+
import { DEFAULT_PROTOTYPE_RELATION, PROTOTYPE_ENTRY_KEYS, PROTOTYPE_NODE_KIND, isPrototypeSlug, prototypeNodeId, prototypeReference, prototypeSlugOf, prototypeUrlOf, toEpisodePrototypeEntry, } from "@miadi/episodic-memory-schema";
|
|
23
|
+
import { missingManifestRemedy } from "./episode.js";
|
|
24
|
+
import { edgesFrom, failure, wheelJson } from "./review.js";
|
|
25
|
+
export class PrototypeError extends Error {
|
|
26
|
+
code;
|
|
27
|
+
constructor(code, message) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.code = code;
|
|
30
|
+
this.name = "PrototypeError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The slug an input names: a slug or `miadi-prototype:<slug>`. */
|
|
34
|
+
export function requirePrototypeSlug(raw) {
|
|
35
|
+
const text = typeof raw === "string" ? raw.trim() : "";
|
|
36
|
+
if (isPrototypeSlug(text))
|
|
37
|
+
return text;
|
|
38
|
+
const slug = prototypeSlugOf(text);
|
|
39
|
+
if (slug)
|
|
40
|
+
return slug;
|
|
41
|
+
throw new PrototypeError("invalid_prototype", `prototype '${String(raw)}' is not a slug or a miadi-prototype: reference`);
|
|
42
|
+
}
|
|
43
|
+
/** The published address an input names, or a refusal. */
|
|
44
|
+
export function requirePrototypeUrl(raw) {
|
|
45
|
+
const url = prototypeUrlOf(raw);
|
|
46
|
+
if (!url)
|
|
47
|
+
throw new PrototypeError("invalid_prototype", `prototype address '${String(raw)}' must be an https URL`);
|
|
48
|
+
if (looksLikeEditor(url))
|
|
49
|
+
throw new PrototypeError("invalid_prototype", `'${url}' is an editing address; give the published address as url and this one as editor`);
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
/** A v0 chat page is where a prototype is edited, never where it is published. */
|
|
53
|
+
export function looksLikeEditor(url) {
|
|
54
|
+
try {
|
|
55
|
+
const u = new URL(url);
|
|
56
|
+
return /(^|\.)v0\.(app|dev)$/i.test(u.hostname) && /\/chat\//.test(u.pathname);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The published and the editing address are two doors; one URL cannot be both. */
|
|
63
|
+
export function assertDistinctPrototypeAddresses(url, editor) {
|
|
64
|
+
if (editor && editor === url)
|
|
65
|
+
throw new PrototypeError("invalid_prototype", "the editing address equals the published address; a reader would be handed the editor");
|
|
66
|
+
}
|
|
67
|
+
/** The editing address, when given: https, kept off the manifest. */
|
|
68
|
+
export function optionalEditorUrl(raw) {
|
|
69
|
+
if (raw === undefined || raw === null || raw === "")
|
|
70
|
+
return undefined;
|
|
71
|
+
const url = prototypeUrlOf(raw);
|
|
72
|
+
if (url)
|
|
73
|
+
return url;
|
|
74
|
+
throw new PrototypeError("invalid_prototype", `editing address '${String(raw)}' must be an https URL`);
|
|
75
|
+
}
|
|
76
|
+
function quoted(doc, value) {
|
|
77
|
+
const node = doc.createNode(value);
|
|
78
|
+
node.type = Scalar.QUOTE_SINGLE;
|
|
79
|
+
return node;
|
|
80
|
+
}
|
|
81
|
+
function valueNode(doc, value) {
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
const seq = doc.createNode([]);
|
|
84
|
+
for (const item of value)
|
|
85
|
+
seq.items.push(quoted(doc, item));
|
|
86
|
+
return seq;
|
|
87
|
+
}
|
|
88
|
+
return quoted(doc, value);
|
|
89
|
+
}
|
|
90
|
+
function entryNode(doc, entry) {
|
|
91
|
+
const map = doc.createNode({});
|
|
92
|
+
for (const key of PROTOTYPE_ENTRY_KEYS) {
|
|
93
|
+
const value = entry[key];
|
|
94
|
+
if (value === undefined || value === "" || (Array.isArray(value) && value.length === 0))
|
|
95
|
+
continue;
|
|
96
|
+
map.set(key, valueNode(doc, value));
|
|
97
|
+
}
|
|
98
|
+
return map;
|
|
99
|
+
}
|
|
100
|
+
const sameEntry = (a, b) => a !== null && a.id === b.id;
|
|
101
|
+
/**
|
|
102
|
+
* Add a prototype to `episode.yaml`'s `prototypes:` list, or fill the keys an
|
|
103
|
+
* existing entry lacks. Comments, key order and every other field survive.
|
|
104
|
+
* Refuses a `prototypes` key that is not a list. Never writes an editing address.
|
|
105
|
+
*/
|
|
106
|
+
export async function upsertEpisodePrototype(input) {
|
|
107
|
+
if (!existsSync(input.episodeYamlPath)) {
|
|
108
|
+
throw new PrototypeError("prototype_manifest_conflict", missingManifestRemedy(dirname(input.episodeYamlPath)));
|
|
109
|
+
}
|
|
110
|
+
const doc = parseDocument(await readFile(input.episodeYamlPath, "utf8"));
|
|
111
|
+
if (doc.errors.length > 0) {
|
|
112
|
+
throw new PrototypeError("prototype_manifest_conflict", `unreadable episode.yaml ${input.episodeYamlPath}: ${doc.errors[0].message}`);
|
|
113
|
+
}
|
|
114
|
+
if (!isMap(doc.contents)) {
|
|
115
|
+
throw new PrototypeError("prototype_manifest_conflict", `episode.yaml ${input.episodeYamlPath} is not a mapping`);
|
|
116
|
+
}
|
|
117
|
+
const list = doc.get("prototypes", true);
|
|
118
|
+
let created = false;
|
|
119
|
+
const filled = [];
|
|
120
|
+
let entry;
|
|
121
|
+
if (list === undefined || list === null || (isScalar(list) && (list.value === null || list.value === undefined))) {
|
|
122
|
+
created = true;
|
|
123
|
+
entry = input.entry;
|
|
124
|
+
const seq = doc.createNode([]);
|
|
125
|
+
seq.items.push(entryNode(doc, entry));
|
|
126
|
+
if (isScalar(list) && list.comment)
|
|
127
|
+
seq.comment = list.comment;
|
|
128
|
+
doc.set("prototypes", seq);
|
|
129
|
+
}
|
|
130
|
+
else if (!isSeq(list)) {
|
|
131
|
+
throw new PrototypeError("prototype_manifest_conflict", `prototypes in ${input.episodeYamlPath} is not a list — refusing to overwrite`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const index = list.items.findIndex((item) => sameEntry(toEpisodePrototypeEntry(isMap(item) ? item.toJSON() : item), input.entry));
|
|
135
|
+
if (index < 0) {
|
|
136
|
+
created = true;
|
|
137
|
+
entry = input.entry;
|
|
138
|
+
list.items.push(entryNode(doc, entry));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const item = list.items[index];
|
|
142
|
+
if (!isMap(item)) {
|
|
143
|
+
entry = input.entry;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
for (const key of PROTOTYPE_ENTRY_KEYS) {
|
|
147
|
+
const value = input.entry[key];
|
|
148
|
+
if (value === undefined || value === "" || (Array.isArray(value) && value.length === 0))
|
|
149
|
+
continue;
|
|
150
|
+
const present = item.get(key);
|
|
151
|
+
if (present === undefined || present === null || present === "") {
|
|
152
|
+
item.set(key, valueNode(doc, value));
|
|
153
|
+
filled.push(key);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
entry = toEpisodePrototypeEntry(item.toJSON()) ?? input.entry;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const wrote = (created || filled.length > 0) && !input.dryRun;
|
|
161
|
+
if (wrote)
|
|
162
|
+
await writeFile(input.episodeYamlPath, doc.toString(), "utf8");
|
|
163
|
+
return { entry, created, filled, wrote, dryRun: input.dryRun === true };
|
|
164
|
+
}
|
|
165
|
+
/** The relationship type of an episode→prototype edge already on the wheel. Never throws. */
|
|
166
|
+
export async function existingPrototypeRelation(mwUrl, episodeNodeId, nodeId, options = {}) {
|
|
167
|
+
const listing = await wheelJson(options.fetchImpl ?? fetch, `${mwUrl.replace(/\/+$/, "")}/api/edges?limit=all`);
|
|
168
|
+
if (!listing.ok)
|
|
169
|
+
return undefined;
|
|
170
|
+
const edge = edgesFrom(listing.body).find((e) => String(e.from_id) === episodeNodeId && String(e.to_id) === nodeId);
|
|
171
|
+
return typeof edge?.relationship_type === "string" && edge.relationship_type ? edge.relationship_type : undefined;
|
|
172
|
+
}
|
|
173
|
+
/** The editing address a prototype node holds, for a viewer the door has already checked. Never throws. */
|
|
174
|
+
export async function prototypeEditorUrl(mwUrl, slug, options = {}) {
|
|
175
|
+
const read = await wheelJson(options.fetchImpl ?? fetch, `${mwUrl.replace(/\/+$/, "")}/api/nodes/${encodeURIComponent(prototypeNodeId(slug))}`);
|
|
176
|
+
if (!read.ok)
|
|
177
|
+
return undefined;
|
|
178
|
+
const editor = read.body?.node?.metadata?.editor_url;
|
|
179
|
+
return typeof editor === "string" && editor ? editor : undefined;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Put the prototype node and the episode→prototype edge on the wheel. A
|
|
183
|
+
* prototype is a `knowledge` node. When the node exists, only an editing
|
|
184
|
+
* address it lacks is added, so a hand-written name and description stay.
|
|
185
|
+
*/
|
|
186
|
+
export async function projectEpisodePrototype(mwUrl, input, options = {}) {
|
|
187
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
188
|
+
const base = mwUrl.replace(/\/+$/, "");
|
|
189
|
+
const nodeId = prototypeNodeId(input.entry.id);
|
|
190
|
+
const edgeId = `${input.episodeNodeId}:${nodeId}`;
|
|
191
|
+
const projection = {
|
|
192
|
+
node: { id: nodeId, state: "pending" },
|
|
193
|
+
edge: { id: edgeId, state: "pending", relationship_type: input.relation },
|
|
194
|
+
};
|
|
195
|
+
const nodeUrl = `${base}/api/nodes/${encodeURIComponent(nodeId)}`;
|
|
196
|
+
const read = await wheelJson(fetchImpl, nodeUrl);
|
|
197
|
+
if (read.ok) {
|
|
198
|
+
const node = read.body?.node;
|
|
199
|
+
if (!input.editor || node?.metadata?.editor_url) {
|
|
200
|
+
projection.node.state = "already-present";
|
|
201
|
+
}
|
|
202
|
+
else if (options.dryRun) {
|
|
203
|
+
projection.node.state = "skipped";
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const patched = await wheelJson(fetchImpl, nodeUrl, {
|
|
207
|
+
method: "PATCH",
|
|
208
|
+
headers: { "content-type": "application/json" },
|
|
209
|
+
body: JSON.stringify({ metadata: { editor_url: input.editor } }),
|
|
210
|
+
});
|
|
211
|
+
projection.node = patched.ok ? { id: nodeId, state: "refreshed" } : { id: nodeId, state: "pending", error: failure("PATCH", nodeUrl, patched) };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (read.status === 404) {
|
|
215
|
+
if (options.dryRun) {
|
|
216
|
+
projection.node.state = "skipped";
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const title = input.entry.title ?? input.entry.id;
|
|
220
|
+
const created = await wheelJson(fetchImpl, `${base}/api/nodes`, {
|
|
221
|
+
method: "POST",
|
|
222
|
+
headers: { "content-type": "application/json" },
|
|
223
|
+
body: JSON.stringify({
|
|
224
|
+
id: nodeId,
|
|
225
|
+
type: "knowledge",
|
|
226
|
+
name: `Prototype — ${title}`,
|
|
227
|
+
description: `A prototype made from episode ${input.episodeFolder}: ${title}.`,
|
|
228
|
+
direction: "south",
|
|
229
|
+
metadata: {
|
|
230
|
+
kind: PROTOTYPE_NODE_KIND,
|
|
231
|
+
slug: input.entry.id,
|
|
232
|
+
public_url: input.entry.url,
|
|
233
|
+
address: prototypeReference(input.entry.id),
|
|
234
|
+
episode_path: input.episodeFolder,
|
|
235
|
+
...(input.entry.made_with ? { made_with: input.entry.made_with } : {}),
|
|
236
|
+
...(input.entry.source ? { source: input.entry.source } : {}),
|
|
237
|
+
...(input.entry.commit ? { commit: input.entry.commit } : {}),
|
|
238
|
+
...(input.entry.issue ? { issue: input.entry.issue } : {}),
|
|
239
|
+
...(input.entry.reads?.length ? { reads: input.entry.reads } : {}),
|
|
240
|
+
...(input.editor ? { editor_url: input.editor } : {}),
|
|
241
|
+
},
|
|
242
|
+
}),
|
|
243
|
+
});
|
|
244
|
+
projection.node = created.ok ? { id: nodeId, state: "created" } : { id: nodeId, state: "pending", error: failure("POST", `${base}/api/nodes`, created) };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
projection.node = { id: nodeId, state: "pending", error: failure("GET", nodeUrl, read) };
|
|
249
|
+
}
|
|
250
|
+
if (projection.node.state === "pending") {
|
|
251
|
+
projection.edge.error = "the prototype node is not on the wheel yet";
|
|
252
|
+
return projection;
|
|
253
|
+
}
|
|
254
|
+
const edgesUrl = `${base}/api/edges`;
|
|
255
|
+
const listing = await wheelJson(fetchImpl, `${edgesUrl}?limit=all`);
|
|
256
|
+
if (!listing.ok) {
|
|
257
|
+
projection.edge.error = failure("GET", edgesUrl, listing);
|
|
258
|
+
return projection;
|
|
259
|
+
}
|
|
260
|
+
const existing = edgesFrom(listing.body).find((edge) => String(edge.from_id) === input.episodeNodeId && String(edge.to_id) === nodeId);
|
|
261
|
+
if (existing) {
|
|
262
|
+
projection.edge = { id: edgeId, state: "already-present", relationship_type: String(existing.relationship_type ?? input.relation) };
|
|
263
|
+
return projection;
|
|
264
|
+
}
|
|
265
|
+
if (options.dryRun) {
|
|
266
|
+
projection.edge.state = "skipped";
|
|
267
|
+
return projection;
|
|
268
|
+
}
|
|
269
|
+
const posted = await wheelJson(fetchImpl, edgesUrl, {
|
|
270
|
+
method: "POST",
|
|
271
|
+
headers: { "content-type": "application/json" },
|
|
272
|
+
body: JSON.stringify({ from_id: input.episodeNodeId, to_id: nodeId, relationship_type: input.relation, strength: 1, obligations: [] }),
|
|
273
|
+
});
|
|
274
|
+
if (posted.ok && posted.body?.replaced === true) {
|
|
275
|
+
projection.edge = { id: edgeId, state: "pending", relationship_type: input.relation, error: "the wheel replaced an edge the listing did not show; check the edge by hand" };
|
|
276
|
+
}
|
|
277
|
+
else if (posted.ok)
|
|
278
|
+
projection.edge.state = "created";
|
|
279
|
+
else if (posted.status === 409)
|
|
280
|
+
projection.edge.state = "already-present";
|
|
281
|
+
else
|
|
282
|
+
projection.edge.error = failure("POST", edgesUrl, posted);
|
|
283
|
+
return projection;
|
|
284
|
+
}
|
|
285
|
+
export { DEFAULT_PROTOTYPE_RELATION };
|
|
286
|
+
//# sourceMappingURL=prototype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype.js","sourceRoot":"","sources":["../src/prototype.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,O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,EAAE,OAAO,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;KACvI,CAAC,CAAA;IACF,IAAI,MAAM,CAAC,EAAE,IAAK,MAAM,CAAC,IAAsC,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;QACnF,UAAU,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,6EAA6E,EAAE,CAAA;IAC7K,CAAC;SAAM,IAAI,MAAM,CAAC,EAAE;QAAE,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;SAClD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,iBAAiB,CAAA;;QACpE,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC9D,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
|
package/dist/references.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export * from "./chronicle-dsl.js";
|
|
9
9
|
export * from "./foundation-dsl.js";
|
|
10
|
+
export * from "./artefact-dsl.js";
|
|
11
|
+
export * from "./rise-dsl.js";
|
|
10
12
|
export * from "./text-references.js";
|
|
11
13
|
export * from "./markdown-directives.js";
|
|
12
14
|
//# sourceMappingURL=references.d.ts.map
|
package/dist/references.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA"}
|
package/dist/references.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export * from "./chronicle-dsl.js";
|
|
9
9
|
export * from "./foundation-dsl.js";
|
|
10
|
+
export * from "./artefact-dsl.js";
|
|
11
|
+
export * from "./rise-dsl.js";
|
|
10
12
|
export * from "./text-references.js";
|
|
11
13
|
export * from "./markdown-directives.js";
|
|
12
14
|
//# sourceMappingURL=references.js.map
|
package/dist/references.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The RISE address — a specification, wherever its repository is checked out
|
|
3
|
+
* (jgwill/Miadi#769, A4; Guillaume, 2026-10-10: "rise://<owner>/<repo>/<filepath>
|
|
4
|
+
* that way we just have to wire something locally of where the repo is").
|
|
5
|
+
*
|
|
6
|
+
* rise://<owner>/<repo>/<path>[@<commit>]
|
|
7
|
+
*
|
|
8
|
+
* rise://jgwill/Miadi/rispecs/AGENTS.md
|
|
9
|
+
* rise://jgwill/llms-txt/llms-rise-framework.txt@27cf18f
|
|
10
|
+
* rise://jgwill/episodes/miadi-chronicle/2026-10-10-episode-552-x/rispecs/what-an-episode-holds/SPEC.md
|
|
11
|
+
*
|
|
12
|
+
* The address names the repository and the file, never a host path. Where
|
|
13
|
+
* that repository is checked out on this host is a local map, read by the
|
|
14
|
+
* server-only `rise-workspaces.ts` (exported from the package root, never from
|
|
15
|
+
* `./references`, which stays free of Node so a browser can take it). A host
|
|
16
|
+
* with no checkout opens the file on GitHub.
|
|
17
|
+
* Grounding: foundations/resource-addressing-and-terminal-hypermedia/.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RISE_SCHEME = "rise:";
|
|
20
|
+
export interface ParsedRiseUri {
|
|
21
|
+
uri: string;
|
|
22
|
+
canonical: string;
|
|
23
|
+
owner: string;
|
|
24
|
+
repo: string;
|
|
25
|
+
/** Repository-relative path, forward slashes, no leading slash. */
|
|
26
|
+
path: string;
|
|
27
|
+
/** A commit, tag or branch the address pins. */
|
|
28
|
+
commit?: string;
|
|
29
|
+
query: Record<string, string>;
|
|
30
|
+
options: Record<string, string>;
|
|
31
|
+
fragment?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function isRiseUri(href: string | undefined): boolean;
|
|
34
|
+
export declare function canonicalRiseRef(owner: string, repo: string, path: string, commit?: string): string;
|
|
35
|
+
export declare function parseRiseUri(uri: string): ParsedRiseUri | null;
|
|
36
|
+
/** The wheel node id a spec address names: `rise:<owner>/<repo>/<path>` (no commit: one node per file). */
|
|
37
|
+
export declare function riseNodeId(parsed: Pick<ParsedRiseUri, "owner" | "repo" | "path">): string;
|
|
38
|
+
/** Repositories whose remote is not GitHub: `jgwill/episodes` lives on gaia (`/srv/git/jgwill/episodes.git`). */
|
|
39
|
+
export declare const RISE_REPOS_WITHOUT_GITHUB: ReadonlySet<string>;
|
|
40
|
+
/** The file on GitHub, at the pinned commit or at HEAD of the default branch; null when the repository has no GitHub page. */
|
|
41
|
+
export declare function riseGithubUrl(parsed: Pick<ParsedRiseUri, "owner" | "repo" | "path" | "commit" | "fragment">, defaultRef?: string): string | null;
|
|
42
|
+
/** Every `rise:` address in a text, as written, in order of first appearance; code is skipped. */
|
|
43
|
+
export declare function extractRiseUris(text: string): string[];
|
|
44
|
+
//# sourceMappingURL=rise-dsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rise-dsl.d.ts","sourceRoot":"","sources":["../src/rise-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AASD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE3D;AAUD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnG;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAyB9D;AAED,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAEzF;AAED,iHAAiH;AACjH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAgC,CAAA;AAE1F,8HAA8H;AAC9H,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE,UAAU,SAAS,GAAG,MAAM,GAAG,IAAI,CAKhJ;AAED,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAatD"}
|
package/dist/rise-dsl.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The RISE address — a specification, wherever its repository is checked out
|
|
3
|
+
* (jgwill/Miadi#769, A4; Guillaume, 2026-10-10: "rise://<owner>/<repo>/<filepath>
|
|
4
|
+
* that way we just have to wire something locally of where the repo is").
|
|
5
|
+
*
|
|
6
|
+
* rise://<owner>/<repo>/<path>[@<commit>]
|
|
7
|
+
*
|
|
8
|
+
* rise://jgwill/Miadi/rispecs/AGENTS.md
|
|
9
|
+
* rise://jgwill/llms-txt/llms-rise-framework.txt@27cf18f
|
|
10
|
+
* rise://jgwill/episodes/miadi-chronicle/2026-10-10-episode-552-x/rispecs/what-an-episode-holds/SPEC.md
|
|
11
|
+
*
|
|
12
|
+
* The address names the repository and the file, never a host path. Where
|
|
13
|
+
* that repository is checked out on this host is a local map, read by the
|
|
14
|
+
* server-only `rise-workspaces.ts` (exported from the package root, never from
|
|
15
|
+
* `./references`, which stays free of Node so a browser can take it). A host
|
|
16
|
+
* with no checkout opens the file on GitHub.
|
|
17
|
+
* Grounding: foundations/resource-addressing-and-terminal-hypermedia/.
|
|
18
|
+
*/
|
|
19
|
+
import { OPTION_PREFIX } from "./chronicle-dsl.js";
|
|
20
|
+
export const RISE_SCHEME = "rise:";
|
|
21
|
+
const NAME = "[A-Za-z0-9][A-Za-z0-9._-]{0,99}";
|
|
22
|
+
// [1]=owner [2]=repo [3]=path [4]=commit [5]=query [6]=fragment
|
|
23
|
+
const RISE_URI_RE = new RegExp(`^rise:(?:\\/\\/)?(${NAME})\\/(${NAME})\\/((?:[A-Za-z0-9._~-]{1,128}\\/){0,16}[A-Za-z0-9._~-]{1,128})(?:@([A-Za-z0-9._\\/-]{1,80}))?(?:\\?([^#\\u0000-\\u001f\\u007f-\\u009f]*))?(?:#([^\\u0000-\\u001f\\u007f-\\u009f]*))?$`, "i");
|
|
24
|
+
export function isRiseUri(href) {
|
|
25
|
+
return typeof href === "string" && /^rise:/i.test(href.trim());
|
|
26
|
+
}
|
|
27
|
+
function safeDecode(s) {
|
|
28
|
+
try {
|
|
29
|
+
return decodeURIComponent(s);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return s;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function canonicalRiseRef(owner, repo, path, commit) {
|
|
36
|
+
return `${RISE_SCHEME}//${owner}/${repo}/${path}${commit ? `@${commit}` : ""}`;
|
|
37
|
+
}
|
|
38
|
+
export function parseRiseUri(uri) {
|
|
39
|
+
const trimmed = uri.trim();
|
|
40
|
+
const m = RISE_URI_RE.exec(trimmed);
|
|
41
|
+
if (!m || !m[1] || !m[2] || !m[3])
|
|
42
|
+
return null;
|
|
43
|
+
const [, owner, repo, path, commit] = m;
|
|
44
|
+
const segments = path.split("/");
|
|
45
|
+
if (segments.some((s) => s === "." || s === ".." || s.startsWith(".")))
|
|
46
|
+
return null;
|
|
47
|
+
if (owner.includes("..") || repo.includes(".."))
|
|
48
|
+
return null;
|
|
49
|
+
const query = {};
|
|
50
|
+
const options = {};
|
|
51
|
+
for (const pair of (m[5] ?? "").split("&")) {
|
|
52
|
+
if (!pair)
|
|
53
|
+
continue;
|
|
54
|
+
const eq = pair.indexOf("=");
|
|
55
|
+
const key = safeDecode(eq === -1 ? pair : pair.slice(0, eq));
|
|
56
|
+
const value = eq === -1 ? "" : safeDecode(pair.slice(eq + 1));
|
|
57
|
+
if (key.startsWith(OPTION_PREFIX))
|
|
58
|
+
options[key.slice(OPTION_PREFIX.length)] = value;
|
|
59
|
+
else
|
|
60
|
+
query[key] = value;
|
|
61
|
+
}
|
|
62
|
+
const fragment = m[6] || undefined;
|
|
63
|
+
const params = [
|
|
64
|
+
...Object.entries(query).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`),
|
|
65
|
+
...Object.entries(options).map(([k, v]) => `${OPTION_PREFIX}${encodeURIComponent(k)}=${encodeURIComponent(v)}`),
|
|
66
|
+
];
|
|
67
|
+
const canonical = canonicalRiseRef(owner, repo, path, commit) + (params.length > 0 ? `?${params.join("&")}` : "") + (fragment ? `#${fragment}` : "");
|
|
68
|
+
return { uri: trimmed, canonical, owner: owner, repo: repo, path: path, ...(commit ? { commit } : {}), query, options, ...(fragment ? { fragment } : {}) };
|
|
69
|
+
}
|
|
70
|
+
/** The wheel node id a spec address names: `rise:<owner>/<repo>/<path>` (no commit: one node per file). */
|
|
71
|
+
export function riseNodeId(parsed) {
|
|
72
|
+
return `rise:${parsed.owner}/${parsed.repo}/${parsed.path}`;
|
|
73
|
+
}
|
|
74
|
+
/** Repositories whose remote is not GitHub: `jgwill/episodes` lives on gaia (`/srv/git/jgwill/episodes.git`). */
|
|
75
|
+
export const RISE_REPOS_WITHOUT_GITHUB = new Set(["jgwill/episodes"]);
|
|
76
|
+
/** The file on GitHub, at the pinned commit or at HEAD of the default branch; null when the repository has no GitHub page. */
|
|
77
|
+
export function riseGithubUrl(parsed, defaultRef = "HEAD") {
|
|
78
|
+
if (RISE_REPOS_WITHOUT_GITHUB.has(`${parsed.owner}/${parsed.repo}`))
|
|
79
|
+
return null;
|
|
80
|
+
const ref = parsed.commit ?? defaultRef;
|
|
81
|
+
const path = parsed.path.split("/").map(encodeURIComponent).join("/");
|
|
82
|
+
return `https://github.com/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}/blob/${encodeURIComponent(ref)}/${path}${parsed.fragment ? `#${encodeURI(parsed.fragment)}` : ""}`;
|
|
83
|
+
}
|
|
84
|
+
/** Every `rise:` address in a text, as written, in order of first appearance; code is skipped. */
|
|
85
|
+
export function extractRiseUris(text) {
|
|
86
|
+
const prose = text.replace(/```[\s\S]*?```/g, " ").replace(/`[^`\n]*`/g, " ");
|
|
87
|
+
const re = /(?<![\w/?=&%.~+:@#!-])rise:(?:\/\/)?[A-Za-z0-9._~:/?=&%#+@-]{1,600}/gi;
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const m of prose.matchAll(re)) {
|
|
91
|
+
const raw = m[0].replace(/[.,;:)\]]+$/, "");
|
|
92
|
+
if (!seen.has(raw) && parseRiseUri(raw)) {
|
|
93
|
+
seen.add(raw);
|
|
94
|
+
out.push(raw);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=rise-dsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rise-dsl.js","sourceRoot":"","sources":["../src/rise-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAgBlC,MAAM,IAAI,GAAG,iCAAiC,CAAA;AAC9C,gEAAgE;AAChE,MAAM,WAAW,GAAG,IAAI,MAAM,CAC5B,qBAAqB,IAAI,QAAQ,IAAI,wLAAwL,EAC7N,GAAG,CACJ,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,OAAO,OAAO,IAAI,KA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G,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a `rise://` repository is checked out on this host — server-only
|
|
3
|
+
* (reads the filesystem), exported from the package root and never from
|
|
4
|
+
* `./references` (jgwill/Miadi#769, A4; review F1).
|
|
5
|
+
*
|
|
6
|
+
* Order: `MIADI_RISE_WORKSPACES` (JSON, `{ "owner/repo": "/path" }`), then
|
|
7
|
+
* `config/stc-workspaces.json` (its `workspaces[].repository` → `localPath`),
|
|
8
|
+
* then the `/workspace/repos/<owner>/<repo>` convention, then the checkouts
|
|
9
|
+
* this host is known to keep. `KNOWN_HOST_PATHS` is the reverse map, for
|
|
10
|
+
* manifests that cite a host path instead of an address.
|
|
11
|
+
*/
|
|
12
|
+
import type { HostPathRepository } from "@miadi/episodic-memory-schema";
|
|
13
|
+
import type { ParsedRiseUri } from "./rise-dsl.js";
|
|
14
|
+
/** Host paths older manifests cite, read as the repository they are checkouts of (gaia's layout). */
|
|
15
|
+
export declare const KNOWN_HOST_PATHS: ReadonlyArray<HostPathRepository>;
|
|
16
|
+
/** The checkouts this host keeps for repositories the workspace map may not list. */
|
|
17
|
+
export declare const KNOWN_RISE_WORKSPACES: Record<string, string>;
|
|
18
|
+
export interface RiseWorkspaceOptions {
|
|
19
|
+
env?: NodeJS.ProcessEnv;
|
|
20
|
+
/** The `config/stc-workspaces.json` to read; default is the Miadi checkout's. */
|
|
21
|
+
workspacesFile?: string;
|
|
22
|
+
/** The folder the `/workspace/repos/<owner>/<repo>` convention lives under. */
|
|
23
|
+
reposRoot?: string;
|
|
24
|
+
known?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Where `<owner>/<repo>` is checked out on this host, or null. Order:
|
|
28
|
+
* `MIADI_RISE_WORKSPACES`, the stc workspaces map, `/workspace/repos`, the
|
|
29
|
+
* known checkouts. A path is answered only when it exists.
|
|
30
|
+
*/
|
|
31
|
+
export declare function riseWorkspacePath(owner: string, repo: string, options?: RiseWorkspaceOptions): string | null;
|
|
32
|
+
/** The file a spec address names on this host, or null when the repository is not checked out here. */
|
|
33
|
+
export declare function riseLocalPath(parsed: Pick<ParsedRiseUri, "owner" | "repo" | "path">, options?: RiseWorkspaceOptions): string | null;
|
|
34
|
+
//# sourceMappingURL=rise-workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rise-workspaces.d.ts","sourceRoot":"","sources":["../src/rise-workspaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,qGAAqG;AACrG,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAM9D,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIxD,CAAA;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,GAAG,IAAI,CAwBhH;AAED,uGAAuG;AACvG,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,GAAG,IAAI,CAKvI"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a `rise://` repository is checked out on this host — server-only
|
|
3
|
+
* (reads the filesystem), exported from the package root and never from
|
|
4
|
+
* `./references` (jgwill/Miadi#769, A4; review F1).
|
|
5
|
+
*
|
|
6
|
+
* Order: `MIADI_RISE_WORKSPACES` (JSON, `{ "owner/repo": "/path" }`), then
|
|
7
|
+
* `config/stc-workspaces.json` (its `workspaces[].repository` → `localPath`),
|
|
8
|
+
* then the `/workspace/repos/<owner>/<repo>` convention, then the checkouts
|
|
9
|
+
* this host is known to keep. `KNOWN_HOST_PATHS` is the reverse map, for
|
|
10
|
+
* manifests that cite a host path instead of an address.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
/** Host paths older manifests cite, read as the repository they are checkouts of (gaia's layout). */
|
|
15
|
+
export const KNOWN_HOST_PATHS = [
|
|
16
|
+
{ prefix: "/src/Miadi/", owner: "jgwill", repo: "Miadi" },
|
|
17
|
+
{ prefix: "/a/src/Miadi/", owner: "jgwill", repo: "Miadi" },
|
|
18
|
+
{ prefix: "/a/src/Miadi-18/", owner: "jgwill", repo: "Miadi" },
|
|
19
|
+
{ prefix: "/etc/claude-code/", owner: "jgwill", repo: "etc-claude-code" },
|
|
20
|
+
{ prefix: "/srv/miadi/episodes/", owner: "jgwill", repo: "episodes" },
|
|
21
|
+
];
|
|
22
|
+
/** The checkouts this host keeps for repositories the workspace map may not list. */
|
|
23
|
+
export const KNOWN_RISE_WORKSPACES = {
|
|
24
|
+
"jgwill/Miadi": "/a/src/Miadi",
|
|
25
|
+
"jgwill/etc-claude-code": "/etc/claude-code",
|
|
26
|
+
"jgwill/episodes": "/srv/miadi/episodes",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Where `<owner>/<repo>` is checked out on this host, or null. Order:
|
|
30
|
+
* `MIADI_RISE_WORKSPACES`, the stc workspaces map, `/workspace/repos`, the
|
|
31
|
+
* known checkouts. A path is answered only when it exists.
|
|
32
|
+
*/
|
|
33
|
+
export function riseWorkspacePath(owner, repo, options = {}) {
|
|
34
|
+
const env = options.env ?? process.env;
|
|
35
|
+
const key = `${owner}/${repo}`;
|
|
36
|
+
const candidates = [];
|
|
37
|
+
try {
|
|
38
|
+
const fromEnv = env.MIADI_RISE_WORKSPACES ? JSON.parse(env.MIADI_RISE_WORKSPACES) : {};
|
|
39
|
+
if (typeof fromEnv[key] === "string")
|
|
40
|
+
candidates.push(fromEnv[key]);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// an unreadable env map is no map
|
|
44
|
+
}
|
|
45
|
+
const file = options.workspacesFile ?? join(env.MIADI_SRC ?? "/a/src/Miadi", "config", "stc-workspaces.json");
|
|
46
|
+
try {
|
|
47
|
+
const doc = JSON.parse(readFileSync(file, "utf8"));
|
|
48
|
+
for (const w of doc.workspaces ?? []) {
|
|
49
|
+
if (w.repository === key && typeof w.localPath === "string")
|
|
50
|
+
candidates.push(w.localPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// no map on this host
|
|
55
|
+
}
|
|
56
|
+
candidates.push(join(options.reposRoot ?? "/workspace/repos", owner, repo));
|
|
57
|
+
const known = options.known ?? KNOWN_RISE_WORKSPACES;
|
|
58
|
+
if (known[key])
|
|
59
|
+
candidates.push(known[key]);
|
|
60
|
+
for (const candidate of candidates)
|
|
61
|
+
if (existsSync(candidate))
|
|
62
|
+
return candidate;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/** The file a spec address names on this host, or null when the repository is not checked out here. */
|
|
66
|
+
export function riseLocalPath(parsed, options = {}) {
|
|
67
|
+
const root = riseWorkspacePath(parsed.owner, parsed.repo, options);
|
|
68
|
+
if (!root)
|
|
69
|
+
return null;
|
|
70
|
+
const file = join(root, ...parsed.path.split("/"));
|
|
71
|
+
return existsSync(file) ? file : null;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=r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