cc-safety-net 1.0.5 → 1.0.6

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.
@@ -5126,7 +5126,7 @@ function writeJsonAtomic(path, value) {
5126
5126
  }
5127
5127
 
5128
5128
  // src/core/rules/policy/scope-policy.ts
5129
- import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
5129
+ import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
5130
5130
  import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
5131
5131
 
5132
5132
  // src/core/rules/rulebook.ts
@@ -5552,8 +5552,9 @@ function sha256Digest(content) {
5552
5552
  // src/core/rules/policy/scope-policy.ts
5553
5553
  function loadRulesPolicy(options2 = {}) {
5554
5554
  const paths = getPolicyPaths(options2);
5555
+ const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
5555
5556
  const user = readRulesConfig(paths.userConfigPath);
5556
- const project = readRulesConfig(paths.projectConfigPath);
5557
+ const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
5557
5558
  const errors = [
5558
5559
  ...getLegacyRulesConfigErrors(paths, options2),
5559
5560
  ...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
@@ -5724,6 +5725,19 @@ function rulesPolicyToConfig(policy) {
5724
5725
  }
5725
5726
  return { version: 1, rules: policy.rules };
5726
5727
  }
5728
+ function isSameConfigPath(userConfigPath, projectConfigPath) {
5729
+ if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
5730
+ return true;
5731
+ }
5732
+ if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
5733
+ return false;
5734
+ }
5735
+ try {
5736
+ return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
5737
+ } catch {
5738
+ return false;
5739
+ }
5740
+ }
5727
5741
  function getLegacyRulesConfigErrors(paths, options2) {
5728
5742
  return Array.from(new Set([
5729
5743
  ...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
@@ -7927,7 +7941,7 @@ import { existsSync as existsSync14 } from "node:fs";
7927
7941
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
7928
7942
  import { tmpdir as tmpdir4 } from "node:os";
7929
7943
  import { delimiter, extname, join as join11 } from "node:path";
7930
- var CURRENT_VERSION = "1.0.5";
7944
+ var CURRENT_VERSION = "1.0.6";
7931
7945
  var VERSION_FETCH_TIMEOUT_MS = 2000;
7932
7946
  var PI_PROBE_TIMEOUT_MS = 5000;
7933
7947
  var PI_SENTINEL_COMMAND = "cc-safety-net";
@@ -9436,7 +9450,7 @@ function formatTraceJson(result) {
9436
9450
  return JSON.stringify(result, null, 2);
9437
9451
  }
9438
9452
  // src/bin/help.ts
9439
- var version = "1.0.5";
9453
+ var version = "1.0.6";
9440
9454
  var INDENT = " ";
9441
9455
  var PROGRAM_NAME = "cc-safety-net";
9442
9456
  function formatOptionFlags(option) {
package/dist/index.js CHANGED
@@ -5070,7 +5070,7 @@ function writeJsonAtomic(path, value) {
5070
5070
  }
5071
5071
 
5072
5072
  // src/core/rules/policy/scope-policy.ts
5073
- import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
5073
+ import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
5074
5074
  import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
5075
5075
 
5076
5076
  // src/core/rules/rulebook.ts
@@ -5496,8 +5496,9 @@ function sha256Digest(content) {
5496
5496
  // src/core/rules/policy/scope-policy.ts
5497
5497
  function loadRulesPolicy(options2 = {}) {
5498
5498
  const paths = getPolicyPaths(options2);
5499
+ const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
5499
5500
  const user = readRulesConfig(paths.userConfigPath);
5500
- const project = readRulesConfig(paths.projectConfigPath);
5501
+ const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
5501
5502
  const errors = [
5502
5503
  ...getLegacyRulesConfigErrors(paths, options2),
5503
5504
  ...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
@@ -5668,6 +5669,19 @@ function rulesPolicyToConfig(policy) {
5668
5669
  }
5669
5670
  return { version: 1, rules: policy.rules };
5670
5671
  }
5672
+ function isSameConfigPath(userConfigPath, projectConfigPath) {
5673
+ if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
5674
+ return true;
5675
+ }
5676
+ if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
5677
+ return false;
5678
+ }
5679
+ try {
5680
+ return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
5681
+ } catch {
5682
+ return false;
5683
+ }
5684
+ }
5671
5685
  function getLegacyRulesConfigErrors(paths, options2) {
5672
5686
  return Array.from(new Set([
5673
5687
  ...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
package/dist/pi/index.js CHANGED
@@ -5134,7 +5134,7 @@ function writeJsonAtomic(path, value) {
5134
5134
  }
5135
5135
 
5136
5136
  // src/core/rules/policy/scope-policy.ts
5137
- import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
5137
+ import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
5138
5138
  import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
5139
5139
 
5140
5140
  // src/core/rules/rulebook.ts
@@ -5560,8 +5560,9 @@ function sha256Digest(content) {
5560
5560
  // src/core/rules/policy/scope-policy.ts
5561
5561
  function loadRulesPolicy(options2 = {}) {
5562
5562
  const paths = getPolicyPaths(options2);
5563
+ const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
5563
5564
  const user = readRulesConfig(paths.userConfigPath);
5564
- const project = readRulesConfig(paths.projectConfigPath);
5565
+ const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
5565
5566
  const errors = [
5566
5567
  ...getLegacyRulesConfigErrors(paths, options2),
5567
5568
  ...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
@@ -5732,6 +5733,19 @@ function rulesPolicyToConfig(policy) {
5732
5733
  }
5733
5734
  return { version: 1, rules: policy.rules };
5734
5735
  }
5736
+ function isSameConfigPath(userConfigPath, projectConfigPath) {
5737
+ if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
5738
+ return true;
5739
+ }
5740
+ if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
5741
+ return false;
5742
+ }
5743
+ try {
5744
+ return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
5745
+ } catch {
5746
+ return false;
5747
+ }
5748
+ }
5735
5749
  function getLegacyRulesConfigErrors(paths, options2) {
5736
5750
  return Array.from(new Set([
5737
5751
  ...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A coding agent CLI hook - block destructive git and filesystem commands before execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",