@miadi/inquiry-weave 0.14.3 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -16,6 +16,10 @@ export * from "./attention-node.js";
16
16
  export * from "./attention.js";
17
17
  export * from "./captures.js";
18
18
  export * from "./catalog.js";
19
+ export * from "./readings.js";
20
+ export * from "./text-references.js";
21
+ export * from "./chronicle-dsl.js";
22
+ export * from "./chronicle-terminal.js";
19
23
  export * from "./story-library.js";
20
24
  export * from "./git-landing.js";
21
25
  export * from "./closing.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -16,6 +16,10 @@ export * from "./attention-node.js";
16
16
  export * from "./attention.js";
17
17
  export * from "./captures.js";
18
18
  export * from "./catalog.js";
19
+ export * from "./readings.js";
20
+ export * from "./text-references.js";
21
+ export * from "./chronicle-dsl.js";
22
+ export * from "./chronicle-terminal.js";
19
23
  export * from "./story-library.js";
20
24
  export * from "./git-landing.js";
21
25
  export * from "./closing.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc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**
2
+ * Episode readings: the theme, direction and arc a surface groups an episode
3
+ * under (jgwill/Miadi#506, moved here by jgwill/Miadi#706).
4
+ *
5
+ * The catalog (`buildChronicleCatalog`) carries no direction, theme or arc.
6
+ * Those are *readings* of an episode, not facts on disk: keyword guesses over
7
+ * its folder name, slug, title, type and status. They live here so the web
8
+ * room (`app/chronicle`) and the terminal browser read an episode by the same
9
+ * rule. Pure and deterministic, with no I/O, so it is safe in a client bundle
10
+ * through the `@miadi/inquiry-weave/readings` subpath.
11
+ */
12
+ import type { EpisodeManifestEntry } from "@miadi/episodic-memory-schema";
13
+ export type DirectionKey = "east" | "south" | "west" | "north";
14
+ export type ArcKey = "Book I · The Threshold" | "Book II · The Orchard" | "Book III · The Council";
15
+ export interface EpisodeReadings {
16
+ theme: string;
17
+ direction: DirectionKey;
18
+ arc: ArcKey;
19
+ }
20
+ /** The part of a catalog entry a reading looks at. */
21
+ export type ReadableEntry = Pick<EpisodeManifestEntry, "name" | "slug" | "title" | "type" | "status" | "number">;
22
+ export declare const DIRECTION_ORDER: readonly DirectionKey[];
23
+ /** First match wins, in this order. No match reads as "chronicle". */
24
+ export declare const THEME_KEYWORDS: ReadonlyArray<readonly [string, readonly string[]]>;
25
+ /** First match wins, in this order. No match falls back to the number's turn of the wheel. */
26
+ export declare const DIRECTION_KEYWORDS: ReadonlyArray<readonly [DirectionKey, readonly string[]]>;
27
+ /** Arcs in order. `maxNumber` is the inclusive last episode number; the last arc is open-ended. */
28
+ export declare const ARC_BOUNDARIES: ReadonlyArray<{
29
+ key: ArcKey;
30
+ maxNumber?: number;
31
+ }>;
32
+ export declare function inferTheme(entry: ReadableEntry): string;
33
+ export declare function inferDirection(entry: ReadableEntry): DirectionKey;
34
+ export declare function inferArc(entry: ReadableEntry): ArcKey;
35
+ export declare function readEpisode(entry: ReadableEntry): EpisodeReadings;
36
+ //# sourceMappingURL=readings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readings.d.ts","sourceRoot":"","sources":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0 +1,73 @@
1
+ /**
2
+ * Episode readings: the theme, direction and arc a surface groups an episode
3
+ * under (jgwill/Miadi#506, moved here by jgwill/Miadi#706).
4
+ *
5
+ * The catalog (`buildChronicleCatalog`) carries no direction, theme or arc.
6
+ * Those are *readings* of an episode, not facts on disk: keyword guesses over
7
+ * its folder name, slug, title, type and status. They live here so the web
8
+ * room (`app/chronicle`) and the terminal browser read an episode by the same
9
+ * rule. Pure and deterministic, with no I/O, so it is safe in a client bundle
10
+ * through the `@miadi/inquiry-weave/readings` subpath.
11
+ */
12
+ export const DIRECTION_ORDER = ["east", "south", "west", "north"];
13
+ /** First match wins, in this order. No match reads as "chronicle". */
14
+ export const THEME_KEYWORDS = [
15
+ ["ceremony", ["ceremony", "ceremonial", "medicine-wheel", "medicine wheel", "fire-keeper", "sacred", "relational", "council-table", "wheel"]],
16
+ ["orchestration", ["orchestrat", "conductor", "herd", "dispatch", "coordination", "delegation", "multi-agent", "pane", "tmux", "consolidat"]],
17
+ ["runtime", ["runtime", "hermes", "tide", "socket", "boundary", "launch", "server", "a2a", "gateway"]],
18
+ ["agents", ["agent", "skill", "copilot", "claude", "ava", "navigator", "operator", "witness"]],
19
+ ["inquiry", ["inquiry", "pde", "decompos", "question", "qmd", "tension", "structural", "glossary"]],
20
+ ["memory", ["memory", "episodic", "continuity", "ledger", "redis", "data-layer", "data layer", "persistence"]],
21
+ ["portal", ["portal", "house", "threshold", "tushell", "lantern", "tree"]],
22
+ ];
23
+ /** First match wins, in this order. No match falls back to the number's turn of the wheel. */
24
+ export const DIRECTION_KEYWORDS = [
25
+ ["east", ["portal", "threshold", "vision", "outline", "glossary", "plan", "foundation", "begin", "prelude", "lantern", "seed"]],
26
+ ["south", ["orchestrat", "runtime", "build", "agent", "delegation", "pipeline", "integration", "evolution", "growth", "gateway", "dispatch"]],
27
+ ["west", ["reflection", "review", "witness", "narration", "revision", "retrospect", "editor", "closure", "note", "triage", "media"]],
28
+ ["north", ["wisdom", "council", "memory", "ledger", "accountab", "security", "governance", "snapshot", "chronicle-data", "witness-layer"]],
29
+ ];
30
+ /** Arcs in order. `maxNumber` is the inclusive last episode number; the last arc is open-ended. */
31
+ export const ARC_BOUNDARIES = [
32
+ { key: "Book I · The Threshold", maxNumber: 27 },
33
+ { key: "Book II · The Orchard", maxNumber: 103 },
34
+ { key: "Book III · The Council" },
35
+ ];
36
+ function haystack(entry) {
37
+ return [entry.name, entry.slug, entry.title, entry.type, entry.status]
38
+ .filter(Boolean)
39
+ .join(" ")
40
+ .toLowerCase();
41
+ }
42
+ export function inferTheme(entry) {
43
+ const h = haystack(entry);
44
+ for (const [theme, kws] of THEME_KEYWORDS) {
45
+ if (kws.some((k) => h.includes(k)))
46
+ return theme;
47
+ }
48
+ return "chronicle";
49
+ }
50
+ export function inferDirection(entry) {
51
+ const h = haystack(entry);
52
+ for (const [dir, kws] of DIRECTION_KEYWORDS) {
53
+ if (kws.some((k) => h.includes(k)))
54
+ return dir;
55
+ }
56
+ // No keyword: rotate by number so episodes still flow through all four
57
+ // directions. This is why a reading is not a fact the episode declared.
58
+ return DIRECTION_ORDER[(entry.number ?? 0) % 4];
59
+ }
60
+ export function inferArc(entry) {
61
+ const n = entry.number;
62
+ if (n === undefined)
63
+ return "Book II · The Orchard";
64
+ for (const arc of ARC_BOUNDARIES) {
65
+ if (arc.maxNumber === undefined || n <= arc.maxNumber)
66
+ return arc.key;
67
+ }
68
+ return ARC_BOUNDARIES[ARC_BOUNDARIES.length - 1].key;
69
+ }
70
+ export function readEpisode(entry) {
71
+ return { theme: inferTheme(entry), direction: inferDirection(entry), arc: inferArc(entry) };
72
+ }
73
+ //# sourceMappingURL=readings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readings.js","sourceRoot":"","sources":["../src/readings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmBH,MAAM,CAAC,MAAM,eAAe,GAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;A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
+ /**
2
+ * Find the chronicle, ceremony and circle references in a piece of text
3
+ * (jgwill/Miadi#706).
4
+ *
5
+ * A web page folds `{{ … }}` directives into links and lets its markdown
6
+ * parser hand it each href (`app/chronicle/lib/dsl.ts`). A terminal has no
7
+ * such parser, so this module scans the text once and returns every reference
8
+ * with its position, in the forms SPEC.md §3 and §9 allow:
9
+ *
10
+ * - directive: `{{ miadi-chronicle:126 | label="Mila" }}`, `{{ ceremony:cede9d8f }}`,
11
+ * `{{ circle:1790153219791:zv10r2 }}`, `{{ miadi-circle:… }}`
12
+ * - link: `[text](miadi-chronicle:126)`
13
+ * - autolink: `<miadi-ceremony:…>`
14
+ * - bare: `**Episode:** miadi-chronicle://349`, as ceremony notes are written
15
+ *
16
+ * Code spans and fenced blocks are skipped, and every candidate must parse
17
+ * with `parseMiadiChronicleUri` or `parseWheelRefUri`, so nothing malformed
18
+ * becomes a chip. Short wheel forms expand by syntax alone, as the app does:
19
+ * a ceremony UUID prefix stays a prefix, for the wheel to match or refuse.
20
+ * Pure, no I/O.
21
+ */
22
+ import { type WheelRefKind } from "./chronicle-dsl.js";
23
+ export type TextReferenceKind = "chronicle" | WheelRefKind;
24
+ export type TextReferenceForm = "directive" | "link" | "autolink" | "bare";
25
+ export interface TextReference {
26
+ /** Offset of the first character of `raw` in the text. */
27
+ start: number;
28
+ /** Offset just past `raw`. */
29
+ end: number;
30
+ /** The source text of the whole reference, brackets and braces included. */
31
+ raw: string;
32
+ kind: TextReferenceKind;
33
+ form: TextReferenceForm;
34
+ /** The reference to resolve: a `miadi-chronicle:` URI as written, or a canonical `miadi-ceremony:` / `miadi-circle:` URI. */
35
+ uri: string;
36
+ /** The words the author gave it (link text or `label=`), if any. */
37
+ label?: string;
38
+ /** Rendering options (`show`, `label`, …) from a directive tail or `mc.*` params. */
39
+ options: Record<string, string>;
40
+ }
41
+ /** The wheel id a short form names: `circle:<rest>`, a ceremony UUID (or prefix), or `ceremony:<rest>`. */
42
+ export declare function expandWheelShortForm(kind: WheelRefKind, rest: string): string;
43
+ /** Every reference in `text`, in reading order. Code spans and fences are skipped. */
44
+ export declare function findTextReferences(text: string): TextReference[];
45
+ //# sourceMappingURL=text-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-references.d.ts","sourceRoot":"","sources":["../src/text-references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,CAAA;AAC1D,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,iBAAiB,CAAA;IACvB,IAAI,EAAE,iBAAiB,CAAA;IACvB,6HAA6H;IAC7H,GAAG,EAAE,MAAM,CAAA;IACX,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAqBD,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7E;AAqDD,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAShE"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Find the chronicle, ceremony and circle references in a piece of text
3
+ * (jgwill/Miadi#706).
4
+ *
5
+ * A web page folds `{{ … }}` directives into links and lets its markdown
6
+ * parser hand it each href (`app/chronicle/lib/dsl.ts`). A terminal has no
7
+ * such parser, so this module scans the text once and returns every reference
8
+ * with its position, in the forms SPEC.md §3 and §9 allow:
9
+ *
10
+ * - directive: `{{ miadi-chronicle:126 | label="Mila" }}`, `{{ ceremony:cede9d8f }}`,
11
+ * `{{ circle:1790153219791:zv10r2 }}`, `{{ miadi-circle:… }}`
12
+ * - link: `[text](miadi-chronicle:126)`
13
+ * - autolink: `<miadi-ceremony:…>`
14
+ * - bare: `**Episode:** miadi-chronicle://349`, as ceremony notes are written
15
+ *
16
+ * Code spans and fenced blocks are skipped, and every candidate must parse
17
+ * with `parseMiadiChronicleUri` or `parseWheelRefUri`, so nothing malformed
18
+ * becomes a chip. Short wheel forms expand by syntax alone, as the app does:
19
+ * a ceremony UUID prefix stays a prefix, for the wheel to match or refuse.
20
+ * Pure, no I/O.
21
+ */
22
+ import { canonicalWheelRef, parseMiadiChronicleUri, parseWheelRefUri, } from "./chronicle-dsl.js";
23
+ // Directives are single-line, and their option tail is one quantifier (the
24
+ // app's review found a cubic backtrack with three: jgwill/Miadi#680, F2).
25
+ const CHRONICLE_DIRECTIVE_RE = /\{\{[ \t]*(miadi-chronicle:(?:\/\/)?[^|}\s]+)[ \t]*(?:\|([^}\n]*))?\}\}/gi;
26
+ const WHEEL_DIRECTIVE_RE = /\{\{[ \t]*(miadi-)?(ceremony|circle):(?:\/\/)?([A-Za-z0-9._~:-]+)\/?[ \t]*(?:\|([^}\n]*))?\}\}/gi;
27
+ const LINK_RE = /\[((?:\\.|[^\]\\\n])*)\]\((miadi-(?:chronicle|ceremony|circle):[^)\s]+)\)/gi;
28
+ const AUTOLINK_RE = /<(miadi-(?:chronicle|ceremony|circle):[^>\s]+)>/gi;
29
+ const BARE_RE = /miadi-(?:chronicle|ceremony|circle):(?:\/\/)?[A-Za-z0-9._~:/?=&%#+-]+/gi;
30
+ const CODE_RE = /```[\s\S]*?(?:```|$(?![\s\S]))|~~~[\s\S]*?(?:~~~|$(?![\s\S]))|`[^`\n]+`/g;
31
+ const HEX_ID_RE = /^[0-9a-f][0-9a-f-]*$/i;
32
+ const OPTION_RE = /([A-Za-z0-9._~-]+)\s*=\s*(?:"([^"\n]*)"|([A-Za-z0-9._~/-]+))/g;
33
+ function parseOptionTail(tail) {
34
+ const options = {};
35
+ if (!tail)
36
+ return options;
37
+ for (const m of tail.matchAll(OPTION_RE))
38
+ options[m[1]] = m[2] !== undefined ? m[2] : m[3];
39
+ return options;
40
+ }
41
+ /** The wheel id a short form names: `circle:<rest>`, a ceremony UUID (or prefix), or `ceremony:<rest>`. */
42
+ export function expandWheelShortForm(kind, rest) {
43
+ if (kind === "circle")
44
+ return `circle:${rest}`;
45
+ return HEX_ID_RE.test(rest) ? rest : `ceremony:${rest}`;
46
+ }
47
+ /** Parse one href or bare mention into a reference, or null. */
48
+ function fromUri(uri, form, label) {
49
+ const chronicle = parseMiadiChronicleUri(uri);
50
+ if (chronicle) {
51
+ const authored = label ?? chronicle.options.label;
52
+ return { kind: "chronicle", form, uri: chronicle.uri, options: chronicle.options, ...(authored ? { label: authored } : {}) };
53
+ }
54
+ const wheel = parseWheelRefUri(uri);
55
+ if (wheel) {
56
+ const authored = label ?? wheel.options.label;
57
+ return { kind: wheel.kind, form, uri: wheel.canonical, options: wheel.options, ...(authored ? { label: authored } : {}) };
58
+ }
59
+ return null;
60
+ }
61
+ function scan(text, offset, out) {
62
+ const taken = [];
63
+ const free = (start, end) => taken.every(([s, e]) => end <= s || start >= e);
64
+ const add = (start, raw, candidate) => {
65
+ const end = start + raw.length;
66
+ if (!candidate || !free(start, end))
67
+ return;
68
+ taken.push([start, end]);
69
+ out.push({ start: offset + start, end: offset + end, raw, ...candidate });
70
+ };
71
+ for (const m of text.matchAll(CHRONICLE_DIRECTIVE_RE)) {
72
+ const options = parseOptionTail(m[2]);
73
+ const found = fromUri(m[1], "directive", options.label);
74
+ add(m.index, m[0], found && { ...found, options: { ...found.options, ...options } });
75
+ }
76
+ for (const m of text.matchAll(WHEEL_DIRECTIVE_RE)) {
77
+ const kind = m[2].toLowerCase();
78
+ const id = m[1] ? m[3] : expandWheelShortForm(kind, m[3]);
79
+ const options = parseOptionTail(m[4]);
80
+ const found = fromUri(canonicalWheelRef(kind, id), "directive", options.label);
81
+ add(m.index, m[0], found && { ...found, options: { ...found.options, ...options } });
82
+ }
83
+ for (const m of text.matchAll(LINK_RE)) {
84
+ const label = m[1].replace(/\\([\\[\]])/g, "$1");
85
+ add(m.index, m[0], fromUri(m[2], "link", label || undefined));
86
+ }
87
+ for (const m of text.matchAll(AUTOLINK_RE))
88
+ add(m.index, m[0], fromUri(m[1], "autolink"));
89
+ for (const m of text.matchAll(BARE_RE)) {
90
+ // Sentence punctuation after a bare mention is not part of it.
91
+ const raw = m[0].replace(/[.,;:!?)\]'"~_-]+$/, "");
92
+ add(m.index, raw, fromUri(raw, "bare"));
93
+ }
94
+ }
95
+ /** Every reference in `text`, in reading order. Code spans and fences are skipped. */
96
+ export function findTextReferences(text) {
97
+ const out = [];
98
+ let at = 0;
99
+ for (const m of text.matchAll(CODE_RE)) {
100
+ scan(text.slice(at, m.index), at, out);
101
+ at = m.index + m[0].length;
102
+ }
103
+ scan(text.slice(at), at, out);
104
+ return out.sort((left, right) => left.start - right.start);
105
+ }
106
+ //# sourceMappingURL=text-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-references.js","sourceRoot":"","sources":["../src/text-references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,GAEjB,MAAM,oBAAoB,CAAA;AAsB3B,2EAA2E;AAC3E,0EAA0E;AAC1E,MAAM,sBAAsB,GAAG,2EAA2E,CAAA;AAC1G,MAAM,kBAAkB,GACtB,kGAAkG,CAAA;AACpG,MAAM,OAAO,GAAG,6EAA6E,CAAA;AAC7F,MAAM,WAAW,GAAG,mDAAmD,CAAA;AACvE,MAAM,OAAO,GAAG,yEAAyE,CAAA;AACzF,MAAM,OAAO,GAAG,0EAA0E,CAAA;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CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAC7B,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/inquiry-weave",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "description": "Relate and sync IAIP inquiry artefacts, their GitHub issues, and miadi-chronicle episodes. Creates vessels and relations only — never inquiry content.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,6 +14,11 @@
14
14
  "import": "./dist/index.js",
15
15
  "default": "./dist/index.js"
16
16
  },
17
+ "./readings": {
18
+ "types": "./dist/readings.d.ts",
19
+ "import": "./dist/readings.js",
20
+ "default": "./dist/readings.js"
21
+ },
17
22
  "./package.json": "./package.json"
18
23
  },
19
24
  "bin": {