@medicine-wheel/developer-repository-mapping 0.27.9 → 0.27.11

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.
@@ -0,0 +1,98 @@
1
+ import { z } from "zod";
2
+ export declare const PackageReadingSchema: z.ZodObject<{
3
+ /** `capability:package-…` */
4
+ capability: z.ZodString;
5
+ name: z.ZodString;
6
+ version: z.ZodOptional<z.ZodString>;
7
+ repository: z.ZodString;
8
+ path: z.ZodString;
9
+ commit: z.ZodString;
10
+ /** runtime dependencies as declared (dependencies, peer, optional): name → range */
11
+ dependsOn: z.ZodRecord<z.ZodString, z.ZodString>;
12
+ /** the commands this package ships */
13
+ bins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
14
+ /** never published: read for what consumes what, not listed as a capability */
15
+ private: z.ZodOptional<z.ZodBoolean>;
16
+ }, "strict", z.ZodTypeAny, {
17
+ name: string;
18
+ path: string;
19
+ repository: string;
20
+ capability: string;
21
+ commit: string;
22
+ dependsOn: Record<string, string>;
23
+ version?: string | undefined;
24
+ private?: boolean | undefined;
25
+ bins?: string[] | undefined;
26
+ }, {
27
+ name: string;
28
+ path: string;
29
+ repository: string;
30
+ capability: string;
31
+ commit: string;
32
+ dependsOn: Record<string, string>;
33
+ version?: string | undefined;
34
+ private?: boolean | undefined;
35
+ bins?: string[] | undefined;
36
+ }>;
37
+ export type PackageReading = z.infer<typeof PackageReadingSchema>;
38
+ export interface ConsumesEdge {
39
+ /** the consuming package's capability */
40
+ from: string;
41
+ /** the consumed package's capability */
42
+ to: string;
43
+ type: "consumes";
44
+ fromName: string;
45
+ toName: string;
46
+ /** the range `from` declares on `to` */
47
+ range: string;
48
+ }
49
+ /** `consumes` edges between the packages read, first-party only. */
50
+ export declare function consumesEdges(packages: readonly PackageReading[]): ConsumesEdge[];
51
+ export type BumpLevel = "major" | "minor" | "patch";
52
+ export declare function bumpVersion(version: string, level: BumpLevel): string | undefined;
53
+ /**
54
+ * Whether `version` satisfies `range`, for the forms first-party manifests
55
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
56
+ * forms, read as pnpm publishes them against `published` (the consumed
57
+ * package's version when the consumer was released). Undefined for anything
58
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
59
+ */
60
+ export declare function satisfies(version: string, range: string, published?: string): boolean | undefined;
61
+ export interface ImpactLink {
62
+ name: string;
63
+ capability: string;
64
+ repository: string;
65
+ version?: string;
66
+ /** the range the consumer declares (downstream) or this package declares (upstream) */
67
+ range: string;
68
+ }
69
+ export interface ImpactConsumer extends ImpactLink {
70
+ /** 1 for a direct consumer, 2 for a consumer of a consumer, … */
71
+ depth: number;
72
+ /** the consumer it is reached through, from depth 2 */
73
+ via?: string;
74
+ /** with a bump, depth 1: whether its range reaches the new version */
75
+ accepts?: boolean;
76
+ /** with a bump: what the consumer needs */
77
+ action?: string;
78
+ }
79
+ export interface ImpactAnswer {
80
+ package: {
81
+ name: string;
82
+ capability: string;
83
+ version?: string;
84
+ repository: string;
85
+ };
86
+ bump?: {
87
+ level: BumpLevel;
88
+ from: string;
89
+ to: string;
90
+ };
91
+ /** upstream: the first-party packages it consumes */
92
+ consumes: ImpactLink[];
93
+ /** downstream: who consumes it, directly or through others */
94
+ consumers: ImpactConsumer[];
95
+ }
96
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
97
+ export declare function impactOf(packageOrCapability: string, packages: readonly PackageReading[], bump?: BumpLevel): ImpactAnswer | undefined;
98
+ //# sourceMappingURL=capability-impact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-impact.d.ts","sourceRoot":"","sources":["../src/capability-impact.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;IAE7B,6BAA6B;;;;;;;IAO7B,oFAAoF;;IAEpF,sCAAsC;;IAEtC,+EAA+E;;;;;;;;;;;;;;;;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,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACpF,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,qDAAqD;IACrD,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,8DAA8D;IAC9D,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CA+DrI"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ // What a version bump touches, pure. The scan reads each package's version
3
+ // and the ranges it declares on other packages it maps; a `consumes` edge
4
+ // joins a package to each first-party package it depends on, across
5
+ // repositories. `impactOf` answers, for one package: what it consumes
6
+ // (upstream), who consumes it, directly and through others (downstream), and
7
+ // with a bump, which direct consumers' ranges stop reaching the new version.
8
+ // A range published with `workspace:*` pins the exact version, so its
9
+ // consumer is released again after any bump: the drift
10
+ // verify-published-deps reported when hooks-interpreter moved to 0.7.
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PackageReadingSchema = void 0;
13
+ exports.consumesEdges = consumesEdges;
14
+ exports.bumpVersion = bumpVersion;
15
+ exports.satisfies = satisfies;
16
+ exports.impactOf = impactOf;
17
+ const zod_1 = require("zod");
18
+ exports.PackageReadingSchema = zod_1.z
19
+ .object({
20
+ /** `capability:package-…` */
21
+ capability: zod_1.z.string().min(1),
22
+ name: zod_1.z.string().min(1),
23
+ version: zod_1.z.string().min(1).optional(),
24
+ repository: zod_1.z.string().min(1),
25
+ path: zod_1.z.string().min(1),
26
+ commit: zod_1.z.string().min(1),
27
+ /** runtime dependencies as declared (dependencies, peer, optional): name → range */
28
+ dependsOn: zod_1.z.record(zod_1.z.string()),
29
+ /** the commands this package ships */
30
+ bins: zod_1.z.array(zod_1.z.string().min(1)).optional(),
31
+ /** never published: read for what consumes what, not listed as a capability */
32
+ private: zod_1.z.boolean().optional(),
33
+ })
34
+ .strict();
35
+ /** `consumes` edges between the packages read, first-party only. */
36
+ function consumesEdges(packages) {
37
+ const byName = new Map(packages.map((p) => [p.name, p]));
38
+ return packages.flatMap((p) => Object.entries(p.dependsOn).flatMap(([name, range]) => {
39
+ const to = byName.get(name);
40
+ return to && to.name !== p.name ? [{ from: p.capability, to: to.capability, type: "consumes", fromName: p.name, toName: to.name, range }] : [];
41
+ }));
42
+ }
43
+ function parseVersion(v) {
44
+ const m = v ? /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(v.trim()) : null;
45
+ return m ? [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)] : undefined;
46
+ }
47
+ const cmp = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
48
+ function bumpVersion(version, level) {
49
+ const v = parseVersion(version);
50
+ if (!v)
51
+ return undefined;
52
+ if (level === "major")
53
+ return `${v[0] + 1}.0.0`;
54
+ if (level === "minor")
55
+ return `${v[0]}.${v[1] + 1}.0`;
56
+ return `${v[0]}.${v[1]}.${v[2] + 1}`;
57
+ }
58
+ /**
59
+ * Whether `version` satisfies `range`, for the forms first-party manifests
60
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
61
+ * forms, read as pnpm publishes them against `published` (the consumed
62
+ * package's version when the consumer was released). Undefined for anything
63
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
64
+ */
65
+ function satisfies(version, range, published) {
66
+ const r = range.trim();
67
+ if (r.startsWith("workspace:")) {
68
+ const form = r.slice("workspace:".length);
69
+ if (!published)
70
+ return undefined;
71
+ if (form === "*" || form === "")
72
+ return satisfies(version, published);
73
+ if (form === "^" || form === "~")
74
+ return satisfies(version, `${form}${published}`);
75
+ return satisfies(version, form);
76
+ }
77
+ if (r === "*" || r === "" || r === "latest" || r === "x")
78
+ return true;
79
+ const v = parseVersion(version);
80
+ if (!v)
81
+ return undefined;
82
+ if (/^\^/.test(r)) {
83
+ const base = parseVersion(r.slice(1));
84
+ if (!base)
85
+ return undefined;
86
+ if (cmp(v, base) < 0)
87
+ return false;
88
+ if (base[0] > 0)
89
+ return v[0] === base[0];
90
+ if (base[1] > 0)
91
+ return v[0] === 0 && v[1] === base[1];
92
+ return v[0] === 0 && v[1] === 0 && v[2] === base[2];
93
+ }
94
+ if (/^~/.test(r)) {
95
+ const base = parseVersion(r.slice(1));
96
+ return base ? cmp(v, base) >= 0 && v[0] === base[0] && v[1] === base[1] : undefined;
97
+ }
98
+ if (/^>=/.test(r)) {
99
+ const base = parseVersion(r.slice(2));
100
+ return base ? cmp(v, base) >= 0 : undefined;
101
+ }
102
+ if (/^\d/.test(r) && !/[\s|<>]/.test(r)) {
103
+ const base = parseVersion(r);
104
+ return base ? cmp(v, base) === 0 : undefined;
105
+ }
106
+ return undefined;
107
+ }
108
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
109
+ function impactOf(packageOrCapability, packages, bump) {
110
+ const target = packages.find((p) => p.name === packageOrCapability || p.capability === packageOrCapability);
111
+ if (!target)
112
+ return undefined;
113
+ const edges = consumesEdges(packages);
114
+ const byCapability = new Map(packages.map((p) => [p.capability, p]));
115
+ const to = bump && target.version ? bumpVersion(target.version, bump) : undefined;
116
+ const consumes = edges
117
+ .filter((e) => e.from === target.capability)
118
+ .map((e) => {
119
+ const p = byCapability.get(e.to);
120
+ return { name: p.name, capability: p.capability, repository: p.repository, ...(p.version ? { version: p.version } : {}), range: e.range };
121
+ });
122
+ const consumers = [];
123
+ const seen = new Set([target.capability]);
124
+ let frontier = [{ capability: target.capability }];
125
+ for (let depth = 1; frontier.length; depth++) {
126
+ const next = [];
127
+ for (const { capability } of frontier) {
128
+ for (const e of edges.filter((x) => x.to === capability)) {
129
+ if (seen.has(e.from))
130
+ continue;
131
+ seen.add(e.from);
132
+ const p = byCapability.get(e.from);
133
+ const link = {
134
+ name: p.name,
135
+ capability: p.capability,
136
+ repository: p.repository,
137
+ ...(p.version ? { version: p.version } : {}),
138
+ range: e.range,
139
+ depth,
140
+ ...(depth > 1 ? { via: byCapability.get(capability).name } : {}),
141
+ };
142
+ if (to && target.version) {
143
+ if (depth === 1) {
144
+ const accepts = satisfies(to, e.range, target.version);
145
+ if (accepts !== undefined)
146
+ link.accepts = accepts;
147
+ link.action =
148
+ accepts === true
149
+ ? `${e.range} already reaches ${to}`
150
+ : e.range.startsWith("workspace:")
151
+ ? `release ${p.name} again: ${e.range} is published as ${e.range === "workspace:*" ? target.version : `${e.range.slice(10)}${target.version}`}, which does not reach ${to}`
152
+ : accepts === false
153
+ ? `widen ${e.range} to reach ${to}, then release ${p.name}`
154
+ : `read ${e.range} by hand`;
155
+ }
156
+ else {
157
+ link.action = `downstream through ${link.via}`;
158
+ }
159
+ }
160
+ consumers.push(link);
161
+ next.push({ capability: e.from });
162
+ }
163
+ }
164
+ frontier = next;
165
+ }
166
+ consumers.sort((a, b) => a.depth - b.depth || a.name.localeCompare(b.name));
167
+ return {
168
+ package: { name: target.name, capability: target.capability, ...(target.version ? { version: target.version } : {}), repository: target.repository },
169
+ ...(to && bump && target.version ? { bump: { level: bump, from: target.version, to } } : {}),
170
+ consumes,
171
+ consumers,
172
+ };
173
+ }
174
+ //# sourceMappingURL=capability-impact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-impact.js","sourceRoot":"","sources":["../src/capability-impact.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,sEAAsE;AACtE,6EAA6E;AAC7E,6EAA6E;AAC7E,sEAAsE;AACtE,uDAAuD;AACvD,sEAAsE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Q;QACR,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Capabilities, pure: what a git repository provides, read from its own files.
3
+ * Its packages (package.json), its CLIs (a package's `bin`) and its skills
4
+ * (SKILL.md, or a reader written for a file that defines them in code) become
5
+ * `capability` nodes of @medicine-wheel/capabilities, and the repository
6
+ * `provides` each one. A row states what the files say, never what a model
7
+ * guesses: a description over 55 words is not cut, the row is
8
+ * `needs-resolution` without a statement. Every row is pending until a person
9
+ * reads it.
10
+ */
11
+ import { type CapabilityFacet } from "@medicine-wheel/capabilities";
12
+ export type CapabilityKind = "package" | "cli" | "skill";
13
+ export declare const CAPABILITY_KINDS: readonly CapabilityKind[];
14
+ /** `capability:<kind>-<slug>`: `@miadi/inquiry-weave` → `capability:package-miadi-inquiry-weave`. */
15
+ export declare function capabilityId(kind: CapabilityKind, name: string): string;
16
+ /** The kind a capability id names, or undefined for a capability no scan wrote. */
17
+ export declare function kindOf(nodeId: string): CapabilityKind | undefined;
18
+ /** One thing a repository's files say it provides. */
19
+ export interface Artefact {
20
+ kind: CapabilityKind;
21
+ name: string;
22
+ /** what the files say it is, uncut */
23
+ description?: string;
24
+ /** the file that says so, relative to the repository */
25
+ path: string;
26
+ /** for a CLI: the package that ships it */
27
+ package?: string;
28
+ }
29
+ /** The fields of a package.json the scan reads. Never throws: an unreadable manifest has no name. */
30
+ export declare function parsePackageJson(text: string): {
31
+ name?: string;
32
+ version?: string;
33
+ description?: string;
34
+ bins: string[];
35
+ /** runtime dependencies (dependencies, peerDependencies, optionalDependencies): name → range */
36
+ dependsOn: Record<string, string>;
37
+ /** `"private": true`: never published, so not offered to others */
38
+ private?: boolean;
39
+ };
40
+ /** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
41
+ export declare function parseSkillFrontMatter(text: string): {
42
+ name?: string;
43
+ description?: string;
44
+ };
45
+ /**
46
+ * The folders a repository declares as its packages: `workspaces` of the root
47
+ * package.json (an array, or `{ packages }`), else the `packages:` list of
48
+ * pnpm-workspace.yaml. `.` is the root. Only `dir` and `dir/*` are expanded.
49
+ */
50
+ export declare function workspaceGlobs(rootPackageJson?: string, pnpmWorkspace?: string): string[];
51
+ /** The package.json paths of a repository's declared packages, among the files it holds. */
52
+ export declare function packageManifests(globs: readonly string[], files: readonly string[]): string[];
53
+ /** The SKILL.md files a repository holds, outside dependencies and archives. */
54
+ /**
55
+ * The address a person cites a capability by, in an episode, an issue, an
56
+ * inquiry, a ceremony diary or a circle turn (Episode 568's Capability
57
+ * Registry, the scheme decided by William on 2026-11-01), for the repository
58
+ * that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
59
+ */
60
+ export declare function capabilityAddress(repository: string, kind: CapabilityKind, name: string): string;
61
+ /**
62
+ * A capability a repository defines in code rather than in a file of its own,
63
+ * read by a reader written for that repository and that file, never guessed
64
+ * from a name (Episode 568, P15). `read` gets the file's text at the scanned
65
+ * commit and answers what it defines.
66
+ */
67
+ export interface CodeReader {
68
+ /** `repository:<owner>/<name>`, compared case-folded */
69
+ repository: string;
70
+ path: string;
71
+ read(text: string): Artefact[];
72
+ }
73
+ /**
74
+ * The medicine wheel's skills: `cli/skills.ts` defines each one as a
75
+ * `{ name, title, description, target, … }` record, and `mw skill install` /
76
+ * `mwsrv skill install` write it out as a SKILL.md. The statement is the
77
+ * record's own description.
78
+ */
79
+ export declare function medicineWheelSkills(text: string): Artefact[];
80
+ /** The readers written so far, one per repository file that defines capabilities in code. */
81
+ export declare const CODE_READERS: readonly CodeReader[];
82
+ export declare function skillFiles(files: readonly string[]): string[];
83
+ export interface CapabilityRowContext {
84
+ /** `repository:<owner>/<name>` */
85
+ repository: string;
86
+ /** the commit the files were read at */
87
+ commit: string;
88
+ observedBy: string;
89
+ /** ISO 8601 */
90
+ observedAt: string;
91
+ }
92
+ /**
93
+ * Capability rows for one repository. One row per id: two files naming the
94
+ * same skill are one capability with both files as its grounding.
95
+ */
96
+ export declare function capabilityRows(artefacts: readonly Artefact[], ctx: CapabilityRowContext): CapabilityFacet[];
97
+ /**
98
+ * Rows from several repositories as one inventory: a capability two
99
+ * repositories provide is one row that both provide, with both files as its
100
+ * grounding. The first row read keeps its name and statement.
101
+ */
102
+ export declare function mergeCapabilityRows(rows: readonly CapabilityFacet[]): CapabilityFacet[];
103
+ /** One `provides` edge: a repository provides a capability, said by whoever said the capability. */
104
+ export interface ProvidesEdge {
105
+ from: string;
106
+ to: string;
107
+ type: "provides";
108
+ statedBy: string;
109
+ statedAt: string;
110
+ grounding: string[];
111
+ revision: CapabilityFacet["revision"];
112
+ }
113
+ /** The `provides` edges a set of capability rows holds, one per provider. */
114
+ export declare function providesEdges(capabilities: readonly CapabilityFacet[]): ProvidesEdge[];
115
+ /** The capabilities a repository provides, matched case-folded, by kind then id. */
116
+ export declare function capabilitiesOf(repository: string, capabilities: readonly CapabilityFacet[]): CapabilityFacet[];
117
+ //# sourceMappingURL=capability-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-scan.d.ts","sourceRoot":"","sources":["../src/capability-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAAgC,CAAC;AAQvF,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGjE;AAED,sDAAsD;AACtD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;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AE,MAAM,GAAG,QAAQ,EAAE,CAO5D;AAED,6FAA6F;AAC7F,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAE7C,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAK7D;AAED,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,EAAE,GAAG,EAAE,oBAAoB,GAAG,eAAe,EAAE,CAyB3G;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,EAAE,CAYvF;AAED,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACvC;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,YAAY,EAAE,SAAS,eAAe,EAAE,GAAG,YAAY,EAAE,CAYtF;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,EAAE,CAG9G"}
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ /**
3
+ * Capabilities, pure: what a git repository provides, read from its own files.
4
+ * Its packages (package.json), its CLIs (a package's `bin`) and its skills
5
+ * (SKILL.md, or a reader written for a file that defines them in code) become
6
+ * `capability` nodes of @medicine-wheel/capabilities, and the repository
7
+ * `provides` each one. A row states what the files say, never what a model
8
+ * guesses: a description over 55 words is not cut, the row is
9
+ * `needs-resolution` without a statement. Every row is pending until a person
10
+ * reads it.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.CODE_READERS = exports.CAPABILITY_KINDS = void 0;
14
+ exports.capabilityId = capabilityId;
15
+ exports.kindOf = kindOf;
16
+ exports.parsePackageJson = parsePackageJson;
17
+ exports.parseSkillFrontMatter = parseSkillFrontMatter;
18
+ exports.workspaceGlobs = workspaceGlobs;
19
+ exports.packageManifests = packageManifests;
20
+ exports.capabilityAddress = capabilityAddress;
21
+ exports.medicineWheelSkills = medicineWheelSkills;
22
+ exports.skillFiles = skillFiles;
23
+ exports.capabilityRows = capabilityRows;
24
+ exports.mergeCapabilityRows = mergeCapabilityRows;
25
+ exports.providesEdges = providesEdges;
26
+ exports.capabilitiesOf = capabilitiesOf;
27
+ const capabilities_1 = require("@medicine-wheel/capabilities");
28
+ exports.CAPABILITY_KINDS = ["package", "cli", "skill"];
29
+ const slug = (value) => value
30
+ .toLowerCase()
31
+ .replace(/[^a-z0-9]+/g, "-")
32
+ .replace(/^-+|-+$/g, "");
33
+ /** `capability:<kind>-<slug>`: `@miadi/inquiry-weave` → `capability:package-miadi-inquiry-weave`. */
34
+ function capabilityId(kind, name) {
35
+ return `capability:${kind}-${slug(name)}`;
36
+ }
37
+ /** The kind a capability id names, or undefined for a capability no scan wrote. */
38
+ function kindOf(nodeId) {
39
+ const m = /^capability:(package|cli|skill)-/.exec(nodeId);
40
+ return m ? m[1] : undefined;
41
+ }
42
+ /** The fields of a package.json the scan reads. Never throws: an unreadable manifest has no name. */
43
+ function parsePackageJson(text) {
44
+ try {
45
+ const p = JSON.parse(text);
46
+ const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
47
+ const name = str(p.name);
48
+ const version = str(p.version);
49
+ const description = str(p.description);
50
+ let bins = [];
51
+ if (typeof p.bin === "string" && name)
52
+ bins = [name.replace(/^@[^/]+\//, "")];
53
+ else if (p.bin && typeof p.bin === "object")
54
+ bins = Object.keys(p.bin);
55
+ const dependsOn = {};
56
+ for (const key of ["optionalDependencies", "peerDependencies", "dependencies"]) {
57
+ const deps = p[key];
58
+ if (deps && typeof deps === "object") {
59
+ for (const [dep, range] of Object.entries(deps))
60
+ if (typeof range === "string")
61
+ dependsOn[dep] = range;
62
+ }
63
+ }
64
+ return { ...(name ? { name } : {}), ...(version ? { version } : {}), ...(description ? { description } : {}), bins, dependsOn, ...(p.private === true ? { private: true } : {}) };
65
+ }
66
+ catch {
67
+ return { bins: [], dependsOn: {} };
68
+ }
69
+ }
70
+ /** `name` and `description` from a SKILL.md front matter, plain, quoted or folded (`>`, `|`). */
71
+ function parseSkillFrontMatter(text) {
72
+ const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
73
+ if (!m)
74
+ return {};
75
+ const lines = m[1].split(/\r?\n/);
76
+ const field = (key) => {
77
+ const i = lines.findIndex((l) => new RegExp(`^${key}:`).test(l));
78
+ if (i < 0)
79
+ return undefined;
80
+ let value = lines[i].slice(key.length + 1).trim();
81
+ if (/^[>|][+-]?$/.test(value)) {
82
+ const folded = [];
83
+ for (const l of lines.slice(i + 1)) {
84
+ if (/^\S/.test(l))
85
+ break;
86
+ folded.push(l.trim());
87
+ }
88
+ value = folded.join(" ").trim();
89
+ }
90
+ value = value.replace(/^(["'])([\s\S]*)\1$/, "$2").trim();
91
+ return value || undefined;
92
+ };
93
+ const name = field("name");
94
+ const description = field("description");
95
+ return { ...(name ? { name } : {}), ...(description ? { description } : {}) };
96
+ }
97
+ /**
98
+ * The folders a repository declares as its packages: `workspaces` of the root
99
+ * package.json (an array, or `{ packages }`), else the `packages:` list of
100
+ * pnpm-workspace.yaml. `.` is the root. Only `dir` and `dir/*` are expanded.
101
+ */
102
+ function workspaceGlobs(rootPackageJson, pnpmWorkspace) {
103
+ try {
104
+ const root = rootPackageJson ? JSON.parse(rootPackageJson) : {};
105
+ const w = root.workspaces;
106
+ const list = Array.isArray(w) ? w : w && typeof w === "object" ? w.packages : undefined;
107
+ if (Array.isArray(list) && list.length)
108
+ return [".", ...list.filter((x) => typeof x === "string")];
109
+ }
110
+ catch {
111
+ // an unreadable root manifest declares nothing
112
+ }
113
+ if (pnpmWorkspace) {
114
+ const block = /(^|\n)packages:\s*\n((?:[ \t]+-[^\n]*\n?)+)/.exec(pnpmWorkspace);
115
+ if (block) {
116
+ return block[2]
117
+ .split("\n")
118
+ .map((l) => l.replace(/^[ \t]+-\s*/, "").replace(/\s+#.*$/, "").replace(/^['"]|['"]$/g, "").trim())
119
+ .filter(Boolean);
120
+ }
121
+ }
122
+ return ["."];
123
+ }
124
+ /** The package.json paths of a repository's declared packages, among the files it holds. */
125
+ function packageManifests(globs, files) {
126
+ const manifests = new Set();
127
+ const held = new Set(files);
128
+ for (const glob of globs) {
129
+ const dir = glob.replace(/^\.\//, "").replace(/\/+$/, "");
130
+ if (dir === "." || dir === "") {
131
+ if (held.has("package.json"))
132
+ manifests.add("package.json");
133
+ }
134
+ else if (dir.endsWith("/*")) {
135
+ const base = `${dir.slice(0, -2)}/`;
136
+ for (const f of files) {
137
+ const rest = f.startsWith(base) ? f.slice(base.length) : "";
138
+ if (/^[^/]+\/package\.json$/.test(rest))
139
+ manifests.add(f);
140
+ }
141
+ }
142
+ else if (held.has(`${dir}/package.json`)) {
143
+ manifests.add(`${dir}/package.json`);
144
+ }
145
+ }
146
+ return [...manifests].sort();
147
+ }
148
+ /** The SKILL.md files a repository holds, outside dependencies and archives. */
149
+ /**
150
+ * The address a person cites a capability by, in an episode, an issue, an
151
+ * inquiry, a ceremony diary or a circle turn (Episode 568's Capability
152
+ * Registry, the scheme decided by William on 2026-11-01), for the repository
153
+ * that provides it: `miadi-capability://jgwill/medicine-wheel/cli/mw`.
154
+ */
155
+ function capabilityAddress(repository, kind, name) {
156
+ return `miadi-capability://${repository.replace(/^repository:/, "")}/${kind}/${name}`;
157
+ }
158
+ /**
159
+ * The medicine wheel's skills: `cli/skills.ts` defines each one as a
160
+ * `{ name, title, description, target, … }` record, and `mw skill install` /
161
+ * `mwsrv skill install` write it out as a SKILL.md. The statement is the
162
+ * record's own description.
163
+ */
164
+ function medicineWheelSkills(text) {
165
+ const out = [];
166
+ 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;
167
+ for (const m of text.matchAll(re)) {
168
+ out.push({ kind: "skill", name: m[1], description: m[2].replace(/\\(.)/g, "$1"), path: "cli/skills.ts" });
169
+ }
170
+ return out;
171
+ }
172
+ /** The readers written so far, one per repository file that defines capabilities in code. */
173
+ exports.CODE_READERS = [
174
+ { repository: "repository:jgwill/medicine-wheel", path: "cli/skills.ts", read: medicineWheelSkills },
175
+ ];
176
+ function skillFiles(files) {
177
+ return files
178
+ .filter((f) => /(^|\/)SKILL\.md$/.test(f))
179
+ .filter((f) => !/(^|\/)(node_modules|archives?|archived-[^/]*|dist|\.next)\//.test(f))
180
+ .sort();
181
+ }
182
+ /**
183
+ * Capability rows for one repository. One row per id: two files naming the
184
+ * same skill are one capability with both files as its grounding.
185
+ */
186
+ function capabilityRows(artefacts, ctx) {
187
+ const where = `${ctx.repository.replace(/^repository:/, "")}@${ctx.commit.slice(0, 12)}`;
188
+ const rows = new Map();
189
+ for (const a of artefacts) {
190
+ const nodeId = capabilityId(a.kind, a.name);
191
+ const grounding = `${where}:${a.path}`;
192
+ const existing = rows.get(nodeId);
193
+ if (existing) {
194
+ if (!existing.grounding.includes(grounding))
195
+ existing.grounding.push(grounding);
196
+ continue;
197
+ }
198
+ const fits = a.description ? (0, capabilities_1.checkStatement)(a.description).fits : false;
199
+ rows.set(nodeId, {
200
+ nodeId,
201
+ name: a.name,
202
+ ...(fits ? { statement: a.description } : {}),
203
+ status: fits ? "clear" : "needs-resolution",
204
+ providedBy: [ctx.repository],
205
+ statedBy: ctx.observedBy,
206
+ statedAt: ctx.observedAt,
207
+ grounding: [grounding],
208
+ revision: "pending",
209
+ });
210
+ }
211
+ return [...rows.values()];
212
+ }
213
+ /**
214
+ * Rows from several repositories as one inventory: a capability two
215
+ * repositories provide is one row that both provide, with both files as its
216
+ * grounding. The first row read keeps its name and statement.
217
+ */
218
+ function mergeCapabilityRows(rows) {
219
+ const merged = new Map();
220
+ for (const row of rows) {
221
+ const existing = merged.get(row.nodeId);
222
+ if (!existing) {
223
+ merged.set(row.nodeId, { ...row, providedBy: [...row.providedBy], grounding: [...row.grounding] });
224
+ continue;
225
+ }
226
+ for (const p of row.providedBy)
227
+ if (!existing.providedBy.includes(p))
228
+ existing.providedBy.push(p);
229
+ for (const g of row.grounding)
230
+ if (!existing.grounding.includes(g))
231
+ existing.grounding.push(g);
232
+ }
233
+ return [...merged.values()].sort((a, b) => (a.nodeId < b.nodeId ? -1 : a.nodeId > b.nodeId ? 1 : 0));
234
+ }
235
+ /** The `provides` edges a set of capability rows holds, one per provider. */
236
+ function providesEdges(capabilities) {
237
+ return capabilities.flatMap((c) => c.providedBy.map((from) => ({
238
+ from,
239
+ to: c.nodeId,
240
+ type: "provides",
241
+ statedBy: c.statedBy,
242
+ statedAt: c.statedAt,
243
+ grounding: c.grounding,
244
+ revision: c.revision,
245
+ })));
246
+ }
247
+ /** The capabilities a repository provides, matched case-folded, by kind then id. */
248
+ function capabilitiesOf(repository, capabilities) {
249
+ const id = (repository.startsWith("repository:") ? repository : `repository:${repository}`).toLowerCase();
250
+ return capabilities.filter((c) => c.providedBy.some((p) => p.toLowerCase() === id));
251
+ }
252
+ //# sourceMappingURL=capability-scan.js.map