Skip to content

armgit / Orkas

Public Imported from GitHub
0

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.

10.2 KB
Raw Blame
import { describe, expect, it } from 'vitest';
import * as fs from 'node:fs';
import * as path from 'node:path';

const root = path.join(__dirname, '../..');

function read(rel: string) {
  return fs.readFileSync(path.join(root, rel), 'utf8');
}

function readJson(rel: string) {
  return JSON.parse(read(rel));
}

function cssBlock(css: string, selector: RegExp) {
  return css.match(selector)?.[1] || '';
}

function cssBlockLast(css: string, selector: RegExp) {
  return [...css.matchAll(selector)].at(-1)?.[1] || '';
}

describe('synced PC surface regressions', () => {
  it('keeps card Use actions as text buttons and reserves icon sizing for icon buttons', () => {
    const css = read('src/renderer/style.css');
    const html = read('src/renderer/index.html');

    const useBlock = cssBlock(css, /\.agent-card-use,\s*\.skill-card-use,\s*\.agent-dialog-btn\s*{([\s\S]*?)}/);
    expect(useBlock).toContain('padding: 4px 10px;');
    expect(useBlock).toContain('border-radius: 8px;');
    expect(useBlock).toContain('background: var(--primary);');
    expect(useBlock).not.toContain('width: 26px;');
    expect(useBlock).not.toContain('border-radius: 50%;');

    const iconBlock = cssBlock(css, /\.btn-icon-use\s*{([\s\S]*?)}/);
    expect(iconBlock).toContain('width: 26px;');
    expect(iconBlock).toContain('height: 26px;');
    expect(iconBlock).toContain('border-radius: 8px;');

    expect(css).toContain('.skill-card--global-group');
    expect(css).toContain('.skill-card-disclosure');
    expect(html).toContain('class="skill-card-use skill-dialog-btn" id="skill-use-btn"');
    expect(html).toContain('class="agent-card-use agent-dialog-btn" id="agent-use-btn"');
  });

  it('keeps AI Team, Skills, and Connectors on the commercial card-width breakpoints', () => {
    const css = read('src/renderer/style.css');

    const agentCardBlock = cssBlockLast(css, /\.agent-card\s*{([\s\S]*?)}/g);
    expect(agentCardBlock).toContain('gap: 2px;');
    expect(agentCardBlock).toContain('min-height: 132px;');

    const agentHeaderBlock = cssBlockLast(css, /\.agent-card-header\s*{([\s\S]*?)}/g);
    expect(agentHeaderBlock).toContain('padding-right: 26px;');
    expect(css).toContain('.agent-card-title');
    expect(css).toContain('.agent-card-meta');

    const agentMoreBlock = cssBlockLast(css, /(?:^|\n)\.agent-card-more\s*{([\s\S]*?)}/g);
    expect(agentMoreBlock).toContain('position: absolute;');
    expect(agentMoreBlock).toContain('right: 12px;');
    expect(agentMoreBlock).toContain('width: 22px;');

    const skillDescBlock = cssBlock(css, /\.skill-card-desc\s*{([\s\S]*?)}/);
    expect(skillDescBlock).toContain('color: var(--text-2);');

    const chipBlock = cssBlock(css, /\.marketplace-card-chip,\s*\.skill-card-chip,\s*\.agent-card-chip\s*{([\s\S]*?)}/);
    expect(chipBlock).toContain('display: inline-flex;');
    expect(chipBlock).toContain('box-sizing: border-box;');
    expect(chipBlock).toContain('min-height: 20px;');
    expect(chipBlock).toContain('line-height: 1.2;');

    for (const selector of [
      'skills-grid',
      'skills-source-section-grid',
      'agents-grid',
      'agents-source-section-grid',
      'marketplace-grid',
    ]) {
      const block = cssBlock(css, new RegExp(`\\.${selector}\\s*{([\\s\\S]*?)}`));
      expect(block, selector).toContain('grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));');
      expect(block, selector).toContain('gap: 16px;');
    }

    const connectorGridBlock = cssBlock(css, /\.connectors-grid\s*{([\s\S]*?)}/);
    expect(connectorGridBlock).toContain('--connector-card-min: 280px;');
    expect(connectorGridBlock).toContain('--connector-grid-gap: 16px;');
    expect(css).not.toContain('--tab-card-min:');
    expect(css).toContain('.agents-grid-header-titles');
    expect(css).toContain('.agents-grid-subtitle');
  });

  it('keeps the named AI Team and Skills header entries aligned with the commercial copy', () => {
    const html = read('src/renderer/index.html');
    const locales = Object.fromEntries(['en', 'zh', 'ja', 'pt'].map((locale) => [
      locale,
      JSON.parse(read(`src/renderer/locales/${locale}.json`)) as Record<string, string>,
    ]));

    expect(html).toContain('data-i18n="agents.connect_cli_btn"');
    expect(html).toContain('data-i18n="agents.connect_cli_sub"');
    expect(html).toContain('data-i18n="skills.more_btn"');
    expect(locales.en['agents.connect_cli_btn']).toBe('Connect an agent');
    expect(locales.en['skills.more_btn']).toBe('Skill marketplace');
    expect(locales.zh['agents.connect_cli_btn']).toBe('接入智能体');
    expect(locales.zh['skills.more_btn']).toBe('技能市场');
    expect(locales.ja['agents.connect_cli_btn']).toBe('エージェントを接続');
    expect(locales.ja['skills.more_btn']).toBe('スキルマーケット');
    expect(locales.pt['agents.connect_cli_btn']).toBe('Conectar agente');
    expect(locales.pt['skills.more_btn']).toBe('Mercado de habilidades');
  });

  it('exposes the local Commander profile to the renderer', () => {
    const ipc = read('src/main/ipc/index.ts');
    const profile = read('src/main/data/commander.json');
    const parsed = JSON.parse(profile);
    const fromToken = ['fr', 'om'].join('');
    const commanderProfileImport = ['im', 'port * as commanderProfile ', fromToken, " '", '..', "/features/commander_profile'"].join('');

    expect(ipc).toContain(commanderProfileImport);
    expect(ipc).toContain("'commander.getProfile'");
    expect(ipc).toContain("'commander.runtimeStats.get'");
    expect(profile).toContain('Orkas 的总调度者');
    expect(parsed.knowhow.zh.length).toBeGreaterThan(0);
    expect(parsed.standards.zh.length).toBeGreaterThan(0);
    expect(parsed.workflow.zh.length).toBeGreaterThan(0);
  });

  it('keeps the synced Agent detail shell that can render the Commander profile', () => {
    const html = read('src/renderer/index.html');
    const css = read('src/renderer/style.css');

    for (const marker of [
      'agents-grid-header-titles',
      'agents-grid-subtitle',
      'agents-detail-hero',
      'agents-detail-stats-section',
      'agents-detail-memory-section',
      'agents-detail-knowhow-section',
      'agents-detail-output-standards-section',
      'agents-detail-input-output-section',
      'agents-detail-output-format-control',
    ]) {
      expect(html).toContain(marker);
    }

    for (const staleMarker of [
      'agents-detail-category-section',
      'agents-detail-output-format-section',
    ]) {
      expect(html).not.toContain(staleMarker);
    }

    for (const selector of [
      '.agents-detail-hero',
      '.agents-detail-stats',
      '.agents-detail-list',
      '.agents-detail-io',
      '.agents-profile-chip',
      '.agents-memory-grid',
      '.agents-detail-label::before',
    ]) {
      expect(css).toContain(selector);
    }
  });

  it('restores user-owned speech key configuration with the public Orkas voice preset', () => {
    const html = read('src/renderer/index.html');
    const settings = read('src/renderer/modules/settings.js');
    const auth = read('src/main/features/auth.ts');
    const ipc = read('src/main/ipc/index.ts');
    const ttsAuth = read('src/main/features/tts_auth.ts');
    const fromToken = ['fr', 'om'].join('');
    const ttsAuthImport = ['im', 'port * as ttsAuth ', fromToken, " '", '..', "/features/tts_auth'"].join('');

    for (const marker of [
      'id="settings-tts-provider"',
      'id="settings-tts-key-input"',
      'id="settings-tts-add-btn"',
      'id="settings-tts-entries"',
    ]) {
      expect(html).toContain(marker);
    }
    expect(settings).toContain("_settingsSafeCall('settings tts refresh', _settingsRefreshTtsProfiles)");
    expect(settings).toContain("window.orkas.invoke('ttsAuth.list')");
    expect(settings).toContain("window.orkas.invoke('ttsAuth.add'");
    expect(settings).toContain('_settingsRenderTtsEntries');
    expect(auth).toContain('export interface TtsProfile');
    expect(auth).toContain('export function loadTtsProfiles');
    expect(ipc).toContain(ttsAuthImport);
    expect(ipc).toContain("'ttsAuth.list'");
    expect(ttsAuth).toContain("id: 'doubao'");
    expect(ttsAuth).toContain("id: 'openai'");
    expect(ttsAuth).toContain('ORKAS_API_PROVIDER');
    expect(ttsAuth).toContain('Orkas · Voice');
    expect(ttsAuth).not.toContain('ORKAS_VOICE');
  });

  it('keeps Settings local execution modes and edits the commander avatar from AI Team', () => {
    const html = read('src/renderer/index.html');
    const settings = read('src/renderer/modules/settings.js');
    const agents = read('src/renderer/modules/agents.js');
    const locales = ['en', 'zh', 'ja', 'pt'].map((lang) => readJson(`src/renderer/locales/${lang}.json`));

    for (const marker of [
      'value="workspace_approval"',
      'value="all_files_approval"',
      'value="all_files_auto"',
      'settings.localexec.mode.workspace_approval',
      'settings.localexec.mode.all_files_approval',
      'settings.localexec.mode.all_files_auto',
    ]) {
      expect(html).toContain(marker);
    }

    for (const marker of [
      'value="off"',
      'value="risk_prompt"',
      'value="allow_all"',
      'settings.localexec.mode.off',
      'settings.localexec.mode.risk_prompt',
      'settings.localexec.mode.allow_all',
    ]) {
      expect(html).not.toContain(marker);
    }

    expect(settings).toContain("const _LOCALEXEC_MODES = ['workspace_approval', 'all_files_approval', 'all_files_auto'];");
    expect(settings).toContain("'all_files_approval'");
    expect(settings).not.toContain("const _LOCALEXEC_MODES = ['off', 'risk_prompt', 'allow_all'];");
    expect(html).not.toContain('settings-commander-avatar');
    expect(settings).not.toContain('_settingsRenderCommanderAvatar');
    expect(settings).not.toContain('_settingsRefreshCommanderAvatar');
    expect(agents).toContain("window.orkas.invoke('prefs.setCommanderAvatar'");
    expect(agents).toContain('allowCommanderCombo: true');
    expect(agents).toContain('hideIcons: true');

    for (const locale of locales) {
      for (const key of [
        'settings.localexec.mode.workspace_approval',
        'settings.localexec.mode.all_files_approval',
        'settings.localexec.mode.all_files_auto',
      ]) {
        expect(locale[key]).toEqual(expect.any(String));
        expect(locale[key].length).toBeGreaterThan(0);
      }
    }
  });
});