@miadi/relational-git-repository-mapper 0.5.1 → 0.6.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 +33 -3
- package/dist/capabilities.d.ts +2 -102
- package/dist/capabilities.js +20 -248
- package/dist/cli.js +8 -4
- package/dist/commit.d.ts +67 -0
- package/dist/commit.js +209 -0
- package/dist/impact.d.ts +2 -89
- package/dist/impact.js +8 -167
- package/dist/index.d.ts +4 -3
- package/dist/index.js +13 -2
- package/dist/join.d.ts +28 -1
- package/dist/join.js +69 -10
- package/dist/lineage.d.ts +4 -4
- package/dist/read.d.ts +20 -3
- package/dist/read.js +38 -5
- package/dist/scan.d.ts +2 -19
- package/dist/scan.js +7 -80
- package/dist/shipped-capabilities.js +1081 -826
- package/dist/types.d.ts +3 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,8 +18,10 @@ package). The CLI keeps its name, `miadi-repomap`.
|
|
|
18
18
|
it registers. Lifecycle, purpose, git drift, features, relations.
|
|
19
19
|
- **The sessions** come from the witness team's session inventory, read with
|
|
20
20
|
`@miadi/hooks-interpreter` (`readInventoryRecords`): one record per Claude session.
|
|
21
|
-
- **The join**: a record's `repo` (`owner/name`)
|
|
22
|
-
`
|
|
21
|
+
- **The join**: a record's `repo` (`owner/name`) and the repository of each commit its
|
|
22
|
+
`links.trace` names (`owner/name@sha`), case-folded, matched to `repository:<owner>/<name>`.
|
|
23
|
+
A session that committed to two repositories appears under both, with the commits it made
|
|
24
|
+
in each (`commits`). Records that name no repository are counted, not shown.
|
|
23
25
|
|
|
24
26
|
Per session it carries `session_id`, `tmux_session_name`, `status`, the team
|
|
25
27
|
(`team_fit.team.id`, else `team`), `mission`, `date` (as YYYY-MM-DD), the titles of `work_completed`, the
|
|
@@ -82,7 +84,11 @@ miadi-repomap capabilities # every capability, and who
|
|
|
82
84
|
miadi-repomap scan <clone>... --by "<who>" # read a clone's default branch, print JSONL rows
|
|
83
85
|
```
|
|
84
86
|
|
|
85
|
-
`scan`
|
|
87
|
+
`scan` takes a repository's own `.miadi/capabilities.jsonl` first when the commit holds one,
|
|
88
|
+
merged with what the commit's files say. Anyone writes that file with
|
|
89
|
+
`npx @medicine-wheel/developer-repository-mapping capabilities scan --write`, which is where the
|
|
90
|
+
scan now lives, so it runs without the Factory. `scan` reads a repository's default branch
|
|
91
|
+
(`origin/HEAD`) from git objects, never its
|
|
86
92
|
working tree, so a clone on another branch or with edits of its own reads the same. It reads
|
|
87
93
|
the packages the repository declares (`workspaces`, or `pnpm-workspace.yaml`), each
|
|
88
94
|
package's `bin`, and every `SKILL.md` outside `node_modules` and archives. A statement is the
|
|
@@ -100,6 +106,29 @@ In the app: `GET /api/repositories/capabilities[?repository=owner/name]` answers
|
|
|
100
106
|
capabilities and their `provides` edges, `GET /api/repositories/{owner}/{name}` carries them,
|
|
101
107
|
and the repository page's Lineage card lists them by kind.
|
|
102
108
|
|
|
109
|
+
## Which capabilities a commit changed
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { capabilitiesOfCommit } from "@miadi/relational-git-repository-mapper";
|
|
113
|
+
capabilitiesOfCommit("jgwill/Miadi@b746c9a4", "/a/src/Miadi").capabilities.map((c) => c.address);
|
|
114
|
+
// → miadi-capability://jgwill/Miadi/package/@miadi/inquiry-weave, miadi-capability://jgwill/Miadi/package/miadi-project
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Given `owner/name@sha` and a local clone whose `origin` is that repository (GitHub, or a
|
|
118
|
+
host's own git server), it reads the commit against its first parent and answers the
|
|
119
|
+
registry's rows whose defining files changed: for a package any file in its folder (a file
|
|
120
|
+
counts for the deepest package folder that holds it), for a CLI its `bin` entry point (and
|
|
121
|
+
for a `dist/<x>.js` entry its `src/<x>` source), for a skill its `SKILL.md`. A lockfile, and
|
|
122
|
+
a `package.json` whose version or dependency ranges alone moved, define nothing, so a commit
|
|
123
|
+
that changes only those answers `skipped: "versions-only"`. Each answer carries an
|
|
124
|
+
attribution of `@medicine-wheel/capabilities` with revision `pending`, grounded in the commit
|
|
125
|
+
and its files. It never fetches: a clone that does not hold the commit, or whose origin names
|
|
126
|
+
another repository, is refused (`CommitReadError`). `changedCapabilities` is the pure half.
|
|
127
|
+
|
|
128
|
+
A record's `capabilities[]` is read back: `capabilitySessions(address, records)` lists the
|
|
129
|
+
sessions whose record names a capability, and `findCapability(parts, { sessions: true })`
|
|
130
|
+
carries them. The app's `/api/repositories/capability` answers them to the write tier only.
|
|
131
|
+
|
|
103
132
|
## Where a repository lives
|
|
104
133
|
|
|
105
134
|
A name like `jgwill/episodes` does not say where the repository is. `miadi-repomap where`
|
|
@@ -139,6 +168,7 @@ name them (`miadi-chronicle://<number>`), linked to the chronicle page.
|
|
|
139
168
|
| `MIADI_REPOSITORY_LINEAGE` | none | a lineage JSONL read before the shipped rows |
|
|
140
169
|
| `MIADI_REPOSITORY_CAPABILITIES` | none | a capability JSONL read before the shipped rows |
|
|
141
170
|
| `MIADI_REPOSITORY_HOSTS` | none | a where JSONL (`where --write`) read before the shipped readings |
|
|
171
|
+
| `MIADI_REPOSITORY_PACKAGES` | none | a package readings JSONL (`mw-repomap capabilities map --packages`) read before the shipped ones |
|
|
142
172
|
| `MIADI_HOST_GIT_ROOTS` | `/srv/git` | where `where` looks for bare repositories, colon-separated |
|
|
143
173
|
|
|
144
174
|
## CLI
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -1,102 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type CapabilityKind
|
|
3
|
-
export declare const CAPABILITY_KINDS: readonly CapabilityKind[];
|
|
4
|
-
/** `capability:<kind>-<slug>`: `@miadi/inquiry-weave` → `capability:package-miadi-inquiry-weave`. */
|
|
5
|
-
export declare function capabilityId(kind: CapabilityKind, name: string): string;
|
|
6
|
-
/** The kind a capability id names, or undefined for a capability no scan wrote. */
|
|
7
|
-
export declare function kindOf(nodeId: string): CapabilityKind | undefined;
|
|
8
|
-
/** One thing a repository's files say it provides. */
|
|
9
|
-
export interface Artefact {
|
|
10
|
-
kind: CapabilityKind;
|
|
11
|
-
name: string;
|
|
12
|
-
/** what the files say it is, uncut */
|
|
13
|
-
description?: string;
|
|
14
|
-
/** the file that says so, relative to the repository */
|
|
15
|
-
path: string;
|
|
16
|
-
}
|
|
17
|
-
/** The fields of a package.json the scan reads. Never throws: an unreadable manifest has no name. */
|
|
18
|
-
export declare function parsePackageJson(text: string): {
|
|
19
|
-
name?: string;
|
|
20
|
-
version?: string;
|
|
21
|
-
description?: string;
|
|
22
|
-
bins: string[];
|
|
23
|
-
/** runtime dependencies (dependencies, peerDependencies, optionalDependencies): name → range */
|
|
24
|
-
dependsOn: Record<string, string>;
|
|
25
|
-
};
|
|
26
|
-
/** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
|
|
27
|
-
export declare function parseSkillFrontMatter(text: string): {
|
|
28
|
-
name?: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* The folders a repository declares as its packages: `workspaces` of the root
|
|
33
|
-
* package.json (an array, or `{ packages }`), else the `packages:` list of
|
|
34
|
-
* pnpm-workspace.yaml. `.` is the root. Only `dir` and `dir/*` are expanded.
|
|
35
|
-
*/
|
|
36
|
-
export declare function workspaceGlobs(rootPackageJson?: string, pnpmWorkspace?: string): string[];
|
|
37
|
-
/** The package.json paths of a repository's declared packages, among the files it holds. */
|
|
38
|
-
export declare function packageManifests(globs: readonly string[], files: readonly string[]): string[];
|
|
39
|
-
/** The SKILL.md files a repository holds, outside dependencies and archives. */
|
|
40
|
-
/**
|
|
41
|
-
* The address a person cites a capability by, in an episode, an issue, an
|
|
42
|
-
* inquiry, a ceremony diary or a circle turn (Episode 568's Capability
|
|
43
|
-
* Registry, the scheme decided by William on 2026-11-01), for the repository
|
|
44
|
-
* that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
|
|
45
|
-
*/
|
|
46
|
-
export declare function capabilityAddress(repository: string, kind: CapabilityKind, name: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* A capability a repository defines in code rather than in a file of its own,
|
|
49
|
-
* read by a reader written for that repository and that file, never guessed
|
|
50
|
-
* from a name (Episode 568, P15). `read` gets the file's text at the scanned
|
|
51
|
-
* commit and answers what it defines.
|
|
52
|
-
*/
|
|
53
|
-
export interface CodeReader {
|
|
54
|
-
/** `repository:<owner>/<name>`, compared case-folded */
|
|
55
|
-
repository: string;
|
|
56
|
-
path: string;
|
|
57
|
-
read(text: string): Artefact[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The medicine wheel's skills: `cli/skills.ts` defines each one as a
|
|
61
|
-
* `{ name, title, description, target, … }` record, and `mw skill install` /
|
|
62
|
-
* `mwsrv skill install` write it out as a SKILL.md. The statement is the
|
|
63
|
-
* record's own description.
|
|
64
|
-
*/
|
|
65
|
-
export declare function medicineWheelSkills(text: string): Artefact[];
|
|
66
|
-
/** The readers written so far, one per repository file that defines capabilities in code. */
|
|
67
|
-
export declare const CODE_READERS: readonly CodeReader[];
|
|
68
|
-
export declare function skillFiles(files: readonly string[]): string[];
|
|
69
|
-
export interface CapabilityRowContext {
|
|
70
|
-
/** `repository:<owner>/<name>` */
|
|
71
|
-
repository: string;
|
|
72
|
-
/** the commit the files were read at */
|
|
73
|
-
commit: string;
|
|
74
|
-
observedBy: string;
|
|
75
|
-
/** ISO 8601 */
|
|
76
|
-
observedAt: string;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Capability rows for one repository. One row per id: two files naming the
|
|
80
|
-
* same skill are one capability with both files as its grounding.
|
|
81
|
-
*/
|
|
82
|
-
export declare function capabilityRows(artefacts: readonly Artefact[], ctx: CapabilityRowContext): CapabilityFacet[];
|
|
83
|
-
/**
|
|
84
|
-
* Rows from several repositories as one inventory: a capability two
|
|
85
|
-
* repositories provide is one row that both provide, with both files as its
|
|
86
|
-
* grounding. The first row read keeps its name and statement.
|
|
87
|
-
*/
|
|
88
|
-
export declare function mergeCapabilityRows(rows: readonly CapabilityFacet[]): CapabilityFacet[];
|
|
89
|
-
/** One `provides` edge: a repository provides a capability, said by whoever said the capability. */
|
|
90
|
-
export interface ProvidesEdge {
|
|
91
|
-
from: string;
|
|
92
|
-
to: string;
|
|
93
|
-
type: "provides";
|
|
94
|
-
statedBy: string;
|
|
95
|
-
statedAt: string;
|
|
96
|
-
grounding: string[];
|
|
97
|
-
revision: CapabilityFacet["revision"];
|
|
98
|
-
}
|
|
99
|
-
/** The `provides` edges a set of capability rows holds, one per provider. */
|
|
100
|
-
export declare function providesEdges(capabilities: readonly CapabilityFacet[]): ProvidesEdge[];
|
|
101
|
-
/** The capabilities a repository provides, matched case-folded, by kind then id. */
|
|
102
|
-
export declare function capabilitiesOf(repository: string, capabilities: readonly CapabilityFacet[]): CapabilityFacet[];
|
|
1
|
+
export { CAPABILITY_KINDS, CODE_READERS, capabilitiesOf, capabilityAddress, capabilityId, capabilityRows, kindOf, medicineWheelSkills, mergeCapabilityRows, packageManifests, parsePackageJson, parseSkillFrontMatter, providesEdges, skillFiles, workspaceGlobs, } from "@medicine-wheel/developer-repository-mapping";
|
|
2
|
+
export type { Artefact, CapabilityKind, CapabilityRowContext, CodeReader, ProvidesEdge } from "@medicine-wheel/developer-repository-mapping";
|
package/dist/capabilities.js
CHANGED
|
@@ -1,250 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// repository `provides` each one. A row states what the files say, never what
|
|
6
|
-
// a model guesses: a description over 55 words is not cut, the row is
|
|
7
|
-
// `needs-resolution` without a statement. Every row is pending until a person
|
|
8
|
-
// reads it.
|
|
9
|
-
// Lane K7c (William, review d04556fd: "inventory and organize capabilities,
|
|
10
|
-
// repositories and recently missions related sessions").
|
|
2
|
+
// The capability scan's pure half lives in @medicine-wheel/developer-repository-mapping
|
|
3
|
+
// (P20), so anyone can run it without the Factory. Re-exported here so this
|
|
4
|
+
// package's surface stays what it was.
|
|
11
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CODE_READERS = exports.CAPABILITY_KINDS = void 0;
|
|
13
|
-
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
|
|
27
|
-
exports
|
|
28
|
-
|
|
29
|
-
.toLowerCase()
|
|
30
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
31
|
-
.replace(/^-+|-+$/g, "");
|
|
32
|
-
/** `capability:<kind>-<slug>`: `@miadi/inquiry-weave` → `capability:package-miadi-inquiry-weave`. */
|
|
33
|
-
function capabilityId(kind, name) {
|
|
34
|
-
return `capability:${kind}-${slug(name)}`;
|
|
35
|
-
}
|
|
36
|
-
/** The kind a capability id names, or undefined for a capability no scan wrote. */
|
|
37
|
-
function kindOf(nodeId) {
|
|
38
|
-
const m = /^capability:(package|cli|skill)-/.exec(nodeId);
|
|
39
|
-
return m ? m[1] : undefined;
|
|
40
|
-
}
|
|
41
|
-
/** The fields of a package.json the scan reads. Never throws: an unreadable manifest has no name. */
|
|
42
|
-
function parsePackageJson(text) {
|
|
43
|
-
try {
|
|
44
|
-
const p = JSON.parse(text);
|
|
45
|
-
const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
|
|
46
|
-
const name = str(p.name);
|
|
47
|
-
const version = str(p.version);
|
|
48
|
-
const description = str(p.description);
|
|
49
|
-
let bins = [];
|
|
50
|
-
if (typeof p.bin === "string" && name)
|
|
51
|
-
bins = [name.replace(/^@[^/]+\//, "")];
|
|
52
|
-
else if (p.bin && typeof p.bin === "object")
|
|
53
|
-
bins = Object.keys(p.bin);
|
|
54
|
-
const dependsOn = {};
|
|
55
|
-
for (const key of ["optionalDependencies", "peerDependencies", "dependencies"]) {
|
|
56
|
-
const deps = p[key];
|
|
57
|
-
if (deps && typeof deps === "object") {
|
|
58
|
-
for (const [dep, range] of Object.entries(deps))
|
|
59
|
-
if (typeof range === "string")
|
|
60
|
-
dependsOn[dep] = range;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { ...(name ? { name } : {}), ...(version ? { version } : {}), ...(description ? { description } : {}), bins, dependsOn };
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return { bins: [], dependsOn: {} };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
|
|
70
|
-
function parseSkillFrontMatter(text) {
|
|
71
|
-
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
72
|
-
if (!m)
|
|
73
|
-
return {};
|
|
74
|
-
const lines = m[1].split(/\r?\n/);
|
|
75
|
-
const field = (key) => {
|
|
76
|
-
const i = lines.findIndex((l) => new RegExp(`^${key}:`).test(l));
|
|
77
|
-
if (i < 0)
|
|
78
|
-
return undefined;
|
|
79
|
-
let value = lines[i].slice(key.length + 1).trim();
|
|
80
|
-
if (/^[>|][+-]?$/.test(value)) {
|
|
81
|
-
const folded = [];
|
|
82
|
-
for (const l of lines.slice(i + 1)) {
|
|
83
|
-
if (/^\S/.test(l))
|
|
84
|
-
break;
|
|
85
|
-
folded.push(l.trim());
|
|
86
|
-
}
|
|
87
|
-
value = folded.join(" ").trim();
|
|
88
|
-
}
|
|
89
|
-
value = value.replace(/^(["'])([\s\S]*)\1$/, "$2").trim();
|
|
90
|
-
return value || undefined;
|
|
91
|
-
};
|
|
92
|
-
const name = field("name");
|
|
93
|
-
const description = field("description");
|
|
94
|
-
return { ...(name ? { name } : {}), ...(description ? { description } : {}) };
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The folders a repository declares as its packages: `workspaces` of the root
|
|
98
|
-
* package.json (an array, or `{ packages }`), else the `packages:` list of
|
|
99
|
-
* pnpm-workspace.yaml. `.` is the root. Only `dir` and `dir/*` are expanded.
|
|
100
|
-
*/
|
|
101
|
-
function workspaceGlobs(rootPackageJson, pnpmWorkspace) {
|
|
102
|
-
try {
|
|
103
|
-
const root = rootPackageJson ? JSON.parse(rootPackageJson) : {};
|
|
104
|
-
const w = root.workspaces;
|
|
105
|
-
const list = Array.isArray(w) ? w : w && typeof w === "object" ? w.packages : undefined;
|
|
106
|
-
if (Array.isArray(list) && list.length)
|
|
107
|
-
return [".", ...list.filter((x) => typeof x === "string")];
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
// an unreadable root manifest declares nothing
|
|
111
|
-
}
|
|
112
|
-
if (pnpmWorkspace) {
|
|
113
|
-
const block = /(^|\n)packages:\s*\n((?:[ \t]+-[^\n]*\n?)+)/.exec(pnpmWorkspace);
|
|
114
|
-
if (block) {
|
|
115
|
-
return block[2]
|
|
116
|
-
.split("\n")
|
|
117
|
-
.map((l) => l.replace(/^[ \t]+-\s*/, "").replace(/\s+#.*$/, "").replace(/^['"]|['"]$/g, "").trim())
|
|
118
|
-
.filter(Boolean);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return ["."];
|
|
122
|
-
}
|
|
123
|
-
/** The package.json paths of a repository's declared packages, among the files it holds. */
|
|
124
|
-
function packageManifests(globs, files) {
|
|
125
|
-
const manifests = new Set();
|
|
126
|
-
const held = new Set(files);
|
|
127
|
-
for (const glob of globs) {
|
|
128
|
-
const dir = glob.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
129
|
-
if (dir === "." || dir === "") {
|
|
130
|
-
if (held.has("package.json"))
|
|
131
|
-
manifests.add("package.json");
|
|
132
|
-
}
|
|
133
|
-
else if (dir.endsWith("/*")) {
|
|
134
|
-
const base = `${dir.slice(0, -2)}/`;
|
|
135
|
-
for (const f of files) {
|
|
136
|
-
const rest = f.startsWith(base) ? f.slice(base.length) : "";
|
|
137
|
-
if (/^[^/]+\/package\.json$/.test(rest))
|
|
138
|
-
manifests.add(f);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else if (held.has(`${dir}/package.json`)) {
|
|
142
|
-
manifests.add(`${dir}/package.json`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return [...manifests].sort();
|
|
146
|
-
}
|
|
147
|
-
/** The SKILL.md files a repository holds, outside dependencies and archives. */
|
|
148
|
-
/**
|
|
149
|
-
* The address a person cites a capability by, in an episode, an issue, an
|
|
150
|
-
* inquiry, a ceremony diary or a circle turn (Episode 568's Capability
|
|
151
|
-
* Registry, the scheme decided by William on 2026-11-01), for the repository
|
|
152
|
-
* that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
|
|
153
|
-
*/
|
|
154
|
-
function capabilityAddress(repository, kind, name) {
|
|
155
|
-
return `miadi-capability://${repository.replace(/^repository:/, "")}/${kind}/${name}`;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* The medicine wheel's skills: `cli/skills.ts` defines each one as a
|
|
159
|
-
* `{ name, title, description, target, … }` record, and `mw skill install` /
|
|
160
|
-
* `mwsrv skill install` write it out as a SKILL.md. The statement is the
|
|
161
|
-
* record's own description.
|
|
162
|
-
*/
|
|
163
|
-
function medicineWheelSkills(text) {
|
|
164
|
-
const out = [];
|
|
165
|
-
const re = /\{\s*name:\s*'([a-z0-9][a-z0-9-]*)',\s*title:\s*'(?:[^'\\\n]|\\.)*',\s*description:\s*'((?:[^'\\\n]|\\.)*)',\s*target:\s*'(?:cli|srv)'/g;
|
|
166
|
-
for (const m of text.matchAll(re)) {
|
|
167
|
-
out.push({ kind: "skill", name: m[1], description: m[2].replace(/\\(.)/g, "$1"), path: "cli/skills.ts" });
|
|
168
|
-
}
|
|
169
|
-
return out;
|
|
170
|
-
}
|
|
171
|
-
/** The readers written so far, one per repository file that defines capabilities in code. */
|
|
172
|
-
exports.CODE_READERS = [
|
|
173
|
-
{ repository: "repository:jgwill/medicine-wheel", path: "cli/skills.ts", read: medicineWheelSkills },
|
|
174
|
-
];
|
|
175
|
-
function skillFiles(files) {
|
|
176
|
-
return files
|
|
177
|
-
.filter((f) => /(^|\/)SKILL\.md$/.test(f))
|
|
178
|
-
.filter((f) => !/(^|\/)(node_modules|archives?|archived-[^/]*|dist|\.next)\//.test(f))
|
|
179
|
-
.sort();
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Capability rows for one repository. One row per id: two files naming the
|
|
183
|
-
* same skill are one capability with both files as its grounding.
|
|
184
|
-
*/
|
|
185
|
-
function capabilityRows(artefacts, ctx) {
|
|
186
|
-
const where = `${ctx.repository.replace(/^repository:/, "")}@${ctx.commit.slice(0, 12)}`;
|
|
187
|
-
const rows = new Map();
|
|
188
|
-
for (const a of artefacts) {
|
|
189
|
-
const nodeId = capabilityId(a.kind, a.name);
|
|
190
|
-
const grounding = `${where}:${a.path}`;
|
|
191
|
-
const existing = rows.get(nodeId);
|
|
192
|
-
if (existing) {
|
|
193
|
-
if (!existing.grounding.includes(grounding))
|
|
194
|
-
existing.grounding.push(grounding);
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
const fits = a.description ? (0, capabilities_1.checkStatement)(a.description).fits : false;
|
|
198
|
-
rows.set(nodeId, {
|
|
199
|
-
nodeId,
|
|
200
|
-
name: a.name,
|
|
201
|
-
...(fits ? { statement: a.description } : {}),
|
|
202
|
-
status: fits ? "clear" : "needs-resolution",
|
|
203
|
-
providedBy: [ctx.repository],
|
|
204
|
-
statedBy: ctx.observedBy,
|
|
205
|
-
statedAt: ctx.observedAt,
|
|
206
|
-
grounding: [grounding],
|
|
207
|
-
revision: "pending",
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return [...rows.values()];
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Rows from several repositories as one inventory: a capability two
|
|
214
|
-
* repositories provide is one row that both provide, with both files as its
|
|
215
|
-
* grounding. The first row read keeps its name and statement.
|
|
216
|
-
*/
|
|
217
|
-
function mergeCapabilityRows(rows) {
|
|
218
|
-
const merged = new Map();
|
|
219
|
-
for (const row of rows) {
|
|
220
|
-
const existing = merged.get(row.nodeId);
|
|
221
|
-
if (!existing) {
|
|
222
|
-
merged.set(row.nodeId, { ...row, providedBy: [...row.providedBy], grounding: [...row.grounding] });
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
for (const p of row.providedBy)
|
|
226
|
-
if (!existing.providedBy.includes(p))
|
|
227
|
-
existing.providedBy.push(p);
|
|
228
|
-
for (const g of row.grounding)
|
|
229
|
-
if (!existing.grounding.includes(g))
|
|
230
|
-
existing.grounding.push(g);
|
|
231
|
-
}
|
|
232
|
-
return [...merged.values()].sort((a, b) => (a.nodeId < b.nodeId ? -1 : a.nodeId > b.nodeId ? 1 : 0));
|
|
233
|
-
}
|
|
234
|
-
/** The `provides` edges a set of capability rows holds, one per provider. */
|
|
235
|
-
function providesEdges(capabilities) {
|
|
236
|
-
return capabilities.flatMap((c) => c.providedBy.map((from) => ({
|
|
237
|
-
from,
|
|
238
|
-
to: c.nodeId,
|
|
239
|
-
type: "provides",
|
|
240
|
-
statedBy: c.statedBy,
|
|
241
|
-
statedAt: c.statedAt,
|
|
242
|
-
grounding: c.grounding,
|
|
243
|
-
revision: c.revision,
|
|
244
|
-
})));
|
|
245
|
-
}
|
|
246
|
-
/** The capabilities a repository provides, matched case-folded, by kind then id. */
|
|
247
|
-
function capabilitiesOf(repository, capabilities) {
|
|
248
|
-
const id = (repository.startsWith("repository:") ? repository : `repository:${repository}`).toLowerCase();
|
|
249
|
-
return capabilities.filter((c) => c.providedBy.some((p) => p.toLowerCase() === id));
|
|
250
|
-
}
|
|
6
|
+
exports.workspaceGlobs = exports.skillFiles = exports.providesEdges = exports.parseSkillFrontMatter = exports.parsePackageJson = exports.packageManifests = exports.mergeCapabilityRows = exports.medicineWheelSkills = exports.kindOf = exports.capabilityRows = exports.capabilityId = exports.capabilityAddress = exports.capabilitiesOf = exports.CODE_READERS = exports.CAPABILITY_KINDS = void 0;
|
|
7
|
+
var developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
|
|
8
|
+
Object.defineProperty(exports, "CAPABILITY_KINDS", { enumerable: true, get: function () { return developer_repository_mapping_1.CAPABILITY_KINDS; } });
|
|
9
|
+
Object.defineProperty(exports, "CODE_READERS", { enumerable: true, get: function () { return developer_repository_mapping_1.CODE_READERS; } });
|
|
10
|
+
Object.defineProperty(exports, "capabilitiesOf", { enumerable: true, get: function () { return developer_repository_mapping_1.capabilitiesOf; } });
|
|
11
|
+
Object.defineProperty(exports, "capabilityAddress", { enumerable: true, get: function () { return developer_repository_mapping_1.capabilityAddress; } });
|
|
12
|
+
Object.defineProperty(exports, "capabilityId", { enumerable: true, get: function () { return developer_repository_mapping_1.capabilityId; } });
|
|
13
|
+
Object.defineProperty(exports, "capabilityRows", { enumerable: true, get: function () { return developer_repository_mapping_1.capabilityRows; } });
|
|
14
|
+
Object.defineProperty(exports, "kindOf", { enumerable: true, get: function () { return developer_repository_mapping_1.kindOf; } });
|
|
15
|
+
Object.defineProperty(exports, "medicineWheelSkills", { enumerable: true, get: function () { return developer_repository_mapping_1.medicineWheelSkills; } });
|
|
16
|
+
Object.defineProperty(exports, "mergeCapabilityRows", { enumerable: true, get: function () { return developer_repository_mapping_1.mergeCapabilityRows; } });
|
|
17
|
+
Object.defineProperty(exports, "packageManifests", { enumerable: true, get: function () { return developer_repository_mapping_1.packageManifests; } });
|
|
18
|
+
Object.defineProperty(exports, "parsePackageJson", { enumerable: true, get: function () { return developer_repository_mapping_1.parsePackageJson; } });
|
|
19
|
+
Object.defineProperty(exports, "parseSkillFrontMatter", { enumerable: true, get: function () { return developer_repository_mapping_1.parseSkillFrontMatter; } });
|
|
20
|
+
Object.defineProperty(exports, "providesEdges", { enumerable: true, get: function () { return developer_repository_mapping_1.providesEdges; } });
|
|
21
|
+
Object.defineProperty(exports, "skillFiles", { enumerable: true, get: function () { return developer_repository_mapping_1.skillFiles; } });
|
|
22
|
+
Object.defineProperty(exports, "workspaceGlobs", { enumerable: true, get: function () { return developer_repository_mapping_1.workspaceGlobs; } });
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
//
|
|
19
19
|
// `capabilities <owner/name>` answers what a repository provides: its
|
|
20
20
|
// packages, CLIs and skills as capability nodes, each with a `provides` edge.
|
|
21
|
-
// `scan` reads a clone's default branch from git objects
|
|
21
|
+
// `scan` reads a clone's default branch from git objects, its own
|
|
22
|
+
// .miadi/capabilities.jsonl first when it holds one (never its working
|
|
22
23
|
// tree) and prints those rows as JSONL, pending until a person reads them.
|
|
23
24
|
// --capabilities adds a host's JSONL before the shipped rows (default
|
|
24
25
|
// MIADI_REPOSITORY_CAPABILITIES).
|
|
@@ -138,7 +139,8 @@ function linkLines(links) {
|
|
|
138
139
|
}
|
|
139
140
|
function sessionLine(s) {
|
|
140
141
|
const ending = s.disposition ? ` ending ${s.disposition.decided ?? `${s.disposition.proposed} (proposed)`}` : "";
|
|
141
|
-
|
|
142
|
+
const commits = s.commits?.length ? ` commits ${s.commits.join(" ")}` : "";
|
|
143
|
+
return ` ${s.date ?? "?"} ${(s.tmux_session_name ?? s.session_id).padEnd(36)} ${(s.team ?? "-").padEnd(10)} ${s.status ?? "-"}${ending} ${s.session_id}${commits}`;
|
|
142
144
|
}
|
|
143
145
|
async function main() {
|
|
144
146
|
const { positional, flags } = parse(process.argv.slice(2));
|
|
@@ -207,8 +209,10 @@ async function main() {
|
|
|
207
209
|
const rows = [];
|
|
208
210
|
const packages = [];
|
|
209
211
|
for (const clone of clones) {
|
|
210
|
-
const result = await (0, scan_1.
|
|
211
|
-
|
|
212
|
+
const result = await (0, scan_1.readRepositoryCapabilities)(clone, { ref: value(flags, "ref"), repository: value(flags, "repository"), observedBy });
|
|
213
|
+
for (const i of result.issues)
|
|
214
|
+
console.error(`${i.severity} ${result.repository.replace(/^repository:/, "")} ${i.file ?? ""}${i.line ? `:${i.line}` : ""} — ${i.message}`);
|
|
215
|
+
console.error(`${result.repository.replace(/^repository:/, "")} @ ${result.commit.slice(0, 12)} (${result.ref}): ${result.capabilities.length} capabilities, from ${result.source === "file" ? "its own .miadi/capabilities.jsonl" : "its files"}`);
|
|
212
216
|
rows.push(...result.capabilities);
|
|
213
217
|
packages.push(...result.packages);
|
|
214
218
|
}
|
package/dist/commit.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Attribution, CapabilityFacet } from "@medicine-wheel/capabilities";
|
|
2
|
+
import { type CapabilityKind } from "./capabilities";
|
|
3
|
+
export interface CommitCapability {
|
|
4
|
+
/** `miadi-capability://<owner>/<repo>/<kind>/<name>` */
|
|
5
|
+
address: string;
|
|
6
|
+
nodeId: string;
|
|
7
|
+
kind: CapabilityKind;
|
|
8
|
+
name: string;
|
|
9
|
+
/** the files of the commit that define it */
|
|
10
|
+
files: string[];
|
|
11
|
+
/** the commit and its files; `revision` is `pending` until a person reads it */
|
|
12
|
+
attribution: Attribution;
|
|
13
|
+
}
|
|
14
|
+
export interface CommitCapabilities {
|
|
15
|
+
/** `owner/name@sha`, as asked */
|
|
16
|
+
commit: string;
|
|
17
|
+
/** `repository:<owner>/<name>`, spelled as the registry rows spell it when one does */
|
|
18
|
+
repository: string;
|
|
19
|
+
/** the full sha */
|
|
20
|
+
sha: string;
|
|
21
|
+
/** every file the commit changed against its first parent */
|
|
22
|
+
files: string[];
|
|
23
|
+
/** `versions-only`: every file changed is a lockfile or a package.json whose version or dependency ranges alone moved */
|
|
24
|
+
skipped?: "versions-only";
|
|
25
|
+
capabilities: CommitCapability[];
|
|
26
|
+
}
|
|
27
|
+
export type CommitReadFailure = "not-a-commit-ref" | "clone-not-of-repository" | "commit-not-in-clone";
|
|
28
|
+
export declare class CommitReadError extends Error {
|
|
29
|
+
readonly code: CommitReadFailure;
|
|
30
|
+
constructor(code: CommitReadFailure, message: string);
|
|
31
|
+
}
|
|
32
|
+
/** A package.json whose change, before to after, is only its version and the ranges of the dependencies it already had. */
|
|
33
|
+
export declare function changesOnlyVersions(before: string | undefined, after: string | undefined): boolean;
|
|
34
|
+
export interface ChangedCapabilitiesInput {
|
|
35
|
+
/** `repository:<owner>/<name>` */
|
|
36
|
+
repository: string;
|
|
37
|
+
/** `owner/name@sha`, used in each attribution's grounding */
|
|
38
|
+
commit: string;
|
|
39
|
+
/** the files the commit changed */
|
|
40
|
+
files: readonly string[];
|
|
41
|
+
/** a file's text at the commit (`after`) or at its first parent (`before`); undefined when it is not there */
|
|
42
|
+
read: (path: string, at: "before" | "after") => string | undefined;
|
|
43
|
+
/** the registry's rows */
|
|
44
|
+
rows: readonly CapabilityFacet[];
|
|
45
|
+
/** who states the attributions; default this package */
|
|
46
|
+
by?: string;
|
|
47
|
+
/** when; default now */
|
|
48
|
+
at?: string;
|
|
49
|
+
}
|
|
50
|
+
/** The pure half: which of the repository's rows the changed files define. */
|
|
51
|
+
export declare function changedCapabilities(input: ChangedCapabilitiesInput): Pick<CommitCapabilities, "capabilities" | "skipped">;
|
|
52
|
+
/** `owner/name` of a remote URL: GitHub's, else the last two segments of the path (a host's own git server). */
|
|
53
|
+
export declare function remoteRepository(url: string): string | undefined;
|
|
54
|
+
export interface CommitCapabilitiesOptions {
|
|
55
|
+
/** the registry's rows; default {@link readCapabilities} (a host's JSONL, then the shipped scan) */
|
|
56
|
+
rows?: readonly CapabilityFacet[];
|
|
57
|
+
by?: string;
|
|
58
|
+
at?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The capability rows `owner/name@sha` changed, read from a local clone whose
|
|
62
|
+
* `origin` is that repository. Read-only: `git remote get-url`, `rev-parse`,
|
|
63
|
+
* `diff`, `show`. Never fetches. Throws {@link CommitReadError} when the ref is
|
|
64
|
+
* not a commit ref, the clone's origin names another repository, or the clone
|
|
65
|
+
* does not hold the commit.
|
|
66
|
+
*/
|
|
67
|
+
export declare function capabilitiesOfCommit(ref: string, clone: string, options?: CommitCapabilitiesOptions): CommitCapabilities;
|