@miadi/relational-git-repository-mapper 0.7.1 → 0.8.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/README.md +30 -3
- package/dist/cli.js +44 -10
- package/dist/commit.js +9 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/read.d.ts +14 -3
- package/dist/read.js +14 -3
- package/dist/shipped-capabilities.js +611 -458
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -81,9 +81,36 @@ 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
|
+
|
|
99
|
+
Since `@medicine-wheel/developer-repository-mapping` 0.27.16 (format version 3,
|
|
100
|
+
jgwill/medicine-wheel#177) a repository also provides applications (kind `app`), and a
|
|
101
|
+
capability says where it is hosted (`hosting`: where it runs, who deploys it, where its code
|
|
102
|
+
is written when not in this repository, how a change reaches it) and which episodes hold it
|
|
103
|
+
(`episodes`). An app is never guessed: a person names its folder with
|
|
104
|
+
`mw-repomap capabilities state app/<name> --path <folder> …`, and the scan reads the
|
|
105
|
+
`package.json` there. The first is Miadi's review service,
|
|
106
|
+
`miadi-capability://jgwill/Miadi/app/miadi-review-service`, a v0 prototype: an agent
|
|
107
|
+
reads in its row that the copy in `packages/review-service/app` is replaced at the next
|
|
108
|
+
import and that a change is a v0 prompt (jgwill/Miadi#1059).
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
miadi-repomap capabilities jgwill/Miadi --stage prototype # the prototypes, where each runs and how a change reaches it
|
|
112
|
+
```
|
|
113
|
+
|
|
87
114
|
`scan` takes a repository's own `.miadi/capabilities.jsonl` first when the commit holds one,
|
|
88
115
|
merged with what the commit's files say. Anyone writes that file with
|
|
89
116
|
`npx @medicine-wheel/developer-repository-mapping capabilities scan --write`, which is where the
|
|
@@ -120,8 +147,8 @@ capabilitiesOfCommit("jgwill/Miadi@b746c9a4", "/a/src/Miadi").capabilities.map((
|
|
|
120
147
|
|
|
121
148
|
Given `owner/name@sha` and a local clone whose `origin` is that repository (GitHub, or a
|
|
122
149
|
host's own git server), it reads the commit against its first parent and answers the
|
|
123
|
-
registry's rows whose defining files changed: for a package any file in its folder
|
|
124
|
-
counts for the deepest package folder that holds it), for a CLI its `bin` entry point (and
|
|
150
|
+
registry's rows whose defining files changed: for a package or an app any file in its folder
|
|
151
|
+
(a file counts for the deepest package or app folder that holds it), for a CLI its `bin` entry point (and
|
|
125
152
|
for a `dist/<x>.js` entry its `src/<x>` source), for a skill its `SKILL.md`. A lockfile, and
|
|
126
153
|
a `package.json` whose version or dependency ranges alone moved, define nothing, so a commit
|
|
127
154
|
that changes only those answers `skipped: "versions-only"`. Each answer carries an
|
|
@@ -182,7 +209,7 @@ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
|
|
|
182
209
|
miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
183
210
|
miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
184
211
|
miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
|
|
185
|
-
miadi-repomap capabilities [<owner/name>] [--capabilities <file>] [--json]
|
|
212
|
+
miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]
|
|
186
213
|
miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
|
|
187
214
|
miadi-repomap where [<owner/name>...] [--write <file>] [--json]
|
|
188
215
|
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("
|
|
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,35 @@ 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, what tracks it, where it is
|
|
105
|
+
* hosted and how a change reaches it, and the episodes that hold it, each when
|
|
106
|
+
* someone said it.
|
|
107
|
+
*/
|
|
108
|
+
function capabilityLines(c, by = "") {
|
|
109
|
+
return [
|
|
110
|
+
` ${(c.kind ?? "other").padEnd(8)} ${c.name}${c.stage ? ` (${c.stage.stage})` : ""}${by}${c.statement ? ` — ${c.statement}` : ` [${c.status}]`}`,
|
|
111
|
+
...(c.achieves ? [` achieves: ${c.achieves.statement} (${c.achieves.statedBy})`] : []),
|
|
112
|
+
...(c.specifications ?? []).map((s) => ` specified in ${s}`),
|
|
113
|
+
...(c.issues?.length ? [` tracked by ${c.issues.join(", ")}`] : []),
|
|
114
|
+
...(c.hosting
|
|
115
|
+
? [
|
|
116
|
+
` hosted${c.hosting.urls?.length ? ` at ${c.hosting.urls.join(", ")}` : ""}, deployed by ${c.hosting.deployedBy} (${c.hosting.statedBy})`,
|
|
117
|
+
...(c.hosting.authoredIn ? [` authored in ${c.hosting.authoredIn}: the copy here is replaced at the next import`] : []),
|
|
118
|
+
...(c.hosting.change ? [` change: ${c.hosting.change}`] : []),
|
|
119
|
+
]
|
|
120
|
+
: []),
|
|
121
|
+
...(c.episodes?.length ? [` held by ${c.episodes.join(", ")}`] : []),
|
|
122
|
+
];
|
|
123
|
+
}
|
|
98
124
|
function parse(argv) {
|
|
99
125
|
const positional = [];
|
|
100
126
|
const flags = {};
|
|
@@ -216,7 +242,7 @@ async function main() {
|
|
|
216
242
|
rows.push(...result.capabilities);
|
|
217
243
|
packages.push(...result.packages);
|
|
218
244
|
}
|
|
219
|
-
for (const row of (0,
|
|
245
|
+
for (const row of (0, capabilities_2.mergeCapabilityRows)(rows))
|
|
220
246
|
console.log(JSON.stringify(row));
|
|
221
247
|
const packagesFile = value(flags, "packages");
|
|
222
248
|
if (packagesFile)
|
|
@@ -224,7 +250,11 @@ async function main() {
|
|
|
224
250
|
return 0;
|
|
225
251
|
}
|
|
226
252
|
if (command === "capabilities") {
|
|
227
|
-
const
|
|
253
|
+
const stage = value(flags, "stage");
|
|
254
|
+
if (stage !== undefined && stage !== "unstated" && !capabilities_1.CAPABILITY_STAGES.includes(stage)) {
|
|
255
|
+
throw new UsageError(`--stage is one of ${[...capabilities_1.CAPABILITY_STAGES, "unstated"].join(", ")}`);
|
|
256
|
+
}
|
|
257
|
+
const answer = (0, read_1.repositoryCapabilities)(positional[1], { capabilities: options.capabilities, ...(stage ? { stage: stage } : {}) });
|
|
228
258
|
for (const i of answer.issues)
|
|
229
259
|
console.error(`${i.severity} ${i.file ?? ""}${i.line ? `:${i.line}` : ""} — ${i.message}`);
|
|
230
260
|
if (flags.json) {
|
|
@@ -232,10 +262,14 @@ async function main() {
|
|
|
232
262
|
return 0;
|
|
233
263
|
}
|
|
234
264
|
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`);
|
|
265
|
+
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, ${answer.counts.app} apps`);
|
|
266
|
+
const stated = Object.entries(answer.stages).filter(([k, n]) => k !== "unstated" && n > 0);
|
|
267
|
+
if (stated.length)
|
|
268
|
+
console.log(` stages: ${stated.map(([k, n]) => `${n} ${k}`).join(", ")}, ${answer.stages.unstated} unstated`);
|
|
236
269
|
for (const c of answer.capabilities) {
|
|
237
270
|
const by = answer.repository ? "" : ` (${c.providedBy.map(short).join(", ")})`;
|
|
238
|
-
|
|
271
|
+
for (const line of capabilityLines(c, by))
|
|
272
|
+
console.log(line);
|
|
239
273
|
if (c.address)
|
|
240
274
|
console.log(` ${c.address}`);
|
|
241
275
|
}
|
|
@@ -314,7 +348,7 @@ async function main() {
|
|
|
314
348
|
r.lineage.taught.length ? ` taught (${r.lineage.taught.length}):` : "",
|
|
315
349
|
...linkLines(r.lineage.taught),
|
|
316
350
|
r.capabilities.length ? ` provides (${r.capabilities.length}):` : "",
|
|
317
|
-
...r.capabilities.
|
|
351
|
+
...r.capabilities.flatMap((c) => capabilityLines(c)),
|
|
318
352
|
r.episodes.length ? ` episodes (${r.episodes.length}):` : "",
|
|
319
353
|
...r.episodes.map((e) => ` ${e.number !== undefined ? `miadi-chronicle://${e.number}` : e.folder}${e.title ? ` ${e.title}` : ""} (${e.sessions} sessions)`),
|
|
320
354
|
` sessions (${r.sessions.length}):`,
|
package/dist/commit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Which capability rows a commit changed (jgwill/Miadi#993). A row is changed
|
|
3
|
-
// when the commit changes a file that defines it: for a package, any
|
|
4
|
-
// its folder; for a CLI, its entry point; for a skill, its SKILL.md. A
|
|
3
|
+
// when the commit changes a file that defines it: for a package or an app, any
|
|
4
|
+
// file in its folder; for a CLI, its entry point; for a skill, its SKILL.md. A
|
|
5
5
|
// package.json whose change is only its version and its dependency ranges,
|
|
6
6
|
// and a lockfile, define nothing, so a commit that changes only those
|
|
7
7
|
// changes no capability. Each answer is a pending attribution until a person
|
|
@@ -118,12 +118,14 @@ function changedCapabilities(input) {
|
|
|
118
118
|
return { skipped: "versions-only", capabilities: [] };
|
|
119
119
|
const rows = input.rows.filter((r) => r.providedBy.some((p) => p.startsWith("repository:") && (0, join_1.repositoryKey)(p.slice("repository:".length)) === key));
|
|
120
120
|
const provider = (r) => r.providedBy.find((p) => p.startsWith("repository:") && (0, join_1.repositoryKey)(p.slice("repository:".length)) === key);
|
|
121
|
-
// A file belongs to the deepest package folder that holds it.
|
|
121
|
+
// A file belongs to the deepest package or app folder that holds it.
|
|
122
122
|
const packages = rows
|
|
123
|
-
.filter((r) => (0, capabilities_1.kindOf)(r.nodeId) === "package")
|
|
124
123
|
.flatMap((r) => {
|
|
124
|
+
const kind = (0, capabilities_1.kindOf)(r.nodeId);
|
|
125
|
+
if (kind !== "package" && kind !== "app")
|
|
126
|
+
return [];
|
|
125
127
|
const manifest = groundedPath(r);
|
|
126
|
-
return manifest && node_path_1.posix.basename(manifest) === "package.json" ? [{ row: r, folder: node_path_1.posix.dirname(manifest) }] : [];
|
|
128
|
+
return manifest && node_path_1.posix.basename(manifest) === "package.json" ? [{ row: r, kind, folder: node_path_1.posix.dirname(manifest) }] : [];
|
|
127
129
|
})
|
|
128
130
|
.sort((a, b) => b.folder.length - a.folder.length);
|
|
129
131
|
const inFolder = (file, folder) => folder === "." || file.startsWith(`${folder}/`);
|
|
@@ -137,7 +139,7 @@ function changedCapabilities(input) {
|
|
|
137
139
|
for (const file of defining) {
|
|
138
140
|
const owner = packages.find((p) => inFolder(file, p.folder));
|
|
139
141
|
if (owner)
|
|
140
|
-
add(owner.row,
|
|
142
|
+
add(owner.row, owner.kind, file);
|
|
141
143
|
}
|
|
142
144
|
for (const row of rows) {
|
|
143
145
|
const kind = (0, capabilities_1.kindOf)(row.nodeId);
|
|
@@ -161,7 +163,7 @@ function changedCapabilities(input) {
|
|
|
161
163
|
const by = input.by ?? "@miadi/relational-git-repository-mapper";
|
|
162
164
|
const capabilities = [...changed.values()]
|
|
163
165
|
.map(({ row, kind, files }) => {
|
|
164
|
-
// A package and a CLI are versioned by the manifest their row is grounded in, as it reads at the commit.
|
|
166
|
+
// A package, an app and a CLI are versioned by the manifest their row is grounded in, as it reads at the commit.
|
|
165
167
|
const manifest = kind === "skill" || kind === "decision" ? undefined : groundedPath(row);
|
|
166
168
|
const isManifest = manifest !== undefined && node_path_1.posix.basename(manifest) === "package.json";
|
|
167
169
|
const version = isManifest ? manifestVersion(input.read(manifest, "after")) : undefined;
|
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
|
-
/**
|
|
78
|
-
export declare
|
|
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
|
-
/**
|
|
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
|
|
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>`):
|