Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
import { describe, expect, it } from 'vitest';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as vm from 'node:vm';
const rendererRoot = path.join(__dirname, '../../src/renderer');
const html = fs.readFileSync(path.join(rendererRoot, 'index.html'), 'utf8');
const source = fs.readFileSync(path.join(rendererRoot, 'modules/project-detail.js'), 'utf8');
const styles = fs.readFileSync(path.join(rendererRoot, 'style.css'), 'utf8');
const locales = Object.fromEntries(['en', 'zh', 'ja', 'pt'].map((locale) => [
locale,
JSON.parse(fs.readFileSync(path.join(rendererRoot, 'locales', `${locale}.json`), 'utf8')),
]));
describe('project memory controls', () => {
it('exposes add/edit/delete controls through project-scoped memory IPC', () => {
expect(html).toContain('id="project-memory-add-btn"');
expect(html).toContain('id="project-memory-editor-input"');
expect(source).toContain("isEdit ? 'memory.replace' : 'memory.add'");
expect(source).toContain("_mutateProjectMemory('memory.remove', { oldText: text })");
expect(source).toContain("target: 'project'");
expect(source).toContain('projectId: pid');
});
it('uses a dedicated editor state with concise context guidance', () => {
expect(html).toContain('data-i18n="project.instructions.subtitle"');
expect(html).toContain('data-i18n="project.memory.subtitle"');
expect(html).toContain('class="project-detail-tab-group" role="tablist"');
expect(html).toMatch(/project-side-card-head project-side-card-head-tabs[\s\S]*?data-project-side-tabs="context"/);
expect(html).toMatch(/project-side-card-head project-side-card-head-tabs[\s\S]*?data-project-side-tabs="resources"/);
expect(styles).toContain('.project-memory-editor:not([hidden]) ~ .project-memory-list');
expect(styles).toContain('.project-memory-editor:not([hidden]) ~ .empty');
expect(source).toContain('input.setSelectionRange(end, end)');
expect(source).not.toContain('input.select()');
});
it('labels the shared instructions and memory card as context in every locale', () => {
expect(html).toContain('data-i18n="project.context.title">Context</span>');
expect(locales.en['project.context.title']).toBe('Context');
expect(locales.zh['project.context.title']).toBe('上下文');
expect(locales.ja['project.context.title']).toBe('コンテキスト');
expect(locales.pt['project.context.title']).toBe('Contexto');
});
it('keeps live progress out of project-memory guidance in every locale', () => {
const forbidden: Record<string, RegExp> = {
en: /\b(progress|update)\b/i,
zh: /进展|进度/,
ja: /進捗/,
pt: /avanços|atualizaç/i,
};
for (const [locale, table] of Object.entries(locales)) {
const guidance = `${table['project.memory.subtitle']} ${table['project.memory.placeholder']}`;
expect(guidance, locale).not.toMatch(forbidden[locale]);
}
});
it('swaps the guidance line for the heading once an entry exists', () => {
const nodes: Record<string, any> = {
'project-memory-list': { innerHTML: '', style: {}, children: [] as any[], appendChild(child: any) { this.children.push(child); } },
'project-memory-empty': { style: {} },
'project-memory-count': { textContent: '' },
'project-memory-section-head': { hidden: false },
};
const context = vm.createContext({
console,
createLogger: () => ({ warn() {}, info() {}, error() {} }),
document: {
readyState: 'loading',
addEventListener() {},
getElementById: (id: string) => nodes[id] || null,
querySelector: () => null,
createElement: () => ({
appendChild() {}, className: '', dataset: {}, style: {}, textContent: '',
setAttribute() {}, addEventListener() {},
}),
},
window: { addEventListener() {}, orkas: { invoke: async () => ({ ok: true }) } },
escapeHtml: (value: string) => value,
t: (key: string) => key,
setTimeout,
clearTimeout,
});
vm.runInContext(source, context, { filename: 'project-detail.js' });
vm.runInContext('_projectMemory = []; _renderProjectMemoryList()', context);
expect(nodes['project-memory-section-head'].hidden).toBe(true);
expect(nodes['project-memory-empty'].style.display).toBe('');
vm.runInContext("_projectMemory = ['The release checklist is the source of truth.']; _renderProjectMemoryList()", context);
expect(nodes['project-memory-section-head'].hidden).toBe(false);
expect(nodes['project-memory-empty'].style.display).toBe('none');
expect(nodes['project-memory-count'].textContent).toBe('1');
});
it('guards project-instruction saves with dirty, limit, and error states', () => {
expect(source).toContain("window.orkas.invoke('projects.instructions.set'");
expect(source).toContain("input.value !== (input.dataset.savedValue || '')");
expect(source).toContain('saveBtn.disabled = !dirty || over');
expect(source).toContain("uiAlert(t('project.instructions.save_failed'))");
expect(source).toContain("input.dataset.projectId = String(_projectDetailPid || '')");
expect(source).toContain('if (input.dataset.projectId === projectId) input.dataset.savedValue = content');
});
});