@agenticprimitives/scripture-content-extension 1.0.0-alpha.6
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/CLAUDE.md +47 -0
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/canon.d.ts +12 -0
- package/dist/canon.d.ts.map +1 -0
- package/dist/canon.js +99 -0
- package/dist/canon.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/spec.md +13 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @agenticprimitives/scripture-content-extension — Claude guide
|
|
2
|
+
|
|
3
|
+
The **scripture vertical** for the verifiable-content substrate (spec 267). It
|
|
4
|
+
lives in the **`domains/` tier** (NOT `packages/`) — a reusable, named package
|
|
5
|
+
that carries vertical vocabulary, kept out of the pure-substrate `packages/` tree
|
|
6
|
+
(ADR-0021 + ADR-0033). Generic core stays in `packages/content-primitives`.
|
|
7
|
+
|
|
8
|
+
## What it owns
|
|
9
|
+
|
|
10
|
+
- `BOOKS` / `lookupBook` — the 66-book Bible canon (OSIS codes). Reference data,
|
|
11
|
+
not a translation, not rendering text.
|
|
12
|
+
- `VERSIFICATION_V1` — the versioned verse-numbering model (the governance seam;
|
|
13
|
+
spec 266 §2.1). Changing it = a deliberate new canonicalId namespace.
|
|
14
|
+
- `scriptureCanonicalLocus()` / `scriptureEnvelope()` — the **controlled-token,
|
|
15
|
+
scheme-independent** locus + envelope the core hashes into a `canonicalId`.
|
|
16
|
+
Validates ranges/integers before hashing. All surface grammars normalize here.
|
|
17
|
+
- `parseScriptureAlias()` — `scripture:john.3.16` + OSIS/USFM/tolerant forms →
|
|
18
|
+
one canonical locus. ASCII-only (confusable defense).
|
|
19
|
+
- `scriptureSelector()` — the structured `selector` an app puts on a descriptor.
|
|
20
|
+
|
|
21
|
+
## Hard rules (ADR-0033)
|
|
22
|
+
|
|
23
|
+
- **No rendering text, no specific translation** here (R1/R3). Editions + text
|
|
24
|
+
are the app's off-platform store; this package only **addresses + selects**.
|
|
25
|
+
- **Translation/edition is NEVER part of the public name** — it's descriptor
|
|
26
|
+
metadata (spec 267 §2). `niv.john.3.16` is not a valid alias (book lookup fails).
|
|
27
|
+
- **All aliases for one verse → one canonicalId.** The id is scheme-independent
|
|
28
|
+
(FRBR Work); never bake a surface grammar into it.
|
|
29
|
+
|
|
30
|
+
## Boundary
|
|
31
|
+
|
|
32
|
+
Depends only on `@agenticprimitives/content-primitives` (for `canonicalReference`
|
|
33
|
+
/ `CanonicalLocusEnvelope`). Must not import naming/profile/relationships/mcp-runtime.
|
|
34
|
+
|
|
35
|
+
## Drift triggers — STOP
|
|
36
|
+
|
|
37
|
+
- "Put verse text / a translation here" — STOP (R1/R3). App store only.
|
|
38
|
+
- "Accept `niv.` / `esv.` as an alias prefix" — STOP. Editions are descriptor metadata.
|
|
39
|
+
- "Encode the surface scheme into the canonicalId" — STOP. The id hashes the
|
|
40
|
+
scheme-INDEPENDENT form; only `versification` (versioned) changes it.
|
|
41
|
+
|
|
42
|
+
## Validate
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm --filter @agenticprimitives/scripture-content-extension typecheck
|
|
46
|
+
pnpm --filter @agenticprimitives/scripture-content-extension test
|
|
47
|
+
```
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Trust Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @agenticprimitives/scripture-content-extension
|
|
2
|
+
|
|
3
|
+
The scripture vertical for [`@agenticprimitives/content-primitives`](../../packages/content-primitives).
|
|
4
|
+
It maps human scripture references to **one scheme-independent canonical locus**,
|
|
5
|
+
so every surface grammar for the same verse resolves to the same `canonicalId`.
|
|
6
|
+
|
|
7
|
+
It lives in the **`domains/` tier** (NOT `packages/`) — a reusable, named package
|
|
8
|
+
that legitimately carries scripture vocabulary, kept out of the pure-substrate
|
|
9
|
+
`packages/` tree. It carries **no rendering text and no specific translation**
|
|
10
|
+
(ADR-0033 R1/R3): editions + text live in the app's off-platform store; this
|
|
11
|
+
package only addresses + selects.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { parseScriptureAlias } from '@agenticprimitives/scripture-content-extension';
|
|
15
|
+
|
|
16
|
+
const r = parseScriptureAlias('John 3:16');
|
|
17
|
+
r.reference.id; // canonicalId — same for 'scripture:john.3.16', 'Jn 3.16', OSIS, USFM…
|
|
18
|
+
r.selector; // { kind:'scripture', work:'bible/John', book:'John', chapter:3, verse:16, versification:'protestant-66-v1' }
|
|
19
|
+
r.canonicalForm; // the scheme-independent structured locus the core hashes
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The `versification` is the **governance seam**: it is part of the canonical form,
|
|
23
|
+
so changing the verse-numbering model is a deliberate new namespace, never an
|
|
24
|
+
accidental break. Translation/edition is **never** part of the public name — it
|
|
25
|
+
is descriptor metadata (spec 267). Phase-1 aliases are US-ASCII only (confusable
|
|
26
|
+
defense). See [spec 267](../../specs/267-scripture-demo-vertical.md).
|
package/dist/canon.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface BibleBook {
|
|
2
|
+
/** OSIS book code, e.g. 'John'. Used in the canonical locus `work`. */
|
|
3
|
+
osis: string;
|
|
4
|
+
/** Human display name. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Chapter count (for UI pickers + range validation). */
|
|
7
|
+
chapters: number;
|
|
8
|
+
}
|
|
9
|
+
/** The 66-book Protestant canon (OSIS codes). */
|
|
10
|
+
export declare const BOOKS: BibleBook[];
|
|
11
|
+
export declare function lookupBook(token: string): BibleBook | undefined;
|
|
12
|
+
//# sourceMappingURL=canon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canon.d.ts","sourceRoot":"","sources":["../src/canon.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,iDAAiD;AACjD,eAAO,MAAM,KAAK,EAAE,SAAS,EAmE5B,CAAC;AAyBF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE/D"}
|
package/dist/canon.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The Bible canon as reference data (OSIS book codes — the industry standard).
|
|
2
|
+
// This is generic scripture-domain data, not a specific translation and not
|
|
3
|
+
// rendering text (ADR-0033 R1/R3). It lives in this vertical EXTENSION package,
|
|
4
|
+
// never in the content-agnostic core.
|
|
5
|
+
/** The 66-book Protestant canon (OSIS codes). */
|
|
6
|
+
export const BOOKS = [
|
|
7
|
+
{ osis: 'Gen', name: 'Genesis', chapters: 50 },
|
|
8
|
+
{ osis: 'Exod', name: 'Exodus', chapters: 40 },
|
|
9
|
+
{ osis: 'Lev', name: 'Leviticus', chapters: 27 },
|
|
10
|
+
{ osis: 'Num', name: 'Numbers', chapters: 36 },
|
|
11
|
+
{ osis: 'Deut', name: 'Deuteronomy', chapters: 34 },
|
|
12
|
+
{ osis: 'Josh', name: 'Joshua', chapters: 24 },
|
|
13
|
+
{ osis: 'Judg', name: 'Judges', chapters: 21 },
|
|
14
|
+
{ osis: 'Ruth', name: 'Ruth', chapters: 4 },
|
|
15
|
+
{ osis: '1Sam', name: '1 Samuel', chapters: 31 },
|
|
16
|
+
{ osis: '2Sam', name: '2 Samuel', chapters: 24 },
|
|
17
|
+
{ osis: '1Kgs', name: '1 Kings', chapters: 22 },
|
|
18
|
+
{ osis: '2Kgs', name: '2 Kings', chapters: 25 },
|
|
19
|
+
{ osis: '1Chr', name: '1 Chronicles', chapters: 29 },
|
|
20
|
+
{ osis: '2Chr', name: '2 Chronicles', chapters: 36 },
|
|
21
|
+
{ osis: 'Ezra', name: 'Ezra', chapters: 10 },
|
|
22
|
+
{ osis: 'Neh', name: 'Nehemiah', chapters: 13 },
|
|
23
|
+
{ osis: 'Esth', name: 'Esther', chapters: 10 },
|
|
24
|
+
{ osis: 'Job', name: 'Job', chapters: 42 },
|
|
25
|
+
{ osis: 'Ps', name: 'Psalms', chapters: 150 },
|
|
26
|
+
{ osis: 'Prov', name: 'Proverbs', chapters: 31 },
|
|
27
|
+
{ osis: 'Eccl', name: 'Ecclesiastes', chapters: 12 },
|
|
28
|
+
{ osis: 'Song', name: 'Song of Solomon', chapters: 8 },
|
|
29
|
+
{ osis: 'Isa', name: 'Isaiah', chapters: 66 },
|
|
30
|
+
{ osis: 'Jer', name: 'Jeremiah', chapters: 52 },
|
|
31
|
+
{ osis: 'Lam', name: 'Lamentations', chapters: 5 },
|
|
32
|
+
{ osis: 'Ezek', name: 'Ezekiel', chapters: 48 },
|
|
33
|
+
{ osis: 'Dan', name: 'Daniel', chapters: 12 },
|
|
34
|
+
{ osis: 'Hos', name: 'Hosea', chapters: 14 },
|
|
35
|
+
{ osis: 'Joel', name: 'Joel', chapters: 3 },
|
|
36
|
+
{ osis: 'Amos', name: 'Amos', chapters: 9 },
|
|
37
|
+
{ osis: 'Obad', name: 'Obadiah', chapters: 1 },
|
|
38
|
+
{ osis: 'Jonah', name: 'Jonah', chapters: 4 },
|
|
39
|
+
{ osis: 'Mic', name: 'Micah', chapters: 7 },
|
|
40
|
+
{ osis: 'Nah', name: 'Nahum', chapters: 3 },
|
|
41
|
+
{ osis: 'Hab', name: 'Habakkuk', chapters: 3 },
|
|
42
|
+
{ osis: 'Zeph', name: 'Zephaniah', chapters: 3 },
|
|
43
|
+
{ osis: 'Hag', name: 'Haggai', chapters: 2 },
|
|
44
|
+
{ osis: 'Zech', name: 'Zechariah', chapters: 14 },
|
|
45
|
+
{ osis: 'Mal', name: 'Malachi', chapters: 4 },
|
|
46
|
+
{ osis: 'Matt', name: 'Matthew', chapters: 28 },
|
|
47
|
+
{ osis: 'Mark', name: 'Mark', chapters: 16 },
|
|
48
|
+
{ osis: 'Luke', name: 'Luke', chapters: 24 },
|
|
49
|
+
{ osis: 'John', name: 'John', chapters: 21 },
|
|
50
|
+
{ osis: 'Acts', name: 'Acts', chapters: 28 },
|
|
51
|
+
{ osis: 'Rom', name: 'Romans', chapters: 16 },
|
|
52
|
+
{ osis: '1Cor', name: '1 Corinthians', chapters: 16 },
|
|
53
|
+
{ osis: '2Cor', name: '2 Corinthians', chapters: 13 },
|
|
54
|
+
{ osis: 'Gal', name: 'Galatians', chapters: 6 },
|
|
55
|
+
{ osis: 'Eph', name: 'Ephesians', chapters: 6 },
|
|
56
|
+
{ osis: 'Phil', name: 'Philippians', chapters: 4 },
|
|
57
|
+
{ osis: 'Col', name: 'Colossians', chapters: 4 },
|
|
58
|
+
{ osis: '1Thess', name: '1 Thessalonians', chapters: 5 },
|
|
59
|
+
{ osis: '2Thess', name: '2 Thessalonians', chapters: 3 },
|
|
60
|
+
{ osis: '1Tim', name: '1 Timothy', chapters: 6 },
|
|
61
|
+
{ osis: '2Tim', name: '2 Timothy', chapters: 4 },
|
|
62
|
+
{ osis: 'Titus', name: 'Titus', chapters: 3 },
|
|
63
|
+
{ osis: 'Phlm', name: 'Philemon', chapters: 1 },
|
|
64
|
+
{ osis: 'Heb', name: 'Hebrews', chapters: 13 },
|
|
65
|
+
{ osis: 'Jas', name: 'James', chapters: 5 },
|
|
66
|
+
{ osis: '1Pet', name: '1 Peter', chapters: 5 },
|
|
67
|
+
{ osis: '2Pet', name: '2 Peter', chapters: 3 },
|
|
68
|
+
{ osis: '1John', name: '1 John', chapters: 5 },
|
|
69
|
+
{ osis: '2John', name: '2 John', chapters: 1 },
|
|
70
|
+
{ osis: '3John', name: '3 John', chapters: 1 },
|
|
71
|
+
{ osis: 'Jude', name: 'Jude', chapters: 1 },
|
|
72
|
+
{ osis: 'Rev', name: 'Revelation', chapters: 22 },
|
|
73
|
+
];
|
|
74
|
+
// Standard USFM / Paratext 3-letter book codes, in canonical order (aligned with
|
|
75
|
+
// BOOKS). Lets OSIS and USFM aliases normalize to the same locus (reviewer's
|
|
76
|
+
// alias-equivalence acceptance criterion).
|
|
77
|
+
const USFM_CODES = [
|
|
78
|
+
'GEN', 'EXO', 'LEV', 'NUM', 'DEU', 'JOS', 'JDG', 'RUT', '1SA', '2SA', '1KI', '2KI', '1CH', '2CH', 'EZR',
|
|
79
|
+
'NEH', 'EST', 'JOB', 'PSA', 'PRO', 'ECC', 'SNG', 'ISA', 'JER', 'LAM', 'EZK', 'DAN', 'HOS', 'JOL', 'AMO',
|
|
80
|
+
'OBA', 'JON', 'MIC', 'NAM', 'HAB', 'ZEP', 'HAG', 'ZEC', 'MAL', 'MAT', 'MRK', 'LUK', 'JHN', 'ACT', 'ROM',
|
|
81
|
+
'1CO', '2CO', 'GAL', 'EPH', 'PHP', 'COL', '1TH', '2TH', '1TI', '2TI', 'TIT', 'PHM', 'HEB', 'JAS', '1PE',
|
|
82
|
+
'2PE', '1JN', '2JN', '3JN', 'JUD', 'REV',
|
|
83
|
+
];
|
|
84
|
+
const BY_KEY = new Map();
|
|
85
|
+
for (let i = 0; i < BOOKS.length; i++) {
|
|
86
|
+
const b = BOOKS[i];
|
|
87
|
+
BY_KEY.set(b.osis.toLowerCase(), b);
|
|
88
|
+
BY_KEY.set(b.name.toLowerCase(), b);
|
|
89
|
+
BY_KEY.set(b.name.toLowerCase().replace(/\s+/g, ''), b);
|
|
90
|
+
if (USFM_CODES[i])
|
|
91
|
+
BY_KEY.set(USFM_CODES[i].toLowerCase(), b);
|
|
92
|
+
}
|
|
93
|
+
for (const [alias, osis] of [['jn', 'John'], ['gn', 'Gen'], ['mt', 'Matt'], ['rm', 'Rom']]) {
|
|
94
|
+
BY_KEY.set(alias, BOOKS.find((x) => x.osis === osis));
|
|
95
|
+
}
|
|
96
|
+
export function lookupBook(token) {
|
|
97
|
+
return BY_KEY.get(token.trim().toLowerCase().replace(/\s+/g, ''));
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=canon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canon.js","sourceRoot":"","sources":["../src/canon.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,sCAAsC;AAWtC,iDAAiD;AACjD,MAAM,CAAC,MAAM,KAAK,GAAgB;IAChC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;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CAAC;IACpG,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type CanonicalLocusEnvelope, type CanonicalReference } from '@agenticprimitives/content-primitives';
|
|
2
|
+
import { type BibleBook } from './canon.js';
|
|
3
|
+
export { BOOKS, lookupBook, type BibleBook } from './canon.js';
|
|
4
|
+
/** Content type for a single verse (carried in a descriptor's `contentType`). */
|
|
5
|
+
export declare const SCRIPTURE_VERSE_CONTENT_TYPE = "scripture.verse";
|
|
6
|
+
/** The vertical domain tag in the envelope. */
|
|
7
|
+
export declare const CONTENT_DOMAIN = "scripture";
|
|
8
|
+
/**
|
|
9
|
+
* The versioned locus profile — the governance seam (spec 266 §2.1). Bundles the
|
|
10
|
+
* canon + versification model. Changing it is a deliberate new namespace (a
|
|
11
|
+
* different canonicalId), never an accidental break.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SCRIPTURE_LOCUS_PROFILE_V1 = "ap.scripture.locus.v1";
|
|
14
|
+
/** The verse-NUMBERING model id (not a translation). */
|
|
15
|
+
export declare const VERSIFICATION_V1 = "kjv-v1";
|
|
16
|
+
/** The canon model id. */
|
|
17
|
+
export declare const CANON_V1 = "bible.protestant-66";
|
|
18
|
+
/** Structured, controlled-token canonical locus for a verse (profile v1). */
|
|
19
|
+
export interface ScriptureCanonicalLocusV1 {
|
|
20
|
+
kind: 'scripture.locus';
|
|
21
|
+
/** Controlled work token, e.g. 'bible.book.john' (NOT a display label). */
|
|
22
|
+
work: string;
|
|
23
|
+
canon: string;
|
|
24
|
+
versification: string;
|
|
25
|
+
locusType: 'verse';
|
|
26
|
+
chapter: number;
|
|
27
|
+
verse: number;
|
|
28
|
+
}
|
|
29
|
+
/** Structured scripture selector carried in a descriptor's `selector` field. */
|
|
30
|
+
export interface ScriptureSelector {
|
|
31
|
+
kind: 'scripture';
|
|
32
|
+
/** OSIS book code, e.g. 'John' — display/selector metadata, not identity. */
|
|
33
|
+
book: string;
|
|
34
|
+
chapter: number;
|
|
35
|
+
verse: number;
|
|
36
|
+
versification: string;
|
|
37
|
+
canon: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class InvalidScriptureReferenceError extends Error {
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build the controlled-token canonical locus for a verse. SCHEMA-VALIDATES:
|
|
44
|
+
* chapter/verse must be small positive integers, book must be in canon. All
|
|
45
|
+
* fields are controlled tokens — no user strings enter the hashed object.
|
|
46
|
+
*/
|
|
47
|
+
export declare function scriptureCanonicalLocus(book: BibleBook, chapter: number, verse: number): ScriptureCanonicalLocusV1;
|
|
48
|
+
/** Wrap a canonical locus in the hashed envelope (domain + profile committed). */
|
|
49
|
+
export declare function scriptureEnvelope(locus: ScriptureCanonicalLocusV1): CanonicalLocusEnvelope;
|
|
50
|
+
export declare function scriptureSelector(book: BibleBook, chapter: number, verse: number): ScriptureSelector;
|
|
51
|
+
export interface ParsedScriptureReference {
|
|
52
|
+
book: BibleBook;
|
|
53
|
+
chapter: number;
|
|
54
|
+
verse: number;
|
|
55
|
+
selector: ScriptureSelector;
|
|
56
|
+
locus: ScriptureCanonicalLocusV1;
|
|
57
|
+
reference: CanonicalReference;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse a scripture alias into its canonical locus. Accepts the canonical alias
|
|
61
|
+
* `scripture:john.3.16` and tolerant human forms (`John 3:16`, `Jn 3.16`,
|
|
62
|
+
* OSIS `John.3.16`, USFM `JHN 3:16`). All normalize to the SAME canonical locus
|
|
63
|
+
* → SAME id. Translation/edition prefixes are NOT accepted (they are descriptor
|
|
64
|
+
* metadata, not part of the public name — spec 267 §2): an unknown leading token
|
|
65
|
+
* fails book lookup.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseScriptureAlias(alias: string): ParsedScriptureReference;
|
|
68
|
+
/** The canonical display reference, e.g. 'John 3:16'. */
|
|
69
|
+
export declare function displayReference(book: BibleBook, chapter: number, verse: number): string;
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/D,iFAAiF;AACjF,eAAO,MAAM,4BAA4B,oBAAoB,CAAC;AAE9D,+CAA+C;AAC/C,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAElE,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,0BAA0B;AAC1B,eAAO,MAAM,QAAQ,wBAAwB,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,iBAAiB,CAAC;IACxB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,8BAA+B,SAAQ,KAAK;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAOD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,yBAAyB,CAgBlH;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,GAAG,sBAAsB,CAO1F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAEpG;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,yBAAyB,CAAC;IACjC,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAwB3E;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @agenticprimitives/scripture-content-extension — the scripture vertical for the
|
|
2
|
+
// verifiable-content substrate (spec 267). Owns the Bible canon, a versioned
|
|
3
|
+
// versification model, the scripture.verse selector, and alias parsing that
|
|
4
|
+
// normalizes MANY surface grammars (OSIS / USFM / "Jn 3.16") to ONE
|
|
5
|
+
// scheme-independent, CONTROLLED-TOKEN canonical locus → one canonicalId.
|
|
6
|
+
//
|
|
7
|
+
// JCS does NOT Unicode-normalize strings, so this package converts every surface
|
|
8
|
+
// form to controlled ASCII tokens (e.g. 'bible.book.john') and SCHEMA-VALIDATES
|
|
9
|
+
// the locus BEFORE it reaches the core hash (spec 266 §2.1; threat-model).
|
|
10
|
+
// Carries NO rendering text and NO specific translation (ADR-0033 R1/R3).
|
|
11
|
+
import { canonicalReference, LOCUS_ID_SCHEME, } from '@agenticprimitives/content-primitives';
|
|
12
|
+
import { lookupBook } from './canon.js';
|
|
13
|
+
export { BOOKS, lookupBook } from './canon.js';
|
|
14
|
+
/** Content type for a single verse (carried in a descriptor's `contentType`). */
|
|
15
|
+
export const SCRIPTURE_VERSE_CONTENT_TYPE = 'scripture.verse';
|
|
16
|
+
/** The vertical domain tag in the envelope. */
|
|
17
|
+
export const CONTENT_DOMAIN = 'scripture';
|
|
18
|
+
/**
|
|
19
|
+
* The versioned locus profile — the governance seam (spec 266 §2.1). Bundles the
|
|
20
|
+
* canon + versification model. Changing it is a deliberate new namespace (a
|
|
21
|
+
* different canonicalId), never an accidental break.
|
|
22
|
+
*/
|
|
23
|
+
export const SCRIPTURE_LOCUS_PROFILE_V1 = 'ap.scripture.locus.v1';
|
|
24
|
+
/** The verse-NUMBERING model id (not a translation). */
|
|
25
|
+
export const VERSIFICATION_V1 = 'kjv-v1';
|
|
26
|
+
/** The canon model id. */
|
|
27
|
+
export const CANON_V1 = 'bible.protestant-66';
|
|
28
|
+
export class InvalidScriptureReferenceError extends Error {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = 'InvalidScriptureReferenceError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Controlled work token for a book: 'bible.book.<osis-lowercased>'. */
|
|
35
|
+
function workToken(book) {
|
|
36
|
+
return `bible.book.${book.osis.toLowerCase()}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build the controlled-token canonical locus for a verse. SCHEMA-VALIDATES:
|
|
40
|
+
* chapter/verse must be small positive integers, book must be in canon. All
|
|
41
|
+
* fields are controlled tokens — no user strings enter the hashed object.
|
|
42
|
+
*/
|
|
43
|
+
export function scriptureCanonicalLocus(book, chapter, verse) {
|
|
44
|
+
if (!Number.isInteger(chapter) || chapter < 1 || chapter > book.chapters) {
|
|
45
|
+
throw new InvalidScriptureReferenceError(`invalid chapter ${chapter} for ${book.name}`);
|
|
46
|
+
}
|
|
47
|
+
if (!Number.isInteger(verse) || verse < 1 || verse > 200) {
|
|
48
|
+
throw new InvalidScriptureReferenceError(`invalid verse ${verse}`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
kind: 'scripture.locus',
|
|
52
|
+
work: workToken(book),
|
|
53
|
+
canon: CANON_V1,
|
|
54
|
+
versification: VERSIFICATION_V1,
|
|
55
|
+
locusType: 'verse',
|
|
56
|
+
chapter,
|
|
57
|
+
verse,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Wrap a canonical locus in the hashed envelope (domain + profile committed). */
|
|
61
|
+
export function scriptureEnvelope(locus) {
|
|
62
|
+
return {
|
|
63
|
+
idScheme: LOCUS_ID_SCHEME,
|
|
64
|
+
contentDomain: CONTENT_DOMAIN,
|
|
65
|
+
locusProfile: SCRIPTURE_LOCUS_PROFILE_V1,
|
|
66
|
+
canonicalLocus: locus,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function scriptureSelector(book, chapter, verse) {
|
|
70
|
+
return { kind: 'scripture', book: book.osis, chapter, verse, versification: VERSIFICATION_V1, canon: CANON_V1 };
|
|
71
|
+
}
|
|
72
|
+
// Reject non-ASCII up front — defeats homograph/confusable attacks on book names
|
|
73
|
+
// (spec 266 §threat-model). Phase-1 aliases are US-ASCII only.
|
|
74
|
+
const ASCII_ONLY = /^[\x20-\x7E]*$/;
|
|
75
|
+
/**
|
|
76
|
+
* Parse a scripture alias into its canonical locus. Accepts the canonical alias
|
|
77
|
+
* `scripture:john.3.16` and tolerant human forms (`John 3:16`, `Jn 3.16`,
|
|
78
|
+
* OSIS `John.3.16`, USFM `JHN 3:16`). All normalize to the SAME canonical locus
|
|
79
|
+
* → SAME id. Translation/edition prefixes are NOT accepted (they are descriptor
|
|
80
|
+
* metadata, not part of the public name — spec 267 §2): an unknown leading token
|
|
81
|
+
* fails book lookup.
|
|
82
|
+
*/
|
|
83
|
+
export function parseScriptureAlias(alias) {
|
|
84
|
+
const raw = alias.normalize('NFC').trim();
|
|
85
|
+
if (!ASCII_ONLY.test(raw)) {
|
|
86
|
+
throw new InvalidScriptureReferenceError('non-ASCII characters are rejected in Phase 1 (confusable defense)');
|
|
87
|
+
}
|
|
88
|
+
const body = raw.replace(/^(scripture|osis|usfm):/i, '').trim();
|
|
89
|
+
const m = /^([1-3]?\s*[A-Za-z]+)[\s.]+(\d+)[\s.:](\d+)$/.exec(body);
|
|
90
|
+
if (!m)
|
|
91
|
+
throw new InvalidScriptureReferenceError(`unrecognized scripture reference: "${alias}"`);
|
|
92
|
+
const book = lookupBook(m[1]);
|
|
93
|
+
if (!book)
|
|
94
|
+
throw new InvalidScriptureReferenceError(`unknown book: "${m[1]}"`);
|
|
95
|
+
const chapter = Number(m[2]);
|
|
96
|
+
const verse = Number(m[3]);
|
|
97
|
+
const locus = scriptureCanonicalLocus(book, chapter, verse); // validates ranges
|
|
98
|
+
const canonicalAlias = `scripture:${book.osis}.${chapter}.${verse}`;
|
|
99
|
+
return {
|
|
100
|
+
book,
|
|
101
|
+
chapter,
|
|
102
|
+
verse,
|
|
103
|
+
selector: scriptureSelector(book, chapter, verse),
|
|
104
|
+
locus,
|
|
105
|
+
reference: canonicalReference(scriptureEnvelope(locus), canonicalAlias),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The canonical display reference, e.g. 'John 3:16'. */
|
|
109
|
+
export function displayReference(book, chapter, verse) {
|
|
110
|
+
return `${book.name} ${chapter}:${verse}`;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,6EAA6E;AAC7E,4EAA4E;AAC5E,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,2EAA2E;AAC3E,0EAA0E;AAE1E,OAAO,EACL,kBAAkB,EAClB,eAAe,GAGhB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAS,UAAU,EAAkB,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAE/D,iFAAiF;AACjF,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAElE,wDAAwD;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AACzC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AAyB9C,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED,wEAAwE;AACxE,SAAS,SAAS,CAAC,IAAe;IAChC,OAAO,cAAc,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAe,EAAE,OAAe,E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AAa;IAC9E,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;AAC5C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/scripture-content-extension",
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
|
+
"description": "Scripture vertical for the verifiable-content substrate: the Bible canon (OSIS book codes), a versioned versification model, the scripture.verse selector, and alias parsing (scripture:book.chapter.verse + tolerant forms) that normalizes many surface grammars to ONE scheme-independent canonical locus. Depends on verifiable-content; carries no rendering text and no specific translation.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
|
|
9
|
+
"directory": "packages/scripture-content-extension"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/scripture-content-extension",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"dist",
|
|
27
|
+
"spec.md",
|
|
28
|
+
"README.md",
|
|
29
|
+
"CLAUDE.md"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@agenticprimitives/content-primitives": "1.0.0-alpha.6"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.7.0",
|
|
39
|
+
"vitest": "^4.1.8"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"scripture",
|
|
43
|
+
"bible",
|
|
44
|
+
"osis",
|
|
45
|
+
"verifiable-content",
|
|
46
|
+
"agentic"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:unit": "vitest run",
|
|
53
|
+
"test:watch": "vitest",
|
|
54
|
+
"clean": "rm -rf dist"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/spec.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @agenticprimitives/scripture-content-extension — spec
|
|
2
|
+
|
|
3
|
+
Design lives in [`../../specs/267-scripture-demo-vertical.md`](../../specs/267-scripture-demo-vertical.md)
|
|
4
|
+
(the scripture vertical) on top of
|
|
5
|
+
[`../../specs/266-verifiable-content-substrate.md`](../../specs/266-verifiable-content-substrate.md)
|
|
6
|
+
(the generic substrate).
|
|
7
|
+
|
|
8
|
+
Architecture decision:
|
|
9
|
+
[ADR-0033](../../docs/architecture/decisions/0033-content-agnostic-verifiable-content-firewall.md)
|
|
10
|
+
— content-agnostic core + the **`domains/` tier**: a reused vertical is a named
|
|
11
|
+
package OUTSIDE `packages/` (which stays pure substrate). Amends ADR-0021.
|
|
12
|
+
|
|
13
|
+
Do not edit a divergent copy here — edit the canonical spec.
|