agent-guardrails 0.3.7 → 0.3.9

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
  }
@@ -264,6 +264,10 @@ export async function run({ repoRoot, config, foreground = false, locale = null
264
264
 
265
265
  // Start file watcher
266
266
  watcher = await createWatcher(repoRoot, config, (filePath) => {
267
+ const absolutePath = path.resolve(filePath);
268
+ if (!absolutePath.startsWith(path.resolve(repoRoot) + path.sep) && absolutePath !== path.resolve(repoRoot)) {
269
+ return; // 跳过项目目录外的文件变更
270
+ }
267
271
  log(`File changed: ${filePath}`);
268
272
  info.incrementChecks();
269
273
  info.updateLastCheck();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-guardrails",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "mcpName": "io.github.logi-cmd/agent-guardrails",
5
5
  "description": "Production guardrails for AI coding agents",
6
6
  "type": "module",