@hawkeyexl/manni 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-HNPRXGD7.js → chunk-7QVYG66K.js} +369 -16
- package/dist/chunk-7QVYG66K.js.map +1 -0
- package/dist/{chunk-2DC2GSRH.js → chunk-UCLMW3RE.js} +7167 -4683
- package/dist/chunk-UCLMW3RE.js.map +1 -0
- package/dist/{chunk-UTXTVCBV.js → chunk-ZWPVZUJI.js} +82 -73
- package/dist/chunk-ZWPVZUJI.js.map +1 -0
- package/dist/cli.js +4080 -76
- package/dist/cli.js.map +1 -1
- package/dist/docmeta.js +2 -2
- package/dist/index.d.ts +936 -723
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-2DC2GSRH.js.map +0 -1
- package/dist/chunk-HNPRXGD7.js.map +0 -1
- package/dist/chunk-UTXTVCBV.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -128,14 +128,6 @@ interface MetadataExtractor {
|
|
|
128
128
|
name: string;
|
|
129
129
|
/** Lowercase file extensions this extractor handles, incl. dot (e.g. ".md"). */
|
|
130
130
|
extensions: string[];
|
|
131
|
-
/**
|
|
132
|
-
* Whether this extractor can *read* — false for a format that is registered
|
|
133
|
-
* but not yet wired up. Every registered extractor sets it true today; it is
|
|
134
|
-
* kept because it is a distinct capability from writability, which is the
|
|
135
|
-
* presence of `apply`. A format can read without writing, and one being
|
|
136
|
-
* added could be declared before it can do either.
|
|
137
|
-
*/
|
|
138
|
-
implemented: boolean;
|
|
139
131
|
/**
|
|
140
132
|
* Extract metadata from raw file content.
|
|
141
133
|
*
|
|
@@ -358,6 +350,16 @@ declare function selectCollections(collections: readonly CollectionConfig[], nam
|
|
|
358
350
|
*/
|
|
359
351
|
declare function isMember(collection: CollectionConfig, relPath: string): boolean;
|
|
360
352
|
|
|
353
|
+
/** Vale's settings under `tools.vale`. */
|
|
354
|
+
interface ValeToolConfig {
|
|
355
|
+
/** Vale's config file, as written, relative to `manni.config.yaml`. */
|
|
356
|
+
config?: string;
|
|
357
|
+
}
|
|
358
|
+
/** The document's top-level `tools:`, one namespace per outside tool. */
|
|
359
|
+
interface ToolsConfig {
|
|
360
|
+
vale?: ValeToolConfig;
|
|
361
|
+
}
|
|
362
|
+
|
|
361
363
|
interface ConfigFile {
|
|
362
364
|
/** Absolute path to the file. */
|
|
363
365
|
path: string;
|
|
@@ -387,6 +389,12 @@ interface ConfigFile {
|
|
|
387
389
|
* document *is* the tool's section, so it carries no family-wide keys.
|
|
388
390
|
*/
|
|
389
391
|
collections: CollectionConfig[];
|
|
392
|
+
/**
|
|
393
|
+
* The document's top-level `tools:` (proposal 0052), an outside tool's
|
|
394
|
+
* settings, parsed once here for the same reason as `collections`. `{}` when
|
|
395
|
+
* the key is absent, and always `{}` for a `legacy` file.
|
|
396
|
+
*/
|
|
397
|
+
tools: ToolsConfig;
|
|
390
398
|
/**
|
|
391
399
|
* The document's top-level `encryptionKey:` (proposal 0045), validated
|
|
392
400
|
* here. Absent when the key is, and always absent for a `legacy` file, for
|
|
@@ -703,6 +711,14 @@ interface DerivedField {
|
|
|
703
711
|
* reports it, when one does. `derive` writes there, never into the page.
|
|
704
712
|
*/
|
|
705
713
|
manifest?: string;
|
|
714
|
+
/**
|
|
715
|
+
* Proposal 0047: the manifest a field other than `provenance` is written
|
|
716
|
+
* into, as the run reports it, when a manifest of the page's collections
|
|
717
|
+
* owns the key. Absent when the value goes to the page.
|
|
718
|
+
*/
|
|
719
|
+
destination?: string;
|
|
720
|
+
/** The 1-based line of the key in `destination` after the write. Absent under `dryRun` and `check`. */
|
|
721
|
+
destinationLine?: number;
|
|
706
722
|
}
|
|
707
723
|
/**
|
|
708
724
|
* The `schema` ref a stale-field finding carries, and so its baseline and
|
|
@@ -728,9 +744,14 @@ declare function compareDerived(field: DerivableField, asserted: unknown, derive
|
|
|
728
744
|
* field that is `stale` or `unset`. Current and unknown fields file nothing.
|
|
729
745
|
*
|
|
730
746
|
* `lineFor` is the document's own pointer lookup, so a finding lands on the
|
|
731
|
-
* line the asserted key sits on; an unset field has no line.
|
|
747
|
+
* line the asserted key sits on; an unset field has no line. `locate` answers
|
|
748
|
+
* for a value a manifest supplied (proposal 0047): the finding then names the
|
|
749
|
+
* manifest and its line, as every other manifest finding does.
|
|
732
750
|
*/
|
|
733
|
-
declare function staleFindings(fields: readonly DerivedField[], lineFor: (pointer: string) => number | undefined
|
|
751
|
+
declare function staleFindings(fields: readonly DerivedField[], lineFor: (pointer: string) => number | undefined, locate?: (pointer: string) => {
|
|
752
|
+
file: string;
|
|
753
|
+
line?: number;
|
|
754
|
+
} | undefined): FieldError[];
|
|
734
755
|
|
|
735
756
|
interface SchemaOverride {
|
|
736
757
|
/**
|
|
@@ -1367,183 +1388,205 @@ declare function runGet(opts: GetOptions): Promise<GetFileResult[]>;
|
|
|
1367
1388
|
/** Ask a yes/no question; `true` only for a yes. */
|
|
1368
1389
|
type Confirm = (question: string) => Promise<boolean>;
|
|
1369
1390
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
|
|
1399
|
-
/** Permit an input set that resolves to zero files (see `assertNonEmpty`). */
|
|
1400
|
-
allowEmpty?: boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* The `schema` ref a collision finding carries, and so its baseline and rule
|
|
1393
|
+
* identity: `external:owned/external`. Shaped like `check:<name>` so
|
|
1394
|
+
* `classifyRef` passes it through as a built-in id rather than resolving it
|
|
1395
|
+
* as a cwd-relative file path, and reserved in the registry for the same
|
|
1396
|
+
* reason `check` is.
|
|
1397
|
+
*/
|
|
1398
|
+
declare const EXTERNAL_OWNED_SCHEMA = "external:owned";
|
|
1399
|
+
/**
|
|
1400
|
+
* The `schema` ref of a duplicate-join finding (0039): two documents carry
|
|
1401
|
+
* the same value of a join field, so one manifest entry matched both.
|
|
1402
|
+
*/
|
|
1403
|
+
declare const EXTERNAL_DUPLICATE_SCHEMA = "external:duplicate";
|
|
1404
|
+
/**
|
|
1405
|
+
* The `keyword` every external-metadata finding carries: no Ajv keyword
|
|
1406
|
+
* produced it.
|
|
1407
|
+
*/
|
|
1408
|
+
declare const EXTERNAL_KEYWORD = "external";
|
|
1409
|
+
/** The join that names documents by path, and the default. */
|
|
1410
|
+
declare const PATH_JOIN = "path";
|
|
1411
|
+
/** One value a manifest supplied, and where it was written. */
|
|
1412
|
+
interface ExternalMetadataValue {
|
|
1413
|
+
value: unknown;
|
|
1414
|
+
/** The collection whose manifest supplied it (proposal 0041). */
|
|
1415
|
+
collection: string;
|
|
1416
|
+
/** Manifest path as the run reports it: relative to the run's base, posix — or the URL. */
|
|
1417
|
+
file: string;
|
|
1418
|
+
/** 1-based line of the key in the manifest, when known. */
|
|
1419
|
+
line?: number;
|
|
1401
1420
|
/**
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1421
|
+
* 1-based manifest line of every node inside `value`, keyed by the JSON
|
|
1422
|
+
* Pointer relative to `value` (`/2/source/file`). A mapping member sits on
|
|
1423
|
+
* its key's line, and a list item on the line its node starts. Present only
|
|
1424
|
+
* when `value` is a mapping or a list with members; `line` answers for the
|
|
1425
|
+
* value itself.
|
|
1404
1426
|
*/
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1427
|
+
lines?: ReadonlyMap<string, number>;
|
|
1428
|
+
}
|
|
1429
|
+
/** One manifest entry, for the orphan checks. */
|
|
1430
|
+
interface ExternalMetadataEntry {
|
|
1431
|
+
/** The collection whose manifest declared it (proposal 0041). */
|
|
1432
|
+
collection: string;
|
|
1433
|
+
/** `path`, or the frontmatter field this entry is keyed by. */
|
|
1434
|
+
join: string;
|
|
1435
|
+
/** Absolute document path, for a path entry. */
|
|
1436
|
+
abs?: string;
|
|
1437
|
+
/** The key exactly as written in the manifest. */
|
|
1438
|
+
spelled: string;
|
|
1439
|
+
/** Manifest path as the run reports it. */
|
|
1440
|
+
file: string;
|
|
1441
|
+
/** 1-based line of the entry in the manifest, when known. */
|
|
1442
|
+
line?: number;
|
|
1443
|
+
}
|
|
1444
|
+
/** Every manifest of a run, loaded once and consulted per document. */
|
|
1445
|
+
interface ExternalMetadataIndex {
|
|
1410
1446
|
/**
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1447
|
+
* Owned key -> every collection that owns it, with the manifest that does.
|
|
1448
|
+
*
|
|
1449
|
+
* A list rather than one entry, because two collections may legitimately
|
|
1450
|
+
* each own the same key (0041 rule 5): `guides` and `blog` can both supply
|
|
1451
|
+
* `owner`. Ambiguity only exists for a file that is a member of both, which
|
|
1452
|
+
* is decided per file in `mergeExternalMetadata`.
|
|
1416
1453
|
*/
|
|
1454
|
+
owners: ReadonlyMap<string, readonly {
|
|
1455
|
+
collection: string;
|
|
1456
|
+
file: string;
|
|
1457
|
+
}[]>;
|
|
1458
|
+
/** Path-joined manifests: absolute document path -> owned key -> value. */
|
|
1459
|
+
byPath: ReadonlyMap<string, ReadonlyMap<string, ExternalMetadataValue>>;
|
|
1460
|
+
/** Field-joined manifests: field -> value -> owned key -> value. */
|
|
1461
|
+
byField: ReadonlyMap<string, ReadonlyMap<string, ReadonlyMap<string, ExternalMetadataValue>>>;
|
|
1462
|
+
/** Every manifest entry, in manifest order. */
|
|
1463
|
+
entries: readonly ExternalMetadataEntry[];
|
|
1464
|
+
}
|
|
1465
|
+
interface LoadExternalMetadataOptions {
|
|
1466
|
+
/** Directory `externalMetadata[].file` and every manifest key resolve from. */
|
|
1467
|
+
configDir: string;
|
|
1468
|
+
/** Directory the run's file labels are relative to; manifests are reported the same way. */
|
|
1469
|
+
base: string;
|
|
1470
|
+
/** `--offline` / `offline:`: a URL manifest is refused rather than fetched (0038). */
|
|
1417
1471
|
offline?: boolean;
|
|
1472
|
+
/** Network timeout for a URL manifest; the schema fetch's default otherwise. */
|
|
1473
|
+
timeoutMs?: number;
|
|
1474
|
+
/** For tests: the environment `tokenEnv` is read from. */
|
|
1475
|
+
env?: Record<string, string | undefined>;
|
|
1476
|
+
}
|
|
1477
|
+
/** A place a merged value lives, for a finding that must name it. */
|
|
1478
|
+
interface SourceLocation {
|
|
1479
|
+
file: string;
|
|
1480
|
+
line?: number;
|
|
1481
|
+
col?: number;
|
|
1482
|
+
}
|
|
1483
|
+
/** A key the document carries that a manifest owns. */
|
|
1484
|
+
interface ExternalMetadataCollision {
|
|
1485
|
+
key: string;
|
|
1486
|
+
/** The owning manifest, as the run reports it. */
|
|
1487
|
+
file: string;
|
|
1488
|
+
/** The collection that manifest belongs to (proposal 0041). */
|
|
1489
|
+
collection: string;
|
|
1490
|
+
}
|
|
1491
|
+
/** A field-joined entry a document matched (0039). */
|
|
1492
|
+
interface ExternalMetadataJoin {
|
|
1493
|
+
field: string;
|
|
1494
|
+
/** The value matched: the field's plaintext, decrypted first when the page holds it encrypted. */
|
|
1495
|
+
value: string;
|
|
1418
1496
|
/**
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
*/
|
|
1423
|
-
cache?: boolean;
|
|
1424
|
-
/**
|
|
1425
|
-
* `--dry-run`: preview the statement's per-file changes — the diff it
|
|
1426
|
-
* would make, files untouched. Without it a mutating statement applies,
|
|
1427
|
-
* matching `fill`'s convention (proposal 0025; 0022 recorded the original
|
|
1428
|
-
* preview-by-default surface this revises).
|
|
1429
|
-
*/
|
|
1430
|
-
dryRun?: boolean;
|
|
1431
|
-
/**
|
|
1432
|
-
* Values for the statement's named parameters (`$name`, `:name`, `@name`),
|
|
1433
|
-
* keyed by bare name (a `$`/`:`/`@` prefix on a key is tolerated). Each
|
|
1434
|
-
* value passes through the same `bindValue` the projection loader uses —
|
|
1435
|
-
* booleans become 1/0, arrays and objects JSON text — so a bound parameter
|
|
1436
|
-
* compares against a stored cell under exactly the encoding the cell got
|
|
1437
|
-
* (proposal 0029). A parameter the SQL references with no entry here
|
|
1438
|
-
* refuses: unbound would silently bind NULL and match nothing.
|
|
1439
|
-
*/
|
|
1440
|
-
params?: Record<string, unknown>;
|
|
1441
|
-
/**
|
|
1442
|
-
* `-s/--schema`, repeatable: the schema set the run's DDL evolves — CLI
|
|
1443
|
-
* precedence for the DDL planner *only* (proposal 0030). The per-file
|
|
1444
|
-
* resolution walk is skipped and the deduped refs are the set; every guard
|
|
1445
|
-
* inside the set (single local file for ADD, sole declarer for
|
|
1446
|
-
* DROP/RENAME, builtin fork, URL refusal, the trust boundary) runs
|
|
1447
|
-
* unchanged. Collection views keep following the config's resolution. A
|
|
1448
|
-
* run whose statement produces no DDL effect refuses before anything is
|
|
1449
|
-
* applied — a flag that would silently mean nothing must refuse.
|
|
1497
|
+
* The field as the page holds it, when that differs from `value`: the
|
|
1498
|
+
* ciphertext of an encrypted join field (proposal 0045). A finding about
|
|
1499
|
+
* the join names this, never the plaintext.
|
|
1450
1500
|
*/
|
|
1451
|
-
|
|
1501
|
+
pageValue?: string;
|
|
1502
|
+
/** The manifest, as the run reports it. */
|
|
1503
|
+
file: string;
|
|
1504
|
+
/** The collection that manifest belongs to (proposal 0041). */
|
|
1505
|
+
collection: string;
|
|
1506
|
+
}
|
|
1507
|
+
/** What `mergeExternalMetadata` hands back. */
|
|
1508
|
+
interface MergedMetadata {
|
|
1509
|
+
/** The document's metadata with every owned key the manifest supplied. */
|
|
1510
|
+
extracted: ExtractedMetadata;
|
|
1452
1511
|
/**
|
|
1453
|
-
*
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1456
|
-
* `undefined` off a terminal; absent, such a write refuses (exit 2). A dry
|
|
1457
|
-
* run never asks: it writes nothing.
|
|
1512
|
+
* Owned keys the document itself also carried, in document order, each
|
|
1513
|
+
* with the manifest that owns it — so the finding names it without a
|
|
1514
|
+
* second lookup, and without a fallback for an index that is not there.
|
|
1458
1515
|
*/
|
|
1459
|
-
|
|
1516
|
+
collisions: ExternalMetadataCollision[];
|
|
1517
|
+
/** Field-joined entries this document matched, one per manifest at most. */
|
|
1518
|
+
joins: ExternalMetadataJoin[];
|
|
1460
1519
|
/**
|
|
1461
|
-
*
|
|
1462
|
-
* `
|
|
1520
|
+
* Where a merged pointer's value lives. Answers only for a value the
|
|
1521
|
+
* manifest supplied — a bare key or its `/key` pointer, and anything
|
|
1522
|
+
* beneath it — and `undefined` for everything the document owns, which is
|
|
1523
|
+
* what `lineFor` is for.
|
|
1524
|
+
*
|
|
1525
|
+
* The line is the deepest manifest node the pointer reaches, so
|
|
1526
|
+
* `/citations/2` is the third item's line and `/citations/2/source/file`
|
|
1527
|
+
* that member's. A pointer past what the manifest holds falls back to the
|
|
1528
|
+
* nearest ancestor that exists, and at worst to the owned key's line.
|
|
1463
1529
|
*/
|
|
1464
|
-
|
|
1465
|
-
/** The clock an uncommitted body change is dated by. Test seam; default `new Date()`. */
|
|
1466
|
-
now?: () => Date;
|
|
1530
|
+
locate: (pointer: string) => SourceLocation | undefined;
|
|
1467
1531
|
}
|
|
1532
|
+
/** The join an external-metadata config asks for: `path` unless it names a field. */
|
|
1533
|
+
declare function externalMetadataJoin(manifest: Pick<ExternalMetadataConfig, "join">): string;
|
|
1468
1534
|
/**
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1535
|
+
* Load every manifest of every collection the run covers. Resolves to `null`
|
|
1536
|
+
* when none of them declares one, which is every setup that existed before
|
|
1537
|
+
* this feature.
|
|
1538
|
+
*
|
|
1539
|
+
* Every refusal is a `DocmetaError`: the manifest is a config-supplied input,
|
|
1540
|
+
* and one that is missing or misshapen is the run's problem, not a
|
|
1541
|
+
* document's (0014).
|
|
1474
1542
|
*/
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
interface QueryRun {
|
|
1523
|
-
/** Result column names, in SELECT order — present even for zero rows. */
|
|
1524
|
-
columns: string[];
|
|
1525
|
-
rows: Record<string, unknown>[];
|
|
1526
|
-
/** Set when `db` was written: where, and how big the table is. */
|
|
1527
|
-
db?: {
|
|
1528
|
-
path: string;
|
|
1529
|
-
files: number;
|
|
1530
|
-
columns: number;
|
|
1531
|
-
};
|
|
1532
|
-
/**
|
|
1533
|
-
* Present when the statement was a metadata edit: every cell it changed
|
|
1534
|
-
* (empty when a mutating statement matched nothing). Absent on reads.
|
|
1535
|
-
*/
|
|
1536
|
-
changes?: QueryChange[];
|
|
1537
|
-
/**
|
|
1538
|
-
* Where the run stood, in the same shape `ValidateRun.frame` carries — the
|
|
1539
|
-
* path-normalization frame SARIF and JUnit need before they can name a file
|
|
1540
|
-
* the way the repository does (proposal 0026). Constructed from the run's
|
|
1541
|
-
* `cwd`, its config directory, and the directory file labels resolve
|
|
1542
|
-
* against; absent only when a caller built a `QueryRun` by hand.
|
|
1543
|
-
*/
|
|
1544
|
-
frame?: FingerprintContext;
|
|
1545
|
-
}
|
|
1546
|
-
declare function runQuery(opts: QueryOptions): Promise<QueryRun>;
|
|
1543
|
+
declare function loadExternalMetadata(collections: readonly CollectionConfig[], opts: LoadExternalMetadataOptions): Promise<ExternalMetadataIndex | null>;
|
|
1544
|
+
/**
|
|
1545
|
+
* Merge the external metadata for one document into its extracted metadata.
|
|
1546
|
+
*
|
|
1547
|
+
* `label` is the document as the run spells it, relative to `base`; a path
|
|
1548
|
+
* entry matches on the resolved absolute path, never on the spelling, so a
|
|
1549
|
+
* positional run from a subdirectory finds the same entry a config-corpus
|
|
1550
|
+
* run does. A field entry matches on the document's own value of the join
|
|
1551
|
+
* field, wherever the document lives. Stdin never matches a path entry:
|
|
1552
|
+
* there is no file behind it.
|
|
1553
|
+
*
|
|
1554
|
+
* `memberOf` names the collections this document belongs to, and only their
|
|
1555
|
+
* manifests are consulted (0041 rule 4). It is the caller's `memberOf(...)`
|
|
1556
|
+
* result, computed once per file.
|
|
1557
|
+
*
|
|
1558
|
+
* `present`, `format` and the document's own positions are untouched. A
|
|
1559
|
+
* manifest key is not in the document, so `lineFor` keeps answering
|
|
1560
|
+
* `undefined` for it, and `locate` answers instead.
|
|
1561
|
+
*
|
|
1562
|
+
* A join field the page holds encrypted (proposal 0045) is decrypted with
|
|
1563
|
+
* `options.encryptionKey` before it is matched. With no key, and a manifest
|
|
1564
|
+
* of this document's collections joining on that field, the run cannot match
|
|
1565
|
+
* and refuses. A ciphertext that does not decrypt matches nothing.
|
|
1566
|
+
*/
|
|
1567
|
+
declare function mergeExternalMetadata(label: string, extracted: ExtractedMetadata, index: ExternalMetadataIndex | null, memberOf: readonly string[], base: string, options?: {
|
|
1568
|
+
encryptionKey?: () => string | undefined;
|
|
1569
|
+
}): MergedMetadata;
|
|
1570
|
+
/** The `/key` pointer for an external-metadata finding, RFC 6901 escaped. */
|
|
1571
|
+
declare function externalMetadataPointer(key: string): string;
|
|
1572
|
+
/**
|
|
1573
|
+
* Path entries naming no loaded document.
|
|
1574
|
+
*
|
|
1575
|
+
* `loaded` are the run's file labels, relative to `base`. Checked only when
|
|
1576
|
+
* the run is the config corpus (the same invariant corpus checks use): a
|
|
1577
|
+
* positional path means the operator chose to look at part of the corpus,
|
|
1578
|
+
* and an entry for the rest is expected, not orphaned.
|
|
1579
|
+
*/
|
|
1580
|
+
declare function orphanEntries(index: ExternalMetadataIndex | null, loaded: readonly string[], base: string, collections?: readonly string[]): ExternalMetadataEntry[];
|
|
1581
|
+
/**
|
|
1582
|
+
* Field entries no loaded document matched (0039). `matched` is field -> the
|
|
1583
|
+
* values documents in the run carried, which the caller collects from each
|
|
1584
|
+
* document's `joins` — so this runs after the per-file loop, under the same
|
|
1585
|
+
* corpus invariant as `orphanEntries`.
|
|
1586
|
+
*/
|
|
1587
|
+
declare function orphanJoins(index: ExternalMetadataIndex | null, matched: ReadonlyMap<string, ReadonlySet<string>>, collections?: readonly string[]): ExternalMetadataEntry[];
|
|
1588
|
+
/** The operational error an orphan check raises, naming the first entry. */
|
|
1589
|
+
declare function orphanError(orphans: readonly ExternalMetadataEntry[]): DocmetaError;
|
|
1547
1590
|
|
|
1548
1591
|
interface BuiltinInfo {
|
|
1549
1592
|
id: string;
|
|
@@ -1673,199 +1716,213 @@ declare function schemaLoadOptions(args: {
|
|
|
1673
1716
|
/** Load and return the JSON Schema object for a reference. */
|
|
1674
1717
|
declare function loadSchema(ref: string, options?: LoadSchemaOptions): Promise<Record<string, unknown>>;
|
|
1675
1718
|
|
|
1676
|
-
interface SchemasInfo {
|
|
1677
|
-
builtins: BuiltinInfo[];
|
|
1678
|
-
formats: {
|
|
1679
|
-
name: string;
|
|
1680
|
-
extensions: string[];
|
|
1681
|
-
implemented: boolean;
|
|
1682
|
-
/** Whether `manni meta fill` can write metadata back to this format. */
|
|
1683
|
-
writable: boolean;
|
|
1684
|
-
}[];
|
|
1685
|
-
}
|
|
1686
|
-
declare function getSchemasInfo(): SchemasInfo;
|
|
1687
|
-
/**
|
|
1688
|
-
* Where a vendored schema lands by default.
|
|
1689
|
-
*
|
|
1690
|
-
* **Not** `.docmeta/`, which is gitignored wholesale and holds the schema and
|
|
1691
|
-
* proposal caches. A vendored schema is the opposite kind of artifact: it has
|
|
1692
|
-
* to be committed, because being in the consuming repository's own history is
|
|
1693
|
-
* the entire point of vendoring.
|
|
1694
|
-
*/
|
|
1695
|
-
declare const DEFAULT_VENDOR_DIR = "./schema";
|
|
1696
|
-
interface VendorOptions {
|
|
1697
|
-
/** The `http(s)` URL to download. */
|
|
1698
|
-
url: string;
|
|
1699
|
-
/** Directory for the vendored copy, relative to `cwd`. Default `./schema`. */
|
|
1700
|
-
dir?: string;
|
|
1701
|
-
/** `-c/--config`. Absent discovers a config, or creates one in `cwd`. */
|
|
1702
|
-
configPath?: string;
|
|
1703
|
-
cwd?: string;
|
|
1704
|
-
/** Diagnostics for the user; the CLI writes these to stderr. */
|
|
1705
|
-
onNotice?: (message: string) => void;
|
|
1706
|
-
/** Fetch timeout, in ms. Defaults to the registry's. */
|
|
1707
|
-
timeoutMs?: number;
|
|
1708
|
-
/** Response size cap, in bytes. Defaults to the registry's. */
|
|
1709
|
-
maxBytes?: number;
|
|
1710
|
-
}
|
|
1711
|
-
interface VendorResult {
|
|
1712
|
-
/** The URL that was downloaded. */
|
|
1713
|
-
url: string;
|
|
1714
|
-
/** The vendored file, relative to `cwd`, posix-style. */
|
|
1715
|
-
file: string;
|
|
1716
|
-
/** The pin recorded for it. */
|
|
1717
|
-
integrity: string;
|
|
1718
|
-
/** Size of the vendored copy, in bytes. */
|
|
1719
|
-
bytes: number;
|
|
1720
|
-
/** The config that was written, relative to `cwd`, posix-style. */
|
|
1721
|
-
config: string;
|
|
1722
|
-
/** Whether that config had to be created. */
|
|
1723
|
-
configCreated: boolean;
|
|
1724
|
-
/** Whether an existing `schemas:` entry was replaced rather than appended. */
|
|
1725
|
-
replaced: boolean;
|
|
1726
|
-
/** Whether the downloaded bytes were identical to the copy already on disk. */
|
|
1727
|
-
unchanged: boolean;
|
|
1728
|
-
}
|
|
1729
1719
|
/**
|
|
1730
|
-
*
|
|
1720
|
+
* `x-manni-location` (proposal 0047): where a schema would like a top-level
|
|
1721
|
+
* key's value stored, on the page or in external metadata.
|
|
1731
1722
|
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1734
|
-
*
|
|
1735
|
-
*
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
* Download a remote schema into the repository and pin it.
|
|
1723
|
+
* The keyword is registered on every Ajv meta builds (validator.ts), next to
|
|
1724
|
+
* `x-manni-encrypt`, and like it records where it was evaluated. Ajv's own
|
|
1725
|
+
* resolution is the walker, so a mark counts through `$ref`, `allOf` and a
|
|
1726
|
+
* referenced built-in, and inside the `anyOf`, `oneOf` and `if`/`then`
|
|
1727
|
+
* branches Ajv takes. Only top-level properties carry a preference; a nested
|
|
1728
|
+
* mark is accepted and ignored. `Validator.locationPreferences` is the one
|
|
1729
|
+
* question commands ask of it.
|
|
1740
1730
|
*
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1731
|
+
* One schema marking one key both ways is judged twice. Through `properties`,
|
|
1732
|
+
* `allOf` and local `$ref` alone, it is refused when the schema compiles.
|
|
1733
|
+
* Across conditional branches it is not an error: Ajv evaluates failing
|
|
1734
|
+
* branches too, so that schema gives the key no preference.
|
|
1735
|
+
*/
|
|
1736
|
+
/** The schema keyword. */
|
|
1737
|
+
declare const LOCATION_KEYWORD = "x-manni-location";
|
|
1738
|
+
/** Where a top-level key prefers to live. */
|
|
1739
|
+
type FieldLocation = "page" | "external";
|
|
1740
|
+
/** A key's preferred location, and the schema ref whose mark decided it. */
|
|
1741
|
+
interface LocationPreference {
|
|
1742
|
+
location: FieldLocation;
|
|
1743
|
+
/** The ref, as given to `locationPreferences`, whose mark won. */
|
|
1744
|
+
schema: string;
|
|
1745
|
+
}
|
|
1748
1746
|
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
/** Self-reported confidence was below the threshold. */
|
|
1752
|
-
"low-confidence"
|
|
1753
|
-
/** Writing it would leave the document failing its own schema. */
|
|
1754
|
-
| "schema-mismatch"
|
|
1755
|
-
/** The model declined to propose a value. */
|
|
1756
|
-
| "no-proposal"
|
|
1757
|
-
/**
|
|
1758
|
-
* The field is managed by `derive` (`derive.fields` in the config), so it
|
|
1759
|
-
* was never sent for inference: only `manni meta derive` writes it.
|
|
1760
|
-
*/
|
|
1761
|
-
| "managed";
|
|
1762
|
-
interface FilledField {
|
|
1763
|
-
/** JSON Pointer, e.g. "/title" — the same form `validate` reports. */
|
|
1764
|
-
field: string;
|
|
1765
|
-
required: boolean;
|
|
1766
|
-
confidence: number;
|
|
1767
|
-
reasoning: string;
|
|
1747
|
+
declare class Validator {
|
|
1748
|
+
private readonly schemaOptions;
|
|
1768
1749
|
/**
|
|
1769
|
-
*
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1750
|
+
* How this validator's schemas are loaded: the disk cache location, its TTL,
|
|
1751
|
+
* and `--offline`. Held per instance rather than read from module state, so
|
|
1752
|
+
* two differently-configured validations in one process each get their own
|
|
1753
|
+
* settings.
|
|
1754
|
+
*
|
|
1755
|
+
* That is not full isolation, and the difference matters to a library
|
|
1756
|
+
* caller: `schema-registry` keeps a process-wide memo of fetched schemas, so
|
|
1757
|
+
* one validator's successful fetch is visible to another. `offline` is
|
|
1758
|
+
* excluded from that sharing on purpose — an offline validator will not be
|
|
1759
|
+
* served something this process pulled over the network — but the memo is
|
|
1760
|
+
* still shared, so a URL fetched once is not re-fetched per instance.
|
|
1772
1761
|
*/
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
skipReason?: SkipReason;
|
|
1762
|
+
constructor(schemaOptions?: LoadSchemaOptions);
|
|
1763
|
+
private ajvByDialect;
|
|
1776
1764
|
/**
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
1765
|
+
* Keyed on the in-flight *promise*, not the resolved validator. Caching the
|
|
1766
|
+
* result made this a check-then-act race: `fill` walks files through a worker
|
|
1767
|
+
* pool, so every worker missed the cache while the first `loadSchema` was
|
|
1768
|
+
* still pending and they all then compiled the same schema into the one
|
|
1769
|
+
* shared per-dialect Ajv. Ajv registers a schema's `$id` on the first compile
|
|
1770
|
+
* and rejects the second with "schema with key or id ... already exists",
|
|
1771
|
+
* which took down any multi-file run against an $id-bearing schema. Storing
|
|
1772
|
+
* the promise before the first await lets the losers await the one compile.
|
|
1779
1773
|
*/
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
/**
|
|
1783
|
-
* One `meta-provenance` entry as `fill` writes it (proposal 0046): the model,
|
|
1784
|
-
* the JSON Pointers of the fields it proposed, escaped per RFC 6901, and the
|
|
1785
|
-
* confidence each was written at. Keys are the page's own spelling, so the
|
|
1786
|
-
* JSON report shows exactly what landed in the document. An entry `fill`
|
|
1787
|
-
* merged into keeps whatever else it held.
|
|
1788
|
-
*/
|
|
1789
|
-
interface MetaProvenanceEntry {
|
|
1790
|
-
"generated-by": string;
|
|
1791
|
-
fields: string[];
|
|
1792
|
-
confidence: Record<string, number>;
|
|
1793
|
-
[other: string]: unknown;
|
|
1794
|
-
}
|
|
1795
|
-
/**
|
|
1796
|
-
* What became of this file's `meta-provenance` entry. It is never a failure:
|
|
1797
|
-
* neither outcome changes the summary or the exit code.
|
|
1798
|
-
*/
|
|
1799
|
-
type MetaProvenanceReport = {
|
|
1800
|
-
written: true;
|
|
1801
|
-
entry: MetaProvenanceEntry;
|
|
1802
|
-
}
|
|
1803
|
-
/** The page's schemas, checked with the entry in place, reject it. */
|
|
1804
|
-
| {
|
|
1805
|
-
written: false;
|
|
1806
|
-
skipReason: "schema-mismatch";
|
|
1807
|
-
}
|
|
1808
|
-
/** A manifest in one of the page's collections owns the key. */
|
|
1809
|
-
| {
|
|
1810
|
-
written: false;
|
|
1811
|
-
skipReason: "manifest-owned";
|
|
1812
|
-
manifest: string;
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* The format's writer cannot hold a list of entries (an HTML or XML
|
|
1816
|
-
* attribute holds one line), so the fields were written without it.
|
|
1817
|
-
*/
|
|
1818
|
-
| {
|
|
1819
|
-
written: false;
|
|
1820
|
-
skipReason: "unwritable";
|
|
1821
|
-
};
|
|
1822
|
-
interface FillFileResult {
|
|
1823
|
-
file: string;
|
|
1824
|
-
format: string;
|
|
1825
|
-
schemas: string[];
|
|
1826
|
-
fields: FilledField[];
|
|
1827
|
-
/** Whether the file's content changed (false under --dry-run too). */
|
|
1828
|
-
changed: boolean;
|
|
1829
|
-
/** Parse failure, read-only format, or provider error. */
|
|
1830
|
-
error?: string;
|
|
1831
|
-
/** The filled document. Populated only when the caller asks for it. */
|
|
1832
|
-
content?: string;
|
|
1774
|
+
private cache;
|
|
1775
|
+
private ajvFor;
|
|
1833
1776
|
/**
|
|
1834
|
-
*
|
|
1835
|
-
*
|
|
1836
|
-
* under `--dry-run`.
|
|
1777
|
+
* Synchronous by design: the `cache.set` has to happen in the same tick as
|
|
1778
|
+
* the miss, or a second caller can slip in before the entry exists.
|
|
1837
1779
|
*/
|
|
1838
|
-
|
|
1780
|
+
private compile;
|
|
1781
|
+
private compileUncached;
|
|
1782
|
+
/**
|
|
1783
|
+
* The instance pointers of `data` that carry `x-manni-encrypt: true` under
|
|
1784
|
+
* any schema in `refs`, in the order the validator evaluated them.
|
|
1785
|
+
*
|
|
1786
|
+
* A first pass with the recording keyword, so a mark counts exactly where
|
|
1787
|
+
* validation would evaluate it. Only present values are marked: Ajv applies
|
|
1788
|
+
* a property's subschema to a property that exists. A branch Ajv does not
|
|
1789
|
+
* take (`then` behind a failing `if`, an `anyOf` branch after a passing
|
|
1790
|
+
* one) contributes nothing; a branch it takes contributes its marks
|
|
1791
|
+
* whether or not the branch passes, because a ciphertext routinely fails
|
|
1792
|
+
* the rest of its own subschema until it is decrypted.
|
|
1793
|
+
*/
|
|
1794
|
+
markedPointers(data: Record<string, unknown>, refs: string[]): Promise<Set<string>>;
|
|
1795
|
+
/**
|
|
1796
|
+
* The location each top-level key of `data` prefers under `refs`: `page` or
|
|
1797
|
+
* `external`, and the ref whose `x-manni-location` mark decided it. A key no
|
|
1798
|
+
* schema marks has no entry.
|
|
1799
|
+
*
|
|
1800
|
+
* A first pass with the recording keyword, as `markedPointers` runs, so a
|
|
1801
|
+
* mark counts exactly where validation would evaluate it, and a nested mark
|
|
1802
|
+
* is ignored. Only present values are marked: Ajv applies a property's
|
|
1803
|
+
* subschema to a property that exists. A caller asking where a key it is
|
|
1804
|
+
* about to write belongs passes `data` that already holds the candidate
|
|
1805
|
+
* value. `$schema` is stripped first, as validation does.
|
|
1806
|
+
*
|
|
1807
|
+
* Refs are evaluated in order and a later ref's mark wins. A ref that says
|
|
1808
|
+
* both values for one key unconditionally is refused when it compiles; one
|
|
1809
|
+
* whose evaluated branches say both gives that key no preference.
|
|
1810
|
+
*/
|
|
1811
|
+
locationPreferences(data: Record<string, unknown>, refs: string[]): Promise<Map<string, LocationPreference>>;
|
|
1812
|
+
/**
|
|
1813
|
+
* Validate `data` against every schema in `refs`. Returns all violations,
|
|
1814
|
+
* each tagged with the schema that produced it and a source line via
|
|
1815
|
+
* `lineFor`.
|
|
1816
|
+
*
|
|
1817
|
+
* `colFor` is optional and additive: this signature is public, so a fourth
|
|
1818
|
+
* *required* parameter — or a widened third one — would be a consumer break.
|
|
1819
|
+
* Callers with an extractor that supplies no column pass nothing and get the
|
|
1820
|
+
* previous behavior exactly.
|
|
1821
|
+
*/
|
|
1822
|
+
validate(data: Record<string, unknown>, refs: string[], lineFor: (pointer: string) => number | undefined, colFor?: (pointer: string) => number | undefined,
|
|
1823
|
+
/**
|
|
1824
|
+
* Where a merged value lives when it is not in the document (proposal
|
|
1825
|
+
* 0037): a manifest's file and line. Consulted before `lineFor`,
|
|
1826
|
+
* and additive in the way `colFor` was.
|
|
1827
|
+
*/
|
|
1828
|
+
locate?: (pointer: string) => SourceLocation | undefined): Promise<FieldError[]>;
|
|
1839
1829
|
}
|
|
1840
|
-
|
|
1830
|
+
|
|
1831
|
+
/** Why a value was moved: its schema's mark, or a manifest that already owns the key. */
|
|
1832
|
+
type RelocateMoveReason = "preferred" | "owned";
|
|
1833
|
+
/** Why a value stayed on the side it is on. */
|
|
1834
|
+
type RelocateStayReason = "no-home" | "read-only-format" | "no-join-value" | "values-differ" | "url-manifest" | "unreadable";
|
|
1835
|
+
/** One value that moved, or would under `dryRun`. */
|
|
1836
|
+
type RelocateMove = {
|
|
1837
|
+
key: string;
|
|
1838
|
+
to: "page";
|
|
1839
|
+
from: string;
|
|
1840
|
+
reason: RelocateMoveReason;
|
|
1841
|
+
} | {
|
|
1842
|
+
key: string;
|
|
1843
|
+
to: "manifest";
|
|
1844
|
+
manifest: string;
|
|
1845
|
+
/** 1-based line of the key in the manifest afterwards. Absent under `dryRun`. */
|
|
1846
|
+
line?: number;
|
|
1847
|
+
reason: RelocateMoveReason;
|
|
1848
|
+
};
|
|
1849
|
+
/** One value that stayed on the wrong side. */
|
|
1850
|
+
interface RelocateStay {
|
|
1851
|
+
key: string;
|
|
1852
|
+
reason: RelocateStayReason;
|
|
1853
|
+
/** The sentence the pretty reporter prints after `stays: `. Not part of the JSON shape. */
|
|
1854
|
+
detail?: string;
|
|
1855
|
+
}
|
|
1856
|
+
interface RelocateFileResult {
|
|
1857
|
+
/** The page, as the run labels it. */
|
|
1858
|
+
file: string;
|
|
1859
|
+
moved: RelocateMove[];
|
|
1860
|
+
stayed: RelocateStay[];
|
|
1861
|
+
/** A member page outside the paths the run named, reached through a `keys:` or `paths:` change. */
|
|
1862
|
+
beyond: boolean;
|
|
1863
|
+
}
|
|
1864
|
+
interface RelocateManifestResult {
|
|
1865
|
+
/** The manifest as the run reports it: relative to the run's base, or the URL. */
|
|
1866
|
+
file: string;
|
|
1867
|
+
collection: string;
|
|
1868
|
+
/** Its index in the collection's `externalMetadata:` before the run. */
|
|
1869
|
+
index: number;
|
|
1870
|
+
created: boolean;
|
|
1871
|
+
keysAdded: string[];
|
|
1872
|
+
keysRemoved: string[];
|
|
1873
|
+
/** The keys it owns afterwards. */
|
|
1874
|
+
keys: string[];
|
|
1875
|
+
/** Whether its last key went, so the config no longer declares it (R3). */
|
|
1876
|
+
undeclared: boolean;
|
|
1877
|
+
/** Pages beyond the named paths whose values a `keys:` change moves, or leaves. */
|
|
1878
|
+
beyond: number;
|
|
1879
|
+
}
|
|
1880
|
+
interface RelocateConfigResult {
|
|
1881
|
+
/** The config file relative to the working directory, or null when there is none and none was needed. */
|
|
1882
|
+
file: string | null;
|
|
1883
|
+
created: boolean;
|
|
1884
|
+
collectionsCreated: {
|
|
1885
|
+
name: string;
|
|
1886
|
+
paths: string[];
|
|
1887
|
+
}[];
|
|
1888
|
+
pathsAdded: {
|
|
1889
|
+
collection: string;
|
|
1890
|
+
path: string;
|
|
1891
|
+
}[];
|
|
1892
|
+
}
|
|
1893
|
+
interface RelocateSummary {
|
|
1894
|
+
/** Pages with a value moved or stayed. */
|
|
1841
1895
|
files: number;
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
/** Skipped fields that the schema lists as required — drives exit code 1. */
|
|
1846
|
-
requiredSkipped: number;
|
|
1847
|
-
errors: number;
|
|
1848
|
-
costUsd: number;
|
|
1849
|
-
cached: number;
|
|
1896
|
+
moved: number;
|
|
1897
|
+
stayed: number;
|
|
1898
|
+
manifestsCreated: number;
|
|
1850
1899
|
}
|
|
1851
|
-
interface
|
|
1852
|
-
results: FillFileResult[];
|
|
1853
|
-
summary: FillSummary;
|
|
1854
|
-
/** Echoed so JSON consumers and CI can assert which gate actually ran. */
|
|
1855
|
-
threshold: number;
|
|
1900
|
+
interface RelocateResult {
|
|
1856
1901
|
dryRun: boolean;
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1902
|
+
config: RelocateConfigResult;
|
|
1903
|
+
/** Every manifest the run creates, changes the keys of, or moves a value into or out of. */
|
|
1904
|
+
manifests: RelocateManifestResult[];
|
|
1905
|
+
files: RelocateFileResult[];
|
|
1906
|
+
summary: RelocateSummary;
|
|
1861
1907
|
}
|
|
1862
|
-
|
|
1908
|
+
|
|
1909
|
+
interface QueryOptions {
|
|
1910
|
+
/**
|
|
1911
|
+
* One SQL statement. The table is `docs`; see the system columns below.
|
|
1912
|
+
* May be empty when `db` is set — export without querying.
|
|
1913
|
+
*/
|
|
1914
|
+
sql: string;
|
|
1915
|
+
/**
|
|
1916
|
+
* `--db`: also write the built database to this file, for any SQLite
|
|
1917
|
+
* front-end (sqlite3, Datasette, duckdb) to open afterwards. The file is a
|
|
1918
|
+
* regenerated artifact: an existing SQLite file at the path is overwritten,
|
|
1919
|
+
* anything else is refused.
|
|
1920
|
+
*/
|
|
1921
|
+
db?: string;
|
|
1863
1922
|
inputs: string[];
|
|
1864
|
-
cliSchemas?: string[];
|
|
1865
|
-
exts?: string[];
|
|
1866
|
-
exclude?: string[];
|
|
1867
|
-
/** `--as` format override (extractor name). */
|
|
1868
1923
|
as?: string;
|
|
1924
|
+
exclude?: string[];
|
|
1925
|
+
exts?: string[];
|
|
1869
1926
|
configPath?: string;
|
|
1870
1927
|
/** `--no-config`: skip config discovery and use the built-in defaults. */
|
|
1871
1928
|
noConfig?: boolean;
|
|
@@ -1890,429 +1947,590 @@ interface FillOptions {
|
|
|
1890
1947
|
/** Called once when a config governs the run, so the CLI can report it. */
|
|
1891
1948
|
onConfigLoaded?: (info: ConfigNotice) => void;
|
|
1892
1949
|
/**
|
|
1893
|
-
* `--offline
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
* (`--provider mock`, `--dry-run`).
|
|
1950
|
+
* `--offline`, accepted for surface parity with the other commands. DDL
|
|
1951
|
+
* statements do resolve the corpus's schema set (0024), but only from disk
|
|
1952
|
+
* and the bundled built-ins — a URL ref refuses with "vendor it first"
|
|
1953
|
+
* before anything could fetch — so there is still no network dependency to
|
|
1954
|
+
* suppress.
|
|
1899
1955
|
*/
|
|
1900
1956
|
offline?: boolean;
|
|
1901
|
-
/** Restrict proposals to these top-level fields. */
|
|
1902
|
-
fields?: string[];
|
|
1903
|
-
/** Minimum self-reported confidence to write (0-1). Default 0.7. */
|
|
1904
|
-
confidence?: number;
|
|
1905
|
-
/** Report proposals without writing them. */
|
|
1906
|
-
dryRun?: boolean;
|
|
1907
|
-
provider?: string;
|
|
1908
|
-
model?: string;
|
|
1909
|
-
/** Use the on-disk proposal cache. Default true. */
|
|
1910
|
-
cache?: boolean;
|
|
1911
|
-
/** Refuse a hosted provider: inference must run on this machine. */
|
|
1912
|
-
local?: boolean;
|
|
1913
|
-
/** Stop after this many inference calls. Counts calls, not files. */
|
|
1914
|
-
maxTurns?: number;
|
|
1915
|
-
/** Characters of document per call. Default 12000. */
|
|
1916
|
-
chunkChars?: number;
|
|
1917
|
-
/** Files inferred in parallel. Default 4. */
|
|
1918
|
-
concurrency?: number;
|
|
1919
|
-
/** Include the filled document on each result (used for stdin and tests). */
|
|
1920
|
-
includeContent?: boolean;
|
|
1921
|
-
/** Test seam: bypasses `makeProvider`, so no API key is needed. */
|
|
1922
|
-
inferenceProvider?: InferenceProvider;
|
|
1923
1957
|
/**
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
* off a terminal; absent, the run refuses (exit 2) before the first model
|
|
1928
|
-
* request.
|
|
1958
|
+
* `--no-cache` (false): ask GitHub or GitLab again rather than reading the
|
|
1959
|
+
* review cache. Only a statement naming the `derived` table consults it,
|
|
1960
|
+
* and only for `reviewed-by` and `last-reviewed`; absent leaves it on.
|
|
1929
1961
|
*/
|
|
1930
|
-
|
|
1962
|
+
cache?: boolean;
|
|
1931
1963
|
/**
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1964
|
+
* `--dry-run`: preview the statement's per-file changes — the diff it
|
|
1965
|
+
* would make, files untouched. Without it a mutating statement applies,
|
|
1966
|
+
* matching `fill`'s convention (proposal 0025; 0022 recorded the original
|
|
1967
|
+
* preview-by-default surface this revises).
|
|
1934
1968
|
*/
|
|
1935
|
-
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
declare function runFill(opts: FillOptions): Promise<FillRun>;
|
|
1939
|
-
|
|
1940
|
-
interface DeriveOptions {
|
|
1941
|
-
inputs: string[];
|
|
1969
|
+
dryRun?: boolean;
|
|
1942
1970
|
/**
|
|
1943
|
-
*
|
|
1944
|
-
*
|
|
1945
|
-
*
|
|
1971
|
+
* Values for the statement's named parameters (`$name`, `:name`, `@name`),
|
|
1972
|
+
* keyed by bare name (a `$`/`:`/`@` prefix on a key is tolerated). Each
|
|
1973
|
+
* value passes through the same `bindValue` the projection loader uses —
|
|
1974
|
+
* booleans become 1/0, arrays and objects JSON text — so a bound parameter
|
|
1975
|
+
* compares against a stored cell under exactly the encoding the cell got
|
|
1976
|
+
* (proposal 0029). A parameter the SQL references with no entry here
|
|
1977
|
+
* refuses: unbound would silently bind NULL and match nothing.
|
|
1946
1978
|
*/
|
|
1947
|
-
|
|
1948
|
-
/** `--fields`: the managed fields to stamp this run; config `derive.fields` otherwise. */
|
|
1949
|
-
fields?: string[];
|
|
1950
|
-
/** `--sources`: the sources to consult; config `derive.sources`, else all four. */
|
|
1951
|
-
sources?: string[];
|
|
1952
|
-
/** `--dry-run`: report what would change and write nothing. */
|
|
1953
|
-
dryRun?: boolean;
|
|
1954
|
-
/** `--check`: implies `dryRun`; stale and unset fields are findings. */
|
|
1955
|
-
check?: boolean;
|
|
1956
|
-
/** Use the on-disk GitHub or GitLab review cache. Default true. */
|
|
1957
|
-
cache?: boolean;
|
|
1958
|
-
/** `--as` format override (extractor name). */
|
|
1959
|
-
as?: string;
|
|
1960
|
-
exts?: string[];
|
|
1961
|
-
exclude?: string[];
|
|
1962
|
-
configPath?: string;
|
|
1963
|
-
/** `--no-config`: skip config discovery and use the built-in defaults. */
|
|
1964
|
-
noConfig?: boolean;
|
|
1965
|
-
cwd?: string;
|
|
1966
|
-
/** Permit an input set that resolves to zero files (see `assertNonEmpty`). */
|
|
1967
|
-
allowEmpty?: boolean;
|
|
1979
|
+
params?: Record<string, unknown>;
|
|
1968
1980
|
/**
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1981
|
+
* `-s/--schema`, repeatable: the schema set the run's DDL evolves — CLI
|
|
1982
|
+
* precedence for the DDL planner *only* (proposal 0030). The per-file
|
|
1983
|
+
* resolution walk is skipped and the deduped refs are the set; every guard
|
|
1984
|
+
* inside the set (single local file for ADD, sole declarer for
|
|
1985
|
+
* DROP/RENAME, builtin fork, URL refusal, the trust boundary) runs
|
|
1986
|
+
* unchanged. Collection views keep following the config's resolution. A
|
|
1987
|
+
* run whose statement produces no DDL effect refuses before anything is
|
|
1988
|
+
* applied — a flag that would silently mean nothing must refuse.
|
|
1971
1989
|
*/
|
|
1972
|
-
|
|
1973
|
-
/** Diagnostics for the user; the CLI writes these to stderr. */
|
|
1974
|
-
onNotice?: (message: string) => void;
|
|
1975
|
-
/** Called once when a config governs the run, so the CLI can report it. */
|
|
1976
|
-
onConfigLoaded?: (info: ConfigNotice) => void;
|
|
1977
|
-
/** The clock an uncommitted body change is dated by. Test seam; default `new Date()`. */
|
|
1978
|
-
now?: () => Date;
|
|
1979
|
-
/** The review client, for every repository in the run. Test seam; default `gh` / `glab`. */
|
|
1980
|
-
reviews?: ReviewClient;
|
|
1990
|
+
schemas?: string[];
|
|
1981
1991
|
/**
|
|
1982
|
-
* How to ask for a new encryption key when
|
|
1983
|
-
* `x-manni-encrypt`
|
|
1984
|
-
* (proposal 0045). The CLI passes `terminalConfirm()`, which is
|
|
1985
|
-
* off a terminal; absent, such a
|
|
1986
|
-
* asks: it writes nothing.
|
|
1992
|
+
* How to ask for a new encryption key when an `UPDATE` or `INSERT` writes
|
|
1993
|
+
* a column its schema marks `x-manni-encrypt` and no key is available
|
|
1994
|
+
* (proposal 0045). The CLI passes `terminalConfirm()`, which is
|
|
1995
|
+
* `undefined` off a terminal; absent, such a write refuses (exit 2). A dry
|
|
1996
|
+
* run never asks: it writes nothing.
|
|
1987
1997
|
*/
|
|
1988
1998
|
confirm?: Confirm;
|
|
1999
|
+
/**
|
|
2000
|
+
* Called with relocate's result when a write's P1 offer was accepted and
|
|
2001
|
+
* the values moved (proposal 0047), so the CLI can print relocate's report.
|
|
2002
|
+
*/
|
|
2003
|
+
onRelocated?: (result: RelocateResult) => void;
|
|
1989
2004
|
/**
|
|
1990
2005
|
* The environment `MANNI_ENCRYPTION_KEY` is read from. Defaults to
|
|
1991
2006
|
* `process.env`; tests pass their own.
|
|
1992
2007
|
*/
|
|
1993
2008
|
env?: NodeJS.ProcessEnv;
|
|
1994
|
-
/**
|
|
1995
|
-
|
|
1996
|
-
* lines go to, or the lines a `<path>:L1-L2` positional names. Absent reads
|
|
1997
|
-
* `MANNI_GENERATED_BY` from `env`; an empty value is unset either way.
|
|
1998
|
-
*/
|
|
1999
|
-
generatedBy?: string;
|
|
2009
|
+
/** The clock an uncommitted body change is dated by. Test seam; default `new Date()`. */
|
|
2010
|
+
now?: () => Date;
|
|
2000
2011
|
}
|
|
2001
|
-
|
|
2012
|
+
/**
|
|
2013
|
+
* One thing a statement changed, in file-space terms. Cell-level kinds carry
|
|
2014
|
+
* a `key` (a set, a deletion via `SET k = NULL` / `ALTER DROP COLUMN`, or a
|
|
2015
|
+
* key rename); file-level kinds carry the whole event (`cleared` — the block
|
|
2016
|
+
* stripped by DELETE; `created` — a file INSERT made; `renamed` — a `_path`
|
|
2017
|
+
* move). Exactly one kind per object.
|
|
2018
|
+
*
|
|
2019
|
+
* `manifest` (proposal 0047) names the external-metadata manifest the change
|
|
2020
|
+
* lands in, as the run reports it, when it lands in one: an owned key's set,
|
|
2021
|
+
* removal or rename, a created file's owned keys, a stripped document's
|
|
2022
|
+
* entry, or a moved document's entry.
|
|
2023
|
+
*/
|
|
2024
|
+
type QueryChange = {
|
|
2002
2025
|
file: string;
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2026
|
+
written: boolean;
|
|
2027
|
+
manifest?: string;
|
|
2028
|
+
} & ({
|
|
2029
|
+
key: string;
|
|
2030
|
+
from: unknown;
|
|
2031
|
+
to: unknown;
|
|
2032
|
+
} | {
|
|
2033
|
+
key: string;
|
|
2034
|
+
from: unknown;
|
|
2035
|
+
deleted: true;
|
|
2036
|
+
} | {
|
|
2037
|
+
key: string;
|
|
2038
|
+
renamedFrom: string;
|
|
2039
|
+
to: unknown;
|
|
2040
|
+
} | {
|
|
2041
|
+
cleared: true;
|
|
2042
|
+
from: Record<string, unknown>;
|
|
2043
|
+
} | {
|
|
2044
|
+
created: true;
|
|
2045
|
+
to: Record<string, unknown>;
|
|
2046
|
+
} | {
|
|
2047
|
+
renamed: string;
|
|
2048
|
+
} | {
|
|
2049
|
+
/** A DDL statement edited the schema itself (0024): `file` is the
|
|
2050
|
+
* schema written — an in-place edit, or the fork of a builtin. */
|
|
2051
|
+
schema: true;
|
|
2052
|
+
op: "add" | "drop" | "rename";
|
|
2053
|
+
key: string;
|
|
2054
|
+
renamedTo?: string;
|
|
2055
|
+
type?: string;
|
|
2056
|
+
/** 0028: a declared type equal to a format name carries the format. */
|
|
2057
|
+
format?: string;
|
|
2058
|
+
/** 0028: a `CHECK (k IN (…))` on the added column carries the enum. */
|
|
2059
|
+
enum?: (string | number)[];
|
|
2060
|
+
required?: boolean;
|
|
2061
|
+
forkedFrom?: string;
|
|
2062
|
+
} | {
|
|
2063
|
+
/** A DDL side effect on the governing config file: a fork repoints the
|
|
2064
|
+
* `schemas:` entry (`key: "schemas"`), an in-place edit of a pinned
|
|
2065
|
+
* schema refreshes its pin (`key: "integrity"`). Disclosed as a change
|
|
2066
|
+
* because the preview must name every file `--write` will touch. */
|
|
2067
|
+
config: true;
|
|
2068
|
+
key: string;
|
|
2069
|
+
from: unknown;
|
|
2070
|
+
to: unknown;
|
|
2071
|
+
});
|
|
2072
|
+
interface QueryRun {
|
|
2073
|
+
/** Result column names, in SELECT order — present even for zero rows. */
|
|
2074
|
+
columns: string[];
|
|
2075
|
+
rows: Record<string, unknown>[];
|
|
2076
|
+
/** Set when `db` was written: where, and how big the table is. */
|
|
2077
|
+
db?: {
|
|
2078
|
+
path: string;
|
|
2079
|
+
files: number;
|
|
2080
|
+
columns: number;
|
|
2081
|
+
};
|
|
2007
2082
|
/**
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
* patch the format serializes to the same bytes is not a change.
|
|
2083
|
+
* Present when the statement was a metadata edit: every cell it changed
|
|
2084
|
+
* (empty when a mutating statement matched nothing). Absent on reads.
|
|
2011
2085
|
*/
|
|
2012
|
-
|
|
2013
|
-
/** Why the file could not be derived or written; the run goes on without it. */
|
|
2014
|
-
error?: string;
|
|
2086
|
+
changes?: QueryChange[];
|
|
2015
2087
|
/**
|
|
2016
|
-
*
|
|
2017
|
-
*
|
|
2088
|
+
* Where the run stood, in the same shape `ValidateRun.frame` carries — the
|
|
2089
|
+
* path-normalization frame SARIF and JUnit need before they can name a file
|
|
2090
|
+
* the way the repository does (proposal 0026). Constructed from the run's
|
|
2091
|
+
* `cwd`, its config directory, and the directory file labels resolve
|
|
2092
|
+
* against; absent only when a caller built a `QueryRun` by hand.
|
|
2018
2093
|
*/
|
|
2019
|
-
|
|
2094
|
+
frame?: FingerprintContext;
|
|
2020
2095
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
*/
|
|
2032
|
-
ranges?: number;
|
|
2033
|
-
stale: number;
|
|
2034
|
-
unset: number;
|
|
2035
|
-
unknown: number;
|
|
2036
|
-
errors: number;
|
|
2096
|
+
declare function runQuery(opts: QueryOptions): Promise<QueryRun>;
|
|
2097
|
+
|
|
2098
|
+
interface SchemasInfo {
|
|
2099
|
+
builtins: BuiltinInfo[];
|
|
2100
|
+
formats: {
|
|
2101
|
+
name: string;
|
|
2102
|
+
extensions: string[];
|
|
2103
|
+
/** Whether `manni meta fill` can write metadata back to this format. */
|
|
2104
|
+
writable: boolean;
|
|
2105
|
+
}[];
|
|
2037
2106
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2107
|
+
declare function getSchemasInfo(): SchemasInfo;
|
|
2108
|
+
/**
|
|
2109
|
+
* Where a vendored schema lands by default.
|
|
2110
|
+
*
|
|
2111
|
+
* **Not** `.docmeta/`, which is gitignored wholesale and holds the schema and
|
|
2112
|
+
* proposal caches. A vendored schema is the opposite kind of artifact: it has
|
|
2113
|
+
* to be committed, because being in the consuming repository's own history is
|
|
2114
|
+
* the entire point of vendoring.
|
|
2115
|
+
*/
|
|
2116
|
+
declare const DEFAULT_VENDOR_DIR = "./schema";
|
|
2117
|
+
interface VendorOptions {
|
|
2118
|
+
/** The `http(s)` URL to download. */
|
|
2119
|
+
url: string;
|
|
2120
|
+
/** Directory for the vendored copy, relative to `cwd`. Default `./schema`. */
|
|
2121
|
+
dir?: string;
|
|
2122
|
+
/** `-c/--config`. Absent discovers a config, or creates one in `cwd`. */
|
|
2123
|
+
configPath?: string;
|
|
2124
|
+
cwd?: string;
|
|
2125
|
+
/** Diagnostics for the user; the CLI writes these to stderr. */
|
|
2126
|
+
onNotice?: (message: string) => void;
|
|
2127
|
+
/** Fetch timeout, in ms. Defaults to the registry's. */
|
|
2128
|
+
timeoutMs?: number;
|
|
2129
|
+
/** Response size cap, in bytes. Defaults to the registry's. */
|
|
2130
|
+
maxBytes?: number;
|
|
2131
|
+
}
|
|
2132
|
+
interface VendorResult {
|
|
2133
|
+
/** The URL that was downloaded. */
|
|
2134
|
+
url: string;
|
|
2135
|
+
/** The vendored file, relative to `cwd`, posix-style. */
|
|
2136
|
+
file: string;
|
|
2137
|
+
/** The pin recorded for it. */
|
|
2138
|
+
integrity: string;
|
|
2139
|
+
/** Size of the vendored copy, in bytes. */
|
|
2140
|
+
bytes: number;
|
|
2141
|
+
/** The config that was written, relative to `cwd`, posix-style. */
|
|
2142
|
+
config: string;
|
|
2143
|
+
/** Whether that config had to be created. */
|
|
2144
|
+
configCreated: boolean;
|
|
2145
|
+
/** Whether an existing `schemas:` entry was replaced rather than appended. */
|
|
2146
|
+
replaced: boolean;
|
|
2147
|
+
/** Whether the downloaded bytes were identical to the copy already on disk. */
|
|
2148
|
+
unchanged: boolean;
|
|
2047
2149
|
}
|
|
2048
|
-
declare function runDerive(opts: DeriveOptions): Promise<DeriveRun>;
|
|
2049
|
-
|
|
2050
2150
|
/**
|
|
2051
|
-
* The
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2054
|
-
*
|
|
2055
|
-
*
|
|
2151
|
+
* The filename for a vendored schema, derived from the URL's last path segment.
|
|
2152
|
+
*
|
|
2153
|
+
* Sanitized rather than trusted: the segment reaches the filesystem, so
|
|
2154
|
+
* anything that is not an ordinary filename character is replaced, and a
|
|
2155
|
+
* leading dot is prefixed away so the copy cannot land as a hidden file that
|
|
2156
|
+
* directory walks skip.
|
|
2056
2157
|
*/
|
|
2057
|
-
declare
|
|
2158
|
+
declare function vendorFileName(url: string): string;
|
|
2058
2159
|
/**
|
|
2059
|
-
*
|
|
2060
|
-
*
|
|
2160
|
+
* Download a remote schema into the repository and pin it.
|
|
2161
|
+
*
|
|
2162
|
+
* The order of operations is the contract: everything that can refuse does so
|
|
2163
|
+
* *before* the network call or the write, so a refused run leaves the working
|
|
2164
|
+
* tree exactly as it found it.
|
|
2061
2165
|
*/
|
|
2062
|
-
declare
|
|
2166
|
+
declare function runVendorSchema(opts: VendorOptions): Promise<VendorResult>;
|
|
2167
|
+
|
|
2168
|
+
/** Shared shapes for the `fill` command, split out to keep imports acyclic. */
|
|
2169
|
+
|
|
2170
|
+
/** Why a proposed value was not written. */
|
|
2171
|
+
type SkipReason =
|
|
2172
|
+
/** Self-reported confidence was below the threshold. */
|
|
2173
|
+
"low-confidence"
|
|
2174
|
+
/** Writing it would leave the document failing its own schema. */
|
|
2175
|
+
| "schema-mismatch"
|
|
2176
|
+
/** The model declined to propose a value. */
|
|
2177
|
+
| "no-proposal"
|
|
2063
2178
|
/**
|
|
2064
|
-
* The `
|
|
2065
|
-
*
|
|
2179
|
+
* The field is managed by `derive` (`derive.fields` in the config), so it
|
|
2180
|
+
* was never sent for inference: only `manni meta derive` writes it.
|
|
2066
2181
|
*/
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
collection: string;
|
|
2075
|
-
/** Manifest path as the run reports it: relative to the run's base, posix — or the URL. */
|
|
2076
|
-
file: string;
|
|
2077
|
-
/** 1-based line of the key in the manifest, when known. */
|
|
2078
|
-
line?: number;
|
|
2182
|
+
| "managed";
|
|
2183
|
+
interface FilledField {
|
|
2184
|
+
/** JSON Pointer, e.g. "/title" — the same form `validate` reports. */
|
|
2185
|
+
field: string;
|
|
2186
|
+
required: boolean;
|
|
2187
|
+
confidence: number;
|
|
2188
|
+
reasoning: string;
|
|
2079
2189
|
/**
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2082
|
-
*
|
|
2083
|
-
* when `value` is a mapping or a list with members; `line` answers for the
|
|
2084
|
-
* value itself.
|
|
2190
|
+
* Absent when the field was skipped. `(encrypted)` when the field's schema
|
|
2191
|
+
* marks it `x-manni-encrypt`: the page holds the ciphertext, and no report
|
|
2192
|
+
* prints either that or the plaintext (proposal 0045).
|
|
2085
2193
|
*/
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
interface ExternalMetadataEntry {
|
|
2090
|
-
/** The collection whose manifest declared it (proposal 0041). */
|
|
2091
|
-
collection: string;
|
|
2092
|
-
/** `path`, or the frontmatter field this entry is keyed by. */
|
|
2093
|
-
join: string;
|
|
2094
|
-
/** Absolute document path, for a path entry. */
|
|
2095
|
-
abs?: string;
|
|
2096
|
-
/** The key exactly as written in the manifest. */
|
|
2097
|
-
spelled: string;
|
|
2098
|
-
/** Manifest path as the run reports it. */
|
|
2099
|
-
file: string;
|
|
2100
|
-
/** 1-based line of the entry in the manifest, when known. */
|
|
2101
|
-
line?: number;
|
|
2102
|
-
}
|
|
2103
|
-
/** Every manifest of a run, loaded once and consulted per document. */
|
|
2104
|
-
interface ExternalMetadataIndex {
|
|
2194
|
+
value?: unknown;
|
|
2195
|
+
written: boolean;
|
|
2196
|
+
skipReason?: SkipReason;
|
|
2105
2197
|
/**
|
|
2106
|
-
*
|
|
2107
|
-
*
|
|
2108
|
-
* A list rather than one entry, because two collections may legitimately
|
|
2109
|
-
* each own the same key (0041 rule 5): `guides` and `blog` can both supply
|
|
2110
|
-
* `owner`. Ambiguity only exists for a file that is a member of both, which
|
|
2111
|
-
* is decided per file in `mergeExternalMetadata`.
|
|
2198
|
+
* The value was written encrypted, because the field's schema marks it
|
|
2199
|
+
* `x-manni-encrypt`. Absent otherwise.
|
|
2112
2200
|
*/
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
byField: ReadonlyMap<string, ReadonlyMap<string, ReadonlyMap<string, ExternalMetadataValue>>>;
|
|
2121
|
-
/** Every manifest entry, in manifest order. */
|
|
2122
|
-
entries: readonly ExternalMetadataEntry[];
|
|
2201
|
+
encrypted?: boolean;
|
|
2202
|
+
/**
|
|
2203
|
+
* Proposal 0047: the manifest the value was written into, as the run
|
|
2204
|
+
* reports it, when a manifest of the page's collections owns the key.
|
|
2205
|
+
* Absent when the value went to the page.
|
|
2206
|
+
*/
|
|
2207
|
+
destination?: string;
|
|
2123
2208
|
}
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2209
|
+
/**
|
|
2210
|
+
* One `meta-provenance` entry as `fill` writes it (proposal 0046): the model,
|
|
2211
|
+
* the JSON Pointers of the fields it proposed, escaped per RFC 6901, and the
|
|
2212
|
+
* confidence each was written at. Keys are the page's own spelling, so the
|
|
2213
|
+
* JSON report shows exactly what landed in the document. An entry `fill`
|
|
2214
|
+
* merged into keeps whatever else it held.
|
|
2215
|
+
*/
|
|
2216
|
+
interface MetaProvenanceEntry {
|
|
2217
|
+
"generated-by": string;
|
|
2218
|
+
fields: string[];
|
|
2219
|
+
confidence: Record<string, number>;
|
|
2220
|
+
[other: string]: unknown;
|
|
2135
2221
|
}
|
|
2136
|
-
/**
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2222
|
+
/**
|
|
2223
|
+
* What became of this file's `meta-provenance` entry. It is never a failure:
|
|
2224
|
+
* neither outcome changes the summary or the exit code.
|
|
2225
|
+
*/
|
|
2226
|
+
type MetaProvenanceReport = {
|
|
2227
|
+
written: true;
|
|
2228
|
+
entry: MetaProvenanceEntry;
|
|
2229
|
+
/** The manifest the entry was written into, when one owns `meta-provenance` (0047). */
|
|
2230
|
+
destination?: string;
|
|
2141
2231
|
}
|
|
2142
|
-
/**
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
file: string;
|
|
2147
|
-
/** The collection that manifest belongs to (proposal 0041). */
|
|
2148
|
-
collection: string;
|
|
2232
|
+
/** The page's schemas, checked with the entry in place, reject it. */
|
|
2233
|
+
| {
|
|
2234
|
+
written: false;
|
|
2235
|
+
skipReason: "schema-mismatch";
|
|
2149
2236
|
}
|
|
2150
|
-
/** A
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2237
|
+
/** A URL manifest in one of the page's collections owns the key, and cannot be written (0047). */
|
|
2238
|
+
| {
|
|
2239
|
+
written: false;
|
|
2240
|
+
skipReason: "manifest-owned";
|
|
2241
|
+
manifest: string;
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* The format's writer cannot hold a list of entries (an HTML or XML
|
|
2245
|
+
* attribute holds one line), so the fields were written without it.
|
|
2246
|
+
*/
|
|
2247
|
+
| {
|
|
2248
|
+
written: false;
|
|
2249
|
+
skipReason: "unwritable";
|
|
2250
|
+
};
|
|
2251
|
+
interface FillFileResult {
|
|
2252
|
+
file: string;
|
|
2253
|
+
format: string;
|
|
2254
|
+
schemas: string[];
|
|
2255
|
+
fields: FilledField[];
|
|
2256
|
+
/** Whether the file's content changed (false under --dry-run too). */
|
|
2257
|
+
changed: boolean;
|
|
2258
|
+
/** Parse failure, read-only format, or provider error. */
|
|
2259
|
+
error?: string;
|
|
2260
|
+
/** The filled document. Populated only when the caller asks for it. */
|
|
2261
|
+
content?: string;
|
|
2155
2262
|
/**
|
|
2156
|
-
* The
|
|
2157
|
-
*
|
|
2158
|
-
*
|
|
2263
|
+
* The `meta-provenance` entry recording the fields this run wrote
|
|
2264
|
+
* (proposal 0046). Absent when no field was written; reported, not written,
|
|
2265
|
+
* under `--dry-run`.
|
|
2159
2266
|
*/
|
|
2160
|
-
|
|
2161
|
-
/** The manifest, as the run reports it. */
|
|
2162
|
-
file: string;
|
|
2163
|
-
/** The collection that manifest belongs to (proposal 0041). */
|
|
2164
|
-
collection: string;
|
|
2267
|
+
metaProvenance?: MetaProvenanceReport;
|
|
2165
2268
|
}
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2269
|
+
interface FillSummary {
|
|
2270
|
+
files: number;
|
|
2271
|
+
changed: number;
|
|
2272
|
+
written: number;
|
|
2273
|
+
skipped: number;
|
|
2274
|
+
/** Skipped fields that the schema lists as required — drives exit code 1. */
|
|
2275
|
+
requiredSkipped: number;
|
|
2276
|
+
errors: number;
|
|
2277
|
+
costUsd: number;
|
|
2278
|
+
cached: number;
|
|
2279
|
+
}
|
|
2280
|
+
interface FillRun {
|
|
2281
|
+
results: FillFileResult[];
|
|
2282
|
+
summary: FillSummary;
|
|
2283
|
+
/** Echoed so JSON consumers and CI can assert which gate actually ran. */
|
|
2284
|
+
threshold: number;
|
|
2285
|
+
dryRun: boolean;
|
|
2286
|
+
provider: string;
|
|
2287
|
+
model: string;
|
|
2288
|
+
/** True when the call cap stopped the run before every file was seen. */
|
|
2289
|
+
turnsSpent: boolean;
|
|
2290
|
+
}
|
|
2291
|
+
interface FillOptions {
|
|
2292
|
+
inputs: string[];
|
|
2293
|
+
cliSchemas?: string[];
|
|
2294
|
+
exts?: string[];
|
|
2295
|
+
exclude?: string[];
|
|
2296
|
+
/** `--as` format override (extractor name). */
|
|
2297
|
+
as?: string;
|
|
2298
|
+
configPath?: string;
|
|
2299
|
+
/** `--no-config`: skip config discovery and use the built-in defaults. */
|
|
2300
|
+
noConfig?: boolean;
|
|
2301
|
+
/**
|
|
2302
|
+
* `--collection <name>`, repeatable: run over the named configured
|
|
2303
|
+
* collections instead of every declared one (proposal 0041). Cannot be
|
|
2304
|
+
* combined with positional paths; `-` is allowed beside it.
|
|
2305
|
+
*/
|
|
2306
|
+
collections?: string[];
|
|
2307
|
+
cwd?: string;
|
|
2308
|
+
/** Content for the `-` (stdin) input, injected by the CLI/tests. */
|
|
2309
|
+
stdinContent?: string;
|
|
2310
|
+
/** Permit an input set that resolves to zero files (see `assertNonEmpty`). */
|
|
2311
|
+
allowEmpty?: boolean;
|
|
2312
|
+
/**
|
|
2313
|
+
* `--no-gitignore` (false). Absent leaves config `respectGitignore:` in
|
|
2314
|
+
* charge, which itself defaults to on.
|
|
2315
|
+
*/
|
|
2316
|
+
respectGitignore?: boolean;
|
|
2317
|
+
/** Diagnostics for the user; the CLI writes these to stderr. */
|
|
2318
|
+
onNotice?: (message: string) => void;
|
|
2319
|
+
/** Called once when a config governs the run, so the CLI can report it. */
|
|
2320
|
+
onConfigLoaded?: (info: ConfigNotice) => void;
|
|
2321
|
+
/**
|
|
2322
|
+
* `--offline`: never fetch a remote **schema**. Absent leaves config
|
|
2323
|
+
* `offline:` in charge.
|
|
2324
|
+
*
|
|
2325
|
+
* Scoped to schema loading only. It says nothing about the inference
|
|
2326
|
+
* provider, which is a separate network dependency with its own controls
|
|
2327
|
+
* (`--provider mock`, `--dry-run`).
|
|
2328
|
+
*/
|
|
2329
|
+
offline?: boolean;
|
|
2330
|
+
/** Restrict proposals to these top-level fields. */
|
|
2331
|
+
fields?: string[];
|
|
2332
|
+
/** Minimum self-reported confidence to write (0-1). Default 0.7. */
|
|
2333
|
+
confidence?: number;
|
|
2334
|
+
/** Report proposals without writing them. */
|
|
2335
|
+
dryRun?: boolean;
|
|
2336
|
+
provider?: string;
|
|
2337
|
+
model?: string;
|
|
2338
|
+
/** Use the on-disk proposal cache. Default true. */
|
|
2339
|
+
cache?: boolean;
|
|
2340
|
+
/** Refuse a hosted provider: inference must run on this machine. */
|
|
2341
|
+
local?: boolean;
|
|
2342
|
+
/** Stop after this many inference calls. Counts calls, not files. */
|
|
2343
|
+
maxTurns?: number;
|
|
2344
|
+
/** Characters of document per call. Default 12000. */
|
|
2345
|
+
chunkChars?: number;
|
|
2346
|
+
/** Files inferred in parallel. Default 4. */
|
|
2347
|
+
concurrency?: number;
|
|
2348
|
+
/** Include the filled document on each result (used for stdin and tests). */
|
|
2349
|
+
includeContent?: boolean;
|
|
2350
|
+
/** Test seam: bypasses `makeProvider`, so no API key is needed. */
|
|
2351
|
+
inferenceProvider?: InferenceProvider;
|
|
2352
|
+
/**
|
|
2353
|
+
* How to ask for a new encryption key when a field its schema marks
|
|
2354
|
+
* `x-manni-encrypt` is about to be written and no key is available
|
|
2355
|
+
* (proposal 0045). The CLI passes `terminalConfirm()`, which is `undefined`
|
|
2356
|
+
* off a terminal; absent, the run refuses (exit 2) before the first model
|
|
2357
|
+
* request.
|
|
2358
|
+
*/
|
|
2359
|
+
confirm?: Confirm;
|
|
2170
2360
|
/**
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
2173
|
-
* second lookup, and without a fallback for an index that is not there.
|
|
2361
|
+
* The environment `MANNI_ENCRYPTION_KEY` is read from. Defaults to
|
|
2362
|
+
* `process.env`; tests pass their own.
|
|
2174
2363
|
*/
|
|
2175
|
-
|
|
2176
|
-
/** Field-joined entries this document matched, one per manifest at most. */
|
|
2177
|
-
joins: ExternalMetadataJoin[];
|
|
2364
|
+
env?: NodeJS.ProcessEnv;
|
|
2178
2365
|
/**
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
* beneath it — and `undefined` for everything the document owns, which is
|
|
2182
|
-
* what `lineFor` is for.
|
|
2183
|
-
*
|
|
2184
|
-
* The line is the deepest manifest node the pointer reaches, so
|
|
2185
|
-
* `/citations/2` is the third item's line and `/citations/2/source/file`
|
|
2186
|
-
* that member's. A pointer past what the manifest holds falls back to the
|
|
2187
|
-
* nearest ancestor that exists, and at worst to the owned key's line.
|
|
2366
|
+
* Called with relocate's result after the user accepts a P1 offer
|
|
2367
|
+
* (proposal 0047), so the CLI can print what moved before the report.
|
|
2188
2368
|
*/
|
|
2189
|
-
|
|
2369
|
+
onRelocated?: (result: RelocateResult) => void;
|
|
2190
2370
|
}
|
|
2191
|
-
/** The join an external-metadata config asks for: `path` unless it names a field. */
|
|
2192
|
-
declare function externalMetadataJoin(manifest: Pick<ExternalMetadataConfig, "join">): string;
|
|
2193
|
-
/**
|
|
2194
|
-
* Load every manifest of every collection the run covers. Resolves to `null`
|
|
2195
|
-
* when none of them declares one, which is every setup that existed before
|
|
2196
|
-
* this feature.
|
|
2197
|
-
*
|
|
2198
|
-
* Every refusal is a `DocmetaError`: the manifest is a config-supplied input,
|
|
2199
|
-
* and one that is missing or misshapen is the run's problem, not a
|
|
2200
|
-
* document's (0014).
|
|
2201
|
-
*/
|
|
2202
|
-
declare function loadExternalMetadata(collections: readonly CollectionConfig[], opts: LoadExternalMetadataOptions): Promise<ExternalMetadataIndex | null>;
|
|
2203
|
-
/**
|
|
2204
|
-
* Merge the external metadata for one document into its extracted metadata.
|
|
2205
|
-
*
|
|
2206
|
-
* `label` is the document as the run spells it, relative to `base`; a path
|
|
2207
|
-
* entry matches on the resolved absolute path, never on the spelling, so a
|
|
2208
|
-
* positional run from a subdirectory finds the same entry a config-corpus
|
|
2209
|
-
* run does. A field entry matches on the document's own value of the join
|
|
2210
|
-
* field, wherever the document lives. Stdin never matches a path entry:
|
|
2211
|
-
* there is no file behind it.
|
|
2212
|
-
*
|
|
2213
|
-
* `memberOf` names the collections this document belongs to, and only their
|
|
2214
|
-
* manifests are consulted (0041 rule 4). It is the caller's `memberOf(...)`
|
|
2215
|
-
* result, computed once per file.
|
|
2216
|
-
*
|
|
2217
|
-
* `present`, `format` and the document's own positions are untouched. A
|
|
2218
|
-
* manifest key is not in the document, so `lineFor` keeps answering
|
|
2219
|
-
* `undefined` for it, and `locate` answers instead.
|
|
2220
|
-
*
|
|
2221
|
-
* A join field the page holds encrypted (proposal 0045) is decrypted with
|
|
2222
|
-
* `options.encryptionKey` before it is matched. With no key, and a manifest
|
|
2223
|
-
* of this document's collections joining on that field, the run cannot match
|
|
2224
|
-
* and refuses. A ciphertext that does not decrypt matches nothing.
|
|
2225
|
-
*/
|
|
2226
|
-
declare function mergeExternalMetadata(label: string, extracted: ExtractedMetadata, index: ExternalMetadataIndex | null, memberOf: readonly string[], base: string, options?: {
|
|
2227
|
-
encryptionKey?: () => string | undefined;
|
|
2228
|
-
}): MergedMetadata;
|
|
2229
|
-
/** The `/key` pointer for an external-metadata finding, RFC 6901 escaped. */
|
|
2230
|
-
declare function externalMetadataPointer(key: string): string;
|
|
2231
|
-
/**
|
|
2232
|
-
* Path entries naming no loaded document.
|
|
2233
|
-
*
|
|
2234
|
-
* `loaded` are the run's file labels, relative to `base`. Checked only when
|
|
2235
|
-
* the run is the config corpus (the same invariant corpus checks use): a
|
|
2236
|
-
* positional path means the operator chose to look at part of the corpus,
|
|
2237
|
-
* and an entry for the rest is expected, not orphaned.
|
|
2238
|
-
*/
|
|
2239
|
-
declare function orphanEntries(index: ExternalMetadataIndex | null, loaded: readonly string[], base: string, collections?: readonly string[]): ExternalMetadataEntry[];
|
|
2240
|
-
/**
|
|
2241
|
-
* Field entries no loaded document matched (0039). `matched` is field -> the
|
|
2242
|
-
* values documents in the run carried, which the caller collects from each
|
|
2243
|
-
* document's `joins` — so this runs after the per-file loop, under the same
|
|
2244
|
-
* corpus invariant as `orphanEntries`.
|
|
2245
|
-
*/
|
|
2246
|
-
declare function orphanJoins(index: ExternalMetadataIndex | null, matched: ReadonlyMap<string, ReadonlySet<string>>, collections?: readonly string[]): ExternalMetadataEntry[];
|
|
2247
|
-
/** The operational error an orphan check raises, naming the first entry. */
|
|
2248
|
-
declare function orphanError(orphans: readonly ExternalMetadataEntry[]): DocmetaError;
|
|
2249
2371
|
|
|
2250
|
-
declare
|
|
2251
|
-
|
|
2372
|
+
declare function runFill(opts: FillOptions): Promise<FillRun>;
|
|
2373
|
+
|
|
2374
|
+
interface DeriveOptions {
|
|
2375
|
+
inputs: string[];
|
|
2252
2376
|
/**
|
|
2253
|
-
*
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2256
|
-
* settings.
|
|
2257
|
-
*
|
|
2258
|
-
* That is not full isolation, and the difference matters to a library
|
|
2259
|
-
* caller: `schema-registry` keeps a process-wide memo of fetched schemas, so
|
|
2260
|
-
* one validator's successful fetch is visible to another. `offline` is
|
|
2261
|
-
* excluded from that sharing on purpose — an offline validator will not be
|
|
2262
|
-
* served something this process pulled over the network — but the memo is
|
|
2263
|
-
* still shared, so a URL fetched once is not re-fetched per instance.
|
|
2377
|
+
* `--collection <name>`, repeatable: stamp only the named configured
|
|
2378
|
+
* collections instead of every declared one (proposal 0041). Cannot be
|
|
2379
|
+
* combined with paths.
|
|
2264
2380
|
*/
|
|
2265
|
-
|
|
2266
|
-
|
|
2381
|
+
collections?: string[];
|
|
2382
|
+
/** `--fields`: the managed fields to stamp this run; config `derive.fields` otherwise. */
|
|
2383
|
+
fields?: string[];
|
|
2384
|
+
/** `--sources`: the sources to consult; config `derive.sources`, else all four. */
|
|
2385
|
+
sources?: string[];
|
|
2386
|
+
/** `--dry-run`: report what would change and write nothing. */
|
|
2387
|
+
dryRun?: boolean;
|
|
2388
|
+
/** `--check`: implies `dryRun`; stale and unset fields are findings. */
|
|
2389
|
+
check?: boolean;
|
|
2390
|
+
/** Use the on-disk GitHub or GitLab review cache. Default true. */
|
|
2391
|
+
cache?: boolean;
|
|
2392
|
+
/** `--as` format override (extractor name). */
|
|
2393
|
+
as?: string;
|
|
2394
|
+
exts?: string[];
|
|
2395
|
+
exclude?: string[];
|
|
2396
|
+
configPath?: string;
|
|
2397
|
+
/** `--no-config`: skip config discovery and use the built-in defaults. */
|
|
2398
|
+
noConfig?: boolean;
|
|
2399
|
+
cwd?: string;
|
|
2400
|
+
/** Permit an input set that resolves to zero files (see `assertNonEmpty`). */
|
|
2401
|
+
allowEmpty?: boolean;
|
|
2267
2402
|
/**
|
|
2268
|
-
*
|
|
2269
|
-
*
|
|
2270
|
-
* pool, so every worker missed the cache while the first `loadSchema` was
|
|
2271
|
-
* still pending and they all then compiled the same schema into the one
|
|
2272
|
-
* shared per-dialect Ajv. Ajv registers a schema's `$id` on the first compile
|
|
2273
|
-
* and rejects the second with "schema with key or id ... already exists",
|
|
2274
|
-
* which took down any multi-file run against an $id-bearing schema. Storing
|
|
2275
|
-
* the promise before the first await lets the losers await the one compile.
|
|
2403
|
+
* `--no-gitignore` (false). Absent leaves config `respectGitignore:` in
|
|
2404
|
+
* charge, which itself defaults to on.
|
|
2276
2405
|
*/
|
|
2277
|
-
|
|
2278
|
-
|
|
2406
|
+
respectGitignore?: boolean;
|
|
2407
|
+
/** Diagnostics for the user; the CLI writes these to stderr. */
|
|
2408
|
+
onNotice?: (message: string) => void;
|
|
2409
|
+
/** Called once when a config governs the run, so the CLI can report it. */
|
|
2410
|
+
onConfigLoaded?: (info: ConfigNotice) => void;
|
|
2411
|
+
/** The clock an uncommitted body change is dated by. Test seam; default `new Date()`. */
|
|
2412
|
+
now?: () => Date;
|
|
2413
|
+
/** The review client, for every repository in the run. Test seam; default `gh` / `glab`. */
|
|
2414
|
+
reviews?: ReviewClient;
|
|
2279
2415
|
/**
|
|
2280
|
-
*
|
|
2281
|
-
*
|
|
2416
|
+
* How to ask for a new encryption key when a field its schema marks
|
|
2417
|
+
* `x-manni-encrypt` is about to be stamped and no key is available
|
|
2418
|
+
* (proposal 0045). The CLI passes `terminalConfirm()`, which is `undefined`
|
|
2419
|
+
* off a terminal; absent, such a stamp refuses (exit 2). A dry run never
|
|
2420
|
+
* asks: it writes nothing.
|
|
2282
2421
|
*/
|
|
2283
|
-
|
|
2284
|
-
private compileUncached;
|
|
2422
|
+
confirm?: Confirm;
|
|
2285
2423
|
/**
|
|
2286
|
-
* The
|
|
2287
|
-
*
|
|
2288
|
-
*
|
|
2289
|
-
* A first pass with the recording keyword, so a mark counts exactly where
|
|
2290
|
-
* validation would evaluate it. Only present values are marked: Ajv applies
|
|
2291
|
-
* a property's subschema to a property that exists. A branch Ajv does not
|
|
2292
|
-
* take (`then` behind a failing `if`, an `anyOf` branch after a passing
|
|
2293
|
-
* one) contributes nothing; a branch it takes contributes its marks
|
|
2294
|
-
* whether or not the branch passes, because a ciphertext routinely fails
|
|
2295
|
-
* the rest of its own subschema until it is decrypted.
|
|
2424
|
+
* The environment `MANNI_ENCRYPTION_KEY` is read from. Defaults to
|
|
2425
|
+
* `process.env`; tests pass their own.
|
|
2296
2426
|
*/
|
|
2297
|
-
|
|
2427
|
+
env?: NodeJS.ProcessEnv;
|
|
2298
2428
|
/**
|
|
2299
|
-
*
|
|
2300
|
-
*
|
|
2301
|
-
* `
|
|
2302
|
-
*
|
|
2303
|
-
* `colFor` is optional and additive: this signature is public, so a fourth
|
|
2304
|
-
* *required* parameter — or a widened third one — would be a consumer break.
|
|
2305
|
-
* Callers with an extractor that supplies no column pass nothing and get the
|
|
2306
|
-
* previous behavior exactly.
|
|
2429
|
+
* `--generated-by <name>` (proposal 0046): the machine uncommitted body
|
|
2430
|
+
* lines go to, or the lines a `<path>:L1-L2` positional names. Absent reads
|
|
2431
|
+
* `MANNI_GENERATED_BY` from `env`; an empty value is unset either way.
|
|
2307
2432
|
*/
|
|
2308
|
-
|
|
2433
|
+
generatedBy?: string;
|
|
2309
2434
|
/**
|
|
2310
|
-
*
|
|
2311
|
-
*
|
|
2312
|
-
* and additive in the way `colFor` was.
|
|
2435
|
+
* Called with relocate's result after the user accepts a P1 offer
|
|
2436
|
+
* (proposal 0047), so the CLI can print what moved before the report.
|
|
2313
2437
|
*/
|
|
2314
|
-
|
|
2438
|
+
onRelocated?: (result: RelocateResult) => void;
|
|
2439
|
+
}
|
|
2440
|
+
interface DeriveFileResult {
|
|
2441
|
+
file: string;
|
|
2442
|
+
/** Extractor/format used; `unknown` when none matched the file. */
|
|
2443
|
+
format: string;
|
|
2444
|
+
/** One entry per requested field, in the requested order. Empty on `error`. */
|
|
2445
|
+
fields: DerivedField[];
|
|
2446
|
+
/**
|
|
2447
|
+
* Whether writing the stale and unset fields changed the document, or
|
|
2448
|
+
* would have but for `dryRun`. Computed from the writer's output, so a
|
|
2449
|
+
* patch the format serializes to the same bytes is not a change.
|
|
2450
|
+
*/
|
|
2451
|
+
changed: boolean;
|
|
2452
|
+
/** Why the file could not be derived or written; the run goes on without it. */
|
|
2453
|
+
error?: string;
|
|
2454
|
+
/**
|
|
2455
|
+
* Under `check`, the findings for this file: one per stale or unset field,
|
|
2456
|
+
* at the field's line, plus one for an `error`. Absent otherwise.
|
|
2457
|
+
*/
|
|
2458
|
+
findings?: FieldError[];
|
|
2459
|
+
}
|
|
2460
|
+
interface DeriveSummary {
|
|
2461
|
+
files: number;
|
|
2462
|
+
/** Files whose document changed, or would have under `dryRun`. */
|
|
2463
|
+
changed: number;
|
|
2464
|
+
/** Fields whose write reached the disk: always 0 under `dryRun` and `check`. */
|
|
2465
|
+
written: number;
|
|
2466
|
+
/**
|
|
2467
|
+
* `provenance` ranges whose write reached the disk (proposal 0046): always
|
|
2468
|
+
* 0 under `dryRun` and `check`. Present only when the run derives
|
|
2469
|
+
* `provenance`.
|
|
2470
|
+
*/
|
|
2471
|
+
ranges?: number;
|
|
2472
|
+
stale: number;
|
|
2473
|
+
unset: number;
|
|
2474
|
+
unknown: number;
|
|
2475
|
+
errors: number;
|
|
2476
|
+
}
|
|
2477
|
+
interface DeriveRun {
|
|
2478
|
+
results: DeriveFileResult[];
|
|
2479
|
+
summary: DeriveSummary;
|
|
2480
|
+
dryRun: boolean;
|
|
2481
|
+
check: boolean;
|
|
2482
|
+
/** One status per source the run consulted; a source nobody asked for is absent. */
|
|
2483
|
+
sources: Partial<Record<DeriveSource, SourceStatus$1>>;
|
|
2484
|
+
/** Where the run stood, for the SARIF reporter under `check`. See `ValidateRun.frame`. */
|
|
2485
|
+
frame: FingerprintContext;
|
|
2486
|
+
}
|
|
2487
|
+
declare function runDerive(opts: DeriveOptions): Promise<DeriveRun>;
|
|
2488
|
+
|
|
2489
|
+
/**
|
|
2490
|
+
* `relocate` (proposal 0047): move every value to where its schema's
|
|
2491
|
+
* `x-manni-location` mark and the config's manifests say it belongs.
|
|
2492
|
+
*
|
|
2493
|
+
* Out of the page and into a manifest go the values a schema prefers in
|
|
2494
|
+
* external metadata and the values a manifest already owns. Out of a manifest
|
|
2495
|
+
* and into the page go the values a schema prefers on the page. The
|
|
2496
|
+
* collection, manifest file and config entry a value needs are created on the
|
|
2497
|
+
* way, and a change to a manifest's `keys:` covers every member page of its
|
|
2498
|
+
* collection. The planning and writing live in `core/relocation.ts`, which the
|
|
2499
|
+
* writers' and validate's offers share; this is the command around it.
|
|
2500
|
+
*
|
|
2501
|
+
* Two refusals come before the config is read, because each rules out the
|
|
2502
|
+
* whole run: stdin, which is not a document a manifest can name, and
|
|
2503
|
+
* `--no-config`, which leaves nowhere to declare a manifest.
|
|
2504
|
+
*/
|
|
2505
|
+
|
|
2506
|
+
interface RelocateOptions {
|
|
2507
|
+
/** Files, directories and globs. Empty falls back to the configured collections. `-` is refused. */
|
|
2508
|
+
inputs: string[];
|
|
2509
|
+
/** `--fields`: only these keys. Each must carry a mark, or be manifest-owned, for some file. */
|
|
2510
|
+
fields?: string[];
|
|
2511
|
+
/** `--collection <name>`, repeatable: run over these configured collections. */
|
|
2512
|
+
collections?: string[];
|
|
2513
|
+
/** `-s/--schema`, repeatable: the schema set every page is judged by. */
|
|
2514
|
+
cliSchemas?: string[];
|
|
2515
|
+
/** `--dry-run`: report what would move and be created; write nothing. */
|
|
2516
|
+
dryRun?: boolean;
|
|
2517
|
+
/** `--as`: force an extractor. */
|
|
2518
|
+
as?: string;
|
|
2519
|
+
exts?: string[];
|
|
2520
|
+
exclude?: string[];
|
|
2521
|
+
configPath?: string;
|
|
2522
|
+
/** `--no-config`: refused, since relocate writes the config. */
|
|
2523
|
+
noConfig?: boolean;
|
|
2524
|
+
cwd?: string;
|
|
2525
|
+
allowEmpty?: boolean;
|
|
2526
|
+
/** `--no-gitignore` (false). Absent leaves config `respectGitignore:` in charge. */
|
|
2527
|
+
respectGitignore?: boolean;
|
|
2528
|
+
onNotice?: (message: string) => void;
|
|
2529
|
+
onConfigLoaded?: (info: ConfigNotice) => void;
|
|
2530
|
+
/** Where `MANNI_ENCRYPTION_KEY` is read, for an encrypted join field. Defaults to `process.env`. */
|
|
2531
|
+
env?: NodeJS.ProcessEnv;
|
|
2315
2532
|
}
|
|
2533
|
+
declare function runRelocate(opts: RelocateOptions): Promise<RelocateResult>;
|
|
2316
2534
|
|
|
2317
2535
|
/** One value re-encrypted: where, and the ciphertext before and after. */
|
|
2318
2536
|
interface ReencryptedValue {
|
|
@@ -3211,15 +3429,13 @@ contents: string | Uint8Array): Promise<void>;
|
|
|
3211
3429
|
|
|
3212
3430
|
/**
|
|
3213
3431
|
* Extractor registry. Maps file extensions to extractors and resolves an
|
|
3214
|
-
* extractor by name (for the `--as` override).
|
|
3215
|
-
*
|
|
3216
|
-
* declared-but-unwired format out of directory walks, so an unfinished format
|
|
3217
|
-
* can be registered without becoming "supported".
|
|
3432
|
+
* extractor by name (for the `--as` override). A registered extractor reads
|
|
3433
|
+
* its format, so registration is what makes an extension supported.
|
|
3218
3434
|
*/
|
|
3219
3435
|
|
|
3220
|
-
/** Resolve
|
|
3436
|
+
/** Resolve the extractor for a file extension (incl. dot). */
|
|
3221
3437
|
declare function extractorForExtension(ext: string): MetadataExtractor | undefined;
|
|
3222
|
-
/** Extensions handled by
|
|
3438
|
+
/** Extensions handled by registered extractors (used for directory walks). */
|
|
3223
3439
|
declare function supportedExtensions(): string[];
|
|
3224
3440
|
|
|
3225
3441
|
type KeySource = "env" | "config" | "none";
|
|
@@ -3271,7 +3487,7 @@ interface CitationSource {
|
|
|
3271
3487
|
/** The git commit hash the pin was taken at: 7 to 64 lowercase hex. */
|
|
3272
3488
|
"commit-sha"?: string;
|
|
3273
3489
|
}
|
|
3274
|
-
/** One entry of `citations`, as the schema (`manni:citations:1.0.0-proposal.
|
|
3490
|
+
/** One entry of `citations`, as the schema (`manni:citations:1.0.0-proposal.4`) spells it. */
|
|
3275
3491
|
interface Citation {
|
|
3276
3492
|
id?: string;
|
|
3277
3493
|
claim?: CitationClaim;
|
|
@@ -3907,12 +4123,9 @@ declare function readSource(root: string, index: SourceIndex, range: SourceRange
|
|
|
3907
4123
|
* `indexOf` for the delimiters, never a regex over the whole page, and is
|
|
3908
4124
|
* handed the body only, so a `cite` inside frontmatter is never matched.
|
|
3909
4125
|
*
|
|
3910
|
-
* It does not read code. An opener inside a fenced block
|
|
3911
|
-
*
|
|
3912
|
-
*
|
|
3913
|
-
* backticks closed by a run of the same length on the same line) is skipped,
|
|
3914
|
-
* so a page that documents the syntax carries no statements. html and xml
|
|
3915
|
-
* have neither; a `<pre>` is not code to this scanner.
|
|
4126
|
+
* It does not read code. An opener inside a fenced block or a backtick span,
|
|
4127
|
+
* as `src/shared/code-regions.ts` finds them, is skipped, so a page that
|
|
4128
|
+
* documents the syntax carries no statements.
|
|
3916
4129
|
*
|
|
3917
4130
|
* Every form parses in both markdown and mdx. The first form is what
|
|
3918
4131
|
* `formatStatement` writes: the html comment for markdown, the jsx comment
|
|
@@ -4993,4 +5206,4 @@ declare namespace index {
|
|
|
4993
5206
|
export { type index_EncryptionContext as EncryptionContext, index_KeyError as KeyError, type index_KeyRotateOptions as KeyRotateOptions, type index_KeyRotateResult as KeyRotateResult, type index_KeySetOptions as KeySetOptions, type index_KeySetResult as KeySetResult, type index_KeySource as KeySource, type index_ResolvedKey as ResolvedKey, type index_RotateManifest as RotateManifest, type index_RotateOutcome as RotateOutcome, type index_RotatePage as RotatePage, type index_RotatedCitation as RotatedCitation, type index_RotatedManifestValue as RotatedManifestValue, type index_RotatedMetadata as RotatedMetadata, type index_RotatedValue as RotatedValue, type index_SkippedCitation as SkippedCitation, type index_SkippedManifestValue as SkippedManifestValue, type index_SkippedMetadata as SkippedMetadata, type index_SkippedValue as SkippedValue, index_decryptValue as decryptValue, index_encryptValue as encryptValue, index_isEncryptedValue as isEncryptedValue, index_resolveEncryptionKey as resolveEncryptionKey, index_runKeyRotate as runKeyRotate, index_runKeySet as runKeySet };
|
|
4994
5207
|
}
|
|
4995
5208
|
|
|
4996
|
-
export { type ApplyOptions, type Approval, type BaselineSummary, BinMissing, type BuiltinDerivableField, COMMON_FORMATS, type CheckConfig, type CollectionConfig, type CommandSourceOptions, type CommandSourceResult, type CommonFormat, type ConfigNotice, DEFAULT_SCHEMAS, DEFAULT_TTL_HOURS, DEFAULT_VENDOR_DIR, DERIVABLE_FIELDS, DERIVED_KEYWORD, DERIVED_STALE_SCHEMA, DERIVE_FORMATS, DERIVE_SOURCES, type DerivableField, type DeriveCommand, type DeriveCommandConfig, type DeriveConfig, type DeriveContext, type DeriveFileResult, type DeriveInput, type DeriveOptions, type DeriveReportFormat, type DeriveReportOptions, type DeriveResult, type DeriveRun, type DeriveSource, type DeriveSummary, type DerivedField, type DerivedRecord, type DerivedStatus, type DerivedValue, type DocmetaConfig, DocmetaError, type DocumentRefTrust, EXTERNAL_DUPLICATE_SCHEMA, EXTERNAL_KEYWORD, EXTERNAL_METADATA_FETCH_MAX_BYTES, EXTERNAL_METADATA_FETCH_TIMEOUT_MS, EXTERNAL_OWNED_SCHEMA, type ExternalMetadataCollision, type ExternalMetadataConfig, type ExternalMetadataEntry, type ExternalMetadataFetchOptions, type ExternalMetadataIndex, type ExternalMetadataJoin, type ExternalMetadataValue, type ExtractOptions, type ExtractedMetadata, FIELD_SOURCES, FILL_FORMATS, type FetchedSchema, type FieldError, type FillConfig, type FillFileResult, type FillOptions, type FillReportFormat, type FillReportOptions, type FillRun, type FillSummary, type FilledField, type FingerprintContext, type FrontmatterFlavor, type FrontmatterLocation, type GetFileResult, type GetOptions, type GetReportOptions, GitHubClient, GitLabClient, INTEGRITY_SHAPE, type JunitOptions, type LoadExternalMetadataOptions, type LoadSchemaOptions, type LoadedConfig, type MergedChange, type MergedMetadata, type MetadataExtractor, type MetadataPatch, PATH_JOIN, PATH_PLACEHOLDER, QUERY_FORMATS, type QueryChange, type QueryFormat, type QueryOptions, type QueryReportOptions, type QueryRun, REPORT_FORMATS, RESOLVED_VIEW, REVIEW_CACHE_DIR, REVIEW_CACHE_VERSION, type ReadOptions, type ReencryptMetadataResult, type ReencryptedValue, type RemoteIdentity, type ReportFormat, type ReportOptions, ReviewCache, type ReviewClient, type ReviewFacts, type ReviewSourceInput, type ReviewSourceResult, type Run, type RunConfig, type RunConfigOptions, type RunSummary, SCHEMA_CACHE_DIR, SCHEMA_CACHE_VERSION, type SarifOptions, SchemaCache, type SchemaCacheConfig, type SchemaCacheEntry, type SchemaEntry, type SchemaPin, type SchemaRefEntry, type SchemaTrustConfig, type SkipReason, type SourceLocation, type SourceStatus$1 as SourceStatus, type SpawnOptions, type ValidateOptions, type ValidateRun, type ValidationResult, Validator, type VendorOptions, type VendorResult, applyFrontmatter, argvFor, assertSourcesAvailable, cachedClient, index$1 as cite, classifyRef, collectSchemaPins, compareDerived, consultedSources, createResolvedView, createReviewClient, deriveFromCommands, deriveFromReviews, deriveMetadata, externalMetadataJoin, externalMetadataPointer, externalMetadataUrlProblem, extractFrontmatter, extractorForExtension, fetchExternalMetadata, fetchSchemaBytes, frontmatterInnerText, getSchemasInfo, identityFromOrigin, integrityOf, isBuiltinField, isCommonFormat, isDeriveFormat, isDeriveSource, isErrorSeverity, isFillFormat, isIntegrity, isMember, isPerFile, isQueryFormat, isReportFormat, index as key, listBuiltins, loadConfig, loadExternalMetadata, loadSchema, locateFrontmatter, memberOf, mentionsResolved, mergeExternalMetadata, orphanEntries, orphanError, orphanJoins, parseCollections, parseConfig, parseOriginUrl, rebaseConfigSchemaRefs, reencryptMetadata, render, renderDerive, renderFill, renderFillGithub, renderGet, renderJunit, renderQuery, renderQueryCsv, renderSarif, resolveRunConfig, resolveSchemaSet, resolvedColumns, run, runDerive, runFill, runGet, runQuery, runValidate, runVendorSchema, schemaCacheDir, schemaEntryRef, schemaLoadOptions, selectCollections, sourcesFor, staleFindings, stringifyValue, supportedExtensions, valueOf, vendorFileName, writeFileAtomic };
|
|
5209
|
+
export { type ApplyOptions, type Approval, type BaselineSummary, BinMissing, type BuiltinDerivableField, COMMON_FORMATS, type CheckConfig, type CollectionConfig, type CommandSourceOptions, type CommandSourceResult, type CommonFormat, type ConfigNotice, DEFAULT_SCHEMAS, DEFAULT_TTL_HOURS, DEFAULT_VENDOR_DIR, DERIVABLE_FIELDS, DERIVED_KEYWORD, DERIVED_STALE_SCHEMA, DERIVE_FORMATS, DERIVE_SOURCES, type DerivableField, type DeriveCommand, type DeriveCommandConfig, type DeriveConfig, type DeriveContext, type DeriveFileResult, type DeriveInput, type DeriveOptions, type DeriveReportFormat, type DeriveReportOptions, type DeriveResult, type DeriveRun, type DeriveSource, type DeriveSummary, type DerivedField, type DerivedRecord, type DerivedStatus, type DerivedValue, type DocmetaConfig, DocmetaError, type DocumentRefTrust, EXTERNAL_DUPLICATE_SCHEMA, EXTERNAL_KEYWORD, EXTERNAL_METADATA_FETCH_MAX_BYTES, EXTERNAL_METADATA_FETCH_TIMEOUT_MS, EXTERNAL_OWNED_SCHEMA, type ExternalMetadataCollision, type ExternalMetadataConfig, type ExternalMetadataEntry, type ExternalMetadataFetchOptions, type ExternalMetadataIndex, type ExternalMetadataJoin, type ExternalMetadataValue, type ExtractOptions, type ExtractedMetadata, FIELD_SOURCES, FILL_FORMATS, type FetchedSchema, type FieldError, type FieldLocation, type FillConfig, type FillFileResult, type FillOptions, type FillReportFormat, type FillReportOptions, type FillRun, type FillSummary, type FilledField, type FingerprintContext, type FrontmatterFlavor, type FrontmatterLocation, type GetFileResult, type GetOptions, type GetReportOptions, GitHubClient, GitLabClient, INTEGRITY_SHAPE, type JunitOptions, LOCATION_KEYWORD, type LoadExternalMetadataOptions, type LoadSchemaOptions, type LoadedConfig, type LocationPreference, type MergedChange, type MergedMetadata, type MetadataExtractor, type MetadataPatch, PATH_JOIN, PATH_PLACEHOLDER, QUERY_FORMATS, type QueryChange, type QueryFormat, type QueryOptions, type QueryReportOptions, type QueryRun, REPORT_FORMATS, RESOLVED_VIEW, REVIEW_CACHE_DIR, REVIEW_CACHE_VERSION, type ReadOptions, type ReencryptMetadataResult, type ReencryptedValue, type RelocateOptions, type RelocateResult, type RemoteIdentity, type ReportFormat, type ReportOptions, ReviewCache, type ReviewClient, type ReviewFacts, type ReviewSourceInput, type ReviewSourceResult, type Run, type RunConfig, type RunConfigOptions, type RunSummary, SCHEMA_CACHE_DIR, SCHEMA_CACHE_VERSION, type SarifOptions, SchemaCache, type SchemaCacheConfig, type SchemaCacheEntry, type SchemaEntry, type SchemaPin, type SchemaRefEntry, type SchemaTrustConfig, type SkipReason, type SourceLocation, type SourceStatus$1 as SourceStatus, type SpawnOptions, type ValidateOptions, type ValidateRun, type ValidationResult, Validator, type VendorOptions, type VendorResult, applyFrontmatter, argvFor, assertSourcesAvailable, cachedClient, index$1 as cite, classifyRef, collectSchemaPins, compareDerived, consultedSources, createResolvedView, createReviewClient, deriveFromCommands, deriveFromReviews, deriveMetadata, externalMetadataJoin, externalMetadataPointer, externalMetadataUrlProblem, extractFrontmatter, extractorForExtension, fetchExternalMetadata, fetchSchemaBytes, frontmatterInnerText, getSchemasInfo, identityFromOrigin, integrityOf, isBuiltinField, isCommonFormat, isDeriveFormat, isDeriveSource, isErrorSeverity, isFillFormat, isIntegrity, isMember, isPerFile, isQueryFormat, isReportFormat, index as key, listBuiltins, loadConfig, loadExternalMetadata, loadSchema, locateFrontmatter, memberOf, mentionsResolved, mergeExternalMetadata, orphanEntries, orphanError, orphanJoins, parseCollections, parseConfig, parseOriginUrl, rebaseConfigSchemaRefs, reencryptMetadata, render, renderDerive, renderFill, renderFillGithub, renderGet, renderJunit, renderQuery, renderQueryCsv, renderSarif, resolveRunConfig, resolveSchemaSet, resolvedColumns, run, runDerive, runFill, runGet, runQuery, runRelocate, runValidate, runVendorSchema, schemaCacheDir, schemaEntryRef, schemaLoadOptions, selectCollections, sourcesFor, staleFindings, stringifyValue, supportedExtensions, valueOf, vendorFileName, writeFileAtomic };
|