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.
Files changed (54) hide show
  1. package/README.md +195 -7
  2. package/dist/answer/index.d.ts +9 -0
  3. package/dist/answer/index.js +15 -0
  4. package/dist/answer/types.d.ts +37 -0
  5. package/dist/answer/types.js +0 -0
  6. package/dist/client/index.d.ts +3 -0
  7. package/dist/client/index.js +16 -0
  8. package/dist/client/judgy.d.ts +11 -0
  9. package/dist/client/judgy.js +28 -0
  10. package/dist/client/types.d.ts +24 -0
  11. package/dist/client/types.js +0 -0
  12. package/dist/context/image.d.ts +8 -0
  13. package/dist/context/image.js +36 -0
  14. package/dist/context/index.d.ts +3 -0
  15. package/dist/context/index.js +21 -0
  16. package/dist/context/types.d.ts +27 -0
  17. package/dist/context/types.js +0 -0
  18. package/dist/errors.d.ts +7 -0
  19. package/dist/errors.js +10 -0
  20. package/dist/index.d.ts +9 -0
  21. package/dist/index.js +4 -0
  22. package/dist/providers/clef.d.ts +21 -0
  23. package/dist/providers/clef.js +47 -0
  24. package/dist/providers/google.d.ts +13 -0
  25. package/dist/providers/google.js +41 -0
  26. package/dist/providers/jev/answers.d.ts +4 -0
  27. package/dist/providers/jev/answers.js +45 -0
  28. package/dist/providers/jev/index.d.ts +16 -0
  29. package/dist/providers/jev/index.js +43 -0
  30. package/dist/providers/jev/questions.d.ts +14 -0
  31. package/dist/providers/jev/questions.js +35 -0
  32. package/dist/providers/jev/types.d.ts +6 -0
  33. package/dist/providers/jev/types.js +0 -0
  34. package/dist/providers/luna/answers.d.ts +7 -0
  35. package/dist/providers/luna/answers.js +63 -0
  36. package/dist/providers/luna/index.d.ts +12 -0
  37. package/dist/providers/luna/index.js +18 -0
  38. package/dist/providers/luna/questions.d.ts +10 -0
  39. package/dist/providers/luna/questions.js +43 -0
  40. package/dist/providers/provider.d.ts +27 -0
  41. package/dist/providers/provider.js +61 -0
  42. package/dist/providers/read.d.ts +17 -0
  43. package/dist/providers/read.js +65 -0
  44. package/dist/providers/types.d.ts +8 -0
  45. package/dist/providers/types.js +0 -0
  46. package/dist/question/index.d.ts +3 -0
  47. package/dist/question/index.js +44 -0
  48. package/dist/question/types.d.ts +42 -0
  49. package/dist/question/types.js +0 -0
  50. package/dist/question/validate.d.ts +7 -0
  51. package/dist/question/validate.js +46 -0
  52. package/dist/types.d.ts +5 -0
  53. package/dist/types.js +0 -0
  54. 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
+ };
@@ -0,0 +1,5 @@
1
+ export interface JudgyErrorOptions {
2
+ /** HTTP status of the provider response, when the failure came from one. */
3
+ readonly status?: number;
4
+ readonly cause?: unknown;
5
+ }
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.1",
4
- "description": "A tiny, tree-shakable router for System 1 decision models. Declare once, call any provider. Not for generative LLMs.",
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/system1.git"
35
+ "url": "git+https://github.com/feuersteiner/judgy.git"
26
36
  },
27
- "homepage": "https://github.com/feuersteiner/system1#readme",
37
+ "homepage": "https://github.com/feuersteiner/judgy#readme",
28
38
  "bugs": {
29
- "url": "https://github.com/feuersteiner/system1/issues"
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
- "@types/bun": "latest"
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
  }