@miadi/relational-git-repository-mapper 0.4.0 → 0.5.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/README.md CHANGED
@@ -29,6 +29,24 @@ keeper's descriptions and file lists stay in the record.
29
29
  When no hub is configured, or the hub clone holds no mapping folder yet, every repository
30
30
  reads "no mapping yet" and still lists its sessions.
31
31
 
32
+ ## The address of a capability
33
+
34
+ Each capability has an address that an episode, an issue, an inquiry, a ceremony
35
+ diary entry or a circle turn cites it by (Episode 568, decided by William on
36
+ 2026-11-01): `miadi-capability://<owner>/<repo>/<kind>/<name>`, for example
37
+ `miadi-capability://jgwill/medicine-wheel/skill/fire-keeper-check`. `capabilities`
38
+ prints it under each row, `capabilityAddress()` makes it, and `findCapability()`
39
+ reads the row an address names. In the app it opens
40
+ `/capabilities/<owner>/<repo>/<kind>/<name>`; the grammar is
41
+ `@miadi/inquiry-weave/references` (`parseCapabilityUri`).
42
+
43
+ ## Capabilities defined in code
44
+
45
+ A repository that defines capabilities in code, not in files of their own, is read
46
+ by a reader written for that file (`CODE_READERS`), never guessed. The first is the
47
+ medicine wheel's `cli/skills.ts`, whose 13 skills `mw skill install` writes out as
48
+ SKILL.md files.
49
+
32
50
  ## Lineage: which git repository learned from which
33
51
 
34
52
  A lineage is not a dependency. `learned-from` says that one repository took what another
@@ -74,7 +92,7 @@ reads it.
74
92
 
75
93
  The package ships a scan of `jgwill/Miadi` and the three lineages (`avadisabelle/coaia-narrative`,
76
94
  `jgwill/coaiajs`, `jgwill/medicine-wheel`), regenerated with
77
- `node scripts/ship-capabilities.mjs <scan.jsonl> <scan.log>`. A host's JSONL
95
+ `node scripts/ship-capabilities.mjs <scan.jsonl> <scan.log> <packages.jsonl>` (and the host readings with `node scripts/ship-hosts.mjs <hosts.jsonl>`). A host's JSONL
78
96
  (`--capabilities` or `MIADI_REPOSITORY_CAPABILITIES`) is read first; the first source to name
79
97
  a capability speaks for it.
80
98
 
@@ -82,6 +100,36 @@ In the app: `GET /api/repositories/capabilities[?repository=owner/name]` answers
82
100
  capabilities and their `provides` edges, `GET /api/repositories/{owner}/{name}` carries them,
83
101
  and the repository page's Lineage card lists them by kind.
84
102
 
103
+ ## Where a repository lives
104
+
105
+ A name like `jgwill/episodes` does not say where the repository is. `miadi-repomap where`
106
+ checks each repository the mapper names: on GitHub (with a token from `GH_TOKEN`,
107
+ `GITHUB_TOKEN` or `gh auth token`, so a private one is seen), else as a bare repository on
108
+ this host (`/srv/git`, or `MIADI_HOST_GIT_ROOTS`). Each reading says `github`, `host-git`,
109
+ `missing` (a 404 a token could have seen, and no bare repository) or `unchecked`. Only a
110
+ GitHub repository gets a GitHub link. `list` and the `/repositories` page set the missing
111
+ ones apart: a session record named a repository that does not exist, and the record is what
112
+ needs correcting. The package ships the readings of its last check; a host's own
113
+ (`where --write <file>`, read through `--hosts` or `MIADI_REPOSITORY_HOSTS`) come first.
114
+
115
+ ## What a version bump touches
116
+
117
+ ```bash
118
+ miadi-repomap impact @miadi/hooks-interpreter --bump minor
119
+ ```
120
+
121
+ The scan reads each package's version and the ranges it declares on other packages it
122
+ read, across repositories. `impact` answers what a package consumes (upstream), who
123
+ consumes it, directly and through others (downstream), and with `--bump`, what each direct
124
+ consumer needs: nothing (its range already reaches the new version), a wider range, or a
125
+ new release because `workspace:*` and `workspace:^` publish the version current at the
126
+ time. In the app: `GET /api/repositories/impact?package=…&bump=…`.
127
+
128
+ ## Episodes
129
+
130
+ A repository's view lists the episodes its sessions worked in, as their inventory records
131
+ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
132
+
85
133
  ## Configuration
