-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (35 loc) · 1.09 KB
/
index.js
File metadata and controls
43 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @jsonfirst/implants v1.0.0
* Official JSONFIRST Protocol implants for LLM governance
*
* Usage:
* const implants = require('@jsonfirst/implants');
* console.log(implants.get('universal')); // returns the JSON string
* console.log(implants.list()); // ['universal','chatgpt','claude','gemini','llama','mistral']
*
* Reference: https://jsonfirst.com
*/
const fs = require('fs');
const path = require('path');
const IMPLANTS_DIR = path.join(__dirname, 'implants');
const AVAILABLE = ['universal', 'chatgpt', 'claude', 'gemini', 'llama', 'mistral'];
function list() {
return AVAILABLE.slice();
}
function get(name) {
if (!AVAILABLE.includes(name)) {
throw new Error(`Unknown implant "${name}". Available: ${AVAILABLE.join(', ')}`);
}
const filePath = path.join(IMPLANTS_DIR, `${name}.json`);
return fs.readFileSync(filePath, 'utf8');
}
function getJSON(name) {
return JSON.parse(get(name));
}
function getAll() {
return AVAILABLE.reduce((acc, name) => {
acc[name] = getJSON(name);
return acc;
}, {});
}
module.exports = { list, get, getJSON, getAll };