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

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
@@ -46,6 +46,22 @@ A meta hub reads every hub it registers (from a local path, or from GitHub by de
46
46
  unless `--local`. `observe --write` and `move` refuse to rewrite a folder while any row
47
47
  fails to parse. Exit codes: 0 done, 1 errors or a failed read, 2 usage error.
48
48
 
49
+ ## What a repository provides
50
+
51
+ Any git repository can keep what it provides in `.miadi/capabilities.jsonl`, committed with its code, so whoever clones it knows what it offers. Nothing else is needed: no account, no registry, no server.
52
+
53
+ ```bash
54
+ npx @medicine-wheel/developer-repository-mapping capabilities scan --write # in a clone: its packages, CLIs and skills
55
+ git add .miadi/capabilities.jsonl && git commit -m "what this repository provides"
56
+
57
+ mw-repomap capabilities show <clone> # what a clone provides, from its own file first
58
+ mw-repomap capabilities state skill/greet "Says hello." --by Ava # a person states a row (55 words at most)
59
+ mw-repomap capabilities scan --check # exit 1 when the file is behind the code
60
+ mw-repomap capabilities map --root ~/repos --out map.jsonl # go through clones and answer one map
61
+ ```
62
+
63
+ A rescan keeps what a person wrote and leaves the file alone when nothing changed. Versions come from each `package.json` at the commit read, so a release does not touch the file. The format is in `rispecs/developer-suite/repository-mapping/capabilities.spec.md`.
64
+
49
65
  ## Library
50
66
 
51
67
  ```ts
@@ -0,0 +1,168 @@
1
+ /**
2
+ * A repository's own capability file, `.miadi/capabilities.jsonl`, pure.
3
+ *
4
+ * The file travels with the repository: whoever clones it knows what it
5
+ * provides, with no Factory and no registry. The first line says what the file
6
+ * is and which repository wrote it; each other line is one capability: its
7
+ * kind, its name, its address, what its files say it is, and the files that
8
+ * say so. Versions and dependency ranges are not here, because every release
9
+ * would make them stale: a reader takes them from each package.json at the
10
+ * commit it reads. The commit is not here either, because a committed file
11
+ * cannot name its own commit: a reader adds the one it read.
12
+ *
13
+ * `mw-repomap capabilities scan --write` writes it. A rescan keeps what a
14
+ * person wrote, and a row the scan wrote stays as it is while its statement
15
+ * stays the same, so a file only changes when the repository did.
16
+ */
17
+ import { z } from 'zod';
18
+ import { type CapabilityFacet } from '@medicine-wheel/capabilities';
19
+ import type { MappingIssue } from './types';
20
+ import { type Artefact, type CapabilityKind } from './capability-scan';
21
+ /** Where a repository keeps it, relative to its root. */
22
+ export declare const CAPABILITY_FILE = ".miadi/capabilities.jsonl";
23
+ export declare const CAPABILITY_FILE_SCHEMA = "medicine-wheel/repository-capabilities";
24
+ /** `statedBy` of a row the scan wrote. Any other name is a person's, and a rescan keeps its words. */
25
+ export declare const SCAN_AUTHOR = "mw-repomap scan";
26
+ export declare const CapabilityFileHeaderSchema: z.ZodObject<{
27
+ schema: z.ZodLiteral<"medicine-wheel/repository-capabilities">;
28
+ version: z.ZodLiteral<1>;
29
+ /** `owner/name`, as the repository was known when the file was written. */
30
+ repository: z.ZodString;
31
+ }, "strict", z.ZodTypeAny, {
32
+ version: 1;
33
+ schema: "medicine-wheel/repository-capabilities";
34
+ repository: string;
35
+ }, {
36
+ version: 1;
37
+ schema: "medicine-wheel/repository-capabilities";
38
+ repository: string;
39
+ }>;
40
+ export type CapabilityFileHeader = z.infer<typeof CapabilityFileHeaderSchema>;
41
+ export declare const CapabilityFileRowSchema: z.ZodEffects<z.ZodObject<{
42
+ statedBy: z.ZodString;
43
+ statedAt: z.ZodString;
44
+ grounding: z.ZodArray<z.ZodString, "many">;
45
+ revision: z.ZodEnum<["pending", "revised", "affirmed"]>;
46
+ revisedBy: z.ZodOptional<z.ZodString>;
47
+ revisedAt: z.ZodOptional<z.ZodString>;
48
+ kind: z.ZodEnum<[CapabilityKind, ...CapabilityKind[]]>;
49
+ name: z.ZodString;
50
+ /** `miadi-capability://<owner>/<repo>/<kind>/<name>` */
51
+ address: z.ZodString;
52
+ statement: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
53
+ status: z.ZodEnum<["clear", "unclear", "undefinable", "needs-resolution"]>;
54
+ /** For a CLI: the package that ships it. */
55
+ package: z.ZodOptional<z.ZodString>;
56
+ }, "strict", z.ZodTypeAny, {
57
+ name: string;
58
+ revision: "pending" | "revised" | "affirmed";
59
+ status: "clear" | "unclear" | "undefinable" | "needs-resolution";
60
+ kind: CapabilityKind;
61
+ address: string;
62
+ statedBy: string;
63
+ statedAt: string;
64
+ grounding: string[];
65
+ package?: string | undefined;
66
+ statement?: string | undefined;
67
+ revisedBy?: string | undefined;
68
+ revisedAt?: string | undefined;
69
+ }, {
70
+ name: string;
71
+ revision: "pending" | "revised" | "affirmed";
72
+ status: "clear" | "unclear" | "undefinable" | "needs-resolution";
73
+ kind: CapabilityKind;
74
+ address: string;
75
+ statedBy: string;
76
+ statedAt: string;
77
+ grounding: string[];
78
+ package?: string | undefined;
79
+ statement?: string | undefined;
80
+ revisedBy?: string | undefined;
81
+ revisedAt?: string | undefined;
82
+ }>, {
83
+ name: string;
84
+ revision: "pending" | "revised" | "affirmed";
85
+ status: "clear" | "unclear" | "undefinable" | "needs-resolution";
86
+ kind: CapabilityKind;
87
+ address: string;
88
+ statedBy: string;
89
+ statedAt: string;
90
+ grounding: string[];
91
+ package?: string | undefined;
92
+ statement?: string | undefined;
93
+ revisedBy?: string | undefined;
94
+ revisedAt?: string | undefined;
95
+ }, {
96
+ name: string;
97
+ revision: "pending" | "revised" | "affirmed";
98
+ status: "clear" | "unclear" | "undefinable" | "needs-resolution";
99
+ kind: CapabilityKind;
100
+ address: string;
101
+ statedBy: string;
102
+ statedAt: string;
103
+ grounding: string[];
104
+ package?: string | undefined;
105
+ statement?: string | undefined;
106
+ revisedBy?: string | undefined;
107
+ revisedAt?: string | undefined;
108
+ }>;
109
+ export type CapabilityFileRow = z.infer<typeof CapabilityFileRowSchema>;
110
+ export interface ParsedCapabilityFile {
111
+ header?: CapabilityFileHeader;
112
+ rows: CapabilityFileRow[];
113
+ issues: MappingIssue[];
114
+ }
115
+ /** Read the file. Never throws: a bad line is an issue, and the good lines around it are still read. */
116
+ export declare function parseCapabilityFile(text: string): ParsedCapabilityFile;
117
+ /** The file's text: the header, then one row per line in a fixed order, so a diff shows only what changed. */
118
+ export declare function renderCapabilityFile(repository: string, rows: readonly CapabilityFileRow[]): string;
119
+ /** The rows a scan's artefacts make: one per capability, the files that say so as grounding. */
120
+ export declare function capabilityFileRows(artefacts: readonly Artefact[], ctx: {
121
+ repository: string;
122
+ statedAt: string;
123
+ }): CapabilityFileRow[];
124
+ export interface CapabilityFileMerge {
125
+ rows: CapabilityFileRow[];
126
+ /** Keys (`kind/name`) the scan found that the file did not hold. */
127
+ added: string[];
128
+ /** Rows the scan wrote and no longer finds. */
129
+ removed: string[];
130
+ /** Rows whose text or files changed. */
131
+ changed: string[];
132
+ /** Rows a person wrote that this scan does not find: kept, and said. */
133
+ keptByPerson: string[];
134
+ }
135
+ /**
136
+ * What the file should hold after a scan.
137
+ *
138
+ * A row a person wrote (any `statedBy` but {@link SCAN_AUTHOR}) keeps its
139
+ * words and its attribution. A statement added by hand to a row the scan could
140
+ * not state is kept the same way. A row the scan wrote takes the scan's
141
+ * statement, and goes back to pending only when the statement changed. The
142
+ * files and the shipping package are always the scan's. The same rule serves
143
+ * a reader, which merges a committed file with what the commit holds.
144
+ */
145
+ export declare function mergeCapabilityFile(existing: readonly CapabilityFileRow[], scanned: readonly CapabilityFileRow[]): CapabilityFileMerge;
146
+ /**
147
+ * The file's rows as capability facets of one repository at one commit: the
148
+ * files become `owner/name@commit:path`, the grounding every registry row carries.
149
+ */
150
+ export declare function capabilityFileFacets(rows: readonly CapabilityFileRow[], ctx: {
151
+ repository: string;
152
+ commit: string;
153
+ }): CapabilityFacet[];
154
+ export interface CapabilityStatementInput {
155
+ kind: CapabilityKind;
156
+ name: string;
157
+ by: string;
158
+ at: string;
159
+ /** With words, the person states it; without, the person affirms what is there. */
160
+ statement?: string;
161
+ }
162
+ /** A person states or affirms one row. An `error` says why not: no such row, or words that do not fit. */
163
+ export declare function stateCapabilityRow(rows: readonly CapabilityFileRow[], input: CapabilityStatementInput): {
164
+ rows: CapabilityFileRow[];
165
+ } | {
166
+ error: string;
167
+ };
168
+ //# sourceMappingURL=capability-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-file.d.ts","sourceRoot":"","sources":["../src/capability-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAqD,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1H,yDAAyD;AACzD,eAAO,MAAM,eAAe,8BAA8B,CAAC;AAC3D,eAAO,MAAM,sBAAsB,2CAA2C,CAAC;AAC/E,sGAAsG;AACtG,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAE7C,eAAO,MAAM,0BAA0B;;;IAInC,2EAA2E;;;;;;;;;;EAGpE,CAAC;AACZ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,uBAAuB;;;;;;;;;IAIhC,wDAAwD;;;;IAIxD,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMS,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AASD,wGAAwG;AACxG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAkBtE;AAMD,8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B,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAezJ"}
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ /**
3
+ * A repository's own capability file, `.miadi/capabilities.jsonl`, pure.
4
+ *
5
+ * The file travels with the repository: whoever clones it knows what it
6
+ * provides, with no Factory and no registry. The first line says what the file
7
+ * is and which repository wrote it; each other line is one capability: its
8
+ * kind, its name, its address, what its files say it is, and the files that
9
+ * say so. Versions and dependency ranges are not here, because every release
10
+ * would make them stale: a reader takes them from each package.json at the
11
+ * commit it reads. The commit is not here either, because a committed file
12
+ * cannot name its own commit: a reader adds the one it read.
13
+ *
14
+ * `mw-repomap capabilities scan --write` writes it. A rescan keeps what a
15
+ * person wrote, and a row the scan wrote stays as it is while its statement
16
+ * stays the same, so a file only changes when the repository did.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.CapabilityFileRowSchema = exports.CapabilityFileHeaderSchema = exports.SCAN_AUTHOR = exports.CAPABILITY_FILE_SCHEMA = exports.CAPABILITY_FILE = void 0;
20
+ exports.parseCapabilityFile = parseCapabilityFile;
21
+ exports.renderCapabilityFile = renderCapabilityFile;
22
+ exports.capabilityFileRows = capabilityFileRows;
23
+ exports.mergeCapabilityFile = mergeCapabilityFile;
24
+ exports.capabilityFileFacets = capabilityFileFacets;
25
+ exports.stateCapabilityRow = stateCapabilityRow;
26
+ const zod_1 = require("zod");
27
+ const capabilities_1 = require("@medicine-wheel/capabilities");
28
+ const jsonl_1 = require("./jsonl");
29
+ const capability_scan_1 = require("./capability-scan");
30
+ /** Where a repository keeps it, relative to its root. */
31
+ exports.CAPABILITY_FILE = '.miadi/capabilities.jsonl';
32
+ exports.CAPABILITY_FILE_SCHEMA = 'medicine-wheel/repository-capabilities';
33
+ /** `statedBy` of a row the scan wrote. Any other name is a person's, and a rescan keeps its words. */
34
+ exports.SCAN_AUTHOR = 'mw-repomap scan';
35
+ exports.CapabilityFileHeaderSchema = zod_1.z
36
+ .object({
37
+ schema: zod_1.z.literal(exports.CAPABILITY_FILE_SCHEMA),
38
+ version: zod_1.z.literal(1),
39
+ /** `owner/name`, as the repository was known when the file was written. */
40
+ repository: zod_1.z.string().min(1),
41
+ })
42
+ .strict();
43
+ exports.CapabilityFileRowSchema = zod_1.z
44
+ .object({
45
+ kind: zod_1.z.enum(capability_scan_1.CAPABILITY_KINDS),
46
+ name: zod_1.z.string().min(1),
47
+ /** `miadi-capability://<owner>/<repo>/<kind>/<name>` */
48
+ address: zod_1.z.string().min(1),
49
+ statement: capabilities_1.StatementSchema.optional(),
50
+ status: capabilities_1.StatementStatusSchema,
51
+ /** For a CLI: the package that ships it. */
52
+ package: zod_1.z.string().min(1).optional(),
53
+ /** `grounding` here is the files that say so, relative to the repository. */
54
+ ...capabilities_1.attributionShape,
55
+ })
56
+ .strict()
57
+ .superRefine((row, ctx) => (0, capabilities_1.refineAttribution)(row, ctx));
58
+ const rowKey = (row) => `${row.kind}/${row.name}`;
59
+ function firstLineEnd(text) {
60
+ const i = text.indexOf('\n');
61
+ return i < 0 ? text.length : i;
62
+ }
63
+ /** Read the file. Never throws: a bad line is an issue, and the good lines around it are still read. */
64
+ function parseCapabilityFile(text) {
65
+ const clean = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
66
+ const end = firstLineEnd(clean);
67
+ const issues = [];
68
+ let header;
69
+ try {
70
+ const parsed = exports.CapabilityFileHeaderSchema.safeParse(JSON.parse(clean.slice(0, end)));
71
+ if (parsed.success)
72
+ header = parsed.data;
73
+ else
74
+ issues.push({ severity: 'error', file: exports.CAPABILITY_FILE, line: 1, message: `the first line is not this file's header: ${parsed.error.issues[0]?.message}` });
75
+ }
76
+ catch (error) {
77
+ issues.push({ severity: 'error', file: exports.CAPABILITY_FILE, line: 1, message: `not JSON: ${error.message}` });
78
+ }
79
+ const rest = (0, jsonl_1.parseJsonl)(clean.slice(end + 1), exports.CapabilityFileRowSchema, exports.CAPABILITY_FILE);
80
+ return {
81
+ ...(header ? { header } : {}),
82
+ rows: rest.rows,
83
+ issues: [...issues, ...rest.issues.map((i) => ({ ...i, ...(i.line ? { line: i.line + 1 } : {}) }))],
84
+ };
85
+ }
86
+ const KIND_ORDER = new Map(capability_scan_1.CAPABILITY_KINDS.map((k, i) => [k, i]));
87
+ const byKindThenName = (a, b) => (KIND_ORDER.get(a.kind) ?? 9) - (KIND_ORDER.get(b.kind) ?? 9) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
88
+ /** The file's text: the header, then one row per line in a fixed order, so a diff shows only what changed. */
89
+ function renderCapabilityFile(repository, rows) {
90
+ const header = { schema: exports.CAPABILITY_FILE_SCHEMA, version: 1, repository: repository.replace(/^repository:/, '') };
91
+ const lines = [...rows].sort(byKindThenName).map((r) => JSON.stringify({
92
+ kind: r.kind,
93
+ name: r.name,
94
+ address: r.address,
95
+ ...(r.statement ? { statement: r.statement } : {}),
96
+ status: r.status,
97
+ ...(r.package ? { package: r.package } : {}),
98
+ statedBy: r.statedBy,
99
+ statedAt: r.statedAt,
100
+ grounding: r.grounding,
101
+ revision: r.revision,
102
+ ...(r.revisedBy ? { revisedBy: r.revisedBy } : {}),
103
+ ...(r.revisedAt ? { revisedAt: r.revisedAt } : {}),
104
+ }));
105
+ return [JSON.stringify(header), ...lines].join('\n') + '\n';
106
+ }
107
+ /** The rows a scan's artefacts make: one per capability, the files that say so as grounding. */
108
+ function capabilityFileRows(artefacts, ctx) {
109
+ const rows = new Map();
110
+ for (const a of artefacts) {
111
+ const key = rowKey(a);
112
+ const existing = rows.get(key);
113
+ if (existing) {
114
+ if (!existing.grounding.includes(a.path))
115
+ existing.grounding.push(a.path);
116
+ continue;
117
+ }
118
+ const fits = a.description ? (0, capabilities_1.checkStatement)(a.description).fits : false;
119
+ rows.set(key, {
120
+ kind: a.kind,
121
+ name: a.name,
122
+ address: (0, capability_scan_1.capabilityAddress)(ctx.repository, a.kind, a.name),
123
+ ...(fits ? { statement: a.description } : {}),
124
+ status: fits ? 'clear' : 'needs-resolution',
125
+ ...(a.package ? { package: a.package } : {}),
126
+ statedBy: exports.SCAN_AUTHOR,
127
+ statedAt: ctx.statedAt,
128
+ grounding: [a.path],
129
+ revision: 'pending',
130
+ });
131
+ }
132
+ return [...rows.values()].sort(byKindThenName);
133
+ }
134
+ /**
135
+ * What the file should hold after a scan.
136
+ *
137
+ * A row a person wrote (any `statedBy` but {@link SCAN_AUTHOR}) keeps its
138
+ * words and its attribution. A statement added by hand to a row the scan could
139
+ * not state is kept the same way. A row the scan wrote takes the scan's
140
+ * statement, and goes back to pending only when the statement changed. The
141
+ * files and the shipping package are always the scan's. The same rule serves
142
+ * a reader, which merges a committed file with what the commit holds.
143
+ */
144
+ function mergeCapabilityFile(existing, scanned) {
145
+ const held = new Map(existing.map((r) => [rowKey(r), r]));
146
+ const seen = new Set();
147
+ const rows = [];
148
+ const added = [];
149
+ const changed = [];
150
+ for (const scan of scanned) {
151
+ const key = rowKey(scan);
152
+ seen.add(key);
153
+ const row = held.get(key);
154
+ if (!row) {
155
+ rows.push(scan);
156
+ added.push(key);
157
+ continue;
158
+ }
159
+ const byPerson = row.statedBy !== exports.SCAN_AUTHOR;
160
+ const keepWords = byPerson || (!scan.statement && Boolean(row.statement));
161
+ let next;
162
+ if (keepWords) {
163
+ next = {
164
+ ...row,
165
+ address: scan.address,
166
+ status: row.status === 'unclear' ? 'unclear' : row.statement ? 'clear' : row.status,
167
+ grounding: scan.grounding,
168
+ ...(scan.package ? { package: scan.package } : {}),
169
+ };
170
+ }
171
+ else if (row.statement === scan.statement) {
172
+ next = { ...row, address: scan.address, status: scan.status, grounding: scan.grounding, ...(scan.package ? { package: scan.package } : {}) };
173
+ }
174
+ else {
175
+ next = scan;
176
+ }
177
+ if (JSON.stringify(rowForCompare(next)) !== JSON.stringify(rowForCompare(row)))
178
+ changed.push(key);
179
+ rows.push(next);
180
+ }
181
+ const removed = [];
182
+ const keptByPerson = [];
183
+ for (const row of existing) {
184
+ const key = rowKey(row);
185
+ if (seen.has(key))
186
+ continue;
187
+ if (row.statedBy === exports.SCAN_AUTHOR) {
188
+ removed.push(key);
189
+ }
190
+ else {
191
+ rows.push(row);
192
+ keptByPerson.push(key);
193
+ }
194
+ }
195
+ return { rows: rows.sort(byKindThenName), added, removed, changed, keptByPerson };
196
+ }
197
+ function rowForCompare(row) {
198
+ return { ...row, grounding: [...row.grounding].sort() };
199
+ }
200
+ /**
201
+ * The file's rows as capability facets of one repository at one commit: the
202
+ * files become `owner/name@commit:path`, the grounding every registry row carries.
203
+ */
204
+ function capabilityFileFacets(rows, ctx) {
205
+ const where = `${ctx.repository.replace(/^repository:/, '')}@${ctx.commit.slice(0, 12)}`;
206
+ return rows.map((r) => ({
207
+ nodeId: (0, capability_scan_1.capabilityId)(r.kind, r.name),
208
+ name: r.name,
209
+ ...(r.statement ? { statement: r.statement } : {}),
210
+ status: r.status,
211
+ providedBy: [ctx.repository],
212
+ statedBy: r.statedBy,
213
+ statedAt: r.statedAt,
214
+ grounding: r.grounding.map((p) => `${where}:${p}`),
215
+ revision: r.revision,
216
+ ...(r.revisedBy ? { revisedBy: r.revisedBy } : {}),
217
+ ...(r.revisedAt ? { revisedAt: r.revisedAt } : {}),
218
+ }));
219
+ }
220
+ /** A person states or affirms one row. An `error` says why not: no such row, or words that do not fit. */
221
+ function stateCapabilityRow(rows, input) {
222
+ const key = rowKey(input);
223
+ const row = rows.find((r) => rowKey(r) === key);
224
+ if (!row)
225
+ return { error: `the file holds no ${key}: run capabilities scan --write first` };
226
+ if (input.statement !== undefined) {
227
+ const check = (0, capabilities_1.checkStatement)(input.statement);
228
+ if (!check.fits)
229
+ return { error: check.words === 0 ? 'a statement needs at least one word' : `${check.words} words, the limit is ${check.limit}` };
230
+ }
231
+ else if (!row.statement) {
232
+ return { error: `${key} has no statement to affirm: give it one` };
233
+ }
234
+ const next = input.statement !== undefined
235
+ ? { ...row, statement: input.statement, status: 'clear', statedBy: input.by, statedAt: input.at, revision: 'revised', revisedBy: input.by, revisedAt: input.at }
236
+ : { ...row, revision: 'affirmed', revisedBy: input.by, revisedAt: input.at };
237
+ return { rows: rows.map((r) => (rowKey(r) === key ? next : r)) };
238
+ }
239
+ //# sourceMappingURL=capability-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-file.js","sourceRoot":"","sources":["../src/capability-file.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AA8DH,kDAkBC;AAOD,oDAmBC;AAGD,gDAwBC;AAwBD,kDA+CC;AAUD,oDAeC;AAYD,gDAeC;AA9PD,6BAAwB;AACxB,+DAOsC;AACtC,mCAAqC;AAErC,uDAA0H;AAE1H,yDAAyD;AAC5C,QAAA,eAAe,GAAG,2BAA2B,CAAC;AAC9C,QAAA,sBAAsB,GAAG,wCAAwC,CAAC;AAC/E,sGAAsG;AACzF,QAAA,WAAW,GAAG,iBAAiB,CAAC;AAEhC,QAAA,0BAA0B,GAAG,OAAC;KACxC,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,8BAAsB,CAAC;IACzC,OAAO,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,2EAA2E;IAC3E,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAGC,QAAA,uBAAuB,GAAG,OAAC;KACrC,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,kCAAoE,CAAC;IAClF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,wDAAwD;IACxD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,SAAS,EAAE,8BAAe,CAAC,QAAQ,EAAE;IACrC,MAAM,EAAE,oCAAqB;IAC7B,4CAA4C;IAC5C,OAAO,EAAE,OAAC,CAAC,MAA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ema: 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
+ }, "strict", z.ZodTypeAny, {
15
+ name: string;
16
+ path: string;
17
+ repository: string;
18
+ capability: string;
19
+ commit: string;
20
+ dependsOn: Record<string, string>;
21
+ version?: string | undefined;
22
+ bins?: string[] | undefined;
23
+ }, {
24
+ name: string;
25
+ path: string;
26
+ repository: string;
27
+ capability: string;
28
+ commit: string;
29
+ dependsOn: Record<string, string>;
30
+ version?: string | undefined;
31
+ bins?: string[] | undefined;
32
+ }>;
33
+ export type PackageReading = z.infer<typeof PackageReadingSchema>;
34
+ export interface ConsumesEdge {
35
+ /** the consuming package's capability */
36
+ from: string;
37
+ /** the consumed package's capability */
38
+ to: string;
39
+ type: "consumes";
40
+ fromName: string;
41
+ toName: string;
42
+ /** the range `from` declares on `to` */
43
+ range: string;
44
+ }
45
+ /** `consumes` edges between the packages read, first-party only. */
46
+ export declare function consumesEdges(packages: readonly PackageReading[]): ConsumesEdge[];
47
+ export type BumpLevel = "major" | "minor" | "patch";
48
+ export declare function bumpVersion(version: string, level: BumpLevel): string | undefined;
49
+ /**
50
+ * Whether `version` satisfies `range`, for the forms first-party manifests
51
+ * use: exact, `^`, `~`, `>=`, `*`/`latest`/empty, and pnpm's `workspace:`
52
+ * forms, read as pnpm publishes them against `published` (the consumed
53
+ * package's version when the consumer was released). Undefined for anything
54
+ * else (`||`, `<`, `file:`, git URLs): read it by hand.
55
+ */
56
+ export declare function satisfies(version: string, range: string, published?: string): boolean | undefined;
57
+ export interface ImpactLink {
58
+ name: string;
59
+ capability: string;
60
+ repository: string;
61
+ version?: string;
62
+ /** the range the consumer declares (downstream) or this package declares (upstream) */
63
+ range: string;
64
+ }
65
+ export interface ImpactConsumer extends ImpactLink {
66
+ /** 1 for a direct consumer, 2 for a consumer of a consumer, … */
67
+ depth: number;
68
+ /** the consumer it is reached through, from depth 2 */
69
+ via?: string;
70
+ /** with a bump, depth 1: whether its range reaches the new version */
71
+ accepts?: boolean;
72
+ /** with a bump: what the consumer needs */
73
+ action?: string;
74
+ }
75
+ export interface ImpactAnswer {
76
+ package: {
77
+ name: string;
78
+ capability: string;
79
+ version?: string;
80
+ repository: string;
81
+ };
82
+ bump?: {
83
+ level: BumpLevel;
84
+ from: string;
85
+ to: string;
86
+ };
87
+ /** upstream: the first-party packages it consumes */
88
+ consumes: ImpactLink[];
89
+ /** downstream: who consumes it, directly or through others */
90
+ consumers: ImpactConsumer[];
91
+ }
92
+ /** The impact of a package, found by name (`@miadi/x`) or capability id; undefined when no reading names it. */
93
+ export declare function impactOf(packageOrCapability: string, packages: readonly PackageReading[], bump?: BumpLevel): ImpactAnswer | undefined;
94
+ //# 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;;;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAEZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,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