@@ -37,24 +37,35 @@ function copyIfMissing(from, to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function escapeRegExp(value) {
|
||||
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
function renameAssistant(text, previous, next) {
|
||||
if (!previous || previous === next) return text;
|
||||
return String(text || '').replace(new RegExp(escapeRegExp(previous), 'g'), next);
|
||||
}
|
||||
|
||||
export function applyAssistantName(dir, name) {
|
||||
const who = normalizeAssistantName(name);
|
||||
const identity = path.join(dir, 'IDENTITY.md');
|
||||
let text = '';
|
||||
try { text = fs.readFileSync(identity, 'utf8'); } catch { text = '# IDENTITY.md\n\n'; }
|
||||
const previous = (text.match(/\*\*Name:\*\*\s*(.+)/) || [])[1]?.trim() || 'Jarvis';
|
||||
text = renameAssistant(text, previous, who);
|
||||
if (/\*\*Name:\*\*/.test(text)) text = text.replace(/\*\*Name:\*\*.*/, `**Name:** ${who}`);
|
||||
else text += `\n- **Name:** ${who}\n`;
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(identity, text);
|
||||
const soul = path.join(dir, 'SOUL.md');
|
||||
try {
|
||||
let soulText = fs.readFileSync(soul, 'utf8');
|
||||
let soulText = renameAssistant(fs.readFileSync(soul, 'utf8'), previous, who);
|
||||
soulText = soulText.replace(/^# SOUL\.md:.*/m, `# SOUL.md: ${who}`);
|
||||
fs.writeFileSync(soul, soulText);
|
||||
} catch {}
|
||||
const memory = path.join(dir, 'MEMORY.md');
|
||||
try {
|
||||
let mem = fs.readFileSync(memory, 'utf8');
|
||||
let mem = renameAssistant(fs.readFileSync(memory, 'utf8'), previous, who);
|
||||
if (/Assistant name:/.test(mem)) mem = mem.replace(/Assistant name:.*/, `Assistant name: ${who}`);
|
||||
fs.writeFileSync(memory, mem);
|
||||
} catch {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const MODEL_PROFILES = Object.freeze({
|
||||
'laptop-4gb-mm': { model: 'qwen3.5-0.8b', minRamGb: 4, vision: true },
|
||||
'laptop-8gb': { model: 'qwen3-1.7b', minRamGb: 8, vision: false },
|
||||
'laptop-8gb-mm': { model: 'qwen3.5-2b', minRamGb: 6, vision: true },
|
||||
'laptop-16gb': { model: 'qwen3.5-4b', minRamGb: 10, vision: true },
|
||||
|
||||
Reference in New Issue
Block a user