judgy 0.0.1 → 0.1.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 +195 -7
- package/dist/answer/index.d.ts +9 -0
- package/dist/answer/index.js +15 -0
- package/dist/answer/types.d.ts +37 -0
- package/dist/answer/types.js +0 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +16 -0
- package/dist/client/judgy.d.ts +11 -0
- package/dist/client/judgy.js +28 -0
- package/dist/client/types.d.ts +24 -0
- package/dist/client/types.js +0 -0
- package/dist/context/image.d.ts +8 -0
- package/dist/context/image.js +36 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.js +21 -0
- package/dist/context/types.d.ts +27 -0
- package/dist/context/types.js +0 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +10 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -0
- package/dist/providers/clef.d.ts +21 -0
- package/dist/providers/clef.js +47 -0
- package/dist/providers/google.d.ts +13 -0
- package/dist/providers/google.js +41 -0
- package/dist/providers/jev/answers.d.ts +4 -0
- package/dist/providers/jev/answers.js +45 -0
- package/dist/providers/jev/index.d.ts +16 -0
- package/dist/providers/jev/index.js +43 -0
- package/dist/providers/jev/questions.d.ts +14 -0
- package/dist/providers/jev/questions.js +35 -0
- package/dist/providers/jev/types.d.ts +6 -0
- package/dist/providers/jev/types.js +0 -0
- package/dist/providers/luna/answers.d.ts +7 -0
- package/dist/providers/luna/answers.js +63 -0
- package/dist/providers/luna/index.d.ts +12 -0
- package/dist/providers/luna/index.js +18 -0
- package/dist/providers/luna/questions.d.ts +10 -0
- package/dist/providers/luna/questions.js +43 -0
- package/dist/providers/provider.d.ts +27 -0
- package/dist/providers/provider.js +61 -0
- package/dist/providers/read.d.ts +17 -0
- package/dist/providers/read.js +65 -0
- package/dist/providers/types.d.ts +8 -0
- package/dist/providers/types.js +0 -0
- package/dist/question/index.d.ts +3 -0
- package/dist/question/index.js +44 -0
- package/dist/question/types.d.ts +42 -0
- package/dist/question/types.js +0 -0
- package/dist/question/validate.d.ts +7 -0
- package/dist/question/validate.js +46 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +0 -0
- package/package.json +34 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JudgyError } from "../errors.js";
|
|
2
|
+
const fail = (message) => {
|
|
3
|
+
throw new JudgyError(message);
|
|
4
|
+
};
|
|
5
|
+
export const checkText = (value, label) => typeof value === 'string' && value.trim().length > 0
|
|
6
|
+
? value
|
|
7
|
+
: fail(`${label} must be a non-empty string.`);
|
|
8
|
+
const checkCount = (items, min, max, label) => {
|
|
9
|
+
if (items.length < min || items.length > max)
|
|
10
|
+
fail(`${label} needs ${min} to ${max} entries, got ${items.length}.`);
|
|
11
|
+
};
|
|
12
|
+
/** Option names follow the strictest provider rule (Gemini) so a question works on every provider. */
|
|
13
|
+
const checkOption = (value) => {
|
|
14
|
+
const option = checkText(value, 'Each choice option');
|
|
15
|
+
if (option !== option.trim() || option.length > 128)
|
|
16
|
+
fail(`Choice option "${option}" must have no surrounding spaces and at most 128 characters.`);
|
|
17
|
+
return option;
|
|
18
|
+
};
|
|
19
|
+
// Array.from visits every position, including holes that map() would skip.
|
|
20
|
+
export const checkOptions = (options) => {
|
|
21
|
+
checkCount(options, 2, 255, 'A choice question');
|
|
22
|
+
const checked = Array.from(options, checkOption);
|
|
23
|
+
if (new Set(checked).size !== checked.length)
|
|
24
|
+
fail('Choice options must be unique.');
|
|
25
|
+
return checked;
|
|
26
|
+
};
|
|
27
|
+
export const checkLevels = (levels) => {
|
|
28
|
+
if (!Array.isArray(levels))
|
|
29
|
+
fail('A score question needs an array of levels.');
|
|
30
|
+
checkCount(levels, 2, 10, 'A score question');
|
|
31
|
+
return Array.from(levels, (level) => checkText(level, 'Each score level'));
|
|
32
|
+
};
|
|
33
|
+
/** Descriptions are optional, but when given they must be strings. */
|
|
34
|
+
export const checkDescriptions = (criteria, label) => {
|
|
35
|
+
for (const [key, description] of Object.entries(criteria))
|
|
36
|
+
if (description !== undefined && typeof description !== 'string')
|
|
37
|
+
fail(`${label} for "${key}" must be a string.`);
|
|
38
|
+
return criteria;
|
|
39
|
+
};
|
|
40
|
+
export const checkBoolCriteria = (criteria) => {
|
|
41
|
+
const { true: yes, false: no } = checkDescriptions(criteria, 'The bool description');
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
...(yes !== undefined && { true: yes }),
|
|
44
|
+
...(no !== undefined && { false: no })
|
|
45
|
+
});
|
|
46
|
+
};
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "judgy",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "A tiny,
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A tiny, zero-dependency router for System 1 decision models. Declare once, call any provider. Not for generative LLMs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"judgy",
|
|
7
7
|
"judge",
|
|
@@ -16,23 +16,51 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
19
28
|
"files": [
|
|
29
|
+
"dist",
|
|
20
30
|
"README.md",
|
|
21
31
|
"LICENSE"
|
|
22
32
|
],
|
|
23
33
|
"repository": {
|
|
24
34
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/feuersteiner/
|
|
35
|
+
"url": "git+https://github.com/feuersteiner/judgy.git"
|
|
26
36
|
},
|
|
27
|
-
"homepage": "https://github.com/feuersteiner/
|
|
37
|
+
"homepage": "https://github.com/feuersteiner/judgy#readme",
|
|
28
38
|
"bugs": {
|
|
29
|
-
"url": "https://github.com/feuersteiner/
|
|
39
|
+
"url": "https://github.com/feuersteiner/judgy/issues"
|
|
30
40
|
},
|
|
31
41
|
"publishConfig": {
|
|
32
42
|
"access": "public",
|
|
33
43
|
"registry": "https://registry.npmjs.org/"
|
|
34
44
|
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"prepare": "lefthook install",
|
|
47
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
48
|
+
"prepack": "bun run build",
|
|
49
|
+
"check": "tsc --noEmit",
|
|
50
|
+
"lint": "prettier --check . && eslint .",
|
|
51
|
+
"format": "prettier --write .",
|
|
52
|
+
"test": "bun test"
|
|
53
|
+
},
|
|
35
54
|
"devDependencies": {
|
|
36
|
-
"@
|
|
55
|
+
"@eslint/js": "^10.0.1",
|
|
56
|
+
"@types/bun": "latest",
|
|
57
|
+
"eslint": "^10.4.1",
|
|
58
|
+
"eslint-config-prettier": "^10.1.8",
|
|
59
|
+
"eslint-plugin-check-file": "^3.3.2",
|
|
60
|
+
"globals": "^17.6.0",
|
|
61
|
+
"lefthook": "^2.2.4",
|
|
62
|
+
"prettier": "^3.8.3",
|
|
63
|
+
"typescript": "~6.0.0",
|
|
64
|
+
"typescript-eslint": "^8.60.1"
|
|
37
65
|
}
|
|
38
66
|
}
|