@miadi/relational-git-repository-mapper 0.5.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
@@ -37,6 +37,34 @@ export declare function workspaceGlobs(rootPackageJson?: string, pnpmWorkspace?:
37
37
  /** The package.json paths of a repository's declared packages, among the files it holds. */
38
38
  export declare function packageManifests(globs: readonly string[], files: readonly string[]): string[];
39
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[];
40
68
  export declare function skillFiles(files: readonly string[]): string[];
41
69
  export interface CapabilityRowContext {
42
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;
@@ -143,6 +145,33 @@ function packageManifests(globs, files) {
143
145
  return [...manifests].sort();
144
146
  }
145
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
+ ];
146
175
  function skillFiles(files) {
147
176
  return files
148
177
  .filter((f) => /(^|\/)SKILL\.md$/.test(f))
package/dist/cli.js CHANGED
@@ -232,6 +232,8 @@ async function main() {
232
232
  for (const c of answer.capabilities) {
233
233
  const by = answer.repository ? "" : ` (${c.providedBy.map(short).join(", ")})`;
234
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}`);
235
237
  }
236
238
  return 0;
237
239
  }
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export type { RepositorySession, MappingState, HubState, RepositoryView, Reposit
2
2
  export { dayOf, teamOf, dispositionOf, sessionOf, repositoryKey, sessionsByRepository, repositoryView, listRepositories, type SessionsByRepository, } from "./join";
3
3
  export { LineageRowSchema, parseLineage, lineageOf, lineageGraph, type LineageRow, type LineageEdge, type LineageLink, type RepositoryLineage, type LineageGraph, } from "./lineage";
4
4
  export { SHIPPED_LINEAGE_JSONL, SHIPPED_LINEAGE_SOURCE } from "./shipped-lineage";
5
- export { CAPABILITY_KINDS, capabilityId, kindOf, parsePackageJson, parseSkillFrontMatter, workspaceGlobs, packageManifests, skillFiles, capabilityRows, mergeCapabilityRows, providesEdges, capabilitiesOf, type CapabilityKind, type Artefact, type CapabilityRowContext, type ProvidesEdge, } from "./capabilities";
5
+ export { CAPABILITY_KINDS, capabilityId, kindOf, parsePackageJson, parseSkillFrontMatter, workspaceGlobs, packageManifests, skillFiles, capabilityRows, mergeCapabilityRows, providesEdges, capabilitiesOf, capabilityAddress, medicineWheelSkills, CODE_READERS, type CapabilityKind, type CodeReader, type Artefact, type CapabilityRowContext, type ProvidesEdge, } from "./capabilities";
6
6
  export { SHIPPED_CAPABILITIES, SHIPPED_CAPABILITIES_SCANS, SHIPPED_CAPABILITIES_SOURCE } from "./shipped-capabilities";
7
7
  export { scanRepository, type ScanOptions, type ScanResult } from "./scan";
8
8
  export { PackageReadingSchema, consumesEdges, bumpVersion, satisfies, impactOf, type PackageReading, type ConsumesEdge, type BumpLevel, type ImpactLink, type ImpactConsumer, type ImpactAnswer, } from "./impact";
@@ -10,4 +10,4 @@ export { RepositoryHostSchema, RepositoryWhereSchema, parseWhere, whereOf, webUr
10
10
  export { checkWhere, type CheckWhereOptions } from "./where";
11
11
  export { SHIPPED_PACKAGES } from "./shipped-capabilities";
12
12
  export { SHIPPED_HOSTS, SHIPPED_HOSTS_SOURCE } from "./shipped-hosts";
13
- export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, readCapabilities, repositoryCapabilities, readWhere, readPackages, repositoryImpact, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, type CapabilitiesRead, type CapabilitiesAnswer, type WhereRead, type ImpactRead, } from "./read";
13
+ export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, readCapabilities, repositoryCapabilities, readWhere, readPackages, repositoryImpact, findCapability, type CapabilityRecord, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, type CapabilitiesRead, type CapabilitiesAnswer, type WhereRead, type ImpactRead, } from "./read";
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@
4
4
  // "Repository" here is always a git repository, never the DDD Repository or a
5
5
  // Data Mapper. Formerly @miadi/relational-repository-mapper (deprecated).
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_HOSTS_SOURCE = exports.SHIPPED_HOSTS = exports.SHIPPED_PACKAGES = exports.checkWhere = exports.webUrlOf = exports.whereOf = exports.parseWhere = exports.RepositoryWhereSchema = exports.RepositoryHostSchema = exports.impactOf = exports.satisfies = exports.bumpVersion = exports.consumesEdges = exports.PackageReadingSchema = exports.scanRepository = exports.SHIPPED_CAPABILITIES_SOURCE = exports.SHIPPED_CAPABILITIES_SCANS = exports.SHIPPED_CAPABILITIES = exports.capabilitiesOf = exports.providesEdges = exports.mergeCapabilityRows = exports.capabilityRows = exports.skillFiles = exports.packageManifests = exports.workspaceGlobs = exports.parseSkillFrontMatter = exports.parsePackageJson = exports.kindOf = exports.capabilityId = exports.CAPABILITY_KINDS = exports.SHIPPED_LINEAGE_SOURCE = exports.SHIPPED_LINEAGE_JSONL = exports.lineageGraph = exports.lineageOf = exports.parseLineage = exports.LineageRowSchema = exports.listRepositories = exports.repositoryView = exports.sessionsByRepository = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
8
- exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = void 0;
7
+ exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_HOSTS_SOURCE = exports.SHIPPED_HOSTS = exports.SHIPPED_PACKAGES = exports.checkWhere = exports.webUrlOf = exports.whereOf = exports.parseWhere = exports.RepositoryWhereSchema = exports.RepositoryHostSchema = exports.impactOf = exports.satisfies = exports.bumpVersion = exports.consumesEdges = exports.PackageReadingSchema = exports.scanRepository = exports.SHIPPED_CAPABILITIES_SOURCE = exports.SHIPPED_CAPABILITIES_SCANS = exports.SHIPPED_CAPABILITIES = exports.CODE_READERS = exports.medicineWheelSkills = exports.capabilityAddress = exports.capabilitiesOf = exports.providesEdges = exports.mergeCapabilityRows = exports.capabilityRows = exports.skillFiles = exports.packageManifests = exports.workspaceGlobs = exports.parseSkillFrontMatter = exports.parsePackageJson = exports.kindOf = exports.capabilityId = exports.CAPABILITY_KINDS = exports.SHIPPED_LINEAGE_SOURCE = exports.SHIPPED_LINEAGE_JSONL = exports.lineageGraph = exports.lineageOf = exports.parseLineage = exports.LineageRowSchema = exports.listRepositories = exports.repositoryView = exports.sessionsByRepository = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
8
+ exports.findCapability = exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = void 0;
9
9
  var join_1 = require("./join");
10
10
  Object.defineProperty(exports, "dayOf", { enumerable: true, get: function () { return join_1.dayOf; } });
11
11
  Object.defineProperty(exports, "teamOf", { enumerable: true, get: function () { return join_1.teamOf; } });
@@ -36,6 +36,9 @@ Object.defineProperty(exports, "capabilityRows", { enumerable: true, get: functi
36
36
  Object.defineProperty(exports, "mergeCapabilityRows", { enumerable: true, get: function () { return capabilities_1.mergeCapabilityRows; } });
37
37
  Object.defineProperty(exports, "providesEdges", { enumerable: true, get: function () { return capabilities_1.providesEdges; } });
38
38
  Object.defineProperty(exports, "capabilitiesOf", { enumerable: true, get: function () { return capabilities_1.capabilitiesOf; } });
39
+ Object.defineProperty(exports, "capabilityAddress", { enumerable: true, get: function () { return capabilities_1.capabilityAddress; } });
40
+ Object.defineProperty(exports, "medicineWheelSkills", { enumerable: true, get: function () { return capabilities_1.medicineWheelSkills; } });
41
+ Object.defineProperty(exports, "CODE_READERS", { enumerable: true, get: function () { return capabilities_1.CODE_READERS; } });
39
42
  var shipped_capabilities_1 = require("./shipped-capabilities");
40
43
  Object.defineProperty(exports, "SHIPPED_CAPABILITIES", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES; } });
41
44
  Object.defineProperty(exports, "SHIPPED_CAPABILITIES_SCANS", { enumerable: true, get: function () { return shipped_capabilities_1.SHIPPED_CAPABILITIES_SCANS; } });
@@ -75,3 +78,4 @@ Object.defineProperty(exports, "repositoryCapabilities", { enumerable: true, get
75
78
  Object.defineProperty(exports, "readWhere", { enumerable: true, get: function () { return read_1.readWhere; } });
76
79
  Object.defineProperty(exports, "readPackages", { enumerable: true, get: function () { return read_1.readPackages; } });
77
80
  Object.defineProperty(exports, "repositoryImpact", { enumerable: true, get: function () { return read_1.repositoryImpact; } });
81
+ Object.defineProperty(exports, "findCapability", { enumerable: true, get: function () { return read_1.findCapability; } });
package/dist/read.d.ts CHANGED
@@ -67,13 +67,38 @@ export interface CapabilitiesAnswer {
67
67
  repository?: string;
68
68
  /** how many of each kind */
69
69
  counts: Record<CapabilityKind | "other", number>;
70
+ /** each with its kind and the address a person cites it by, for the repository asked about or its first provider */
70
71
  capabilities: (CapabilityFacet & {
71
72
  kind?: CapabilityKind;
73
+ address?: string;
72
74
  })[];
73
75
  provides: ProvidesEdge[];
74
76
  }
75
77
  /** "What does this repository provide?", or with no repository, every capability. Reads no hub and no inventory. */
76
78
  export declare function repositoryCapabilities(repository?: string, options?: Pick<ReadOptions, "capabilities">): CapabilitiesAnswer;
79
+ export interface CapabilityRecord {
80
+ /** the row, with its kind and the address a person cites it by */
81
+ capability: CapabilityFacet & {
82
+ kind: CapabilityKind;
83
+ address: string;
84
+ };
85
+ /** `repository:<owner>/<name>`, the provider the address names */
86
+ repository: string;
87
+ /** for a package: its version, the manifest and commit it was read at, and what it consumes and what consumes it */
88
+ impact?: ImpactAnswer;
89
+ scans: typeof SHIPPED_CAPABILITIES_SCANS;
90
+ }
91
+ /**
92
+ * The capability an address names (`miadi-capability:<owner>/<repo>/<kind>/<name>`):
93
+ * the row of that kind and name that the repository provides, compared
94
+ * case-folded on the repository. Undefined when the registry holds none.
95
+ */
96
+ export declare function findCapability(parts: {
97
+ owner: string;
98
+ repo: string;
99
+ kind: string;
100
+ name: string;
101
+ }, options?: Pick<ReadOptions, "capabilities">): CapabilityRecord | undefined;
77
102
  export interface LineageRead {
78
103
  /** the files read, in precedence order */
79
104
  from: string[];
package/dist/read.js CHANGED
@@ -10,6 +10,7 @@ exports.readPackages = readPackages;
10
10
  exports.repositoryImpact = repositoryImpact;
11
11
  exports.readCapabilities = readCapabilities;
12
12
  exports.repositoryCapabilities = repositoryCapabilities;
13
+ exports.findCapability = findCapability;
13
14
  exports.readLineage = readLineage;
14
15
  exports.readHubState = readHubState;
15
16
  exports.readMapper = readMapper;
@@ -123,11 +124,37 @@ function repositoryCapabilities(repository, options = {}) {
123
124
  const capabilities = rows.map((c) => {
124
125
  const kind = (0, capabilities_2.kindOf)(c.nodeId);
125
126
  counts[kind ?? "other"] += 1;
126
- return kind ? { ...c, kind } : { ...c };
127
+ const provider = (id && c.providedBy.find((p) => p.toLowerCase() === id.toLowerCase())) || c.providedBy[0];
128
+ return kind ? { ...c, kind, ...(provider ? { address: (0, capabilities_2.capabilityAddress)(provider, kind, c.name) } : {}) } : { ...c };
127
129
  });
128
130
  const provides = (0, capabilities_2.providesEdges)(rows).filter((e) => !id || e.from.toLowerCase() === id.toLowerCase());
129
131
  return { from: read.from, scans: read.scans, issues: read.issues, ...(id ? { repository: id } : {}), counts, capabilities, provides };
130
132
  }
133
+ /**
134
+ * The capability an address names (`miadi-capability:<owner>/<repo>/<kind>/<name>`):
135
+ * the row of that kind and name that the repository provides, compared
136
+ * case-folded on the repository. Undefined when the registry holds none.
137
+ */
138
+ function findCapability(parts, options = {}) {
139
+ const repository = `repository:${parts.owner}/${parts.repo}`.toLowerCase();
140
+ const read = readCapabilities(options.capabilities);
141
+ for (const c of read.capabilities) {
142
+ const kind = (0, capabilities_2.kindOf)(c.nodeId);
143
+ if (kind !== parts.kind || c.name !== parts.name)
144
+ continue;
145
+ const provider = c.providedBy.find((p) => p.toLowerCase() === repository);
146
+ if (!provider)
147
+ continue;
148
+ const impact = kind === "package" ? (0, impact_1.impactOf)(c.name, readPackages().packages) : undefined;
149
+ return {
150
+ capability: { ...c, kind, address: (0, capabilities_2.capabilityAddress)(provider, kind, c.name) },
151
+ repository: provider,
152
+ ...(impact ? { impact } : {}),
153
+ scans: read.scans,
154
+ };
155
+ }
156
+ return undefined;
157
+ }
131
158
  /**
132
159
  * The lineage: a host's own file first (`--lineage` or
133
160
  * `MIADI_REPOSITORY_LINEAGE`), then the rows this package ships. The first
package/dist/scan.js CHANGED
@@ -65,6 +65,12 @@ async function scanRepository(clone, options) {
65
65
  continue;
66
66
  artefacts.push({ kind: "skill", name, ...(front.description ? { description: front.description } : {}), path: file });
67
67
  }
68
+ // Capabilities defined in code, each by the reader written for its repository's file.
69
+ for (const reader of capabilities_1.CODE_READERS) {
70
+ if (reader.repository.toLowerCase() !== repository.toLowerCase() || !files.includes(reader.path))
71
+ continue;
72
+ artefacts.push(...reader.read((await show(reader.path)) ?? ""));
73
+ }
68
74
  const observedAt = (options.now ?? new Date()).toISOString();
69
75
  return {
70
76
  repository,