86
134
 
87
135
  | variable | default | |
@@ -90,6 +138,8 @@ and the repository page's Lineage card lists them by kind.
90
138
  | `MIADI_SESSION_INVENTORY_DIR` | `~/workspace/.mino/session-inventory` | the inventory records |
91
139
  | `MIADI_REPOSITORY_LINEAGE` | none | a lineage JSONL read before the shipped rows |
92
140
  | `MIADI_REPOSITORY_CAPABILITIES` | none | a capability JSONL read before the shipped rows |
141
+ | `MIADI_REPOSITORY_HOSTS` | none | a where JSONL (`where --write`) read before the shipped readings |
142
+ | `MIADI_HOST_GIT_ROOTS` | `/srv/git` | where `where` looks for bare repositories, colon-separated |
93
143
 
94
144
  ## CLI
95
145
 
@@ -98,7 +148,9 @@ miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json
98
148
  miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
99
149
  miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
100
150
  miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]
101
- miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>]
151
+ miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
152
+ miadi-repomap where [<owner/name>...] [--write <file>] [--json]
153
+ miadi-repomap impact <package> [--bump major|minor|patch] [--json]
102
154
  ```
103
155
 
104
156
  Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage, 2 usage error.
@@ -17,8 +17,11 @@ export interface Artefact {
17
17
  /** The fields of a package.json the scan reads. Never throws: an unreadable manifest has no name. */
18
18
  export declare function parsePackageJson(text: string): {
19
19
  name?: string;
20
+ version?: string;
20
21
  description?: string;
21
22
  bins: string[];
23
+ /** runtime dependencies (dependencies, peerDependencies, optionalDependencies): name → range */
24
+ dependsOn: Record<string, string>;
22
25
  };
23
26
  /** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
24
27
  export declare function parseSkillFrontMatter(text: string): {
@@ -34,6 +37,34 @@ export declare function workspaceGlobs(rootPackageJson?: string, pnpmWorkspace?:
34
37
  /** The package.json paths of a repository's declared packages, among the files it holds. */
35
38
  export declare function packageManifests(globs: readonly string[], files: readonly string[]): string[];
36
39
  /** The SKILL.md files a repository holds, outside dependencies and archives. */
40
+ /**
41
+ * The address a person cites a capability by, in an episode, an issue, an
42
+ * inquiry, a ceremony diary or a circle turn (Episode 568's Capability
43
+ * Registry, the scheme decided by William on 2026-11-01), for the repository
44
+ * that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
45
+ */
46
+ export declare function capabilityAddress(repository: string, kind: CapabilityKind, name: string): string;
47
+ /**
48
+ * A capability a repository defines in code rather than in a file of its own,
49
+ * read by a reader written for that repository and that file, never guessed
50
+ * from a name (Episode 568, P15). `read` gets the file's text at the scanned
51
+ * commit and answers what it defines.
52
+ */
53
+ export interface CodeReader {
54
+ /** `repository:<owner>/<name>`, compared case-folded */
55
+ repository: string;
56
+ path: string;
57
+ read(text: string): Artefact[];
58
+ }
59
+ /**
60
+ * The medicine wheel's skills: `cli/skills.ts` defines each one as a
61
+ * `{ name, title, description, target, … }` record, and `mw skill install` /
62
+ * `mwsrv skill install` write it out as a SKILL.md. The statement is the
63
+ * record's own description.
64
+ */
65
+ export declare function medicineWheelSkills(text: string): Artefact[];
66
+ /** The readers written so far, one per repository file that defines capabilities in code. */
67
+ export declare const CODE_READERS: readonly CodeReader[];
37
68
  export declare function skillFiles(files: readonly string[]): string[];
38
69
  export interface CapabilityRowContext {
39
70
  /** `repository:<owner>/<name>` */
@@ -9,13 +9,15 @@
9
9
  // Lane K7c (William, review d04556fd: "inventory and organize capabilities,
10
10
  // repositories and recently missions related sessions").
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CAPABILITY_KINDS = void 0;
12
+ exports.CODE_READERS = exports.CAPABILITY_KINDS = void 0;
13
13
  exports.capabilityId = capabilityId;
14
14
  exports.kindOf = kindOf;
15
15
  exports.parsePackageJson = parsePackageJson;
16
16
  exports.parseSkillFrontMatter = parseSkillFrontMatter;
17
17
  exports.workspaceGlobs = workspaceGlobs;
18
18
  exports.packageManifests = packageManifests;
19
+ exports.capabilityAddress = capabilityAddress;
20
+ exports.medicineWheelSkills = medicineWheelSkills;
19
21
  exports.skillFiles = skillFiles;
20
22
  exports.capabilityRows = capabilityRows;
21
23
  exports.mergeCapabilityRows = mergeCapabilityRows;
@@ -40,17 +42,28 @@ function kindOf(nodeId) {
40
42
  function parsePackageJson(text) {
41
43
  try {
42
44
  const p = JSON.parse(text);
43
- const name = typeof p.name === "string" && p.name.trim() ? p.name.trim() : undefined;
44
- const description = typeof p.description === "string" && p.description.trim() ? p.description.trim() : undefined;
45
+ const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
46
+ const name = str(p.name);
47
+ const version = str(p.version);
48
+ const description = str(p.description);
45
49
  let bins = [];
46
50
  if (typeof p.bin === "string" && name)
47
51
  bins = [name.replace(/^@[^/]+\//, "")];
48
52
  else if (p.bin && typeof p.bin === "object")
49
53
  bins = Object.keys(p.bin);
50
- return { ...(name ? { name } : {}), ...(description ? { description } : {}), bins };
54
+ const dependsOn = {};
55
+ for (const key of ["optionalDependencies", "peerDependencies", "dependencies"]) {
56
+ const deps = p[key];
57
+ if (deps && typeof deps === "object") {
58
+ for (const [dep, range] of Object.entries(deps))
59
+ if (typeof range === "string")
60
+ dependsOn[dep] = range;
61
+ }
62
+ }
63
+ return { ...(name ? { name } : {}), ...(version ? { version } : {}), ...(description ? { description } : {}), bins, dependsOn };
51
64
  }
52
65
  catch {
53
- return { bins: [] };
66
+ return { bins: [], dependsOn: {} };
54
67
  }
55
68
  }
56
69
  /** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
@@ -132,6 +145,33 @@ function packageManifests(globs, files) {
132
145
  return [...manifests].sort();
133
146
  }
134
147
  /** The SKILL.md files a repository holds, outside dependencies and archives. */
148
+ /**
149
+ * The address a person cites a capability by, in an episode, an issue, an
150
+ * inquiry, a ceremony diary or a circle turn (Episode 568's Capability
151
+ * Registry, the scheme decided by William on 2026-11-01), for the repository
152
+ * that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
153
+ */
154
+ function capabilityAddress(repository, kind, name) {
155
+ return `miadi-capability://${repository.replace(/^repository:/, "")}/${kind}/${name}`;
156
+ }
157
+ /**
158
+ * The medicine wheel's skills: `cli/skills.ts` defines each one as a
159
+ * `{ name, title, description, target, … }` record, and `mw skill install` /
160
+ * `mwsrv skill install` write it out as a SKILL.md. The statement is the
161
+ * record's own description.
162
+ */
163
+ function medicineWheelSkills(text) {
164
+ const out = [];
165
+ const re = /\{\s*name:\s*'([a-z0-9][a-z0-9-]*)',\s*title:\s*'(?:[^'\\\n]|\\.)*',\s*description:\s*'((?:[^'\\\n]|\\.)*)',\s*target:\s*'(?:cli|srv)'/g;
166
+ for (const m of text.matchAll(re)) {
167
+ out.push({ kind: "skill", name: m[1], description: m[2].replace(/\\(.)/g, "$1"), path: "cli/skills.ts" });
168
+ }
169
+ return out;
170
+ }
171
+ /** The readers written so far, one per repository file that defines capabilities in code. */
172
+ exports.CODE_READERS = [
173
+ { repository: "repository:jgwill/medicine-wheel", path: "cli/skills.ts", read: medicineWheelSkills },
174
+ ];
135
175
  function skillFiles(files) {
136
176
  return files
137
177
  .filter((f) => /(^|\/)SKILL\.md$/.test(f))
package/dist/cli.js CHANGED
@@ -6,7 +6,9 @@
6
6
  // miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
7
7
  // miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
8
8
  // miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]
9
- // miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>]
9
+ // miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
10
+ // miadi-repomap where [<owner/name>...] [--write <file>] [--json]
11
+ // miadi-repomap impact <package> [--bump major|minor|patch] [--json]
10
12
  //
11
13
  // `lineage <owner/name>` answers "what did this repository learn from", and
12
14
  // who learned from it; with no repository it prints every lineage. A lineage
@@ -20,6 +22,13 @@
20
22
  // tree) and prints those rows as JSONL, pending until a person reads them.
21
23
  // --capabilities adds a host's JSONL before the shipped rows (default
22
24
  // MIADI_REPOSITORY_CAPABILITIES).
25
+ //
26
+ // `where` checks where each repository lives, on GitHub (with a token from
27
+ // GH_TOKEN, GITHUB_TOKEN or `gh auth token`) or as a bare repository on this
28
+ // host (/srv/git, or MIADI_HOST_GIT_ROOTS), for the repositories named or
29
+ // every one the mapper names. `list` sets apart the repositories found
30
+ // nowhere. `impact` answers what bumping a package touches: what it consumes,
31
+ // who consumes it, and which ranges stop reaching the new version.
23
32
  // --hub defaults to MIADI_REPOSITORY_MAPPING_HUB (a jgwill/jgwill clone, or a
24
33
  // mapping folder); --inventory to MIADI_SESSION_INVENTORY_DIR, else
25
34
  // ~/workspace/.mino/session-inventory. Read-only.
@@ -61,21 +70,27 @@ var __importStar = (this && this.__importStar) || (function () {
61
70
  Object.defineProperty(exports, "__esModule", { value: true });
62
71
  const os = __importStar(require("node:os"));
63
72
  const capabilities_1 = require("./capabilities");
73
+ const node_fs_1 = require("node:fs");
64
74
  const read_1 = require("./read");
75
+ const where_1 = require("./where");
65
76
  const scan_1 = require("./scan");
66
77
  const USAGE = [
67
78
  "usage: miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
68
79
  " miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
69
80
  " miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]",
70
81
  " miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]",
71
- " miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>]",
82
+ " miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]",
83
+ " miadi-repomap where [<owner/name>...] [--write <file>] [--json]",
84
+ " miadi-repomap impact <package> [--bump major|minor|patch] [--json]",
72
85
  ].join("\n");
73
86
  const FLAGS = {
74
- list: ["hub", "inventory", "lineage", "capabilities", "json"],
75
- show: ["hub", "inventory", "lineage", "capabilities", "json"],
87
+ list: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
88
+ show: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
76
89
  lineage: ["lineage", "json"],
77
90
  capabilities: ["capabilities", "json"],
78
- scan: ["ref", "repository", "by"],
91
+ scan: ["ref", "repository", "by", "packages"],
92
+ where: ["write", "json", "hub", "inventory", "by"],
93
+ impact: ["bump", "json"],
79
94
  };
80
95
  class UsageError extends Error {
81
96
  }
@@ -137,7 +152,51 @@ async function main() {
137
152
  inventory: value(flags, "inventory"),
138
153
  lineage: value(flags, "lineage"),
139
154
  capabilities: value(flags, "capabilities"),
155
+ hosts: value(flags, "hosts"),
140
156
  };
157
+ if (command === "where") {
158
+ const named = positional.slice(1);
159
+ const listing = named.length ? undefined : await (0, read_1.repositoryListing)(options);
160
+ const ids = listing ? [...listing.repositories, ...listing.missing].map((r) => r.nodeId) : named;
161
+ const readings = await (0, where_1.checkWhere)(ids, { checkedBy: value(flags, "by") ?? `miadi-repomap where (${os.userInfo().username}@${os.hostname()})` });
162
+ const write = value(flags, "write");
163
+ if (write)
164
+ (0, node_fs_1.writeFileSync)(write, readings.map((r) => JSON.stringify(r)).join("\n") + "\n");
165
+ if (flags.json)
166
+ console.log(JSON.stringify(readings, null, 2));
167
+ else
168
+ for (const r of readings)
169
+ console.log(`${short(r.repository).padEnd(48)} ${r.host.padEnd(10)} ${r.url ?? ""}${r.note ? ` (${r.note})` : ""}`);
170
+ if (write)
171
+ console.error(`${readings.length} readings written to ${write}`);
172
+ return 0;
173
+ }
174
+ if (command === "impact") {
175
+ if (!positional[1])
176
+ throw new UsageError("impact needs a package: @scope/name or capability:package-…");
177
+ const bump = value(flags, "bump");
178
+ if (bump && !["major", "minor", "patch"].includes(bump))
179
+ throw new UsageError("--bump is major, minor or patch");
180
+ const read = (0, read_1.repositoryImpact)(positional[1], bump);
181
+ if (flags.json) {
182
+ console.log(JSON.stringify(read, null, 2));
183
+ return read.impact ? 0 : 1;
184
+ }
185
+ const i = read.impact;
186
+ if (!i) {
187
+ console.error(`miadi-repomap: ${positional[1]} is not a package the shipped scan read`);
188
+ return 1;
189
+ }
190
+ const lines = [
191
+ `${i.package.name}${i.package.version ? `@${i.package.version}` : ""} (${short(i.package.repository)})${i.bump ? ` ${i.bump.level} bump → ${i.bump.to}` : ""}`,
192
+ ` consumes (${i.consumes.length}):`,
193
+ ...i.consumes.map((c) => ` ${c.name}${c.version ? `@${c.version}` : ""} ${c.range} (${short(c.repository)})`),
194
+ ` consumed by (${i.consumers.length}):`,
195
+ ...i.consumers.map((c) => ` ${" ".repeat(c.depth - 1)}${c.name} ${c.depth === 1 ? c.range : `via ${c.via}`} (${short(c.repository)})${c.action ? ` — ${c.action}` : ""}`),
196
+ ];
197
+ console.log(lines.join("\n"));
198
+ return 0;
199
+ }
141
200
  if (command === "scan") {
142
201
  const clones = positional.slice(1);
143
202
  if (!clones.length)
@@ -146,13 +205,18 @@ async function main() {
146
205
  throw new UsageError("--repository names one clone's repository: scan one clone with it");
147
206
  const observedBy = value(flags, "by") ?? `miadi-repomap scan (${os.userInfo().username}@${os.hostname()})`;
148
207
  const rows = [];
208
+ const packages = [];
149
209
  for (const clone of clones) {
150
210
  const result = await (0, scan_1.scanRepository)(clone, { ref: value(flags, "ref"), repository: value(flags, "repository"), observedBy });
151
211
  console.error(`${result.repository.replace(/^repository:/, "")} @ ${result.commit.slice(0, 12)} (${result.ref}): ${result.capabilities.length} capabilities`);
152
212
  rows.push(...result.capabilities);
213
+ packages.push(...result.packages);
153
214
  }
154
215
  for (const row of (0, capabilities_1.mergeCapabilityRows)(rows))
155
216
  console.log(JSON.stringify(row));
217
+ const packagesFile = value(flags, "packages");
218
+ if (packagesFile)
219
+ (0, node_fs_1.writeFileSync)(packagesFile, packages.map((p) => JSON.stringify(p)).join("\n") + "\n");
156
220
  return 0;
157
221
  }
158
222
  if (command === "capabilities") {
@@ -168,6 +232,8 @@ async function main() {
168
232
  for (const c of answer.capabilities) {
169
233
  const by = answer.repository ? "" : ` (${c.providedBy.map(short).join(", ")})`;
170
234
  console.log(` ${(c.kind ?? "other").padEnd(8)} ${c.name}${by}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`);
235
+ if (c.address)
236
+ console.log(` ${c.address}`);
171
237
  }
172
238
  return 0;
173
239
  }
@@ -204,9 +270,14 @@ async function main() {
204
270
  console.error(hubLine(listing.hub));
205
271
  for (const r of listing.repositories) {
206
272
  const state = r.mapped ? `${r.lifecycle} · ${r.drift}` : "no mapping yet";
207
- console.log(`${`${r.owner}/${r.name}`.padEnd(48)} ${String(r.sessions).padStart(4)} sessions ${(r.last_session ?? "").padEnd(10)} ${state.padEnd(24)} ${r.teams.join(",") || "-"}`);
273
+ console.log(`${`${r.owner}/${r.name}`.padEnd(48)} ${r.host.padEnd(10)} ${String(r.sessions).padStart(4)} sessions ${(r.last_session ?? "").padEnd(10)} ${state.padEnd(24)} ${r.teams.join(",") || "-"}`);
208
274
  }
209
275
  console.error(`${listing.repositories.length} repositories; ${listing.inventory.records} records read from ${listing.inventory.from}, ${listing.inventory.without_repo} without a repo`);
276
+ if (listing.missing.length) {
277
+ console.error(`named by session records but found nowhere (${listing.missing.length}):`);
278
+ for (const r of listing.missing)
279
+ console.error(` ${r.owner}/${r.name} ${r.sessions} sessions`);
280
+ }
210
281
  return 0;
211
282
  }
212
283
  if (command === "show") {
@@ -223,7 +294,8 @@ async function main() {
223
294
  return 1;
224
295
  }
225
296
  const lines = [
226
- `${r.owner}/${r.name} ${r.url}`,
297
+ `${r.owner}/${r.name} ${r.url ?? r.where.url ?? ""} [${r.where.host}${r.where.private ? ", private" : ""}${r.where.archived ? ", archived" : ""}]`,
298
+ r.where.note ? ` where: ${r.where.note}` : "",
227
299
  r.repository
228
300
  ? ` ${r.repository.lifecycle} · ${r.repository.origin} · ${r.repository.revision}${r.source ? ` · from ${r.source}` : ""}`
229
301
  : ` ${hubLine(detail.hub)}`,
@@ -239,6 +311,8 @@ async function main() {
239
311
  ...linkLines(r.lineage.taught),
240
312
  r.capabilities.length ? ` provides (${r.capabilities.length}):` : "",
241
313
  ...r.capabilities.map((c) => ` ${(c.kind ?? "other").padEnd(8)} ${c.name}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`),
314
+ r.episodes.length ? ` episodes (${r.episodes.length}):` : "",
315
+ ...r.episodes.map((e) => ` ${e.number !== undefined ? `miadi-chronicle://${e.number}` : e.folder}${e.title ? ` ${e.title}` : ""} (${e.sessions} sessions)`),
242
316
  ` sessions (${r.sessions.length}):`,
243
317
  ...r.sessions.map(sessionLine),
244
318
  ];
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import { type MappingIssue } from "@medicine-wheel/developer-repository-mapping";
3
+ export declare const RepositoryHostSchema: z.ZodEnum<["github", "host-git", "missing", "unchecked"]>;
4
+ export type RepositoryHost = z.infer<typeof RepositoryHostSchema>;
5
+ export declare const RepositoryWhereSchema: z.ZodObject<{
6
+ repository: z.ZodString;
7
+ host: z.ZodEnum<["github", "host-git", "missing", "unchecked"]>;
8
+ /** github: the web page; host-git: `<host>:<path>` of the bare repository */
9
+ url: z.ZodOptional<z.ZodString>;
10
+ private: z.ZodOptional<z.ZodBoolean>;
11
+ archived: z.ZodOptional<z.ZodBoolean>;
12
+ /** why, in a few words: "404 from GitHub with a token, no /srv/git/jgwill/x.git" */
13
+ note: z.ZodOptional<z.ZodString>;
14
+ checkedBy: z.ZodString;
15
+ checkedAt: z.ZodString;
16
+ }, "strict", z.ZodTypeAny, {
17
+ repository: string;
18
+ host: "github" | "host-git" | "missing" | "unchecked";
19
+ checkedBy: string;
20
+ checkedAt: string;
21
+ note?: string | undefined;
22
+ url?: string | undefined;
23
+ private?: boolean | undefined;
24
+ archived?: boolean | undefined;
25
+ }, {
26
+ repository: string;
27
+ host: "github" | "host-git" | "missing" | "unchecked";
28
+ checkedBy: string;
29
+ checkedAt: string;
30
+ note?: string | undefined;
31
+ url?: string | undefined;
32
+ private?: boolean | undefined;
33
+ archived?: boolean | undefined;
34
+ }>;
35
+ export type RepositoryWhere = z.infer<typeof RepositoryWhereSchema>;
36
+ /**
37
+ * Readings from several JSONL texts, in precedence order: the first to name a
38
+ * repository speaks for it. Never throws.
39
+ */
40
+ export declare function parseWhere(texts: readonly {
41
+ text: string;
42
+ source: string;
43
+ }[]): {
44
+ readings: RepositoryWhere[];
45
+ issues: MappingIssue[];
46
+ };
47
+ /** Where a repository lives, or `unchecked` when no reading names it. Matched case-folded. */
48
+ export declare function whereOf(repository: string, readings: readonly RepositoryWhere[]): RepositoryWhere | {
49
+ repository: string;
50
+ host: "unchecked";
51
+ };
52
+ /** The web page of a repository: only GitHub repositories have one here. */
53
+ export declare function webUrlOf(where: {
54
+ host: RepositoryHost;
55
+ url?: string;
56
+ }): string | undefined;
package/dist/hosts.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ // Where a git repository lives, pure. A record or a scan names
3
+ // `repository:<owner>/<name>`, and that name does not say where the repository
4
+ // is: GitHub, a host's own git server (gaia's /srv/git holds jgwill/episodes,
5
+ // the chronicle vessel), or nowhere, when a record named a repository that
6
+ // does not exist. A reading says which, who checked and when; a repository no
7
+ // reading names is `unchecked`. Only a GitHub repository gets a GitHub link.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RepositoryWhereSchema = exports.RepositoryHostSchema = void 0;
10
+ exports.parseWhere = parseWhere;
11
+ exports.whereOf = whereOf;
12
+ exports.webUrlOf = webUrlOf;
13
+ const zod_1 = require("zod");
14
+ const capabilities_1 = require("@medicine-wheel/capabilities");
15
+ const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
16
+ exports.RepositoryHostSchema = zod_1.z.enum(["github", "host-git", "missing", "unchecked"]);
17
+ exports.RepositoryWhereSchema = zod_1.z
18
+ .object({
19
+ repository: developer_repository_mapping_1.RepositoryNodeIdSchema,
20
+ host: exports.RepositoryHostSchema,
21
+ /** github: the web page; host-git: `<host>:<path>` of the bare repository */
22
+ url: zod_1.z.string().min(1).optional(),
23
+ private: zod_1.z.boolean().optional(),
24
+ archived: zod_1.z.boolean().optional(),
25
+ /** why, in a few words: "404 from GitHub with a token, no /srv/git/jgwill/x.git" */
26
+ note: zod_1.z.string().min(1).optional(),
27
+ checkedBy: zod_1.z.string().min(1),
28
+ checkedAt: capabilities_1.TimestampSchema,
29
+ })
30
+ .strict();
31
+ const fold = (id) => id.toLowerCase();
32
+ /**
33
+ * Readings from several JSONL texts, in precedence order: the first to name a
34
+ * repository speaks for it. Never throws.
35
+ */
36
+ function parseWhere(texts) {
37
+ const readings = [];
38
+ const issues = [];
39
+ const seen = new Set();
40
+ for (const { text, source } of texts) {
41
+ const parsed = (0, developer_repository_mapping_1.parseJsonl)(text, exports.RepositoryWhereSchema, source);
42
+ issues.push(...parsed.issues);
43
+ for (const row of parsed.rows) {
44
+ if (seen.has(fold(row.repository)))
45
+ continue;
46
+ seen.add(fold(row.repository));
47
+ readings.push(row);
48
+ }
49
+ }
50
+ return { readings, issues };
51
+ }
52
+ /** Where a repository lives, or `unchecked` when no reading names it. Matched case-folded. */
53
+ function whereOf(repository, readings) {
54
+ const id = repository.startsWith("repository:") ? repository : `repository:${repository}`;
55
+ return readings.find((r) => fold(r.repository) === fold(id)) ?? { repository: id, host: "unchecked" };
56
+ }
57
+ /** The web page of a repository: only GitHub repositories have one here. */
58
+ function webUrlOf(where) {
59
+ return where.host === "github" ? where.url : undefined;
60
+ }
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ export declare const PackageReadingSchema: z.ZodObject<{
3
+ /** `capability:package-…` */
4
+ capability: z.ZodString;
5
+ name: z.ZodString;
6
+ version: z.ZodOptional<z.ZodString>;
7
+ repository: z.ZodString;
8
+ path: z.ZodString;
9
+ commit: z.ZodString;
10
+ /** runtime dependencies as declared (dependencies, peer, optional): name → range */
11
+ dependsOn: z.ZodRecord<z.ZodString, z.ZodString>;
12
+ }, "strict", z.ZodTypeAny, {
13
+ name: string;
14
+ capability: string;
15
+ repository: string;
16
+ path: string;
17
+ commit: string;
18
+ dependsOn: Record<string, string>;
19
+ version?: string | undefined;
20
+ }, {
21
+ name: string;
22
+ capability: string;
23
+ repository: string;
24
+ path: string;
25
+ commit: string;
26
+ dependsOn: Record<string, string>;
27
+ version?: string | undefined;
28
+ }>;
29
+ export type PackageReading = z.infer<typeof PackageReadingSchema>;
30
+ export interface ConsumesEdge {
31
+ /** the consuming package's capability */
32
+ from: string;
33
+ /** the consumed package's capability */
34
+ to: string;
35
+ type: "consumes";
36
+ fromName: string;
37
+ toName: string;
38
+ /** the range `from` declares on `to` */
39
+ range: string;
40
+ }
41
+ /** `consumes` edges between the packages read, first-party only. */
42
+ export declare function consumesEdges(packages: readonly PackageReading[]): ConsumesEdge[];
43
+ export type BumpLevel = "major" | "minor" | "patch";
44
+ export declare function bumpVersion(version: string, level: BumpLevel): string | undefined;
45
+ /**
46
+ * Whether `version` satisfies `range`, for the forms first-party manifests
47
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
48
+ * forms, read as pnpm publishes them against `published` (the consumed
49
+ * package's version when the consumer was released). Undefined for anything
50
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
51
+ */
52
+ export declare function satisfies(version: string, range: string, published?: string): boolean | undefined;
53
+ export interface ImpactLink {
54
+ name: string;
55
+ capability: string;
56
+ repository: string;
57
+ version?: string;
58
+ /** the range the consumer declares (downstream) or this package declares (upstream) */
59
+ range: string;
60
+ }
61
+ export interface ImpactConsumer extends ImpactLink {
62
+ /** 1 for a direct consumer, 2 for a consumer of a consumer, … */
63
+ depth: number;
64
+ /** the consumer it is reached through, from depth 2 */
65
+ via?: string;
66
+ /** with a bump, depth 1: whether its range reaches the new version */
67
+ accepts?: boolean;
68
+ /** with a bump: what the consumer needs */
69
+ action?: string;
70
+ }
71
+ export interface ImpactAnswer {
72
+ package: {
73
+ name: string;
74
+ capability: string;
75
+ version?: string;
76
+ repository: string;
77
+ };
78
+ bump?: {
79
+ level: BumpLevel;
80
+ from: string;
81
+ to: string;
82
+ };
83
+ /** upstream: the first-party packages it consumes */
84
+ consumes: ImpactLink[];
85
+ /** downstream: who consumes it, directly or through others */
86
+ consumers: ImpactConsumer[];
87
+ }
88
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
89
+ export declare function impactOf(packageOrCapability: string, packages: readonly PackageReading[], bump?: BumpLevel): ImpactAnswer | undefined;