Skip to content

Commit fdea86c

Browse files
Release v2.1.0: Update license to CCCL, add Armor of God prayer, fix documentation
- Update license from MIT to CodexCommunion Digital Code License (CCCL) v1.0 - Update package.json, README.md, and CONTRIBUTING.md to reflect CCCL license - Bump version to 2.1.0 - Add new prayer: Armor of God (based on Ephesians 6:10-18) with full 8-language translations - Fix prayer count in README: 56 57 prayers - Fix code examples in README: add missing getPrayerText import - Add comprehensive AI agent development guide (.github/copilot-instructions.md) - Add JSON Schema validation support (prayer-schema.json, validate-with-schema.js) - Add comprehensive documentation (SCHEMA.md, docs/*) - Add pending prayers reference files for future additions - Remove obsolete migration script
1 parent dbb2415 commit fdea86c

22 files changed

+7164
-917
lines changed

.github/copilot-instructions.md

Lines changed: 90 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,111 @@
11
# Prayer Collection Development Guide
22

33
## Project Overview
4-
This is an NPM package providing structured Catholic prayers as JSON files with multilingual support. The project follows a category-based architecture with strict data validation and TypeScript definitions.
4+
NPM package providing traditional Catholic prayers as structured JSON files with multilingual support and static data compilation for universal compatibility (Node.js + browsers).
55

6-
## Core Architecture
6+
## Critical Architecture Patterns
77

8-
### Data Structure
9-
- **Flat File Structure**: All prayers in single `prayers/` directory as `prayer-name.json`
10-
- **Multi-Label Classification**: Rich metadata with primary category + multiple labels
11-
- `primary_category`: Main theological focus ("marian", "christological", "saints")
12-
- `labels`: Array of classifications (["core", "essential", "rosary", "daily"])
13-
- `importance`: Liturgical significance ("essential", "common", "devotional")
14-
- **Multilingual**: Each prayer supports 8 languages (la, en, es, fr, de, it, pt, pl) with required translations
15-
- **Metadata-driven**: Rich metadata includes origin dates, usage contexts, feast days, and devotions
8+
### Static Data Compilation (Universal Compatibility)
9+
**WHY**: Enables browser usage without filesystem operations - critical differentiator from typical JSON packages
1610

17-
### Static Data Compilation
18-
- **Universal Compatibility**: Pre-compiled static data for Node.js + browser environments
19-
- **No Runtime File I/O**: All JSON files compiled into `lib/prayer-data.js` during build
20-
- **Bundler Friendly**: Works with Webpack, Vite, Rollup, Parcel without special configuration
11+
**Build Flow**:
12+
1. `scripts/generate-static-data.js` → Imports all JSON files, generates `lib/prayer-data.js` module
13+
2. `scripts/build.js` → Validates structure, creates `lib/prayer-index.json` + `lib/build-report.json`
14+
3. `index.js` → Imports from `lib/prayer-data.js` (NOT directly from `prayers/` directory)
15+
16+
**Implication**: Never use `require('./prayers/some-prayer.json')` in runtime code. All prayer data MUST flow through the build pipeline.
17+
18+
### Flat File Structure with Multi-Label Classification
19+
**Structure**: All prayers in single `prayers/` directory as `prayers/prayer-id.json` (no subdirectories)
20+
21+
**Classification System** (see `prayers/our-father.json` example):
22+
- `primary_category`: Fixed theological enum ("marian", "christological", "saints", etc.)
23+
- `labels`: Free-form array (kebab-case) - MUST include `primary_category`
24+
- `importance`: Liturgical weight ("essential", "common", "devotional")
25+
26+
**Example**: `prayers/chaplet-of-divine-mercy.json` has `primary_category: "devotional"` and `labels: ["devotional", "mercy", "chaplet", "common"]`
27+
28+
### Content Structure for Complex Prayers
29+
**Simple prayers** use `text` field: `{ "la": { "text": "Pater noster..." } }`
30+
31+
**Complex prayers** (chaplets, rosaries) use `content` array to reference other prayers:
32+
```json
33+
{
34+
"content": [
35+
{ "type": "instructions", "value": "Opening prayers:" },
36+
{ "type": "prayer-reference", "value": "our-father" },
37+
{ "type": "prayer-reference", "value": "hail-mary", "count": 3 },
38+
{ "type": "text", "value": "Glory be to the Father..." }
39+
]
40+
}
41+
```
42+
43+
**getPrayerText()** function (lines 120-160 in `index.js`) recursively resolves references and assembles full text.
2144

2245
## Development Workflows
2346

2447
### Adding New Prayers
25-
1. **JSON Structure**: Copy existing prayer JSON, ensure `id` matches filename (kebab-case)
26-
2. **Label Classification**: Set `primary_category` and add appropriate `labels` array
27-
3. **Required Fields**: All metadata fields are mandatory, especially `origin_date` (use ISO 8601 ranges like "0030/0033")
28-
4. **Language Coverage**: Include all 8 supported languages; partial translations trigger warnings
29-
30-
### Build System Commands
48+
1. **Create JSON**: `prayers/new-prayer-id.json` (filename MUST match `metadata.id`)
49+
2. **Copy Template**: Use `prayers/our-father.json` as base structure
50+
3. **Required Metadata**: All 14 metadata fields mandatory (see `prayer-schema.json` lines 11-29)
51+
4. **Origin Dates**: ISO 8601 format - use ranges for uncertainty ("1050/1150"), prefix "~" for approximation ("~1200")
52+
5. **Translations**: 8 languages required (la, en, es, fr, de, it, pt, pl) - missing translations generate warnings, not errors
53+
6. **Validate**: Run `npm run build` - must pass to publish
54+
55+
### Validation Chain
56+
**Two validation modes**:
57+
- `npm run validate` - Custom validation (zero dependencies, always available)
58+
- `npm run validate:schema` - JSON Schema validation (requires `ajv` dev dependency, more detailed errors)
59+
60+
**Critical Rules** (enforced in `scripts/validate.js` lines 47-69):
61+
- Filename matches `metadata.id` exactly
62+
- `primary_category` appears in `labels` array (warning if missing)
63+
- `labels` array not empty
64+
- Required languages (la, en) must have `text` OR `content` field
65+
- No duplicate prayer IDs across all files
66+
67+
### Build Commands Critical Path
3168
```bash
32-
npm run build # Generates static data + validates JSONs, creates lib/build-report.json
33-
npm run validate # Comprehensive validation with detailed error reporting
34-
npm test # Runs API function tests
35-
npm run test:browser # Tests browser compatibility
36-
npm run prepublishOnly # Auto-runs build + validate before publishing
69+
npm run build # 1. Generate static data 2. Validate 3. Create build-report.json
70+
npm run validate # Standalone validation (run after any JSON edit)
71+
npm test # API function tests (uses lib/prayer-data.js)
72+
npm run test:browser # Browser compatibility tests
73+
npm run prepublishOnly # AUTO-RUNS on `npm publish` - build + validate MUST pass
3774
```
3875

39-
### Git Workflow
40-
To maintain code quality and minimize risk:
76+
**Pre-publish Hook**: `package.json` line 19 - `npm publish` blocked if validation fails
4177

42-
1. **Branching**: Always create a feature branch for new work (`git checkout -b feature/add-new-prayer`)
43-
2. **Incremental Commits**: Make frequent, small commits during development to capture progress and enable easy rollbacks
44-
3. **Validation**: Run `npm run validate` and `npm test` before each commit
45-
4. **Merge Strategy**: When work is complete, merge back to main with squash commits if the branch has many small commits
46-
5. **Push**: Push feature branches to origin for backup and collaboration
78+
## API Patterns
4779

48-
## Code Patterns
80+
### Functional API Design (index.js)
81+
**Immutability**: All functions return copies (`[...ALL_PRAYERS]`, `{ ...PRAYERS[id] }`) - prevent mutations
82+
**Graceful Degradation**: Returns `null` for missing data, never throws on valid input
83+
**Pre-indexed Data**: Static lookups via `PRAYERS_BY_CATEGORY`, `PRAYERS_BY_LABEL` (built at compile time)
4984

50-
### API Design Philosophy
51-
- **Functional API**: All exports are pure functions (`getPrayerById`, `getPrayersByCategory`)
52-
- **Graceful Degradation**: Returns `null` for missing prayers, throws errors only for invalid categories
53-
- **Type Safety**: Full TypeScript definitions in `index.d.ts` with `Prayer`, `PrayerMetadata` interfaces
54-
55-
### Data Validation Rules
56-
- **Filename Convention**: JSON filename must match `metadata.id` exactly
57-
- **Label Validation**: `primary_category` should match one label in `labels` array
58-
- **Date Formats**: Use ISO 8601, ranges for uncertain dates ("1050/1150"), approximate with "~" prefix
59-
- **Language Codes**: ISO 639-1 standard (la, en, es, fr, de, it, pt, pl)
85+
**Example**:
86+
```javascript
87+
getPrayersByLabel('rosary') // Returns pre-indexed array from PRAYERS_BY_LABEL
88+
getPrayerById('invalid-id') // Returns null, not error
89+
getPrayerText('hail-mary', 'en', true) // skipOptional=true for nested references
90+
```
6091

61-
### Common Gotchas
62-
- **Label Consistency**: Ensure `primary_category` appears in `labels` array
63-
- **Missing Translations**: Warnings (not errors) for incomplete language coverage
64-
- **ID Conflicts**: Build fails if multiple prayers share same ID
65-
- **JSON Syntax**: Any malformed JSON breaks validation
92+
### TypeScript Integration
93+
`index.d.ts` defines `Prayer`, `PrayerMetadata`, `Translation`, `LanguageCode` types
94+
No runtime overhead - pure type hints for consumers
6695

67-
## Integration Points
96+
## Common Gotchas
6897

69-
### NPM Package Structure
70-
- **Entry Point**: `index.js` provides runtime API, `index.d.ts` for TypeScript
71-
- **Distribution**: Only `prayers/`, `lib/`, `index.*` files included via `package.json` files field
72-
- **Pre-publish**: `prepublishOnly` hook runs build + validation automatically
98+
1. **Label Consistency**: Forgetting to include `primary_category` in `labels` array triggers warning
99+
2. **Content vs Text**: Complex prayers need `content` array with `prayer-reference` types - can't use simple `text`
100+
3. **Date Ranges**: Uncertain dates require forward slash separator ("1050/1150"), not dash
101+
4. **Build Before Test**: Tests import from `lib/prayer-data.js` - must run `npm run build` after JSON changes
102+
5. **ID Filename Mismatch**: `prayers/hail-mary.json` with `"id": "hail-mary-prayer"` fails validation
73103

74-
### External Dependencies
75-
- **Zero Runtime Dependencies**: Pure Node.js fs/path modules only
76-
- **Build Dependencies**: Node.js >=12.0.0 required for scripts
77-
- **Validation Logic**: Custom validation in `scripts/validate.js`, not using external schema validators
104+
## Sacred Content Guidelines
105+
These are liturgical Catholic prayers - maintain theological accuracy and use established translations. See `CONTRIBUTING.md` for full guidelines on respectful contribution.
78106

79-
When working on this codebase, always run `npm run validate` after JSON changes and understand that the build system is central to data integrity - all prayers must pass validation to publish.
107+
## File Dependencies
108+
- **Runtime**: `index.js``lib/prayer-data.js` (generated)
109+
- **Build**: `scripts/build.js` → calls `scripts/generate-static-data.js`
110+
- **Validation**: `scripts/validate.js` (standalone) OR `scripts/validate-with-schema.js` (uses `prayer-schema.json`)
111+
- **Distribution**: Only `prayers/`, `lib/`, `index.js`, `index.d.ts` published (see `package.json` files field)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ pids
7272

7373
# Optional eslint cache
7474
.eslintcache
75+
76+
raw_prayer_refs/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Contributors will be acknowledged in:
202202

203203
## 📜 License
204204

205-
By contributing, you agree that your contributions will be licensed under the MIT License. Note that while the code is MIT licensed, the prayer content itself consists of traditional Catholic prayers that are in the public domain.
205+
By contributing, you agree that your contributions will be licensed under the CodexCommunion Digital Code License (CCCL) v1.0. Note that while the code and data structures are CCCL licensed, the prayer content itself consists of traditional Catholic prayers that are in the public domain.
206206

207207
## 🙏 Thank You
208208

LICENSE

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
MIT License
1+
CodexCommunion Digital Code License (CCCL) v1.0
2+
Copyright and Effective Date: 2025 AD
23

3-
Copyright (c) 2025 CodexCommunion
4+
This license governs the use of original digital code and related assets provided by CodexCommunion, including but not limited to source code, configuration files, stylesheets, scripts, markup, and other software artifacts (“Code”).
45

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:
6+
1. License Grant
7+
You are granted a non-exclusive, irrevocable, royalty-free license to use, modify, reproduce, and distribute the Code for any lawful purpose, including commercial purposes.
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
9+
2. Restrictions
10+
You may not:
11+
- Modify or use the Code in any way that reasonably promotes blasphemy, heresy, schism, or content hostile to the Catholic Church.
12+
- Distribute modified versions of the Code that intentionally misrepresent or contradict its intended theological or symbolic purpose (e.g., misuse of liturgical symbolism in anti-Catholic contexts).
1413

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.
14+
3. Attribution
15+
Attribution is not required, though appreciated. You may credit the project or artifact as:
16+
“Created by CodexCommunion” or provide a link to the original repository.
2217

23-
---
18+
4. No Warranty / Limitation of Liability
19+
The Code is provided “as is” with no warranties, express or implied. The Licensor disclaims all liability for any use, misuse, or consequences arising from the Code. Use is at your own risk.
2420

25-
## Sacred Content Notice
21+
5. Termination
22+
This license terminates automatically if the above restrictions are materially violated. Upon termination, you must cease using and distributing the Code and destroy all copies in your control.
2623

27-
This collection contains sacred prayers and texts from the Roman Catholic tradition.
28-
While the software implementation is licensed under MIT, users are encouraged to
29-
treat the prayer content with appropriate reverence and respect for its sacred nature.
24+
6. Governing Law and Dispute Resolution
25+
This license shall be interpreted in accordance with the moral and doctrinal principles of the Catholic Church.
3026

31-
The prayers themselves are traditional texts that have been used in Catholic worship
32-
for centuries and are considered to be in the public domain. The translations provided
33-
are based on widely-used liturgical versions and traditional renderings.
27+
Disputes should first be addressed in a spirit of Christian charity, preferably with the guidance of a local Catholic priest.
3428

35-
For liturgical or official church use, please consult with appropriate ecclesiastical
36-
authorities to ensure compliance with current liturgical norms and translations
37-
approved for your region.
29+
If unresolved, the parties may voluntarily submit the matter to arbitration before a diocesan tribunal or other ecclesiastical authority recognized by the Holy See, to the extent permitted under civil law.
30+
31+
If ecclesiastical arbitration is unavailable or declined, this license shall be governed by the laws of the United States of America.
32+
33+
7. Purpose
34+
This license exists to foster faithful, reverent use of digital tools and resources while protecting the integrity of the Catholic faith and tradition.
35+
36+
CodexCommunion

0 commit comments

Comments
 (0)