@miadi/relational-git-repository-mapper 0.7.1 → 0.7.2

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
@@ -81,9 +81,21 @@ Each repository's packages, CLIs and skills are `capability` nodes of
81
81
  ```bash
82
82
  miadi-repomap capabilities jgwill/medicine-wheel # what does the medicine wheel provide?
83
83
  miadi-repomap capabilities # every capability, and who provides it
84
+ miadi-repomap capabilities --stage specified # what is written down and not built yet
84
85
  miadi-repomap scan <clone>... --by "<who>" # read a clone's default branch, print JSONL rows
85
86
  ```
86
87
 
88
+ A capability says what it is (its `statement`, read from its files). Since
89
+ `@medicine-wheel/capabilities` 0.27.15 it can also say what it achieves for someone
90
+ (`achieves`, at most 55 words, signed), where it stands (`stage`: `specified`, `prototype`,
91
+ `implementation`, `released` or `retired`, signed and grounded), where its specifications are
92
+ (`specifications`, `rise://` addresses) and which issues track it (`issues`, `owner/repo#n`).
93
+ A person or an agent states them in the repository's own file with
94
+ `mw-repomap capabilities state <kind>/<name> --achieves … --stage … --specification … --issue … --by <who>`;
95
+ the scan carries them, `capabilities` and `show` print them, and `--stage <stage>` (or
96
+ `unstated`) lists the capabilities at one stage. A capability at stage `specified` is read
97
+ even before any code provides it.
98
+
87
99
  `scan` takes a repository's own `.miadi/capabilities.jsonl` first when the commit holds one,
88
100
  merged with what the commit's files say. Anyone writes that file with
89
101
  `npx @medicine-wheel/developer-repository-mapping capabilities scan --write`, which is where the
@@ -182,7 +194,7 @@ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
182
194
  miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
183
195
  miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
184
196
  miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
185
- miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]
197
+ miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]
186
198
  miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
187
199
  miadi-repomap where [<owner/name>...] [--write <file>] [--json]
188
200
  miadi-repomap impact <package> [--bump major|minor|patch] [--json]
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
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
- // miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]
8
+ // miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]
9
9
  // miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
10
10
  // miadi-repomap where [<owner/name>...] [--write <file>] [--json]
11
11
  // miadi-repomap impact <package> [--bump major|minor|patch] [--json]
@@ -22,7 +22,10 @@
22
22
  // .miadi/capabilities.jsonl first when it holds one (never its working
23
23
  // tree) and prints those rows as JSONL, pending until a person reads them.
24
24
  // --capabilities adds a host's JSONL before the shipped rows (default
25
- // MIADI_REPOSITORY_CAPABILITIES).
25
+ // MIADI_REPOSITORY_CAPABILITIES). Each capability shows what it achieves,
26
+ // where it stands, its specifications and its issues when someone said them;
27
+ // --stage <stage> lists only those at one stage (specified, prototype,
28
+ // implementation, released, retired, or unstated).
26
29
  //
27
30
  // `where` checks where each repository lives, on GitHub (with a token from
28
31
  // GH_TOKEN, GITHUB_TOKEN or `gh auth token`) or as a bare repository on this
@@ -70,7 +73,8 @@ var __importStar = (this && this.__importStar) || (function () {
70
73
  })();
71
74
  Object.defineProperty(exports, "__esModule", { value: true });
72
75
  const os = __importStar(require("node:os"));
73
- const capabilities_1 = require("./capabilities");
76
+ const capabilities_1 = require("@medicine-wheel/capabilities");
77
+ const capabilities_2 = require("./capabilities");
74
78
  const node_fs_1 = require("node:fs");
75
79
  const read_1 = require("./read");
76
80
  const where_1 = require("./where");
