@@ -5126,7 +5126,7 @@ function writeJsonAtomic(path, value) {
51265126}
51275127
51285128// 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" ;
51305130import { dirname as dirname6 , isAbsolute as isAbsolute6 , join as join6 , relative , resolve as resolve5 , sep as sep4 } from "node:path" ;
51315131
51325132// src/core/rules/rulebook.ts
@@ -5552,8 +5552,9 @@ function sha256Digest(content) {
55525552// src/core/rules/policy/scope-policy.ts
55535553function loadRulesPolicy ( options2 = { } ) {
55545554 const paths = getPolicyPaths ( options2 ) ;
5555+ const sameConfigPath = isSameConfigPath ( paths . userConfigPath , paths . projectConfigPath ) ;
55555556 const user = readRulesConfig ( paths . userConfigPath ) ;
5556- const project = readRulesConfig ( paths . projectConfigPath ) ;
5557+ const project = sameConfigPath ? { config : null , errors : [ ] } : readRulesConfig ( paths . projectConfigPath ) ;
55575558 const errors = [
55585559 ...getLegacyRulesConfigErrors ( paths , options2 ) ,
55595560 ...user . errors . map ( ( error ) => `${ paths . userConfigPath } : ${ error } ` ) ,
@@ -5724,6 +5725,19 @@ function rulesPolicyToConfig(policy) {
57245725 }
57255726 return { version : 1 , rules : policy . rules } ;
57265727}
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+ }
57275741function getLegacyRulesConfigErrors ( paths , options2 ) {
57285742 return Array . from ( new Set ( [
57295743 ...getLegacyRulesConfigError ( getLegacyUserRulesConfigPath ( options2 ) , paths . userConfigPath , "~/.cc-safety-net/config.json" ) ,
0 commit comments