@open-agent-toolkit/cli 0.2.26 → 0.2.27
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/assets/NOTICES.md +156 -0
- package/assets/docs/contributing/explainer-kit-verification.md +125 -0
- package/assets/docs/contributing/index.md +1 -0
- package/assets/docs/reference/troubleshooting.md +47 -0
- package/assets/docs/workflows/projects/artifacts.md +24 -6
- package/assets/docs/workflows/skills/explainer-kit-providers.md +144 -0
- package/assets/docs/workflows/skills/explainer-kit.md +121 -69
- package/assets/docs/workflows/skills/index.md +1 -0
- package/assets/public-package-versions.json +4 -4
- package/assets/skills/explainer-kit/SKILL.md +18 -3
- package/assets/skills/explainer-kit/recipes/project-recap.json +43 -16
- package/assets/skills/explainer-kit/references/contracts.md +167 -20
- package/assets/skills/explainer-kit/references/golden-conformance.md +80 -0
- package/assets/skills/explainer-kit/references/visual-authoring.md +92 -0
- package/assets/skills/explainer-kit/references/visual-review.md +57 -0
- package/assets/skills/explainer-kit/schemas/author-request.v2.schema.json +172 -1
- package/assets/skills/explainer-kit/schemas/build-record.schema.json +7 -1
- package/assets/skills/explainer-kit/schemas/fact-base.schema.json +38 -2
- package/assets/skills/explainer-kit/schemas/manifest.schema.json +25 -1
- package/assets/skills/explainer-kit/schemas/run-request.schema.json +4 -0
- package/assets/skills/explainer-kit/schemas/set-plan.v1.schema.json +149 -0
- package/assets/skills/explainer-kit/schemas/visual-review-request.v1.schema.json +117 -0
- package/assets/skills/explainer-kit/schemas/visual-review-result.v1.schema.json +80 -0
- package/assets/skills/explainer-kit/scripts/lib/browser-runtime.mjs +148 -4
- package/assets/skills/explainer-kit/scripts/lib/catalog.mjs +243 -0
- package/assets/skills/explainer-kit/scripts/lib/contracts.mjs +586 -8
- package/assets/skills/explainer-kit/scripts/lib/diagram.mjs +285 -8
- package/assets/skills/explainer-kit/scripts/lib/durability.mjs +35 -0
- package/assets/skills/explainer-kit/scripts/lib/fact-base.mjs +144 -8
- package/assets/skills/explainer-kit/scripts/lib/package-coverage.mjs +379 -0
- package/assets/skills/explainer-kit/scripts/lib/png.mjs +287 -0
- package/assets/skills/explainer-kit/scripts/lib/qa.mjs +280 -8
- package/assets/skills/explainer-kit/scripts/lib/recipes.mjs +132 -3
- package/assets/skills/explainer-kit/scripts/lib/records.mjs +513 -21
- package/assets/skills/explainer-kit/scripts/lib/render.mjs +67 -3
- package/assets/skills/explainer-kit/scripts/lib/s3-static.mjs +43 -1
- package/assets/skills/explainer-kit/scripts/lib/set-plan.mjs +208 -0
- package/assets/skills/explainer-kit/scripts/lib/source-backlinks.mjs +218 -0
- package/assets/skills/explainer-kit/scripts/lib/visual-review.mjs +380 -0
- package/assets/skills/explainer-kit/scripts/render-qa.mjs +48 -10
- package/assets/skills/explainer-kit/scripts/run.mjs +859 -134
- package/assets/skills/oat-explainer-kit/SKILL.md +40 -12
- package/assets/skills/oat-explainer-kit/references/author-callback.md +12 -10
- package/assets/skills/oat-explainer-kit/references/lifecycle-contract.md +40 -2
- package/assets/skills/oat-explainer-kit/references/visual-review-callback.md +72 -0
- package/assets/skills/oat-explainer-kit/scripts/bind-project-sources.mjs +167 -5
- package/assets/skills/oat-explainer-kit/scripts/finalize-tracked-run.mjs +92 -5
- package/assets/skills/oat-explainer-kit/scripts/run.mjs +324 -2
- package/dist/commands/project/archive/archive-utils.d.ts +1 -0
- package/dist/commands/project/archive/archive-utils.d.ts.map +1 -1
- package/dist/commands/project/archive/archive-utils.js +109 -42
- package/dist/commands/project/archive/explainer-package-coverage.d.ts +14 -0
- package/dist/commands/project/archive/explainer-package-coverage.d.ts.map +1 -0
- package/dist/commands/project/archive/explainer-package-coverage.js +27 -0
- package/dist/commands/project/archive/explainer-source-backlinks.d.ts +18 -0
- package/dist/commands/project/archive/explainer-source-backlinks.d.ts.map +1 -0
- package/dist/commands/project/archive/explainer-source-backlinks.js +27 -0
- package/dist/commands/project/archive/push-runner.d.ts +2 -1
- package/dist/commands/project/archive/push-runner.d.ts.map +1 -1
- package/dist/commands/project/archive/push-runner.js +5 -1
- package/dist/release/public-package-contract.d.ts +6 -0
- package/dist/release/public-package-contract.d.ts.map +1 -1
- package/dist/release/public-package-contract.js +75 -0
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from './resolve-config.mjs';
|
|
13
13
|
import { resolveExplainerOutputRoot } from './resolve-paths.mjs';
|
|
14
14
|
|
|
15
|
-
const MINIMUM_CORE_VERSION = '2.0.
|
|
15
|
+
export const MINIMUM_CORE_VERSION = '2.0.3';
|
|
16
16
|
const ADAPTER_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
17
17
|
|
|
18
18
|
export async function runOatExplainer({
|
|
@@ -32,10 +32,18 @@ export async function runOatExplainer({
|
|
|
32
32
|
defaultMode,
|
|
33
33
|
renderStrategy,
|
|
34
34
|
retainRawArtDirection = false,
|
|
35
|
+
planSet,
|
|
36
|
+
planSetModulePath,
|
|
35
37
|
author,
|
|
36
38
|
authorModulePath,
|
|
37
39
|
critic,
|
|
38
40
|
criticModulePath,
|
|
41
|
+
browserSession,
|
|
42
|
+
browserSessionModulePath,
|
|
43
|
+
browserProbe,
|
|
44
|
+
browserProbeModulePath,
|
|
45
|
+
visualCritic,
|
|
46
|
+
visualCriticModulePath,
|
|
39
47
|
coreOptions = {},
|
|
40
48
|
}) {
|
|
41
49
|
const compatibility = await checkCoreCompatibility({
|
|
@@ -54,6 +62,14 @@ export async function runOatExplainer({
|
|
|
54
62
|
error.compatibility = compatibility;
|
|
55
63
|
throw error;
|
|
56
64
|
}
|
|
65
|
+
if (!supportsAdaptiveSetPlanning(compatibility.installedVersion)) {
|
|
66
|
+
const error = new Error(
|
|
67
|
+
`Installed explainer-kit ${compatibility.installedVersion} does not provide adaptive set planning. Run \`oat tools update --pack utility --scope user\`.`,
|
|
68
|
+
);
|
|
69
|
+
error.code = 'E_CORE_INCOMPATIBLE';
|
|
70
|
+
error.compatibility = compatibility;
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
57
73
|
|
|
58
74
|
const resolvedConfig = await resolveExplainerConfig({
|
|
59
75
|
repoRoot,
|
|
@@ -73,6 +89,7 @@ export async function runOatExplainer({
|
|
|
73
89
|
const projectRoot = resolve(repoRoot, activeProject);
|
|
74
90
|
const bound = await bindProjectSources({
|
|
75
91
|
projectRoot,
|
|
92
|
+
repoRoot,
|
|
76
93
|
recipe,
|
|
77
94
|
suppliedFactBasePath,
|
|
78
95
|
});
|
|
@@ -115,16 +132,53 @@ export async function runOatExplainer({
|
|
|
115
132
|
authorModulePath,
|
|
116
133
|
coreOptions,
|
|
117
134
|
});
|
|
135
|
+
const lifecycleSetPlanner = await resolveLifecycleSetPlanner({
|
|
136
|
+
planSet,
|
|
137
|
+
planSetModulePath,
|
|
138
|
+
coreOptions,
|
|
139
|
+
required: recipe === 'project-recap' && mode === 'unattended',
|
|
140
|
+
});
|
|
118
141
|
const lifecycleCritic = await resolveLifecycleCritic({
|
|
119
142
|
critic,
|
|
120
143
|
criticModulePath,
|
|
121
144
|
coreOptions,
|
|
122
145
|
});
|
|
146
|
+
const reviewProvidersRequired =
|
|
147
|
+
recipe === 'project-recap' && mode === 'unattended';
|
|
148
|
+
const lifecycleBrowserSession = await resolveLifecycleBrowserSession({
|
|
149
|
+
core,
|
|
150
|
+
browserSession,
|
|
151
|
+
browserSessionModulePath,
|
|
152
|
+
browserProbe,
|
|
153
|
+
browserProbeModulePath,
|
|
154
|
+
coreOptions,
|
|
155
|
+
required: reviewProvidersRequired,
|
|
156
|
+
});
|
|
157
|
+
const lifecycleVisualCritic = await resolveLifecycleVisualCritic({
|
|
158
|
+
visualCritic,
|
|
159
|
+
visualCriticModulePath,
|
|
160
|
+
coreOptions,
|
|
161
|
+
required: reviewProvidersRequired,
|
|
162
|
+
});
|
|
163
|
+
assertDistinctProviderRoles({
|
|
164
|
+
author: lifecycleAuthor,
|
|
165
|
+
factCritic: lifecycleCritic,
|
|
166
|
+
browserProbe: lifecycleBrowserSession?.probe,
|
|
167
|
+
visualCritic: lifecycleVisualCritic,
|
|
168
|
+
});
|
|
123
169
|
const result = await core.runExplainer(request, {
|
|
124
170
|
...coreOptions,
|
|
171
|
+
...(lifecycleSetPlanner && { planSet: lifecycleSetPlanner }),
|
|
125
172
|
...(lifecycleAuthor && { author: lifecycleAuthor }),
|
|
126
173
|
...(lifecycleCritic && { critic: lifecycleCritic }),
|
|
174
|
+
...(lifecycleBrowserSession && {
|
|
175
|
+
browserSession: lifecycleBrowserSession,
|
|
176
|
+
}),
|
|
177
|
+
...(lifecycleVisualCritic && { visualCritic: lifecycleVisualCritic }),
|
|
127
178
|
...(bound.sourceLoader && { sourceLoader: bound.sourceLoader }),
|
|
179
|
+
...(bound.sourceProvenance && {
|
|
180
|
+
sourceProvenance: bound.sourceProvenance,
|
|
181
|
+
}),
|
|
128
182
|
reviewedSource: bound.reviewedSource,
|
|
129
183
|
});
|
|
130
184
|
const criticContractError = result?.errors?.find(
|
|
@@ -145,6 +199,74 @@ export async function runOatExplainer({
|
|
|
145
199
|
};
|
|
146
200
|
}
|
|
147
201
|
|
|
202
|
+
export function supportsAdaptiveSetPlanning(version) {
|
|
203
|
+
if (typeof version !== 'string') return false;
|
|
204
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-|$)/);
|
|
205
|
+
if (!match) return false;
|
|
206
|
+
const [major, minor, patch] = match.slice(1).map(Number);
|
|
207
|
+
return (
|
|
208
|
+
major === 2 &&
|
|
209
|
+
(minor > 0 ||
|
|
210
|
+
(minor === 0 && patch >= Number(MINIMUM_CORE_VERSION.split('.')[2])))
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function resolveLifecycleSetPlanner({
|
|
215
|
+
planSet,
|
|
216
|
+
planSetModulePath,
|
|
217
|
+
coreOptions,
|
|
218
|
+
required,
|
|
219
|
+
}) {
|
|
220
|
+
if (coreOptions?.planSet !== undefined) {
|
|
221
|
+
throw new TypeError(
|
|
222
|
+
'coreOptions.planSet is not supported at the OAT adapter boundary; supply planSet directly.',
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
if (planSet !== undefined && typeof planSet !== 'function') {
|
|
226
|
+
throw new TypeError('planSet must be a function when supplied.');
|
|
227
|
+
}
|
|
228
|
+
if (planSet !== undefined && planSetModulePath !== undefined) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
'Supply only one provider-neutral set planner callback or set planner module entry point.',
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (planSet === undefined && planSetModulePath === undefined) {
|
|
234
|
+
if (!required) return null;
|
|
235
|
+
const error = new Error(
|
|
236
|
+
'Unattended OAT project recaps require exactly one provider-neutral set planner callback or set planner module entry point.',
|
|
237
|
+
);
|
|
238
|
+
error.code = 'E_SET_PLANNER_REQUIRED';
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
if (planSetModulePath === undefined) {
|
|
242
|
+
return planSet;
|
|
243
|
+
}
|
|
244
|
+
if (
|
|
245
|
+
typeof planSetModulePath !== 'string' ||
|
|
246
|
+
planSetModulePath.trim().length === 0
|
|
247
|
+
) {
|
|
248
|
+
throw new TypeError('planSetModulePath must be a non-empty path.');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let plannerModule;
|
|
252
|
+
try {
|
|
253
|
+
plannerModule = await import(
|
|
254
|
+
pathToFileURL(resolve(planSetModulePath.trim())).href
|
|
255
|
+
);
|
|
256
|
+
} catch (cause) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Unable to load provider-neutral set planner module at ${planSetModulePath}.`,
|
|
259
|
+
{ cause },
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
if (typeof plannerModule.planSet !== 'function') {
|
|
263
|
+
throw new TypeError(
|
|
264
|
+
'Provider-neutral set planner module must export a planSet function.',
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
return plannerModule.planSet;
|
|
268
|
+
}
|
|
269
|
+
|
|
148
270
|
async function resolveLifecycleAuthor({
|
|
149
271
|
author,
|
|
150
272
|
authorModulePath,
|
|
@@ -255,7 +377,7 @@ async function resolveLifecycleCritic({
|
|
|
255
377
|
if (!callback) {
|
|
256
378
|
return null;
|
|
257
379
|
}
|
|
258
|
-
|
|
380
|
+
const wrapped = async (request) => {
|
|
259
381
|
const result = await callback(request);
|
|
260
382
|
if (
|
|
261
383
|
!result ||
|
|
@@ -273,6 +395,206 @@ async function resolveLifecycleCritic({
|
|
|
273
395
|
}
|
|
274
396
|
return result;
|
|
275
397
|
};
|
|
398
|
+
return markProviderIdentity(wrapped, callback);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async function resolveLifecycleBrowserSession({
|
|
402
|
+
core,
|
|
403
|
+
browserSession,
|
|
404
|
+
browserSessionModulePath,
|
|
405
|
+
browserProbe,
|
|
406
|
+
browserProbeModulePath,
|
|
407
|
+
coreOptions,
|
|
408
|
+
required,
|
|
409
|
+
}) {
|
|
410
|
+
if (coreOptions?.browserProbe !== undefined) {
|
|
411
|
+
throw new TypeError(
|
|
412
|
+
'coreOptions.browserProbe is not supported at the OAT adapter boundary; supply browserSession directly.',
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
if (browserProbe !== undefined || browserProbeModulePath !== undefined) {
|
|
416
|
+
throw new TypeError(
|
|
417
|
+
'Bare browserProbe callbacks are not supported at the OAT adapter boundary; supply a branded browserSession created by createBrowserProbeSession().',
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (coreOptions?.browserSession !== undefined) {
|
|
421
|
+
throw new TypeError(
|
|
422
|
+
'coreOptions.browserSession is not supported at the OAT adapter boundary; supply browserSession directly.',
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
if (browserSession !== undefined && browserSessionModulePath !== undefined) {
|
|
426
|
+
throw new Error(
|
|
427
|
+
'Supply only one browser session descriptor or browser session module entry point.',
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
let resolvedSession = browserSession;
|
|
431
|
+
if (browserSessionModulePath !== undefined) {
|
|
432
|
+
if (
|
|
433
|
+
typeof browserSessionModulePath !== 'string' ||
|
|
434
|
+
browserSessionModulePath.trim().length === 0
|
|
435
|
+
) {
|
|
436
|
+
throw new TypeError('browserSessionModulePath must be a non-empty path.');
|
|
437
|
+
}
|
|
438
|
+
let sessionModule;
|
|
439
|
+
try {
|
|
440
|
+
sessionModule = await import(
|
|
441
|
+
pathToFileURL(resolve(browserSessionModulePath.trim())).href
|
|
442
|
+
);
|
|
443
|
+
} catch (cause) {
|
|
444
|
+
throw new Error(
|
|
445
|
+
`Unable to load browser session module at ${browserSessionModulePath}.`,
|
|
446
|
+
{ cause },
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
resolvedSession = sessionModule.browserSession;
|
|
450
|
+
}
|
|
451
|
+
if (!resolvedSession) {
|
|
452
|
+
if (!required) return null;
|
|
453
|
+
const error = new Error(
|
|
454
|
+
'Unattended OAT project recaps require exactly one branded launched-Chromium browser session descriptor or browser session module entry point.',
|
|
455
|
+
);
|
|
456
|
+
error.code = 'E_BROWSER_PROBE_REQUIRED';
|
|
457
|
+
throw error;
|
|
458
|
+
}
|
|
459
|
+
if (typeof core.assertBrowserProbeSession !== 'function') {
|
|
460
|
+
const error = new Error(
|
|
461
|
+
'Compatible explainer-kit does not export browser session validation.',
|
|
462
|
+
);
|
|
463
|
+
error.code = 'E_CORE_INCOMPATIBLE';
|
|
464
|
+
throw error;
|
|
465
|
+
}
|
|
466
|
+
try {
|
|
467
|
+
return core.assertBrowserProbeSession(resolvedSession, {
|
|
468
|
+
allowFixture: !required,
|
|
469
|
+
});
|
|
470
|
+
} catch (cause) {
|
|
471
|
+
const error = new Error(
|
|
472
|
+
`Browser session validation failed: ${cause?.message ?? String(cause)}`,
|
|
473
|
+
{ cause },
|
|
474
|
+
);
|
|
475
|
+
error.code = 'E_BROWSER_PROBE_REQUIRED';
|
|
476
|
+
throw error;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
async function resolveLifecycleVisualCritic({
|
|
481
|
+
visualCritic,
|
|
482
|
+
visualCriticModulePath,
|
|
483
|
+
coreOptions,
|
|
484
|
+
required,
|
|
485
|
+
}) {
|
|
486
|
+
if (coreOptions?.visualCritic !== undefined) {
|
|
487
|
+
throw new TypeError(
|
|
488
|
+
'coreOptions.visualCritic is not supported at the OAT adapter boundary; supply visualCritic directly.',
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
const callback = await resolveProviderCallback({
|
|
492
|
+
callback: visualCritic,
|
|
493
|
+
modulePath: visualCriticModulePath,
|
|
494
|
+
exportName: 'visualCritic',
|
|
495
|
+
label: 'visual critic',
|
|
496
|
+
});
|
|
497
|
+
if (!callback) {
|
|
498
|
+
if (!required) return null;
|
|
499
|
+
const error = new Error(
|
|
500
|
+
'Unattended OAT project recaps require exactly one provider-neutral visual critic callback or visual critic module entry point.',
|
|
501
|
+
);
|
|
502
|
+
error.code = 'E_VISUAL_CRITIC_REQUIRED';
|
|
503
|
+
throw error;
|
|
504
|
+
}
|
|
505
|
+
const wrapped = async (request, evidenceInput) => {
|
|
506
|
+
const result = await callback(request, evidenceInput);
|
|
507
|
+
if (
|
|
508
|
+
!result ||
|
|
509
|
+
typeof result !== 'object' ||
|
|
510
|
+
result.schemaVersion !== 'explainer-kit.visual-review-result/v1' ||
|
|
511
|
+
typeof result.reviewId !== 'string' ||
|
|
512
|
+
!/^[a-z0-9][a-z0-9._-]*$/.test(result.reviewId) ||
|
|
513
|
+
result.requestId !== request?.requestId ||
|
|
514
|
+
result.requestHash !== request?.requestHash ||
|
|
515
|
+
typeof result.reviewedAt !== 'string' ||
|
|
516
|
+
Number.isNaN(Date.parse(result.reviewedAt)) ||
|
|
517
|
+
!['pass', 'correct', 'fail'].includes(result.disposition) ||
|
|
518
|
+
!Array.isArray(result.artifactIds) ||
|
|
519
|
+
result.artifactIds.length !== request?.renderedArtifacts?.length ||
|
|
520
|
+
result.artifactIds.some(
|
|
521
|
+
(artifactId, index) =>
|
|
522
|
+
artifactId !== request.renderedArtifacts[index]?.artifactId,
|
|
523
|
+
) ||
|
|
524
|
+
!Array.isArray(result.findings) ||
|
|
525
|
+
result.findings.some((finding) => !finding || typeof finding !== 'object')
|
|
526
|
+
) {
|
|
527
|
+
throw new Error(
|
|
528
|
+
'Provider-neutral visual critic result does not match the visual review result contract.',
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
return result;
|
|
532
|
+
};
|
|
533
|
+
return markProviderIdentity(wrapped, callback);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async function resolveProviderCallback({
|
|
537
|
+
callback,
|
|
538
|
+
modulePath,
|
|
539
|
+
exportName,
|
|
540
|
+
label,
|
|
541
|
+
}) {
|
|
542
|
+
if (callback !== undefined && typeof callback !== 'function') {
|
|
543
|
+
throw new TypeError(`${exportName} must be a function when supplied.`);
|
|
544
|
+
}
|
|
545
|
+
if (callback !== undefined && modulePath !== undefined) {
|
|
546
|
+
throw new Error(
|
|
547
|
+
`Supply only one provider-neutral ${label} callback or ${label} module entry point.`,
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
if (modulePath === undefined) return callback ?? null;
|
|
551
|
+
if (typeof modulePath !== 'string' || modulePath.trim().length === 0) {
|
|
552
|
+
throw new TypeError(`${exportName}ModulePath must be a non-empty path.`);
|
|
553
|
+
}
|
|
554
|
+
let providerModule;
|
|
555
|
+
try {
|
|
556
|
+
providerModule = await import(
|
|
557
|
+
pathToFileURL(resolve(modulePath.trim())).href
|
|
558
|
+
);
|
|
559
|
+
} catch (cause) {
|
|
560
|
+
throw new Error(
|
|
561
|
+
`Unable to load provider-neutral ${label} module at ${modulePath}.`,
|
|
562
|
+
{ cause },
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
if (typeof providerModule[exportName] !== 'function') {
|
|
566
|
+
throw new TypeError(
|
|
567
|
+
`Provider-neutral ${label} module must export a ${exportName} function.`,
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
return providerModule[exportName];
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const PROVIDER_IDENTITY = Symbol('oat-explainer-provider-identity');
|
|
574
|
+
|
|
575
|
+
function markProviderIdentity(wrapper, callback) {
|
|
576
|
+
Object.defineProperty(wrapper, PROVIDER_IDENTITY, { value: callback });
|
|
577
|
+
return wrapper;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function providerIdentity(callback) {
|
|
581
|
+
return callback?.[PROVIDER_IDENTITY] ?? callback;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function assertDistinctProviderRoles(callbacks) {
|
|
585
|
+
const entries = Object.entries(callbacks).filter(([, callback]) => callback);
|
|
586
|
+
for (let left = 0; left < entries.length; left += 1) {
|
|
587
|
+
for (let right = left + 1; right < entries.length; right += 1) {
|
|
588
|
+
if (
|
|
589
|
+
providerIdentity(entries[left][1]) ===
|
|
590
|
+
providerIdentity(entries[right][1])
|
|
591
|
+
) {
|
|
592
|
+
throw new Error(
|
|
593
|
+
`Provider roles ${entries[left][0]} and ${entries[right][0]} must use distinct callback identities.`,
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
276
598
|
}
|
|
277
599
|
|
|
278
600
|
async function readManifest(result, request) {
|
|
@@ -151,6 +151,7 @@ export declare function resolveLocalArchiveProjectPath(projectsRoot: string, pro
|
|
|
151
151
|
export declare function resolvePrimaryRepoRoot(repoRoot: string, dependencies?: ResolvePrimaryRepoRootDependencies): Promise<string>;
|
|
152
152
|
export declare function resolveArchiveProjectTarget(options: ResolveArchiveProjectTargetOptions, dependencies?: ResolveArchiveProjectTargetDependencies): Promise<ArchiveProjectTarget>;
|
|
153
153
|
export declare function assertDurableArchiveProjectTarget(target: ArchiveProjectTarget): void;
|
|
154
|
+
export declare function verifySelectedProjectRecapForArchive(projectPath: string, projectRecapRun: string): Promise<void>;
|
|
154
155
|
export declare function archiveProjectOnCompletion(options: ArchiveProjectOnCompletionOptions, dependencies?: ArchiveProjectOnCompletionDependencies): Promise<ArchiveProjectOnCompletionResult>;
|
|
155
156
|
export declare function ensureS3ArchiveAccess(options: EnsureS3ArchiveAccessOptions, dependencies?: EnsureS3ArchiveAccessDependencies): Promise<EnsureS3ArchiveAccessResult>;
|
|
156
157
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-utils.d.ts","sourceRoot":"","sources":["../../../../src/commands/project/archive/archive-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,MAAM,EAGP,MAAM,kBAAkB,CAAC;AAc1B,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACX,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"archive-utils.d.ts","sourceRoot":"","sources":["../../../../src/commands/project/archive/archive-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,MAAM,EAGP,MAAM,kBAAkB,CAAC;AAc1B,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACX,MAAM,QAAQ,CAAC;AAUhB,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,KAChD,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,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AAujBD,wBAAsB,oCAAoC,CACxD,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAEf;AA4ED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,iCAAiC,EAC1C,YAAY,GAAE,sCAA2C,GACxD,OAAO,CAAC,gCAAgC,CAAC,CAwH3C;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,EACrC,YAAY,GAAE,iCAAsC,GACnD,OAAO,CAAC,2BAA2B,CAAC,CA+CtC"}
|
|
@@ -5,6 +5,8 @@ import { basename, dirname, isAbsolute, join, posix as path, relative, resolve,
|
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
6
|
import { CliError } from '../../../errors/cli-error.js';
|
|
7
7
|
import { copyDirectory, copySingleFile, dirExists, ensureDir, fileExists, } from '../../../fs/io.js';
|
|
8
|
+
import { loadExplainerPackageCoverage } from './explainer-package-coverage.js';
|
|
9
|
+
import { loadExplainerSourceBacklinks, } from './explainer-source-backlinks.js';
|
|
8
10
|
const execFileAsync = promisify(execFileCallback);
|
|
9
11
|
export const ARCHIVE_SNAPSHOT_METADATA_FILENAME = '.oat-archive-source.json';
|
|
10
12
|
/**
|
|
@@ -281,7 +283,7 @@ async function exportProjectSummary(archivePath, snapshotName, summaryExportPath
|
|
|
281
283
|
await copySummary(summarySource, summaryTarget);
|
|
282
284
|
return summaryTarget;
|
|
283
285
|
}
|
|
284
|
-
function parseProjectRecapManifest(contents) {
|
|
286
|
+
async function parseProjectRecapManifest(contents) {
|
|
285
287
|
let value;
|
|
286
288
|
try {
|
|
287
289
|
value = JSON.parse(contents);
|
|
@@ -289,43 +291,13 @@ function parseProjectRecapManifest(contents) {
|
|
|
289
291
|
catch {
|
|
290
292
|
throw new CliError('Selected project recap has an invalid manifest.json.');
|
|
291
293
|
}
|
|
292
|
-
|
|
294
|
+
const sourceBacklinks = await loadExplainerSourceBacklinks();
|
|
295
|
+
if (!isProjectRecapManifestV1(value, sourceBacklinks)) {
|
|
293
296
|
throw new CliError('Selected project recap manifest does not match the explainer-kit manifest contract.');
|
|
294
297
|
}
|
|
295
|
-
const requiredProvenancePaths = [
|
|
296
|
-
'run-request.json',
|
|
297
|
-
'source/content-approval.json',
|
|
298
|
-
];
|
|
299
|
-
const recordedImmutablePaths = Object.keys(value.immutableHashes);
|
|
300
|
-
const missingLegacyPaths = requiredProvenancePaths.filter((relativePath) => !(relativePath in value.immutableHashes));
|
|
301
|
-
if (missingLegacyPaths.length > 0) {
|
|
302
|
-
throw new CliError(`Selected project recap uses a legacy manifest missing immutable coverage for ${missingLegacyPaths.join(', ')}; regenerate the recap package before archival.`);
|
|
303
|
-
}
|
|
304
|
-
const expectedImmutablePaths = new Set([
|
|
305
|
-
...requiredProvenancePaths,
|
|
306
|
-
value.source.factBasePath,
|
|
307
|
-
'source/fact-base.md',
|
|
308
|
-
...(value.source.authorResultPaths ?? []),
|
|
309
|
-
value.theme.path,
|
|
310
|
-
...value.artifacts.flatMap((artifact) => [
|
|
311
|
-
artifact.contentPath,
|
|
312
|
-
...(artifact.status === 'built' &&
|
|
313
|
-
typeof artifact.renderedPath === 'string'
|
|
314
|
-
? [artifact.renderedPath]
|
|
315
|
-
: []),
|
|
316
|
-
]),
|
|
317
|
-
]);
|
|
318
|
-
if (expectedImmutablePaths.size === 0 ||
|
|
319
|
-
expectedImmutablePaths.size !== recordedImmutablePaths.length ||
|
|
320
|
-
[...expectedImmutablePaths].some((relativePath) => !(relativePath in value.immutableHashes)) ||
|
|
321
|
-
value.artifacts.some((artifact) => artifact.status === 'built' &&
|
|
322
|
-
typeof artifact.renderedPath === 'string' &&
|
|
323
|
-
artifact.hash !== value.immutableHashes[artifact.renderedPath])) {
|
|
324
|
-
throw new CliError('Selected project recap manifest immutable hashes do not cover the complete v1 package.');
|
|
325
|
-
}
|
|
326
298
|
return value;
|
|
327
299
|
}
|
|
328
|
-
function isProjectRecapManifestV1(value) {
|
|
300
|
+
function isProjectRecapManifestV1(value, sourceBacklinks) {
|
|
329
301
|
if (!isRecord(value) ||
|
|
330
302
|
!hasExactKeys(value, [
|
|
331
303
|
'schemaVersion',
|
|
@@ -351,12 +323,14 @@ function isProjectRecapManifestV1(value) {
|
|
|
351
323
|
!isNonEmptyString(value.recipe.id) ||
|
|
352
324
|
!isNonEmptyString(value.recipe.version) ||
|
|
353
325
|
!isRecord(value.source) ||
|
|
354
|
-
!hasExactKeys(value.source, ['factBasePath', 'factBaseHash', 'inputHashes'], ['sourceRevision', 'authorResultPaths']) ||
|
|
326
|
+
!hasExactKeys(value.source, ['factBasePath', 'factBaseHash', 'inputHashes'], ['sourceRevision', 'authorResultPaths', 'backlinks']) ||
|
|
355
327
|
!isSafeRelativePath(value.source.factBasePath) ||
|
|
356
328
|
!isSha256(value.source.factBaseHash) ||
|
|
357
329
|
!isHashMap(value.source.inputHashes) ||
|
|
358
330
|
(value.source.authorResultPaths !== undefined &&
|
|
359
331
|
!isUniqueSafePathArray(value.source.authorResultPaths)) ||
|
|
332
|
+
(value.source.backlinks !== undefined &&
|
|
333
|
+
!isCanonicalSourceBacklinks(value.source.backlinks, sourceBacklinks)) ||
|
|
360
334
|
(value.source.sourceRevision !== undefined &&
|
|
361
335
|
!isNonEmptyString(value.source.sourceRevision)) ||
|
|
362
336
|
!isRecord(value.theme) ||
|
|
@@ -369,7 +343,13 @@ function isProjectRecapManifestV1(value) {
|
|
|
369
343
|
new Set(value.artifacts.map((artifact) => JSON.stringify(artifact)))
|
|
370
344
|
.size !== value.artifacts.length ||
|
|
371
345
|
!isHashMap(value.immutableHashes) ||
|
|
372
|
-
![
|
|
346
|
+
![
|
|
347
|
+
'built-durable',
|
|
348
|
+
'built-not-durable',
|
|
349
|
+
'built-needs-review',
|
|
350
|
+
'failed',
|
|
351
|
+
'incomplete',
|
|
352
|
+
].includes(String(value.outcome)) ||
|
|
373
353
|
!isPathHashRecord(value.buildRecord, 'build-record.json') ||
|
|
374
354
|
(value.publishReceipt !== undefined &&
|
|
375
355
|
!isPathHashRecord(value.publishReceipt, 'publish-receipt.json')) ||
|
|
@@ -451,6 +431,32 @@ function isHashMap(value) {
|
|
|
451
431
|
return (isRecord(value) &&
|
|
452
432
|
Object.entries(value).every(([relativePath, hash]) => isSafeRelativePath(relativePath) && isSha256(hash)));
|
|
453
433
|
}
|
|
434
|
+
function isCanonicalSourceBacklinks(value, sourceBacklinks) {
|
|
435
|
+
if (!Array.isArray(value)) {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
const identities = new Set();
|
|
439
|
+
for (const backlink of value) {
|
|
440
|
+
if (!isRecord(backlink) ||
|
|
441
|
+
!hasExactKeys(backlink, ['sourceId', 'url']) ||
|
|
442
|
+
!isNonEmptyString(backlink.sourceId) ||
|
|
443
|
+
typeof backlink.url !== 'string') {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
try {
|
|
447
|
+
sourceBacklinks.parseCanonicalGithubBlobUrl(backlink.url);
|
|
448
|
+
}
|
|
449
|
+
catch {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
const identity = `${backlink.sourceId}\0${backlink.url}`;
|
|
453
|
+
if (identities.has(identity)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
identities.add(identity);
|
|
457
|
+
}
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
454
460
|
function isUniqueSafePathArray(value) {
|
|
455
461
|
return (Array.isArray(value) &&
|
|
456
462
|
value.length > 0 &&
|
|
@@ -544,17 +550,78 @@ async function verifyProjectRecapImmutableHashes(stagedRoot, manifest) {
|
|
|
544
550
|
}
|
|
545
551
|
return entries.length;
|
|
546
552
|
}
|
|
553
|
+
async function readVerifiedRunMode(runRoot) {
|
|
554
|
+
let request;
|
|
555
|
+
try {
|
|
556
|
+
request = JSON.parse(await readFile(join(runRoot, 'run-request.json'), 'utf8'));
|
|
557
|
+
}
|
|
558
|
+
catch {
|
|
559
|
+
throw new CliError('Hash-verified project recap run-request.json must contain valid JSON.');
|
|
560
|
+
}
|
|
561
|
+
if (!isRecord(request) ||
|
|
562
|
+
(request.mode !== 'interactive' && request.mode !== 'unattended')) {
|
|
563
|
+
throw new CliError('Hash-verified project recap run-request.json must declare interactive or unattended mode.');
|
|
564
|
+
}
|
|
565
|
+
return request.mode;
|
|
566
|
+
}
|
|
567
|
+
async function loadVerifiedProjectRecap(projectPath, projectRecapRun) {
|
|
568
|
+
const sourceRunRoot = await resolveSelectedProjectRecapRun(projectPath, projectRecapRun);
|
|
569
|
+
const manifestContents = await readFile(join(sourceRunRoot, 'manifest.json'), 'utf8');
|
|
570
|
+
const manifest = await parseProjectRecapManifest(manifestContents);
|
|
571
|
+
if (manifest.recipe.id !== 'project-recap') {
|
|
572
|
+
throw new CliError('Selected project recap manifest recipe must be exactly `project-recap`.');
|
|
573
|
+
}
|
|
574
|
+
if (manifest.outcome === 'built-needs-review') {
|
|
575
|
+
throw new CliError('Selected project recap is built-needs-review and requires a passing visual review before archival.');
|
|
576
|
+
}
|
|
577
|
+
const verifiedArtifactCount = await verifyProjectRecapImmutableHashes(sourceRunRoot, manifest);
|
|
578
|
+
const runMode = await readVerifiedRunMode(sourceRunRoot);
|
|
579
|
+
const packageCoverage = await loadExplainerPackageCoverage();
|
|
580
|
+
const missingCoverage = packageCoverage
|
|
581
|
+
.requiredImmutablePackagePaths(manifest, { runMode })
|
|
582
|
+
.filter((relativePath) => !(relativePath in manifest.immutableHashes));
|
|
583
|
+
const missingLegacyCoverage = missingCoverage.filter((relativePath) => ['run-request.json', 'source/content-approval.json'].includes(relativePath));
|
|
584
|
+
if (missingLegacyCoverage.length > 0) {
|
|
585
|
+
throw new CliError(`Selected project recap uses a legacy manifest missing immutable coverage for ${missingLegacyCoverage.join(', ')}; regenerate the recap package before archival.`);
|
|
586
|
+
}
|
|
587
|
+
if (missingCoverage.some((relativePath) => relativePath.startsWith('qa/browser/') ||
|
|
588
|
+
relativePath.startsWith('qa/visual-review/'))) {
|
|
589
|
+
throw new CliError('Selected project recap manifest has an incomplete visual-review evidence chain.');
|
|
590
|
+
}
|
|
591
|
+
if (missingCoverage.length > 0) {
|
|
592
|
+
throw new CliError(`Selected project recap manifest immutable hashes do not cover the complete v2 package: ${missingCoverage.join(', ')}.`);
|
|
593
|
+
}
|
|
594
|
+
try {
|
|
595
|
+
await packageCoverage.validateImmutablePackageEvidence(manifest, {
|
|
596
|
+
runMode,
|
|
597
|
+
read: (relativePath) => readFile(join(sourceRunRoot, relativePath)),
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
throw new CliError(`Selected project recap browser evidence contract is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
602
|
+
}
|
|
603
|
+
if (manifest.artifacts.some((artifact) => artifact.status === 'built' &&
|
|
604
|
+
typeof artifact.renderedPath === 'string' &&
|
|
605
|
+
artifact.hash !== manifest.immutableHashes[artifact.renderedPath])) {
|
|
606
|
+
throw new CliError('Selected project recap artifact hashes do not match the immutable package.');
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
sourceRunRoot,
|
|
610
|
+
manifestContents,
|
|
611
|
+
manifest,
|
|
612
|
+
verifiedArtifactCount,
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
export async function verifySelectedProjectRecapForArchive(projectPath, projectRecapRun) {
|
|
616
|
+
await loadVerifiedProjectRecap(projectPath, projectRecapRun);
|
|
617
|
+
}
|
|
547
618
|
async function exportSelectedProjectRecap(options, snapshotName, dependencies) {
|
|
548
619
|
const selectedRun = options.projectRecapRun?.trim();
|
|
549
620
|
if (!selectedRun) {
|
|
550
621
|
return null;
|
|
551
622
|
}
|
|
552
|
-
const
|
|
553
|
-
const
|
|
554
|
-
const sourceManifest = parseProjectRecapManifest(sourceManifestContents);
|
|
555
|
-
if (sourceManifest.recipe.id !== 'project-recap') {
|
|
556
|
-
throw new CliError('Selected project recap manifest recipe must be exactly `project-recap`.');
|
|
557
|
-
}
|
|
623
|
+
const verified = await loadVerifiedProjectRecap(options.projectPath, selectedRun);
|
|
624
|
+
const { sourceRunRoot, manifestContents: sourceManifestContents, manifest: sourceManifest, } = verified;
|
|
558
625
|
const exportRoot = join(options.repoRoot, '.oat', 'repo', 'reference', 'project-recaps', snapshotName);
|
|
559
626
|
if (await pathExists(exportRoot)) {
|
|
560
627
|
throw new CliError(`Project recap export destination \`${exportRoot}\` already exists; refusing to overwrite it.`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const PACKAGE_COVERAGE_VERSION = "explainer-kit.package-coverage/v2";
|
|
2
|
+
export interface ExplainerPackageCoverage {
|
|
3
|
+
PACKAGE_COVERAGE_VERSION: typeof PACKAGE_COVERAGE_VERSION;
|
|
4
|
+
requiredImmutablePackagePaths: (manifest: unknown, options?: {
|
|
5
|
+
runMode?: 'interactive' | 'unattended';
|
|
6
|
+
}) => string[];
|
|
7
|
+
validateImmutablePackageEvidence: (manifest: unknown, options: {
|
|
8
|
+
runMode?: 'interactive' | 'unattended';
|
|
9
|
+
read: (path: string) => Promise<Buffer | string>;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadExplainerPackageCoverage(): Promise<ExplainerPackageCoverage>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=explainer-package-coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explainer-package-coverage.d.ts","sourceRoot":"","sources":["../../../../src/commands/project/archive/explainer-package-coverage.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,wBAAwB,sCAAsC,CAAC;AAErE,MAAM,WAAW,wBAAwB;IACvC,wBAAwB,EAAE,OAAO,wBAAwB,CAAC;IAC1D,6BAA6B,EAAE,CAC7B,QAAQ,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAAA;KAAE,KACjD,MAAM,EAAE,CAAC;IACd,gCAAgC,EAAE,CAChC,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;QACvC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;KAClD,KACE,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAID,wBAAgB,4BAA4B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAGhF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { CliError } from '../../../errors/cli-error.js';
|
|
4
|
+
import { resolveAssetsRoot } from '../../../fs/assets.js';
|
|
5
|
+
const PACKAGE_COVERAGE_VERSION = 'explainer-kit.package-coverage/v2';
|
|
6
|
+
let cachedCoverage;
|
|
7
|
+
export function loadExplainerPackageCoverage() {
|
|
8
|
+
cachedCoverage ??= loadGeneratedCoverage();
|
|
9
|
+
return cachedCoverage;
|
|
10
|
+
}
|
|
11
|
+
async function loadGeneratedCoverage() {
|
|
12
|
+
const assetsRoot = await resolveAssetsRoot();
|
|
13
|
+
const modulePath = join(assetsRoot, 'skills', 'explainer-kit', 'scripts', 'lib', 'package-coverage.mjs');
|
|
14
|
+
let loaded;
|
|
15
|
+
try {
|
|
16
|
+
loaded = (await import(pathToFileURL(modulePath).href));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new CliError(`Bundled explainer package coverage could not be loaded: ${error instanceof Error ? error.message : String(error)}`, 2);
|
|
20
|
+
}
|
|
21
|
+
if (loaded.PACKAGE_COVERAGE_VERSION !== PACKAGE_COVERAGE_VERSION ||
|
|
22
|
+
typeof loaded.requiredImmutablePackagePaths !== 'function' ||
|
|
23
|
+
typeof loaded.validateImmutablePackageEvidence !== 'function') {
|
|
24
|
+
throw new CliError(`Bundled assets must provide ${PACKAGE_COVERAGE_VERSION} package coverage.`, 2);
|
|
25
|
+
}
|
|
26
|
+
return loaded;
|
|
27
|
+
}
|