agent-guardrails 0.3.6 → 0.3.8

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.
@@ -9,8 +9,8 @@
9
9
  * Triggered by: Edit, Write, MultiEdit tool usage
10
10
  */
11
11
 
12
- import fs from "node:fs";
13
- import path from "node:path";
12
+ const fs = require("node:fs");
13
+ const path = require("node:path");
14
14
 
15
15
  const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
16
16
  const resultFile = path.join(projectDir, ".agent-guardrails", "daemon-result.json");
@@ -20,14 +20,14 @@ if (!fs.existsSync(resultFile)) process.exit(0);
20
20
  try {
21
21
  const data = JSON.parse(fs.readFileSync(resultFile, "utf8"));
22
22
 
23
- if (!data.ok && data.result?.findings?.length > 0) {
23
+ if (!data.ok && data.result && data.result.findings && data.result.findings.length > 0) {
24
24
  const errors = data.result.findings
25
25
  .filter(f => f.severity === "error")
26
- .map(f => `[${f.code}] ${f.message}`)
26
+ .map(f => "[" + f.code + "] " + f.message)
27
27
  .join("\n");
28
28
 
29
29
  if (errors) {
30
- process.stderr.write(`Guardrails daemon detected issues:\n${errors}\n`);
30
+ process.stderr.write("Guardrails daemon detected issues:\n" + errors + "\n");
31
31
  process.exit(2);
32
32
  }
33
33
  }
@@ -276,3 +276,16 @@ export async function run({ repoRoot, config, foreground = false, locale = null
276
276
  // Keep process alive
277
277
  return new Promise(() => { /* never resolve */ });
278
278
  }
279
+
280
+ // ---------------------------------------------------------------------------
281
+ // Self-executing entry (when spawned as background process)
282
+ // ---------------------------------------------------------------------------
283
+
284
+ const args = parseArgs();
285
+ if (args.repoRoot && !args.foreground) {
286
+ const config = args.config || {};
287
+ run({ repoRoot: args.repoRoot, config, foreground: false }).catch((err) => {
288
+ process.stderr.write(`Worker error: ${err.message}\n`);
289
+ process.exit(1);
290
+ });
291
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-guardrails",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "mcpName": "io.github.logi-cmd/agent-guardrails",
5
5
  "description": "Production guardrails for AI coding agents",
6
6
  "type": "module",