MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / load

Method load

packages/node-runtime/src/preferences.ts:83–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 }
82
83 load(): Preferences {
84 if (this.cache) return this.cache
85
86 try {
87 if (fs.existsSync(this.filePath)) {
88 const raw = fs.readFileSync(this.filePath, 'utf-8')
89 const parsed = JSON.parse(raw) as Partial<Preferences>
90 const migrated = this.migrateLegacyDesensitizeRules(parsed, raw)
91 this.cache = this.mergeDefaults(migrated.preferences)
92 if (migrated.changed) {
93 this.writePreferences(this.cache)
94 }
95 return this.cache
96 }
97 } catch (err) {
98 console.warn('[Preferences] Failed to load preferences.json:', err)
99 }
100
101 this.cache = { ...DEFAULTS }
102 return this.cache
103 }
104
105 save(partial: Partial<Preferences>): { success: boolean; error?: string } {
106 try {

Callers 2

saveMethod · 0.95

Calls 5

mergeDefaultsMethod · 0.95
writePreferencesMethod · 0.95
parseMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected