@kevinrabun/judges 3.115.2 → 3.115.4

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.
@@ -168,7 +168,13 @@ export function resolveEvaluator(agent) {
168
168
  .replace(/\.ts$/, ".js"),
169
169
  resolve(process.cwd(), "dist", "evaluators", `${agent.frontmatter.id}.js`),
170
170
  ];
171
- const req = createRequire(import.meta.url);
171
+ // Support both ESM and CJS (esbuild bundle) environments
172
+ const _url = typeof import.meta?.url === "string" ? import.meta.url : undefined;
173
+ const req = _url
174
+ ? createRequire(_url)
175
+ : typeof globalThis.require === "function"
176
+ ? globalThis.require
177
+ : createRequire("file:///" + process.cwd());
172
178
  for (const candidate of candidatePaths) {
173
179
  try {
174
180
  const mod = req(candidate);
@@ -1,17 +1,62 @@
1
1
  /**
2
- * Judge registry bootstrap (agent-native).
2
+ * Judge registry bootstrap.
3
3
  *
4
- * Judges are now sourced from `.judge.md` files in the `agents/` folder (legacy
5
- * `.agent.md` still supported). Each agent frontmatter references an evaluator
6
- * script (in `src/evaluators/`), and the agent loader registers them with the
7
- * unified `JudgeRegistry`.
4
+ * Judges are dual-registered:
5
+ * 1. Static side-effect imports below each module calls
6
+ * `defaultRegistry.register()` at load time. These are inlined by
7
+ * esbuild and work in both ESM and CJS bundles.
8
+ * 2. Agent-native `.judge.md` files loaded at runtime from the `agents/`
9
+ * directory (when available). This enriches / overrides metadata.
8
10
  *
9
- * Legacy side-effect imports have been removed. If you need to add a judge, add
10
- * an agent file and (optionally) an evaluator script, then run:
11
- * - `npm run generate:agents` (to sync)
12
- * - `npm run validate:agents`
11
+ * The static imports guarantee that judges are always available, even in
12
+ * bundled environments (VS Code extension) where `agents/` is absent.
13
13
  */
14
14
  import type { JudgeDefinition } from "../types.js";
15
+ import "./accessibility.js";
16
+ import "./agent-instructions.js";
17
+ import "./ai-code-safety.js";
18
+ import "./api-contract.js";
19
+ import "./api-design.js";
20
+ import "./authentication.js";
21
+ import "./backwards-compatibility.js";
22
+ import "./caching.js";
23
+ import "./ci-cd.js";
24
+ import "./cloud-readiness.js";
25
+ import "./code-structure.js";
26
+ import "./compliance.js";
27
+ import "./concurrency.js";
28
+ import "./configuration-management.js";
29
+ import "./cost-effectiveness.js";
30
+ import "./cybersecurity.js";
31
+ import "./data-security.js";
32
+ import "./data-sovereignty.js";
33
+ import "./database.js";
34
+ import "./dependency-health.js";
35
+ import "./documentation.js";
36
+ import "./error-handling.js";
37
+ import "./ethics-bias.js";
38
+ import "./false-positive-review.js";
39
+ import "./framework-safety.js";
40
+ import "./hallucination-detection.js";
41
+ import "./iac-security.js";
42
+ import "./intent-alignment.js";
43
+ import "./internationalization.js";
44
+ import "./logging-privacy.js";
45
+ import "./logic-review.js";
46
+ import "./maintainability.js";
47
+ import "./model-fingerprint.js";
48
+ import "./multi-turn-coherence.js";
49
+ import "./observability.js";
50
+ import "./over-engineering.js";
51
+ import "./performance.js";
52
+ import "./portability.js";
53
+ import "./rate-limiting.js";
54
+ import "./reliability.js";
55
+ import "./scalability.js";
56
+ import "./security.js";
57
+ import "./software-practices.js";
58
+ import "./testing.js";
59
+ import "./ux.js";
15
60
  /**
16
61
  * Load judges (agent-native). Loads agents from the default `agents/` folder
17
62
  * and returns the current registry snapshot.
@@ -1,28 +1,85 @@
1
1
  /**
2
- * Judge registry bootstrap (agent-native).
2
+ * Judge registry bootstrap.
3
3
  *
4
- * Judges are now sourced from `.judge.md` files in the `agents/` folder (legacy
5
- * `.agent.md` still supported). Each agent frontmatter references an evaluator
6
- * script (in `src/evaluators/`), and the agent loader registers them with the
7
- * unified `JudgeRegistry`.
4
+ * Judges are dual-registered:
5
+ * 1. Static side-effect imports below each module calls
6
+ * `defaultRegistry.register()` at load time. These are inlined by
7
+ * esbuild and work in both ESM and CJS bundles.
8
+ * 2. Agent-native `.judge.md` files loaded at runtime from the `agents/`
9
+ * directory (when available). This enriches / overrides metadata.
8
10
  *
9
- * Legacy side-effect imports have been removed. If you need to add a judge, add
10
- * an agent file and (optionally) an evaluator script, then run:
11
- * - `npm run generate:agents` (to sync)
12
- * - `npm run validate:agents`
11
+ * The static imports guarantee that judges are always available, even in
12
+ * bundled environments (VS Code extension) where `agents/` is absent.
13
13
  */
14
14
  import { defaultRegistry } from "../judge-registry.js";
15
15
  import { loadAndRegisterAgents } from "../agent-loader.js";
16
16
  import { resolve, dirname } from "node:path";
17
17
  import { fileURLToPath } from "node:url";
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = dirname(__filename);
18
+ // ─── Static side-effect imports (self-registering) ──────────────────────────
19
+ import "./accessibility.js";
20
+ import "./agent-instructions.js";
21
+ import "./ai-code-safety.js";
22
+ import "./api-contract.js";
23
+ import "./api-design.js";
24
+ import "./authentication.js";
25
+ import "./backwards-compatibility.js";
26
+ import "./caching.js";
27
+ import "./ci-cd.js";
28
+ import "./cloud-readiness.js";
29
+ import "./code-structure.js";
30
+ import "./compliance.js";
31
+ import "./concurrency.js";
32
+ import "./configuration-management.js";
33
+ import "./cost-effectiveness.js";
34
+ import "./cybersecurity.js";
35
+ import "./data-security.js";
36
+ import "./data-sovereignty.js";
37
+ import "./database.js";
38
+ import "./dependency-health.js";
39
+ import "./documentation.js";
40
+ import "./error-handling.js";
41
+ import "./ethics-bias.js";
42
+ import "./false-positive-review.js";
43
+ import "./framework-safety.js";
44
+ import "./hallucination-detection.js";
45
+ import "./iac-security.js";
46
+ import "./intent-alignment.js";
47
+ import "./internationalization.js";
48
+ import "./logging-privacy.js";
49
+ import "./logic-review.js";
50
+ import "./maintainability.js";
51
+ import "./model-fingerprint.js";
52
+ import "./multi-turn-coherence.js";
53
+ import "./observability.js";
54
+ import "./over-engineering.js";
55
+ import "./performance.js";
56
+ import "./portability.js";
57
+ import "./rate-limiting.js";
58
+ import "./reliability.js";
59
+ import "./scalability.js";
60
+ import "./security.js";
61
+ import "./software-practices.js";
62
+ import "./testing.js";
63
+ import "./ux.js";
64
+ // Support both ESM (import.meta.url) and CJS (esbuild bundle) environments.
65
+ const _importMetaUrl = typeof import.meta?.url === "string" ? import.meta.url : undefined;
66
+ const __filename = _importMetaUrl ? fileURLToPath(_importMetaUrl) : "";
67
+ const __dirname = __filename ? dirname(__filename) : "";
20
68
  let agentsLoaded = false;
21
69
  function loadDefaultAgents() {
22
70
  if (agentsLoaded)
23
71
  return;
24
- const agentsDir = resolve(__dirname, "..", "..", "agents");
25
- loadAndRegisterAgents(agentsDir, defaultRegistry);
72
+ // Static side-effect imports above already registered all built-in judges.
73
+ // In ESM mode, also load from agents/ directory for metadata enrichment.
74
+ if (__dirname) {
75
+ try {
76
+ const agentsDir = resolve(__dirname, "..", "..", "agents");
77
+ loadAndRegisterAgents(agentsDir, defaultRegistry);
78
+ }
79
+ catch {
80
+ // agents/ directory may not exist — built-in judges are already loaded
81
+ }
82
+ }
26
83
  agentsLoaded = true;
27
84
  }
28
85
  // ─── Optional Agent Loader Integration ──────────────────────────────────────
@@ -40,9 +97,12 @@ export async function loadJudges() {
40
97
  * agents can augment or replace built-in judges. If a judge is already
41
98
  * registered, it is skipped.
42
99
  */
43
- export function loadAgentJudges(dir = resolve(__dirname, "..", "..", "agents")) {
100
+ export function loadAgentJudges(dir) {
101
+ const agentsDir = dir ?? (__dirname ? resolve(__dirname, "..", "..", "agents") : "");
102
+ if (!agentsDir)
103
+ return 0; // CJS bundle — no agents directory available
44
104
  agentsLoaded = false; // allow re-run to pick up new agents if dir changes
45
- const count = loadAndRegisterAgents(dir, defaultRegistry);
105
+ const count = loadAndRegisterAgents(agentsDir, defaultRegistry);
46
106
  agentsLoaded = true;
47
107
  return count;
48
108
  }
@@ -136,7 +136,9 @@ export function listSkills(dirPath) {
136
136
  * only the judges referenced by the skill. Returns a tribunal verdict.
137
137
  */
138
138
  export async function runSkill(skillId, code, language, opts) {
139
- const skillsDir = opts?.skillsDir ?? resolve(dirname(fileURLToPath(import.meta.url)), "..", "skills");
139
+ const _skillUrl = typeof import.meta?.url === "string" ? import.meta.url : undefined;
140
+ const skillsDir = opts?.skillsDir ??
141
+ resolve(dirname(_skillUrl ? fileURLToPath(_skillUrl) : __filename || process.argv[1] || process.cwd()), "..", "skills");
140
142
  const skills = loadSkillDirectory(skillsDir);
141
143
  const skill = skills.find((s) => s.frontmatter.id === skillId);
142
144
  if (!skill)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevinrabun/judges",
3
- "version": "3.115.2",
3
+ "version": "3.115.4",
4
4
  "description": "45 specialized judges that evaluate AI-generated code for security, cost, and quality.",
5
5
  "mcpName": "io.github.KevinRabun/judges",
6
6
  "type": "module",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/kevinrabun/judges",
8
8
  "source": "github"
9
9
  },
10
- "version": "3.115.2",
10
+ "version": "3.115.4",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "@kevinrabun/judges",
15
- "version": "3.115.2",
15
+ "version": "3.115.4",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  }
@@ -221,7 +221,13 @@ export function resolveEvaluator(agent: ParsedAgent): AnalyzeFn | undefined {
221
221
  resolve(process.cwd(), "dist", "evaluators", `${agent.frontmatter.id}.js`),
222
222
  ];
223
223
 
224
- const req = createRequire(import.meta.url);
224
+ // Support both ESM and CJS (esbuild bundle) environments
225
+ const _url = typeof import.meta?.url === "string" ? import.meta.url : undefined;
226
+ const req = _url
227
+ ? createRequire(_url)
228
+ : typeof globalThis.require === "function"
229
+ ? globalThis.require
230
+ : createRequire("file:///" + process.cwd());
225
231
  for (const candidate of candidatePaths) {
226
232
  try {
227
233
  const mod = req(candidate) as Record<string, unknown>;
@@ -170,7 +170,14 @@ export async function runSkill(
170
170
  language: string,
171
171
  opts?: { skillsDir?: string; context?: unknown },
172
172
  ): Promise<TribunalVerdict> {
173
- const skillsDir = opts?.skillsDir ?? resolve(dirname(fileURLToPath(import.meta.url)), "..", "skills");
173
+ const _skillUrl = typeof import.meta?.url === "string" ? import.meta.url : undefined;
174
+ const skillsDir =
175
+ opts?.skillsDir ??
176
+ resolve(
177
+ dirname(_skillUrl ? fileURLToPath(_skillUrl) : __filename || process.argv[1] || process.cwd()),
178
+ "..",
179
+ "skills",
180
+ );
174
181
  const skills = loadSkillDirectory(skillsDir);
175
182
  const skill = skills.find((s) => s.frontmatter.id === skillId);
176
183
  if (!skill) throw new Error(`Skill not found: ${skillId}`);