@miadi/relational-git-repository-mapper 0.7.2 → 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 CHANGED
@@ -96,6 +96,21 @@ the scan carries them, `capabilities` and `show` print them, and `--stage <stage
96
96
  `unstated`) lists the capabilities at one stage. A capability at stage `specified` is read
97
97
  even before any code provides it.
98
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
+
99
114
  `scan` takes a repository's own `.miadi/capabilities.jsonl` first when the commit holds one,
100
115
  merged with what the commit's files say. Anyone writes that file with
101
116
  `npx @medicine-wheel/developer-repository-mapping capabilities scan --write`, which is where the
@@ -132,8 +147,8 @@ capabilitiesOfCommit("jgwill/Miadi@b746c9a4", "/a/src/Miadi").capabilities.map((
132
147
 
133
148
  Given `owner/name@sha` and a local clone whose `origin` is that repository (GitHub, or a
134
149
  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 (a file
136
- 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
137
152
  for a `dist/<x>.js` entry its `src/<x>` source), for a skill its `SKILL.md`. A lockfile, and
138
153
  a `package.json` whose version or dependency ranges alone moved, define nothing, so a commit
139
154
  that changes only those answers `skipped: "versions-only"`. Each answer carries an
package/dist/cli.js CHANGED
@@ -101,7 +101,8 @@ class UsageError extends Error {
101
101
  }
102
102
  /**
103
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
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
105
106
  * someone said it.
106
107
  */
107
108
  function capabilityLines(c, by = "") {
@@ -110,6 +111,14 @@ function capabilityLines(c, by = "") {
110
111
  ...(c.achieves ? [` achieves: ${c.achieves.statement} (${c.achieves.statedBy})`] : []),
111
112
  ...(c.specifications ?? []).map((s) => ` specified in ${s}`),
112
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(", ")}`] : []),
113
122
  ];
114
123
  }
115
124
  function parse(argv) {
@@ -253,7 +262,7 @@ async function main() {
253
262
  return 0;
254
263
  }
255
264
  const subject = answer.repository ? short(answer.repository) : "every repository";
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`);
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`);
257
266
  const stated = Object.entries(answer.stages).filter(([k, n]) => k !== "unstated" && n > 0);
258
267
  if (stated.length)
259
268
  console.log(` stages: ${stated.map(([k, n]) => `${n} ${k}`).join(", ")}, ${answer.stages.unstated} unstated`);
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 file in
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, "package", file);
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;