@@ -79,7 +83,7 @@ const USAGE = [
79
83
  "usage: miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
80
84
  " miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
81
85
  " miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]",
82
- " miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]",
86
+ " miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]",
83
87
  " miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]",
84
88
  " miadi-repomap where [<owner/name>...] [--write <file>] [--json]",
85
89
  " miadi-repomap impact <package> [--bump major|minor|patch] [--json]",
@@ -88,13 +92,26 @@ const FLAGS = {
88
92
  list: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
89
93
  show: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
90
94
  lineage: ["lineage", "json"],
91
- capabilities: ["capabilities", "json"],
95
+ capabilities: ["capabilities", "stage", "json"],
92
96
  scan: ["ref", "repository", "by", "packages"],
93
97
  where: ["write", "json", "hub", "inventory", "by"],
94
98
  impact: ["bump", "json"],
95
99
  };
96
100
  class UsageError extends Error {
97
101
  }
102
+ /**
103
+ * One capability as a person reads it: its kind, name, stage and statement,
104
+ * then what it achieves, where it is specified and what tracks it, each when
105
+ * someone said it.
106
+ */
107
+ function capabilityLines(c, by = "") {
108
+ return [
109
+ ` ${(c.kind ?? "other").padEnd(8)} ${c.name}${c.stage ? ` (${c.stage.stage})` : ""}${by}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`,
110
+ ...(c.achieves ? [` achieves: ${c.achieves.statement} (${c.achieves.statedBy})`] : []),
111
+ ...(c.specifications ?? []).map((s) => ` specified in ${s}`),
112
+ ...(c.issues?.length ? [` tracked by ${c.issues.join(", ")}`] : []),
113
+ ];
114
+ }
98
115
  function parse(argv) {
99
116
  const positional = [];
100
117
  const flags = {};
@@ -216,7 +233,7 @@ async function main() {
216
233
  rows.push(...result.capabilities);
217
234
  packages.push(...result.packages);
218
235
  }
219
- for (const row of (0, capabilities_1.mergeCapabilityRows)(rows))
236
+ for (const row of (0, capabilities_2.mergeCapabilityRows)(rows))
220
237
  console.log(JSON.stringify(row));
221
238
  const packagesFile = value(flags, "packages");
222
239
  if (packagesFile)
@@ -224,7 +241,11 @@ async function main() {
224
241
  return 0;
225
242
  }
226
243
  if (command === "capabilities") {
227
- const answer = (0, read_1.repositoryCapabilities)(positional[1], { capabilities: options.capabilities });
244
+ const stage = value(flags, "stage");
245
+ if (stage !== undefined && stage !== "unstated" && !capabilities_1.CAPABILITY_STAGES.includes(stage)) {
246
+ throw new UsageError(`--stage is one of ${[...capabilities_1.CAPABILITY_STAGES, "unstated"].join(", ")}`);
247
+ }
248
+ const answer = (0, read_1.repositoryCapabilities)(positional[1], { capabilities: options.capabilities, ...(stage ? { stage: stage } : {}) });
228
249
  for (const i of answer.issues)
229
250
  console.error(`${i.severity} ${i.file ?? ""}${i.line ? `:${i.line}` : ""} — ${i.message}`);
230
251
  if (flags.json) {
@@ -232,10 +253,14 @@ async function main() {
232
253
  return 0;
233
254
  }
234
255
  const subject = answer.repository ? short(answer.repository) : "every repository";
235
- console.log(`${subject} provides ${answer.capabilities.length}: ${answer.counts.package} packages, ${answer.counts.cli} CLIs, ${answer.counts.skill} skills, ${answer.counts.decision} decisions`);
256
+ console.log(`${subject} provides ${answer.capabilities.length}${answer.stage ? ` at stage ${answer.stage}` : ""}: ${answer.counts.package} packages, ${answer.counts.cli} CLIs, ${answer.counts.skill} skills, ${answer.counts.decision} decisions`);
257
+ const stated = Object.entries(answer.stages).filter(([k, n]) => k !== "unstated" && n > 0);
258
+ if (stated.length)
259
+ console.log(` stages: ${stated.map(([k, n]) => `${n} ${k}`).join(", ")}, ${answer.stages.unstated} unstated`);
236
260
  for (const c of answer.capabilities) {
237
261
  const by = answer.repository ? "" : ` (${c.providedBy.map(short).join(", ")})`;
238
- console.log(` ${(c.kind ?? "other").padEnd(8)} ${c.name}${by}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`);
262
+ for (const line of capabilityLines(c, by))
263
+ console.log(line);
239
264
  if (c.address)
240
265
  console.log(` ${c.address}`);
241
266
  }
@@ -314,7 +339,7 @@ async function main() {
314
339
  r.lineage.taught.length ? ` taught (${r.lineage.taught.length}):` : "",
315
340
  ...linkLines(r.lineage.taught),
316
341
  r.capabilities.length ? ` provides (${r.capabilities.length}):` : "",
317
- ...r.capabilities.map((c) => ` ${(c.kind ?? "other").padEnd(8)} ${c.name}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`),
342
+ ...r.capabilities.flatMap((c) => capabilityLines(c)),
318
343
  r.episodes.length ? ` episodes (${r.episodes.length}):` : "",
319
344
  ...r.episodes.map((e) => ` ${e.number !== undefined ? `miadi-chronicle://${e.number}` : e.folder}${e.title ? ` ${e.title}` : ""} (${e.sessions} sessions)`),
320
345
  ` sessions (${r.sessions.length}):`,
package/dist/index.d.ts CHANGED
@@ -10,5 +10,5 @@ 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, findCapability, type CapabilityRecord, type RelatedCapability, 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, stageOf, readWhere, readPackages, repositoryImpact, findCapability, type CapabilityRecord, type RelatedCapability, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, type CapabilitiesRead, type CapabilitiesAnswer, type WhereRead, type ImpactRead, } from "./read";
14
14
  export { capabilitiesOfCommit, changedCapabilities, changesOnlyVersions, remoteRepository, CommitReadError, type CommitCapability, type CommitCapabilities, type CommitCapabilitiesOptions, type CommitReadFailure, type ChangedCapabilitiesInput, } from "./commit";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // Data Mapper. Formerly @miadi/relational-repository-mapper (deprecated).
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  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.readRepositoryCapabilities = 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.capabilitySessions = exports.capabilityKey = exports.repositoriesOfRecord = exports.parseTraceRef = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
8
- exports.CommitReadError = exports.remoteRepository = exports.changesOnlyVersions = exports.changedCapabilities = exports.capabilitiesOfCommit = exports.findCapability = exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_HOSTS_SOURCE = exports.SHIPPED_HOSTS = void 0;
8
+ exports.CommitReadError = exports.remoteRepository = exports.changesOnlyVersions = exports.changedCapabilities = exports.capabilitiesOfCommit = exports.findCapability = exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.stageOf = exports.repositoryCapabilities = exports.readCapabilities = exports.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_HOSTS_SOURCE = exports.SHIPPED_HOSTS = 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; } });
@@ -80,6 +80,7 @@ Object.defineProperty(exports, "readLineage", { enumerable: true, get: function
80
80
  Object.defineProperty(exports, "repositoryLineage", { enumerable: true, get: function () { return read_1.repositoryLineage; } });
81
81
  Object.defineProperty(exports, "readCapabilities", { enumerable: true, get: function () { return read_1.readCapabilities; } });
82
82
  Object.defineProperty(exports, "repositoryCapabilities", { enumerable: true, get: function () { return read_1.repositoryCapabilities; } });
83
+ Object.defineProperty(exports, "stageOf", { enumerable: true, get: function () { return read_1.stageOf; } });
83
84
  Object.defineProperty(exports, "readWhere", { enumerable: true, get: function () { return read_1.readWhere; } });
84
85
  Object.defineProperty(exports, "readPackages", { enumerable: true, get: function () { return read_1.readPackages; } });
85
86
  Object.defineProperty(exports, "repositoryImpact", { enumerable: true, get: function () { return read_1.repositoryImpact; } });
package/dist/read.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SHIPPED_CAPABILITIES_SCANS } from "./shipped-capabilities";
2
2
  import { type BumpLevel, type ImpactAnswer, type PackageReading } from "./impact";
3
3
  import { type RepositoryWhere } from "./hosts";
4
- import { type CapabilityFacet } from "@medicine-wheel/capabilities";
4
+ import { type CapabilityFacet, type CapabilityStage } from "@medicine-wheel/capabilities";
5
5
  import { type CapabilityKind, type ProvidesEdge } from "./capabilities";
6
6
  import { type MappingIssue, type MergedMapping } from "@medicine-wheel/developer-repository-mapping";
7
7
  import { type CapabilitySession, type SessionsByRepository } from "./join";
@@ -67,6 +67,10 @@ export interface CapabilitiesAnswer {
67
67
  repository?: string;
68
68
  /** how many of each kind */
69
69
  counts: Record<CapabilityKind | "other", number>;
70
+ /** how many at each stage; `unstated` when nobody has said where a capability stands */
71
+ stages: Record<CapabilityStage | "unstated", number>;
72
+ /** with a stage: the one asked about, and only its capabilities are listed */
73
+ stage?: CapabilityStage | "unstated";
70
74
  /** each with its kind and the address a person cites it by, for the repository asked about or its first provider */
71
75
  capabilities: (CapabilityFacet & {
72
76
  kind?: CapabilityKind;
@@ -74,8 +78,15 @@ export interface CapabilitiesAnswer {
74
78
  })[];
75
79
  provides: ProvidesEdge[];
76
80
  }
77
- /** "What does this repository provide?", or with no repository, every capability. Reads no hub and no inventory. */
78
- export declare function repositoryCapabilities(repository?: string, options?: Pick<ReadOptions, "capabilities">): CapabilitiesAnswer;
81
+ /** Where a capability stands, `unstated` when nobody has said. */
82
+ export declare const stageOf: (c: CapabilityFacet) => CapabilityStage | "unstated";
83
+ /**
84
+ * "What does this repository provide?", or with no repository, every capability. Reads no hub and no inventory.
85
+ * With `stage`, only the capabilities at that stage: `specified` lists what is written down and not yet built.
86
+ */
87
+ export declare function repositoryCapabilities(repository?: string, options?: Pick<ReadOptions, "capabilities"> & {
88
+ stage?: CapabilityStage | "unstated";
89
+ }): CapabilitiesAnswer;
79
90
  /** A capability beside another one, with the address that opens it. */
80
91
  export interface RelatedCapability {
81
92
  relation: "consumes" | "consumed-by" | "ships" | "shipped-by";
package/dist/read.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // the hubs it registers) and the session inventory. Read-only; nothing here
4
4
  // writes a mapping or a record.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stageOf = void 0;
6
7
  exports.inventoryDir = inventoryDir;
7
8
  exports.hubPath = hubPath;
8
9
  exports.readWhere = readWhere;
@@ -132,11 +133,21 @@ function readCapabilities(path = process.env.MIADI_REPOSITORY_CAPABILITIES?.trim
132
133
  }
133
134
  return { from: sources.map((s) => s.source), scans: shipped_capabilities_1.SHIPPED_CAPABILITIES_SCANS, capabilities, issues };
134
135
  }
135
- /** "What does this repository provide?", or with no repository, every capability. Reads no hub and no inventory. */
136
+ /** Where a capability stands, `unstated` when nobody has said. */
137
+ const stageOf = (c) => c.stage?.stage ?? "unstated";
138
+ exports.stageOf = stageOf;
139
+ /**
140
+ * "What does this repository provide?", or with no repository, every capability. Reads no hub and no inventory.
141
+ * With `stage`, only the capabilities at that stage: `specified` lists what is written down and not yet built.
142
+ */
136
143
  function repositoryCapabilities(repository, options = {}) {
137
144
  const read = readCapabilities(options.capabilities);
138
145
  const id = repository ? (repository.startsWith("repository:") ? repository : `repository:${repository}`) : undefined;
139
- const rows = id ? (0, capabilities_2.capabilitiesOf)(id, read.capabilities) : read.capabilities;
146
+ const provided = id ? (0, capabilities_2.capabilitiesOf)(id, read.capabilities) : read.capabilities;
147
+ const stages = Object.fromEntries([...capabilities_1.CAPABILITY_STAGES, "unstated"].map((k) => [k, 0]));
148
+ for (const c of provided)
149
+ stages[(0, exports.stageOf)(c)] += 1;
150
+ const rows = options.stage ? provided.filter((c) => (0, exports.stageOf)(c) === options.stage) : provided;
140
151
  const counts = Object.fromEntries([...capabilities_2.CAPABILITY_KINDS, "other"].map((k) => [k, 0]));
141
152
  const capabilities = rows.map((c) => {
142
153
  const kind = (0, capabilities_2.kindOf)(c.nodeId);
@@ -145,7 +156,7 @@ function repositoryCapabilities(repository, options = {}) {
145
156
  return kind ? { ...c, kind, ...(provider ? { address: (0, capabilities_2.capabilityAddress)(provider, kind, c.name) } : {}) } : { ...c };
146
157
  });
147
158
  const provides = (0, capabilities_2.providesEdges)(rows).filter((e) => !id || e.from.toLowerCase() === id.toLowerCase());
148
- return { from: read.from, scans: read.scans, issues: read.issues, ...(id ? { repository: id } : {}), counts, capabilities, provides };
159
+ return { from: read.from, scans: read.scans, issues: read.issues, ...(id ? { repository: id } : {}), counts, stages, ...(options.stage ? { stage: options.stage } : {}), capabilities, provides };
149
160
  }
150
161
  /**
151
162
  * The capability an address names (`miadi-capability:<owner>/<repo>/<kind>/<name>`):