Allow to change the agents name + Workspace files
Rolling release / release (push) Successful in 8m2s

This commit is contained in:
2026-09-12 15:30:11 -04:00
parent 874154f39a
commit 5317576087
30 changed files with 338 additions and 174 deletions
+34
View File
@@ -0,0 +1,34 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, readFileSync, existsSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { ensureAgentWorkspace, applyAssistantName, normalizeAssistantName, templateWorkspaceDir } from '../daemon/agent-workspace.js';
const previous = process.env.XDG_DATA_HOME;
const data = mkdtempSync(path.join(tmpdir(), 'jarvis-workspace-'));
process.env.XDG_DATA_HOME = data;
test('workspace seed copies SOUL and bootstrap, then name writes IDENTITY.md', () => {
const dir = ensureAgentWorkspace({ name: 'Jarvis' });
assert.equal(existsSync(path.join(dir, 'SOUL.md')), true);
assert.equal(existsSync(path.join(dir, 'AGENTS.md')), true);
assert.equal(existsSync(path.join(dir, 'BOOTSTRAP.md')), true);
assert.match(readFileSync(path.join(dir, 'SOUL.md'), 'utf8'), /You are \*\*Jarvis\*\*/);
assert.match(readFileSync(path.join(dir, 'BOOTSTRAP.md'), 'utf8'), /first-run ritual/);
assert.doesNotMatch(readFileSync(path.join(dir, 'AGENTS.md'), 'utf8'), /Pip/);
applyAssistantName(dir, 'Ada');
assert.match(readFileSync(path.join(dir, 'IDENTITY.md'), 'utf8'), /\*\*Name:\*\* Ada/);
assert.match(readFileSync(path.join(dir, 'SOUL.md'), 'utf8'), /# SOUL\.md: Ada/);
const again = ensureAgentWorkspace({ name: 'Ada' });
assert.equal(again, dir);
assert.match(readFileSync(path.join(dir, 'IDENTITY.md'), 'utf8'), /\*\*Name:\*\* Ada/);
assert.equal(normalizeAssistantName(' '), 'Jarvis');
assert.match(templateWorkspaceDir(), /agent-workspace$/);
});
test('cleanup', () => {
if (previous === undefined) delete process.env.XDG_DATA_HOME;
else process.env.XDG_DATA_HOME = previous;
rmSync(data, { recursive: true, force: true });
});