blun-king-cli 9.1.318 → 9.1.319
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.
- package/bin/personality-mode.cjs +13 -6
- package/package.json +1 -1
package/bin/personality-mode.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const os = require('node:os');
|
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
|
|
7
7
|
const MAX_PERSONA_BYTES = 64 * 1024;
|
|
8
|
+
const INVALID_PERSONALITY_CHOICE = Symbol('invalid-personality-choice');
|
|
8
9
|
|
|
9
10
|
function resolvedHome(env) {
|
|
10
11
|
const configured = String(env.BLUN_SHARED_HOME ?? env.BLUN_HOME ?? '').trim();
|
|
@@ -15,21 +16,27 @@ function persistedPersonalityChoice(env) {
|
|
|
15
16
|
const personaPath = path.join(resolvedHome(env), 'persona.json');
|
|
16
17
|
try {
|
|
17
18
|
const stat = fs.lstatSync(personaPath);
|
|
18
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_PERSONA_BYTES) return
|
|
19
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_PERSONA_BYTES) return INVALID_PERSONALITY_CHOICE;
|
|
19
20
|
const persona = JSON.parse(fs.readFileSync(personaPath, 'utf8'));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
21
|
+
if (!persona || typeof persona !== 'object' || Array.isArray(persona)) return INVALID_PERSONALITY_CHOICE;
|
|
22
|
+
if (!Object.prototype.hasOwnProperty.call(persona, 'personalityEnabled')) return undefined;
|
|
23
|
+
return typeof persona.personalityEnabled === 'boolean'
|
|
24
|
+
? persona.personalityEnabled
|
|
25
|
+
: INVALID_PERSONALITY_CHOICE;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return error?.code === 'ENOENT' ? undefined : INVALID_PERSONALITY_CHOICE;
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
function personalityContextEnabled(env = process.env) {
|
|
27
32
|
const persisted = persistedPersonalityChoice(env);
|
|
33
|
+
if (persisted === INVALID_PERSONALITY_CHOICE) return false;
|
|
28
34
|
if (persisted !== undefined) return persisted;
|
|
29
|
-
|
|
35
|
+
const configured = String(env.BLUN_IDENTITY_CONTEXT ?? '').trim();
|
|
36
|
+
if (/^(?:0|false|off)$/iu.test(configured)) return false;
|
|
37
|
+
return true;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
module.exports = {
|
|
33
41
|
personalityContextEnabled,
|
|
34
42
|
};
|
|
35
|
-
|