@miadi/inquiry-weave 0.18.5 → 0.18.7
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/capability-dsl.d.ts +59 -0
- package/dist/capability-dsl.d.ts.map +1 -0
- package/dist/capability-dsl.js +126 -0
- package/dist/capability-dsl.js.map +1 -0
- package/dist/capability-holding.d.ts +68 -0
- package/dist/capability-holding.d.ts.map +1 -0
- package/dist/capability-holding.js +229 -0
- package/dist/capability-holding.js.map +1 -0
- package/dist/chronicle-terminal.d.ts +25 -0
- package/dist/chronicle-terminal.d.ts.map +1 -1
- package/dist/chronicle-terminal.js +38 -0
- package/dist/chronicle-terminal.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +30 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/markdown-directives.d.ts.map +1 -1
- package/dist/markdown-directives.js +9 -3
- package/dist/markdown-directives.js.map +1 -1
- package/dist/mcp-server.js +46 -4
- package/dist/mcp-server.js.map +1 -1
- package/dist/mint.d.ts +39 -0
- package/dist/mint.d.ts.map +1 -1
- package/dist/mint.js +99 -0
- package/dist/mint.js.map +1 -1
- package/dist/references.d.ts +3 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +3 -2
- package/dist/references.js.map +1 -1
- package/dist/text-references.d.ts +1 -1
- package/dist/text-references.d.ts.map +1 -1
- package/dist/text-references.js +12 -4
- package/dist/text-references.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The capability scheme: the address of one thing a git repository provides
|
|
3
|
+
* to others (Episode 568's Capability Registry; the scheme decided by William
|
|
4
|
+
* on 2026-11-01):
|
|
5
|
+
*
|
|
6
|
+
* miadi-capability:<owner>/<repo>/<kind>/<name>
|
|
7
|
+
*
|
|
8
|
+
* miadi-capability://jgwill/medicine-wheel/cli/mw
|
|
9
|
+
* miadi-capability://jgwill/medicine-wheel/skill/fire-keeper-check
|
|
10
|
+
* miadi-capability://jgwill/Miadi/package/@miadi/inquiry-weave
|
|
11
|
+
*
|
|
12
|
+
* `<kind>` is what the repository provides it as: `package`, `cli` and `skill`
|
|
13
|
+
* are what `miadi-repomap scan` reads today. The grammar takes any lowercase
|
|
14
|
+
* word, so a kind the registry adds later (an MCP tool, an API route, a
|
|
15
|
+
* plugin) parses before it resolves. `<name>` is the capability's own name and
|
|
16
|
+
* may hold `/`, as a scoped package does.
|
|
17
|
+
*
|
|
18
|
+
* An address carries an identity and never a location: the registry answers
|
|
19
|
+
* which file it was read from, at which commit, and what it says. The door is
|
|
20
|
+
* `/api/chronicle/open`, which sends the reader to the capability's page. The
|
|
21
|
+
* grammar follows the other artefact schemes: `//` accepted on input and
|
|
22
|
+
* dropped from the canonical form, `mc.*` options folded, control characters
|
|
23
|
+
* refused because a reference is printed into terminals.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MIADI_CAPABILITY_SCHEME = "miadi-capability:";
|
|
26
|
+
export interface CapabilityAddressParts {
|
|
27
|
+
owner: string;
|
|
28
|
+
repo: string;
|
|
29
|
+
/** `package`, `cli`, `skill`, … */
|
|
30
|
+
kind: string;
|
|
31
|
+
/** The capability's own name; a scoped package keeps its `/`. */
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ParsedCapabilityUri extends CapabilityAddressParts {
|
|
35
|
+
/** The full original URI, exactly as given. */
|
|
36
|
+
uri: string;
|
|
37
|
+
/** The canonical spelling: no `//`, options and fragment preserved. */
|
|
38
|
+
canonical: string;
|
|
39
|
+
/** `<owner>/<repo>/<kind>/<name>`. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Query params minus the mc.* rendering options. */
|
|
42
|
+
query: Record<string, string>;
|
|
43
|
+
/** mc.* rendering options, prefix stripped (show, label, …). */
|
|
44
|
+
options: Record<string, string>;
|
|
45
|
+
fragment?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function isCapabilityUri(href: string | undefined): boolean;
|
|
48
|
+
/** The canonical address of a capability, without options. */
|
|
49
|
+
export declare function canonicalCapabilityRef(parts: CapabilityAddressParts): string;
|
|
50
|
+
/** The address as a person cites it in prose, with the `//` a terminal links: `miadi-capability://owner/repo/kind/name`. */
|
|
51
|
+
export declare function capabilityCitation(parts: CapabilityAddressParts): string;
|
|
52
|
+
export declare function parseCapabilityUri(uri: string): ParsedCapabilityUri | null;
|
|
53
|
+
/** The capability's page on a Miadi front: `/capabilities/<owner>/<repo>/<kind>/<name>`. */
|
|
54
|
+
export declare function capabilityPageRoute(parts: CapabilityAddressParts): string;
|
|
55
|
+
/** Where a chip points: the host's open door, which sends the reader to the page. */
|
|
56
|
+
export declare function capabilityOpenRoute(parts: CapabilityAddressParts): string;
|
|
57
|
+
/** Every capability address in a text, as written, in order of first appearance. Code is not a reference. */
|
|
58
|
+
export declare function extractCapabilityUris(text: string): string[];
|
|
59
|
+
//# sourceMappingURL=capability-dsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-dsl.d.ts","sourceRoot":"","sources":["../src/capability-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,eAAO,MAAM,uBAAuB,sBAAsB,CAAA;AAE1D,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IACjE,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAA;IACX,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAA;IACjB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAUD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEjE;AAqBD,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAE5E;AAED,4HAA4H;AAC5H,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAExE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAgC1E;AAED,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAEzE;AAED,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAEzE;AAED,6GAA6G;AAC7G,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAa5D"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The capability scheme: the address of one thing a git repository provides
|
|
3
|
+
* to others (Episode 568's Capability Registry; the scheme decided by William
|
|
4
|
+
* on 2026-11-01):
|
|
5
|
+
*
|
|
6
|
+
* miadi-capability:<owner>/<repo>/<kind>/<name>
|
|
7
|
+
*
|
|
8
|
+
* miadi-capability://jgwill/medicine-wheel/cli/mw
|
|
9
|
+
* miadi-capability://jgwill/medicine-wheel/skill/fire-keeper-check
|
|
10
|
+
* miadi-capability://jgwill/Miadi/package/@miadi/inquiry-weave
|
|
11
|
+
*
|
|
12
|
+
* `<kind>` is what the repository provides it as: `package`, `cli` and `skill`
|
|
13
|
+
* are what `miadi-repomap scan` reads today. The grammar takes any lowercase
|
|
14
|
+
* word, so a kind the registry adds later (an MCP tool, an API route, a
|
|
15
|
+
* plugin) parses before it resolves. `<name>` is the capability's own name and
|
|
16
|
+
* may hold `/`, as a scoped package does.
|
|
17
|
+
*
|
|
18
|
+
* An address carries an identity and never a location: the registry answers
|
|
19
|
+
* which file it was read from, at which commit, and what it says. The door is
|
|
20
|
+
* `/api/chronicle/open`, which sends the reader to the capability's page. The
|
|
21
|
+
* grammar follows the other artefact schemes: `//` accepted on input and
|
|
22
|
+
* dropped from the canonical form, `mc.*` options folded, control characters
|
|
23
|
+
* refused because a reference is printed into terminals.
|
|
24
|
+
*/
|
|
25
|
+
import { OPTION_PREFIX } from "./chronicle-dsl.js";
|
|
26
|
+
export const MIADI_CAPABILITY_SCHEME = "miadi-capability:";
|
|
27
|
+
// [1]=path [2]=query [3]=fragment
|
|
28
|
+
const CAPABILITY_URI_RE = /^miadi-capability:(?:\/\/)?([^?#\s\u0000-\u001f\u007f-\u009f]{1,400})(?:\?([^#\u0000-\u001f\u007f-\u009f]*))?(?:#([^\u0000-\u001f\u007f-\u009f]*))?$/i;
|
|
29
|
+
/** A git owner or repository name, as GitHub and a host's bare repositories spell them. */
|
|
30
|
+
const OWNER_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
31
|
+
const KIND_RE = /^[a-z][a-z0-9-]{0,31}$/;
|
|
32
|
+
/** One segment of a name: an npm name segment, a command, a skill name. */
|
|
33
|
+
const NAME_SEGMENT_RE = /^[A-Za-z0-9@._~+-]{1,214}$/;
|
|
34
|
+
export function isCapabilityUri(href) {
|
|
35
|
+
return typeof href === "string" && /^miadi-capability:/i.test(href.trim());
|
|
36
|
+
}
|
|
37
|
+
function safeDecode(s) {
|
|
38
|
+
try {
|
|
39
|
+
return decodeURIComponent(s);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return s;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** `<owner>/<repo>/<kind>/<name>`, or null when the parts are not an address. */
|
|
46
|
+
function partsOf(path) {
|
|
47
|
+
const segments = path.replace(/\/$/, "").split("/").map(safeDecode);
|
|
48
|
+
if (segments.length < 4)
|
|
49
|
+
return null;
|
|
50
|
+
const [owner, repo, kindWord, ...nameSegments] = segments;
|
|
51
|
+
const kind = kindWord.toLowerCase();
|
|
52
|
+
if (!OWNER_RE.test(owner) || !OWNER_RE.test(repo) || repo.endsWith(".git") || !KIND_RE.test(kind))
|
|
53
|
+
return null;
|
|
54
|
+
if (nameSegments.some((s) => !NAME_SEGMENT_RE.test(s) || s === "." || s === ".."))
|
|
55
|
+
return null;
|
|
56
|
+
return { owner, repo, kind, name: nameSegments.join("/") };
|
|
57
|
+
}
|
|
58
|
+
/** The canonical address of a capability, without options. */
|
|
59
|
+
export function canonicalCapabilityRef(parts) {
|
|
60
|
+
return `${MIADI_CAPABILITY_SCHEME}${parts.owner}/${parts.repo}/${parts.kind}/${parts.name}`;
|
|
61
|
+
}
|
|
62
|
+
/** The address as a person cites it in prose, with the `//` a terminal links: `miadi-capability://owner/repo/kind/name`. */
|
|
63
|
+
export function capabilityCitation(parts) {
|
|
64
|
+
return `${MIADI_CAPABILITY_SCHEME}//${parts.owner}/${parts.repo}/${parts.kind}/${parts.name}`;
|
|
65
|
+
}
|
|
66
|
+
export function parseCapabilityUri(uri) {
|
|
67
|
+
const trimmed = uri.trim();
|
|
68
|
+
const m = CAPABILITY_URI_RE.exec(trimmed);
|
|
69
|
+
if (!m || !m[1])
|
|
70
|
+
return null;
|
|
71
|
+
const parts = partsOf(m[1]);
|
|
72
|
+
if (!parts)
|
|
73
|
+
return null;
|
|
74
|
+
const query = {};
|
|
75
|
+
const options = {};
|
|
76
|
+
for (const pair of (m[2] ?? "").split("&")) {
|
|
77
|
+
if (!pair)
|
|
78
|
+
continue;
|
|
79
|
+
const eq = pair.indexOf("=");
|
|
80
|
+
const key = safeDecode(eq === -1 ? pair : pair.slice(0, eq));
|
|
81
|
+
const value = eq === -1 ? "" : safeDecode(pair.slice(eq + 1));
|
|
82
|
+
if (key.startsWith(OPTION_PREFIX))
|
|
83
|
+
options[key.slice(OPTION_PREFIX.length)] = value;
|
|
84
|
+
else
|
|
85
|
+
query[key] = value;
|
|
86
|
+
}
|
|
87
|
+
const fragment = m[3] || undefined;
|
|
88
|
+
const params = [
|
|
89
|
+
...Object.entries(query).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`),
|
|
90
|
+
...Object.entries(options).map(([k, v]) => `${OPTION_PREFIX}${encodeURIComponent(k)}=${encodeURIComponent(v)}`),
|
|
91
|
+
];
|
|
92
|
+
const canonical = canonicalCapabilityRef(parts) + (params.length > 0 ? `?${params.join("&")}` : "") + (fragment ? `#${fragment}` : "");
|
|
93
|
+
return {
|
|
94
|
+
uri: trimmed,
|
|
95
|
+
canonical,
|
|
96
|
+
...parts,
|
|
97
|
+
id: `${parts.owner}/${parts.repo}/${parts.kind}/${parts.name}`,
|
|
98
|
+
query,
|
|
99
|
+
options,
|
|
100
|
+
...(fragment ? { fragment } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** The capability's page on a Miadi front: `/capabilities/<owner>/<repo>/<kind>/<name>`. */
|
|
104
|
+
export function capabilityPageRoute(parts) {
|
|
105
|
+
return `/capabilities/${[parts.owner, parts.repo, parts.kind, ...parts.name.split("/")].map(encodeURIComponent).join("/")}`;
|
|
106
|
+
}
|
|
107
|
+
/** Where a chip points: the host's open door, which sends the reader to the page. */
|
|
108
|
+
export function capabilityOpenRoute(parts) {
|
|
109
|
+
return `/api/chronicle/open?uri=${encodeURIComponent(canonicalCapabilityRef(parts))}`;
|
|
110
|
+
}
|
|
111
|
+
/** Every capability address in a text, as written, in order of first appearance. Code is not a reference. */
|
|
112
|
+
export function extractCapabilityUris(text) {
|
|
113
|
+
const seen = new Set();
|
|
114
|
+
const out = [];
|
|
115
|
+
const re = /(?<![\w/?=&%.~+:@#!-])miadi-capability:(?:\/\/)?[A-Za-z0-9._~/?=&%#+@-]{1,512}/gi;
|
|
116
|
+
const prose = text.replace(/```[\s\S]*?```/g, " ").replace(/`[^`\n]*`/g, " ");
|
|
117
|
+
for (const m of prose.matchAll(re)) {
|
|
118
|
+
const raw = m[0].replace(/[.,;:)\]]+$/, "");
|
|
119
|
+
if (!seen.has(raw) && parseCapabilityUri(raw)) {
|
|
120
|
+
seen.add(raw);
|
|
121
|
+
out.push(raw);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=capability-dsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-dsl.js","sourceRoot":"","sources":["../src/capability-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAyB1D,kCAAkC;AAClC,MAAM,iBAAiB,GAAG,uJAAuJ,CAAA;AACjL,2FAA2F;AAC3F,MAAM,QAAQ,GAAG,mCAAmC,CAAA;AACpD,MAAM,OAAO,GAAG,wBAAwB,CAAA;AACxC,2EAA2E;AAC3E,MAAM,eAAe,GAAG,4BAA4B,CAAA;AAEpD,MAAM,UAAU,eAAe,CAAC,IAAwB;IACtD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;AAC5E,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAA;IACV,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,OA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E,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAC7H,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAA6B;IAC/D,OAAO,2BAA2B,kBAAkB,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;AACvF,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,MAAM,EAAE,GAAG,kFAAkF,CAAA;IAC7F,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;IAC7E,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACb,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The capability seam: what an episode did with a capability, in the shape
|
|
3
|
+
* the rispec seam set (rispec.ts). One reusable capability node on the wheel
|
|
4
|
+
* (`capability:<kind>-<slug>`, the registry's id, `knowledge` with
|
|
5
|
+
* `metadata.kind: "capability"`), one episode→capability edge whose
|
|
6
|
+
* relationship type is the relation (`uses`, `revises`, `brings-into-being`),
|
|
7
|
+
* and an entry per capability and version in `episode.yaml`'s
|
|
8
|
+
* `capabilities:` list with the evidence of the work.
|
|
9
|
+
*
|
|
10
|
+
* Episode 568's Capability Registry, `EpisodeCapabilityHolding` (P12).
|
|
11
|
+
*/
|
|
12
|
+
import { type CapabilityRef, type EpisodeCapabilityEntry } from "@miadi/episodic-memory-schema";
|
|
13
|
+
export type CapabilityHoldingErrorCode = "invalid_capability" | "capability_manifest_conflict";
|
|
14
|
+
export declare class CapabilityHoldingError extends Error {
|
|
15
|
+
readonly code: CapabilityHoldingErrorCode;
|
|
16
|
+
constructor(code: CapabilityHoldingErrorCode, message: string);
|
|
17
|
+
}
|
|
18
|
+
/** The capability an input names: `miadi-capability:<owner>/<repo>/<kind>/<name>`, `//` accepted. */
|
|
19
|
+
export declare function requireCapabilityRef(raw: unknown): CapabilityRef;
|
|
20
|
+
export interface UpsertEpisodeCapabilityResult {
|
|
21
|
+
entry: EpisodeCapabilityEntry;
|
|
22
|
+
created: boolean;
|
|
23
|
+
filled: string[];
|
|
24
|
+
wrote: boolean;
|
|
25
|
+
dryRun: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add a holding to `episode.yaml`'s `capabilities:` list, or complete the one
|
|
29
|
+
* that holds this capability at this version: keys it lacks are filled and
|
|
30
|
+
* new evidence is appended. The relation an entry already records is kept.
|
|
31
|
+
* Comments, key order and every other field survive. Refuses a
|
|
32
|
+
* `capabilities` key that is not a list.
|
|
33
|
+
*/
|
|
34
|
+
export declare function upsertEpisodeCapability(input: {
|
|
35
|
+
episodeYamlPath: string;
|
|
36
|
+
entry: EpisodeCapabilityEntry;
|
|
37
|
+
dryRun?: boolean;
|
|
38
|
+
}): Promise<UpsertEpisodeCapabilityResult>;
|
|
39
|
+
export type CapabilityProjectionState = "created" | "already-present" | "skipped" | "pending";
|
|
40
|
+
export interface CapabilityProjection {
|
|
41
|
+
node: {
|
|
42
|
+
id: string;
|
|
43
|
+
state: CapabilityProjectionState;
|
|
44
|
+
error?: string;
|
|
45
|
+
};
|
|
46
|
+
edge: {
|
|
47
|
+
id: string;
|
|
48
|
+
state: CapabilityProjectionState;
|
|
49
|
+
relationship_type: string;
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Put the capability node and the episode→capability edge on the wheel. A
|
|
55
|
+
* node that exists is left as it is. One edge joins an episode and a
|
|
56
|
+
* capability whatever the versions; the first relation recorded names it.
|
|
57
|
+
*/
|
|
58
|
+
export declare function projectEpisodeCapability(mwUrl: string, input: {
|
|
59
|
+
episodeNodeId: string;
|
|
60
|
+
episodeFolder: string;
|
|
61
|
+
episodeNumber?: number;
|
|
62
|
+
ref: CapabilityRef;
|
|
63
|
+
entry: EpisodeCapabilityEntry;
|
|
64
|
+
}, options?: {
|
|
65
|
+
fetchImpl?: typeof fetch;
|
|
66
|
+
dryRun?: boolean;
|
|
67
|
+
}): Promise<CapabilityProjection>;
|
|
68
|
+
//# sourceMappingURL=capability-holding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-holding.d.ts","sourceRoot":"","sources":["../src/capability-holding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAA;AAItC,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG,8BAA8B,CAAA;AAE9F,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,IAAI,EAAE,0BAA0B;gBAAhC,IAAI,EAAE,0BAA0B,EAChD,OAAO,EAAE,MAAM;CAKlB;AAED,qGAAqG;AACrG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAIhE;AAID,MAAM,WAAW,6BAA6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an episode did with a capability, in the shape
|
|
3
|
+
* the rispec seam set (rispec.ts). One reusable capability node on the wheel
|
|
4
|
+
* (`capability:<kind>-<slug>`, the registry's id, `knowledge` with
|
|
5
|
+
* `metadata.kind: "capability"`), one episode→capability edge whose
|
|
6
|
+
* relationship type is the relation (`uses`, `revises`, `brings-into-being`),
|
|
7
|
+
* and an entry per capability and version in `episode.yaml`'s
|
|
8
|
+
* `capabilities:` list with the evidence of the work.
|
|
9
|
+
*
|
|
10
|
+
* Episode 568's Capability Registry, `EpisodeCapabilityHolding` (P12).
|
|
11
|
+
*/
|
|
12
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { dirname } from "node:path";
|
|
15
|
+
import { Scalar, isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
16
|
+
import { CAPABILITY_ENTRY_KEYS, CAPABILITY_NODE_KIND, capabilityHoldingKey, capabilityNodeId, parseCapabilityRef, toEpisodeCapabilityEntry, } from "@miadi/episodic-memory-schema";
|
|
17
|
+
import { missingManifestRemedy } from "./episode.js";
|
|
18
|
+
import { edgesFrom, failure, wheelJson } from "./review.js";
|
|
19
|
+
export class CapabilityHoldingError extends Error {
|
|
20
|
+
code;
|
|
21
|
+
constructor(code, message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.name = "CapabilityHoldingError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The capability an input names: `miadi-capability:<owner>/<repo>/<kind>/<name>`, `//` accepted. */
|
|
28
|
+
export function requireCapabilityRef(raw) {
|
|
29
|
+
const ref = parseCapabilityRef(raw);
|
|
30
|
+
if (ref)
|
|
31
|
+
return ref;
|
|
32
|
+
throw new CapabilityHoldingError("invalid_capability", `capability '${String(raw)}' is not a miadi-capability:<owner>/<repo>/<kind>/<name> address`);
|
|
33
|
+
}
|
|
34
|
+
function quoted(doc, value) {
|
|
35
|
+
const node = doc.createNode(value);
|
|
36
|
+
node.type = Scalar.QUOTE_SINGLE;
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
function evidenceNode(doc, evidence) {
|
|
40
|
+
const seq = doc.createNode([]);
|
|
41
|
+
for (const e of evidence)
|
|
42
|
+
seq.items.push(quoted(doc, e));
|
|
43
|
+
return seq;
|
|
44
|
+
}
|
|
45
|
+
function entryNode(doc, entry) {
|
|
46
|
+
const map = doc.createNode({});
|
|
47
|
+
for (const key of CAPABILITY_ENTRY_KEYS) {
|
|
48
|
+
const value = entry[key];
|
|
49
|
+
if (value === undefined || value === "")
|
|
50
|
+
continue;
|
|
51
|
+
if (key === "evidence") {
|
|
52
|
+
if (Array.isArray(value) && value.length > 0)
|
|
53
|
+
map.set(key, evidenceNode(doc, value));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
map.set(key, quoted(doc, value));
|
|
57
|
+
}
|
|
58
|
+
return map;
|
|
59
|
+
}
|
|
60
|
+
const plain = (item) => (isMap(item) ? item.toJSON() : isScalar(item) ? item.value : item);
|
|
61
|
+
/**
|
|
62
|
+
* Add a holding to `episode.yaml`'s `capabilities:` list, or complete the one
|
|
63
|
+
* that holds this capability at this version: keys it lacks are filled and
|
|
64
|
+
* new evidence is appended. The relation an entry already records is kept.
|
|
65
|
+
* Comments, key order and every other field survive. Refuses a
|
|
66
|
+
* `capabilities` key that is not a list.
|
|
67
|
+
*/
|
|
68
|
+
export async function upsertEpisodeCapability(input) {
|
|
69
|
+
if (!existsSync(input.episodeYamlPath)) {
|
|
70
|
+
throw new CapabilityHoldingError("capability_manifest_conflict", missingManifestRemedy(dirname(input.episodeYamlPath)));
|
|
71
|
+
}
|
|
72
|
+
const doc = parseDocument(await readFile(input.episodeYamlPath, "utf8"));
|
|
73
|
+
if (doc.errors.length > 0) {
|
|
74
|
+
throw new CapabilityHoldingError("capability_manifest_conflict", `unreadable episode.yaml ${input.episodeYamlPath}: ${doc.errors[0].message}`);
|
|
75
|
+
}
|
|
76
|
+
if (!isMap(doc.contents)) {
|
|
77
|
+
throw new CapabilityHoldingError("capability_manifest_conflict", `episode.yaml ${input.episodeYamlPath} is not a mapping`);
|
|
78
|
+
}
|
|
79
|
+
const key = capabilityHoldingKey(input.entry);
|
|
80
|
+
const list = doc.get("capabilities", true);
|
|
81
|
+
let created = false;
|
|
82
|
+
const filled = [];
|
|
83
|
+
let entry;
|
|
84
|
+
if (list === undefined || list === null || (isScalar(list) && (list.value === null || list.value === undefined))) {
|
|
85
|
+
created = true;
|
|
86
|
+
entry = input.entry;
|
|
87
|
+
const seq = doc.createNode([]);
|
|
88
|
+
seq.items.push(entryNode(doc, entry));
|
|
89
|
+
doc.set("capabilities", seq);
|
|
90
|
+
}
|
|
91
|
+
else if (!isSeq(list)) {
|
|
92
|
+
throw new CapabilityHoldingError("capability_manifest_conflict", `capabilities in ${input.episodeYamlPath} is not a list — refusing to overwrite`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const index = list.items.findIndex((item) => {
|
|
96
|
+
const read = toEpisodeCapabilityEntry(plain(item));
|
|
97
|
+
return read !== null && capabilityHoldingKey(read) === key;
|
|
98
|
+
});
|
|
99
|
+
if (index < 0) {
|
|
100
|
+
created = true;
|
|
101
|
+
entry = input.entry;
|
|
102
|
+
list.items.push(entryNode(doc, entry));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const item = list.items[index];
|
|
106
|
+
if (!isMap(item)) {
|
|
107
|
+
entry = toEpisodeCapabilityEntry(plain(item)) ?? input.entry;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
for (const k of CAPABILITY_ENTRY_KEYS) {
|
|
111
|
+
if (k === "evidence" || k === "relation")
|
|
112
|
+
continue;
|
|
113
|
+
const value = input.entry[k];
|
|
114
|
+
if (value === undefined || value === "")
|
|
115
|
+
continue;
|
|
116
|
+
const present = item.get(k);
|
|
117
|
+
if (present === undefined || present === null || present === "") {
|
|
118
|
+
item.set(k, quoted(doc, value));
|
|
119
|
+
filled.push(k);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const had = toEpisodeCapabilityEntry(item.toJSON())?.evidence ?? [];
|
|
123
|
+
const more = (input.entry.evidence ?? []).filter((e) => !had.includes(e));
|
|
124
|
+
if (more.length > 0) {
|
|
125
|
+
item.set("evidence", evidenceNode(doc, [...had, ...more]));
|
|
126
|
+
filled.push("evidence");
|
|
127
|
+
}
|
|
128
|
+
entry = toEpisodeCapabilityEntry(item.toJSON()) ?? input.entry;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const wrote = (created || filled.length > 0) && !input.dryRun;
|
|
133
|
+
if (wrote)
|
|
134
|
+
await writeFile(input.episodeYamlPath, doc.toString(), "utf8");
|
|
135
|
+
return { entry, created, filled, wrote, dryRun: input.dryRun === true };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Put the capability node and the episode→capability edge on the wheel. A
|
|
139
|
+
* node that exists is left as it is. One edge joins an episode and a
|
|
140
|
+
* capability whatever the versions; the first relation recorded names it.
|
|
141
|
+
*/
|
|
142
|
+
export async function projectEpisodeCapability(mwUrl, input, options = {}) {
|
|
143
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
144
|
+
const base = mwUrl.replace(/\/+$/, "");
|
|
145
|
+
const nodeId = capabilityNodeId(input.ref);
|
|
146
|
+
const relation = input.entry.relation;
|
|
147
|
+
const projection = {
|
|
148
|
+
node: { id: nodeId, state: "pending" },
|
|
149
|
+
edge: { id: `${input.episodeNodeId}:${nodeId}`, state: "pending", relationship_type: relation },
|
|
150
|
+
};
|
|
151
|
+
const nodeUrl = `${base}/api/nodes/${encodeURIComponent(nodeId)}`;
|
|
152
|
+
const read = await wheelJson(fetchImpl, nodeUrl);
|
|
153
|
+
if (read.ok) {
|
|
154
|
+
projection.node.state = "already-present";
|
|
155
|
+
}
|
|
156
|
+
else if (read.status === 404) {
|
|
157
|
+
if (options.dryRun) {
|
|
158
|
+
projection.node.state = "skipped";
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const created = await wheelJson(fetchImpl, `${base}/api/nodes`, {
|
|
162
|
+
method: "POST",
|
|
163
|
+
headers: { "content-type": "application/json" },
|
|
164
|
+
body: JSON.stringify({
|
|
165
|
+
id: nodeId,
|
|
166
|
+
type: "knowledge",
|
|
167
|
+
name: `Capability — ${input.ref.kind} ${input.ref.name}`,
|
|
168
|
+
description: `One thing ${input.ref.owner}/${input.ref.repo} provides: the ${input.ref.kind} ${input.ref.name}. Its address is ${input.ref.reference}.`,
|
|
169
|
+
metadata: {
|
|
170
|
+
kind: CAPABILITY_NODE_KIND,
|
|
171
|
+
address: input.ref.reference,
|
|
172
|
+
owner: input.ref.owner,
|
|
173
|
+
repo: input.ref.repo,
|
|
174
|
+
capability_kind: input.ref.kind,
|
|
175
|
+
name: input.ref.name,
|
|
176
|
+
provided_by: `repository:${input.ref.owner}/${input.ref.repo}`,
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
projection.node = created.ok ? { id: nodeId, state: "created" } : { id: nodeId, state: "pending", error: failure("POST", `${base}/api/nodes`, created) };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
projection.node = { id: nodeId, state: "pending", error: failure("GET", nodeUrl, read) };
|
|
185
|
+
}
|
|
186
|
+
if (projection.node.state === "pending") {
|
|
187
|
+
projection.edge.error = "the capability node is not on the wheel yet";
|
|
188
|
+
return projection;
|
|
189
|
+
}
|
|
190
|
+
const edgesUrl = `${base}/api/edges`;
|
|
191
|
+
const listing = await wheelJson(fetchImpl, `${edgesUrl}?limit=all`);
|
|
192
|
+
if (!listing.ok) {
|
|
193
|
+
projection.edge.error = failure("GET", edgesUrl, listing);
|
|
194
|
+
return projection;
|
|
195
|
+
}
|
|
196
|
+
const existing = edgesFrom(listing.body).find((edge) => String(edge.from_id) === input.episodeNodeId && String(edge.to_id) === nodeId);
|
|
197
|
+
if (existing) {
|
|
198
|
+
projection.edge = { ...projection.edge, state: "already-present", relationship_type: String(existing.relationship_type ?? relation) };
|
|
199
|
+
return projection;
|
|
200
|
+
}
|
|
201
|
+
if (options.dryRun) {
|
|
202
|
+
projection.edge.state = "skipped";
|
|
203
|
+
return projection;
|
|
204
|
+
}
|
|
205
|
+
const who = input.episodeNumber !== undefined ? `Episode ${input.episodeNumber}` : input.episodeFolder;
|
|
206
|
+
const posted = await wheelJson(fetchImpl, edgesUrl, {
|
|
207
|
+
method: "POST",
|
|
208
|
+
headers: { "content-type": "application/json" },
|
|
209
|
+
body: JSON.stringify({
|
|
210
|
+
from_id: input.episodeNodeId,
|
|
211
|
+
to_id: nodeId,
|
|
212
|
+
relationship_type: relation,
|
|
213
|
+
description: `${who} ${relation.replace(/-/g, " ")} ${input.ref.name}${input.entry.version ? ` ${input.entry.version}` : ""}.`,
|
|
214
|
+
strength: 1,
|
|
215
|
+
obligations: [],
|
|
216
|
+
}),
|
|
217
|
+
});
|
|
218
|
+
if (posted.ok && posted.body?.replaced === true) {
|
|
219
|
+
projection.edge = { ...projection.edge, state: "pending", error: "the wheel replaced an edge the listing did not show; check the edge by hand" };
|
|
220
|
+
}
|
|
221
|
+
else if (posted.ok)
|
|
222
|
+
projection.edge.state = "created";
|
|
223
|
+
else if (posted.status === 409)
|
|
224
|
+
projection.edge.state = "already-present";
|
|
225
|
+
else
|
|
226
|
+
projection.edge.error = failure("POST", edgesUrl, posted);
|
|
227
|
+
return projection;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=capability-holding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-holding.js","sourceRoot":"","sources":["../src/capability-holding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAA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AA;IAC9D,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -371,4 +371,29 @@ export declare function resolveFoundationRefForTerminal(uri: string, options?: {
|
|
|
371
371
|
prefer?: BaseKind | "local-file";
|
|
372
372
|
foundationsRoot?: string;
|
|
373
373
|
}): Promise<FoundationRefResolveResult | null>;
|
|
374
|
+
export interface CapabilityRefResolveResult {
|
|
375
|
+
ok: boolean;
|
|
376
|
+
uri: string;
|
|
377
|
+
canonical: string;
|
|
378
|
+
/** The address as a person cites it, with `//`. */
|
|
379
|
+
citation: string;
|
|
380
|
+
owner: string;
|
|
381
|
+
repo: string;
|
|
382
|
+
kind: string;
|
|
383
|
+
name: string;
|
|
384
|
+
/** The capability's page on each front. */
|
|
385
|
+
destinations: Destination[];
|
|
386
|
+
open: string | null;
|
|
387
|
+
shareable: string | null;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Where a capability address opens: its page on each front this host knows.
|
|
391
|
+
* The page asks the registry, as the reader, what the capability is, which
|
|
392
|
+
* file and commit it was read from, and what consumes it. Nothing is fetched
|
|
393
|
+
* here: an address is opened, not proven, by a terminal.
|
|
394
|
+
*/
|
|
395
|
+
export declare function resolveCapabilityRefForTerminal(uri: string, options?: {
|
|
396
|
+
bases?: WebBases;
|
|
397
|
+
prefer?: BaseKind;
|
|
398
|
+
}): CapabilityRefResolveResult | null;
|
|
374
399
|
//# sourceMappingURL=chronicle-terminal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chronicle-terminal.d.ts","sourceRoot":"","sources":["../src/chronicle-terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"chronicle-ter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CACpB;AAED;;;;GAIG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7F,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAoC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,OAAO,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;CAAO,GACpD,0BAA0B,GAAG,IAAI,CA4BnC"}
|
|
@@ -27,6 +27,7 @@ import { parse as parseYaml } from "yaml";
|
|
|
27
27
|
import { resolveMwUrl } from "./env.js";
|
|
28
28
|
import { parseMiadiChronicleUri, parseWheelRefUri, wheelNodeId, WHEEL_ARTIFACT_KINDS, resolveChronicleRef, judgeFragment, EPISODE_FOUNDATION_SEGMENT, } from "./chronicle-dsl.js";
|
|
29
29
|
import { foundationRoute, parseFoundationUri } from "./foundation-dsl.js";
|
|
30
|
+
import { capabilityCitation, capabilityPageRoute, parseCapabilityUri } from "./capability-dsl.js";
|
|
30
31
|
// ---------------------------------------------------------------------------
|
|
31
32
|
// OSC 8
|
|
32
33
|
// ---------------------------------------------------------------------------
|
|
@@ -663,4 +664,41 @@ export async function resolveFoundationRefForTerminal(uri, options = {}) {
|
|
|
663
664
|
path,
|
|
664
665
|
};
|
|
665
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Where a capability address opens: its page on each front this host knows.
|
|
669
|
+
* The page asks the registry, as the reader, what the capability is, which
|
|
670
|
+
* file and commit it was read from, and what consumes it. Nothing is fetched
|
|
671
|
+
* here: an address is opened, not proven, by a terminal.
|
|
672
|
+
*/
|
|
673
|
+
export function resolveCapabilityRefForTerminal(uri, options = {}) {
|
|
674
|
+
const parsed = parseCapabilityUri(uri);
|
|
675
|
+
if (!parsed)
|
|
676
|
+
return null;
|
|
677
|
+
const bases = options.bases ?? readWebBases();
|
|
678
|
+
const route = capabilityPageRoute(parsed);
|
|
679
|
+
const LABEL = { local: "local", internal: "tailnet", public: "public" };
|
|
680
|
+
const doors = [];
|
|
681
|
+
for (const kind of ["local", "internal", "public"]) {
|
|
682
|
+
const base = bases[kind];
|
|
683
|
+
if (base)
|
|
684
|
+
doors.push({ kind: "room", base: kind, label: `capability·${LABEL[kind]}`, url: `${base.replace(/\/$/, "")}${route}` });
|
|
685
|
+
}
|
|
686
|
+
if (options.prefer) {
|
|
687
|
+
const prefer = options.prefer;
|
|
688
|
+
doors.sort((a, b) => Number(b.base === prefer) - Number(a.base === prefer));
|
|
689
|
+
}
|
|
690
|
+
return {
|
|
691
|
+
ok: true,
|
|
692
|
+
uri: parsed.uri,
|
|
693
|
+
canonical: parsed.canonical,
|
|
694
|
+
citation: capabilityCitation(parsed),
|
|
695
|
+
owner: parsed.owner,
|
|
696
|
+
repo: parsed.repo,
|
|
697
|
+
kind: parsed.kind,
|
|
698
|
+
name: parsed.name,
|
|
699
|
+
destinations: doors,
|
|
700
|
+
open: doors[0]?.url ?? null,
|
|
701
|
+
shareable: doors.find((d) => d.base === "public")?.url ?? doors.find((d) => d.base === "internal")?.url ?? null,
|
|
702
|
+
};
|
|
703
|
+
}
|
|
666
704
|
//# sourceMappingURL=chronicle-terminal.js.map
|