@miadi/relational-git-repository-mapper 0.7.2 → 0.9.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 +55 -7
- package/dist/cli.js +50 -15
- package/dist/commit.js +9 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1
- package/dist/read.d.ts +65 -1
- package/dist/read.js +146 -4
- package/dist/shipped-capabilities.js +576 -456
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -80,11 +80,29 @@ Each repository's packages, CLIs and skills are `capability` nodes of
|
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
82
|
miadi-repomap capabilities jgwill/medicine-wheel # what does the medicine wheel provide?
|
|
83
|
+
miadi-repomap capabilities jgwill/mia-code --clone /src/mia-code # read it from a clone a person names
|
|
83
84
|
miadi-repomap capabilities # every capability, and who provides it
|
|
84
85
|
miadi-repomap capabilities --stage specified # what is written down and not built yet
|
|
85
86
|
miadi-repomap scan <clone>... --by "<who>" # read a clone's default branch, print JSONL rows
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
**A repository is read from its clone on this host when there is one** (0.9.0,
|
|
90
|
+
jgwill/Miadi#1148). A repository that committed its own `.miadi/capabilities.jsonl` is
|
|
91
|
+
shown as that file says, with no intermediate file: `capabilities <owner/name>` and
|
|
92
|
+
`show <owner/name>` read the clone named with `--clone`, else the one found under
|
|
93
|
+
`MIADI_REPOSITORY_CLONES`, else beside the hub clone (`…/repos/jgwill/jgwill` sits beside
|
|
94
|
+
`…/repos/jgwill/<name>`). A folder is the repository's clone only when its `origin`
|
|
95
|
+
names it. The clone is read at its default branch as last fetched (`git fetch` first for
|
|
96
|
+
today's), its own file first, merged with what the commit's files say, and its rows
|
|
97
|
+
replace the shipped rows of that repository. The first line on stderr says which clone,
|
|
98
|
+
which commit and whether it holds a file. With no clone the answer is the map's.
|
|
99
|
+
|
|
100
|
+
Since `@medicine-wheel/developer-repository-mapping` 0.27.20 (format version 5,
|
|
101
|
+
jgwill/medicine-wheel#188) a row also says which commands a CLI carries (`carries`),
|
|
102
|
+
which CLI a command belongs to, and what reads a capability where no `package.json`
|
|
103
|
+
says so (`read by`). A capability still being built is read at `prototype` or
|
|
104
|
+
`implementation` when its stage names an issue, a pull request or a branch.
|
|
105
|
+
|
|
88
106
|
A capability says what it is (its `statement`, read from its files). Since
|
|
89
107
|
`@medicine-wheel/capabilities` 0.27.15 it can also say what it achieves for someone
|
|
90
108
|
(`achieves`, at most 55 words, signed), where it stands (`stage`: `specified`, `prototype`,
|
|
@@ -96,6 +114,21 @@ the scan carries them, `capabilities` and `show` print them, and `--stage <stage
|
|
|
96
114
|
`unstated`) lists the capabilities at one stage. A capability at stage `specified` is read
|
|
97
115
|
even before any code provides it.
|
|
98
116
|
|
|
117
|
+
Since `@medicine-wheel/developer-repository-mapping` 0.27.16 (format version 3,
|
|
118
|
+
jgwill/medicine-wheel#177) a repository also provides applications (kind `app`), and a
|
|
119
|
+
capability says where it is hosted (`hosting`: where it runs, who deploys it, where its code
|
|
120
|
+
is written when not in this repository, how a change reaches it) and which episodes hold it
|
|
121
|
+
(`episodes`). An app is never guessed: a person names its folder with
|
|
122
|
+
`mw-repomap capabilities state app/<name> --path <folder> …`, and the scan reads the
|
|
123
|
+
`package.json` there. The first is Miadi's review service,
|
|
124
|
+
`miadi-capability://jgwill/Miadi/app/miadi-review-service`, a v0 prototype: an agent
|
|
125
|
+
reads in its row that the copy in `packages/review-service/app` is replaced at the next
|
|
126
|
+
import and that a change is a v0 prompt (jgwill/Miadi#1059).
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
miadi-repomap capabilities jgwill/Miadi --stage prototype # the prototypes, where each runs and how a change reaches it
|
|
130
|
+
```
|
|
131
|
+
|
|
99
132
|
`scan` takes a repository's own `.miadi/capabilities.jsonl` first when the commit holds one,
|
|
100
133
|
merged with what the commit's files say. Anyone writes that file with
|
|
101
134
|
`npx @medicine-wheel/developer-repository-mapping capabilities scan --write`, which is where the
|
|
@@ -114,10 +147,24 @@ reads it.
|
|
|
114
147
|
|
|
115
148
|
The package ships a scan of `jgwill/Miadi` and the three lineages (`avadisabelle/coaia-narrative`,
|
|
116
149
|
`jgwill/coaiajs`, `jgwill/medicine-wheel`), regenerated with
|
|
117
|
-
`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
|
|
150
|
+
`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 capability map
|
|
118
151
|
(`--capabilities` or `MIADI_REPOSITORY_CAPABILITIES`) is read first; the first source to name
|
|
119
152
|
a capability speaks for it.
|
|
120
153
|
|
|
154
|
+
`--capabilities` and `MIADI_REPOSITORY_CAPABILITIES` take a **capability map**: one row per
|
|
155
|
+
capability and provider, with `nodeId`, `name`, `providedBy` and its attribution. This
|
|
156
|
+
command writes one:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
mw-repomap capabilities map <clone>... --out map.jsonl # or --root <folder of clones>
|
|
160
|
+
miadi-repomap capabilities <owner/name> --capabilities map.jsonl
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
A repository's own `.miadi/capabilities.jsonl` is not a map: its rows hold `kind`, `name`
|
|
164
|
+
and `address`, and are read with the commit they sit in. Given that file, the command says
|
|
165
|
+
so in one line and exits 1. Any file or clone that could not be read ends `capabilities`
|
|
166
|
+
with exit 1.
|
|
167
|
+
|
|
121
168
|
In the app: `GET /api/repositories/capabilities[?repository=owner/name]` answers with the
|
|
122
169
|
capabilities and their `provides` edges, `GET /api/repositories/{owner}/{name}` carries them,
|
|
123
170
|
and the repository page's Lineage card lists them by kind.
|
|
@@ -132,8 +179,8 @@ capabilitiesOfCommit("jgwill/Miadi@b746c9a4", "/a/src/Miadi").capabilities.map((
|
|
|
132
179
|
|
|
133
180
|
Given `owner/name@sha` and a local clone whose `origin` is that repository (GitHub, or a
|
|
134
181
|
host's own git server), it reads the commit against its first parent and answers the
|
|
135
|
-
registry's rows whose defining files changed: for a package any file in its folder
|
|
136
|
-
counts for the deepest package folder that holds it), for a CLI its `bin` entry point (and
|
|
182
|
+
registry's rows whose defining files changed: for a package or an app any file in its folder
|
|
183
|
+
(a file counts for the deepest package or app folder that holds it), for a CLI its `bin` entry point (and
|
|
137
184
|
for a `dist/<x>.js` entry its `src/<x>` source), for a skill its `SKILL.md`. A lockfile, and
|
|
138
185
|
a `package.json` whose version or dependency ranges alone moved, define nothing, so a commit
|
|
139
186
|
that changes only those answers `skipped: "versions-only"`. Each answer carries an
|
|
@@ -183,7 +230,8 @@ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
|
|
|
183
230
|
| `MIADI_REPOSITORY_MAPPING_HUB` | none | a hub clone (`…/jgwill/jgwill`) or its mapping folder |
|
|
184
231
|
| `MIADI_SESSION_INVENTORY_DIR` | `~/workspace/.mino/session-inventory` | the inventory records |
|
|
185
232
|
| `MIADI_REPOSITORY_LINEAGE` | none | a lineage JSONL read before the shipped rows |
|
|
186
|
-
| `MIADI_REPOSITORY_CAPABILITIES` | none | a capability
|
|
233
|
+
| `MIADI_REPOSITORY_CAPABILITIES` | none | a capability map (`mw-repomap capabilities map --out`) read before the shipped rows |
|
|
234
|
+
| `MIADI_REPOSITORY_CLONES` | the folders around the hub clone | where a repository's clone is looked for, colon-separated: each holds `<owner>/<name>` or `<name>` |
|
|
187
235
|
| `MIADI_REPOSITORY_HOSTS` | none | a where JSONL (`where --write`) read before the shipped readings |
|
|
188
236
|
| `MIADI_REPOSITORY_PACKAGES` | none | a package readings JSONL (`mw-repomap capabilities map --packages`) read before the shipped ones |
|
|
189
237
|
| `MIADI_HOST_GIT_ROOTS` | `/srv/git` | where `where` looks for bare repositories, colon-separated |
|
|
@@ -192,15 +240,15 @@ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
|
|
|
192
240
|
|
|
193
241
|
```bash
|
|
194
242
|
miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
195
|
-
miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
243
|
+
miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--clone <path>] [--json]
|
|
196
244
|
miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
|
|
197
|
-
miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]
|
|
245
|
+
miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--clone <path>] [--json]
|
|
198
246
|
miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]
|
|
199
247
|
miadi-repomap where [<owner/name>...] [--write <file>] [--json]
|
|
200
248
|
miadi-repomap impact <package> [--bump major|minor|patch] [--json]
|
|
201
249
|
```
|
|
202
250
|
|
|
203
|
-
Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage, 2 usage error.
|
|
251
|
+
Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage; `capabilities`: a file or a clone could not be read, 2 usage error.
|
|
204
252
|
|
|
205
253
|
## Library
|
|
206
254
|
|
package/dist/cli.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// miadi-repomap — a repository's mapping rows beside the sessions that worked in it.
|
|
4
4
|
//
|
|
5
5
|
// miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
6
|
-
// miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
|
|
6
|
+
// miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--clone <path>] [--json]
|
|
7
7
|
// miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
|
|
8
|
-
// miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]
|
|
8
|
+
// miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--clone <path>] [--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]
|
|
@@ -21,8 +21,15 @@
|
|
|
21
21
|
// `scan` reads a clone's default branch from git objects, its own
|
|
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
|
-
//
|
|
25
|
-
//
|
|
24
|
+
// With a repository, `capabilities` and `show` read its clone on this host
|
|
25
|
+
// when there is one: the clone named with --clone, else the one found under
|
|
26
|
+
// MIADI_REPOSITORY_CLONES (colon-separated folders holding <owner>/<name> or
|
|
27
|
+
// <name>), else beside the hub clone. The clone's own committed
|
|
28
|
+
// .miadi/capabilities.jsonl speaks first, at its default branch as last
|
|
29
|
+
// fetched, and replaces the shipped rows of that repository.
|
|
30
|
+
// --capabilities adds a host's capability map before the shipped rows (default
|
|
31
|
+
// MIADI_REPOSITORY_CAPABILITIES): the rows `mw-repomap capabilities map
|
|
32
|
+
// <clone>... --out <file>` writes, never a repository's own file. Each capability shows what it achieves,
|
|
26
33
|
// where it stands, its specifications and its issues when someone said them;
|
|
27
34
|
// --stage <stage> lists only those at one stage (specified, prototype,
|
|
28
35
|
// implementation, released, retired, or unstated).
|
|
@@ -37,7 +44,8 @@
|
|
|
37
44
|
// mapping folder); --inventory to MIADI_SESSION_INVENTORY_DIR, else
|
|
38
45
|
// ~/workspace/.mino/session-inventory. Read-only.
|
|
39
46
|
//
|
|
40
|
-
// Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage
|
|
47
|
+
// Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage;
|
|
48
|
+
// `capabilities`: a file or a clone could not be read, 2 usage error.
|
|
41
49
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
42
50
|
if (k2 === undefined) k2 = k;
|
|
43
51
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -81,18 +89,18 @@ const where_1 = require("./where");
|
|
|
81
89
|
const scan_1 = require("./scan");
|
|
82
90
|
const USAGE = [
|
|
83
91
|
"usage: miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
|
|
84
|
-
" miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
|
|
92
|
+
" miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--clone <path>] [--json]",
|
|
85
93
|
" miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]",
|
|
86
|
-
" miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--json]",
|
|
94
|
+
" miadi-repomap capabilities [<owner/name>] [--stage <stage>] [--capabilities <file>] [--clone <path>] [--json]",
|
|
87
95
|
" miadi-repomap scan <clone>... [--ref <ref>] [--repository <owner/name>] [--by <who>] [--packages <file>]",
|
|
88
96
|
" miadi-repomap where [<owner/name>...] [--write <file>] [--json]",
|
|
89
97
|
" miadi-repomap impact <package> [--bump major|minor|patch] [--json]",
|
|
90
98
|
].join("\n");
|
|
91
99
|
const FLAGS = {
|
|
92
100
|
list: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
|
|
93
|
-
show: ["hub", "inventory", "lineage", "capabilities", "hosts", "json"],
|
|
101
|
+
show: ["hub", "inventory", "lineage", "capabilities", "hosts", "clone", "json"],
|
|
94
102
|
lineage: ["lineage", "json"],
|
|
95
|
-
capabilities: ["capabilities", "stage", "json"],
|
|
103
|
+
capabilities: ["capabilities", "stage", "clone", "json"],
|
|
96
104
|
scan: ["ref", "repository", "by", "packages"],
|
|
97
105
|
where: ["write", "json", "hub", "inventory", "by"],
|
|
98
106
|
impact: ["bump", "json"],
|
|
@@ -101,7 +109,8 @@ class UsageError extends Error {
|
|
|
101
109
|
}
|
|
102
110
|
/**
|
|
103
111
|
* One capability as a person reads it: its kind, name, stage and statement,
|
|
104
|
-
* then what it achieves, where it is specified
|
|
112
|
+
* then what it achieves, where it is specified, what tracks it, where it is
|
|
113
|
+
* hosted and how a change reaches it, and the episodes that hold it, each when
|
|
105
114
|
* someone said it.
|
|
106
115
|
*/
|
|
107
116
|
function capabilityLines(c, by = "") {
|
|
@@ -110,6 +119,17 @@ function capabilityLines(c, by = "") {
|
|
|
110
119
|
...(c.achieves ? [` achieves: ${c.achieves.statement} (${c.achieves.statedBy})`] : []),
|
|
111
120
|
...(c.specifications ?? []).map((s) => ` specified in ${s}`),
|
|
112
121
|
...(c.issues?.length ? [` tracked by ${c.issues.join(", ")}`] : []),
|
|
122
|
+
...(c.hosting
|
|
123
|
+
? [
|
|
124
|
+
` hosted${c.hosting.urls?.length ? ` at ${c.hosting.urls.join(", ")}` : ""}, deployed by ${c.hosting.deployedBy} (${c.hosting.statedBy})`,
|
|
125
|
+
...(c.hosting.authoredIn ? [` authored in ${c.hosting.authoredIn}: the copy here is replaced at the next import`] : []),
|
|
126
|
+
...(c.hosting.change ? [` change: ${c.hosting.change}`] : []),
|
|
127
|
+
]
|
|
128
|
+
: []),
|
|
129
|
+
...(c.episodes?.length ? [` held by ${c.episodes.join(", ")}`] : []),
|
|
130
|
+
...(c.commands ?? []).map((command) => ` carries ${command}`),
|
|
131
|
+
...(c.cli ? [` a command of ${c.cli}`] : []),
|
|
132
|
+
...(c.consumers ?? []).map((x) => ` read by ${x.consumer}${x.reads ? `: ${x.reads}` : ""} (${x.statedBy})`),
|
|
113
133
|
];
|
|
114
134
|
}
|
|
115
135
|
function parse(argv) {
|
|
@@ -173,6 +193,8 @@ async function main() {
|
|
|
173
193
|
capabilities: value(flags, "capabilities"),
|
|
174
194
|
hosts: value(flags, "hosts"),
|
|
175
195
|
};
|
|
196
|
+
// `show` reads the repository's clone on this host for what it provides, as `capabilities` does.
|
|
197
|
+
const live = { live: true, ...(value(flags, "clone") ? { clone: value(flags, "clone") } : {}) };
|
|
176
198
|
if (command === "where") {
|
|
177
199
|
const named = positional.slice(1);
|
|
178
200
|
const listing = named.length ? undefined : await (0, read_1.repositoryListing)(options);
|
|
@@ -245,15 +267,28 @@ async function main() {
|
|
|
245
267
|
if (stage !== undefined && stage !== "unstated" && !capabilities_1.CAPABILITY_STAGES.includes(stage)) {
|
|
246
268
|
throw new UsageError(`--stage is one of ${[...capabilities_1.CAPABILITY_STAGES, "unstated"].join(", ")}`);
|
|
247
269
|
}
|
|
248
|
-
const
|
|
270
|
+
const clone = value(flags, "clone");
|
|
271
|
+
if (clone && !positional[1])
|
|
272
|
+
throw new UsageError("--clone names one repository's clone: give the repository, owner/name");
|
|
273
|
+
const answer = await (0, read_1.repositoryCapabilitiesLive)(positional[1], {
|
|
274
|
+
capabilities: options.capabilities,
|
|
275
|
+
...(clone ? { clone } : {}),
|
|
276
|
+
...(stage ? { stage: stage } : {}),
|
|
277
|
+
observedBy: `miadi-repomap capabilities (${os.userInfo().username}@${os.hostname()})`,
|
|
278
|
+
});
|
|
249
279
|
for (const i of answer.issues)
|
|
250
280
|
console.error(`${i.severity} ${i.file ?? ""}${i.line ? `:${i.line}` : ""} — ${i.message}`);
|
|
281
|
+
// A file or a clone that could not be read is not an answer: the command says so with its exit code.
|
|
282
|
+
const failed = answer.issues.some((i) => i.severity === "error") ? 1 : 0;
|
|
251
283
|
if (flags.json) {
|
|
252
284
|
console.log(JSON.stringify(answer, null, 2));
|
|
253
|
-
return
|
|
285
|
+
return failed;
|
|
254
286
|
}
|
|
255
287
|
const subject = answer.repository ? short(answer.repository) : "every repository";
|
|
256
|
-
|
|
288
|
+
if (answer.clone)
|
|
289
|
+
console.error(`read from ${answer.clone.clone} @ ${answer.clone.commit.slice(0, 12)} (${answer.clone.ref}), ${answer.clone.source === "file" ? "its own .miadi/capabilities.jsonl" : "its files: it holds no capability file"}`);
|
|
290
|
+
const more = [answer.counts.command ? `${answer.counts.command} commands` : "", answer.counts.plugin ? `${answer.counts.plugin} plugins` : ""].filter(Boolean);
|
|
291
|
+
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${more.length ? `, ${more.join(", ")}` : ""}`);
|
|
257
292
|
const stated = Object.entries(answer.stages).filter(([k, n]) => k !== "unstated" && n > 0);
|
|
258
293
|
if (stated.length)
|
|
259
294
|
console.log(` stages: ${stated.map(([k, n]) => `${n} ${k}`).join(", ")}, ${answer.stages.unstated} unstated`);
|
|
@@ -264,7 +299,7 @@ async function main() {
|
|
|
264
299
|
if (c.address)
|
|
265
300
|
console.log(` ${c.address}`);
|
|
266
301
|
}
|
|
267
|
-
return
|
|
302
|
+
return failed;
|
|
268
303
|
}
|
|
269
304
|
if (command === "lineage") {
|
|
270
305
|
const answer = (0, read_1.repositoryLineage)(positional[1], { lineage: options.lineage });
|
|
@@ -312,7 +347,7 @@ async function main() {
|
|
|
312
347
|
if (command === "show") {
|
|
313
348
|
if (!positional[1])
|
|
314
349
|
throw new UsageError("show needs a repository: owner/name");
|
|
315
|
-
const detail = await (0, read_1.repositoryDetail)(positional[1], options);
|
|
350
|
+
const detail = await (0, read_1.repositoryDetail)(positional[1], { ...options, ...live });
|
|
316
351
|
if (flags.json) {
|
|
317
352
|
console.log(JSON.stringify(detail, null, 2));
|
|
318
353
|
return detail.repository ? 0 : 1;
|
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, 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";
|
|
13
|
+
export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, readCapabilities, repositoryCapabilities, repositoryCapabilitiesLive, readCloneCapabilities, findRepositoryClone, cloneRoots, isRepositoryCapabilityFile, OWN_FILE_NOT_A_MAP, type CloneReading, 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.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;
|
|
8
|
+
exports.CommitReadError = exports.remoteRepository = exports.changesOnlyVersions = exports.changedCapabilities = exports.capabilitiesOfCommit = exports.findCapability = exports.repositoryImpact = exports.readPackages = exports.readWhere = exports.stageOf = exports.OWN_FILE_NOT_A_MAP = exports.isRepositoryCapabilityFile = exports.cloneRoots = exports.findRepositoryClone = exports.readCloneCapabilities = exports.repositoryCapabilitiesLive = 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,12 @@ 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, "repositoryCapabilitiesLive", { enumerable: true, get: function () { return read_1.repositoryCapabilitiesLive; } });
|
|
84
|
+
Object.defineProperty(exports, "readCloneCapabilities", { enumerable: true, get: function () { return read_1.readCloneCapabilities; } });
|
|
85
|
+
Object.defineProperty(exports, "findRepositoryClone", { enumerable: true, get: function () { return read_1.findRepositoryClone; } });
|
|
86
|
+
Object.defineProperty(exports, "cloneRoots", { enumerable: true, get: function () { return read_1.cloneRoots; } });
|
|
87
|
+
Object.defineProperty(exports, "isRepositoryCapabilityFile", { enumerable: true, get: function () { return read_1.isRepositoryCapabilityFile; } });
|
|
88
|
+
Object.defineProperty(exports, "OWN_FILE_NOT_A_MAP", { enumerable: true, get: function () { return read_1.OWN_FILE_NOT_A_MAP; } });
|
|
83
89
|
Object.defineProperty(exports, "stageOf", { enumerable: true, get: function () { return read_1.stageOf; } });
|
|
84
90
|
Object.defineProperty(exports, "readWhere", { enumerable: true, get: function () { return read_1.readWhere; } });
|
|
85
91
|
Object.defineProperty(exports, "readPackages", { enumerable: true, get: function () { return read_1.readPackages; } });
|
package/dist/read.d.ts
CHANGED
|
@@ -12,14 +12,34 @@ type Env = Record<string, string | undefined>;
|
|
|
12
12
|
export declare function inventoryDir(env?: Env): string;
|
|
13
13
|
/** The hub to read: `MIADI_REPOSITORY_MAPPING_HUB`, a hub clone or its mapping folder. Unset means none. */
|
|
14
14
|
export declare function hubPath(env?: Env): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The folders that hold clones on this host, each as `<root>/<owner>/<name>` or
|
|
17
|
+
* `<root>/<name>`: `MIADI_REPOSITORY_CLONES`, colon-separated. Unset, the
|
|
18
|
+
* folders around the hub clone: `…/repos/jgwill/jgwill` sits beside its owner's
|
|
19
|
+
* other clones, so its parent holds `<name>` and its grandparent `<owner>/<name>`.
|
|
20
|
+
* With no hub either, none: a repository is then read only from a clone a person names.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cloneRoots(env?: Env): string[];
|
|
23
|
+
/**
|
|
24
|
+
* The clone of a repository under the roots: the first folder that is a git
|
|
25
|
+
* repository whose `origin` names it, compared case-folded. A folder of the
|
|
26
|
+
* right name that is a clone of something else is never read as it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findRepositoryClone(repository: string, roots?: readonly string[]): Promise<string | undefined>;
|
|
15
29
|
export interface ReadOptions {
|
|
30
|
+
/** the clone to read one repository's capabilities from, instead of looking for it under {@link cloneRoots} */
|
|
31
|
+
clone?: string;
|
|
32
|
+
/** the folders to look for a repository's clone in; default {@link cloneRoots} */
|
|
33
|
+
clones?: string[];
|
|
34
|
+
/** `repositoryDetail`: read the repository's clone on this host for what it provides. Off by default: it runs git for each file the scan reads. */
|
|
35
|
+
live?: boolean;
|
|
16
36
|
/** hub clone or mapping folder; default {@link hubPath} */
|
|
17
37
|
hub?: string;
|
|
18
38
|
/** inventory directory; default {@link inventoryDir} */
|
|
19
39
|
inventory?: string;
|
|
20
40
|
/** a lineage JSONL read before the shipped one; default `MIADI_REPOSITORY_LINEAGE` */
|
|
21
41
|
lineage?: string;
|
|
22
|
-
/** a capability
|
|
42
|
+
/** a capability map (`mw-repomap capabilities map --out`) read before the shipped rows; default `MIADI_REPOSITORY_CAPABILITIES` */
|
|
23
43
|
capabilities?: string;
|
|
24
44
|
/** a where JSONL (`miadi-repomap where --write`) read before the shipped readings; default `MIADI_REPOSITORY_HOSTS` */
|
|
25
45
|
hosts?: string;
|
|
@@ -59,6 +79,10 @@ export interface CapabilitiesRead {
|
|
|
59
79
|
* capability speaks for it; a later row on the same id is reported and skipped.
|
|
60
80
|
*/
|
|
61
81
|
export declare function readCapabilities(path?: string | undefined): CapabilitiesRead;
|
|
82
|
+
/** What `--capabilities` and `MIADI_REPOSITORY_CAPABILITIES` are told when they are given a repository's own file. */
|
|
83
|
+
export declare const OWN_FILE_NOT_A_MAP = "this is a repository's own .miadi/capabilities.jsonl, not a capability map. A map holds one row per capability and provider, written by \"mw-repomap capabilities map <clone>... --out <file>\". To read one repository from its clone: miadi-repomap capabilities <owner/name> --clone <clone>";
|
|
84
|
+
/** True for the text of a repository's own capability file: its first line is that format's header. */
|
|
85
|
+
export declare function isRepositoryCapabilityFile(text: string): boolean;
|
|
62
86
|
export interface CapabilitiesAnswer {
|
|
63
87
|
from: string[];
|
|
64
88
|
scans: typeof SHIPPED_CAPABILITIES_SCANS;
|
|
@@ -87,6 +111,46 @@ export declare const stageOf: (c: CapabilityFacet) => CapabilityStage | "unstate
|
|
|
87
111
|
export declare function repositoryCapabilities(repository?: string, options?: Pick<ReadOptions, "capabilities"> & {
|
|
88
112
|
stage?: CapabilityStage | "unstated";
|
|
89
113
|
}): CapabilitiesAnswer;
|
|
114
|
+
/** One repository's capabilities as its clone holds them at one commit. */
|
|
115
|
+
export interface CloneReading {
|
|
116
|
+
/** the clone read */
|
|
117
|
+
clone: string;
|
|
118
|
+
/** `repository:<owner>/<name>`, as the clone's origin names it */
|
|
119
|
+
repository: string;
|
|
120
|
+
ref: string;
|
|
121
|
+
commit: string;
|
|
122
|
+
/** `file` when the commit holds the repository's own capability file, `scan` when only its files were read */
|
|
123
|
+
source: "file" | "scan";
|
|
124
|
+
capabilities: CapabilityFacet[];
|
|
125
|
+
issues: MappingIssue[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read one repository from its clone on this host: the clone named, else the
|
|
129
|
+
* one found under {@link cloneRoots}. Its own committed capability file first,
|
|
130
|
+
* merged with what the commit's files say, at its default branch as last
|
|
131
|
+
* fetched. Undefined when this host holds no clone of it. A clone named that
|
|
132
|
+
* is another repository's is an error and is not read.
|
|
133
|
+
*/
|
|
134
|
+
export declare function readCloneCapabilities(repository: string, options?: Pick<ReadOptions, "clone" | "clones"> & {
|
|
135
|
+
ref?: string;
|
|
136
|
+
observedBy?: string;
|
|
137
|
+
}): Promise<CloneReading | {
|
|
138
|
+
clone: string;
|
|
139
|
+
error: string;
|
|
140
|
+
} | undefined>;
|
|
141
|
+
/**
|
|
142
|
+
* "What does this repository provide?", read from its clone on this host when
|
|
143
|
+
* there is one (jgwill/Miadi#1148): a repository that committed its own
|
|
144
|
+
* capability file is shown as that file says, with no map made by hand. With no
|
|
145
|
+
* clone, or no repository, the answer is {@link repositoryCapabilities}'s.
|
|
146
|
+
*/
|
|
147
|
+
export declare function repositoryCapabilitiesLive(repository?: string, options?: Pick<ReadOptions, "capabilities" | "clone" | "clones"> & {
|
|
148
|
+
stage?: CapabilityStage | "unstated";
|
|
149
|
+
ref?: string;
|
|
150
|
+
observedBy?: string;
|
|
151
|
+
}): Promise<CapabilitiesAnswer & {
|
|
152
|
+
clone?: Pick<CloneReading, "clone" | "ref" | "commit" | "source">;
|
|
153
|
+
}>;
|
|
90
154
|
/** A capability beside another one, with the address that opens it. */
|
|
91
155
|
export interface RelatedCapability {
|
|
92
156
|
relation: "consumes" | "consumed-by" | "ships" | "shipped-by";
|