Skip to content
wiki.fftac.org

Spiralist Prompt Workbench - Source Excerpt 61

Back to Spiralist Prompt Workbench

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/assets/js/spiralist-prompt-workbench.js so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/assets/js/spiralist-prompt-workbench.js

return [
        '# Spiralist AI All-Suite Robustness Matrix',
        '',
        `Profile: ${title}`,
        `Suites ready: ${readySuites}/${suites.length}`,
        `Total score: ${totalScore}/${totalRows}`,
        `Status: ${status}`,
        `Next: ${nextAction}`,
        `Engagement pattern: ${engagementLabel}`,
        `Runtime fit: ${runtimeLabel}`,
        'Generated boundary: local browser text assembly only',
        '',
        '## Suite Summary',
        '| Suite | Status | Score | Next action |',
        '|---|---|---|---|',
        ...suites.map((suite) => `| ${toMarkdownTableCell(suite.preset.label)} | ${toMarkdownTableCell(suite.status)} | ${suite.score}/${suite.rows.length} | ${toMarkdownTableCell(suite.nextAction)} |`),
        '',
        '## Cross-Suite Review Items',
        ...(reviewRows.length
          ? [
            '| Suite | Scenario | Evidence | Action |',
            '|---|---|---|---|',
            ...reviewRows.map((row) => `| ${toMarkdownTableCell(row.suite)} | ${toMarkdownTableCell(row.label)} | ${toMarkdownTableCell(row.evidence)} | ${toMarkdownTableCell(row.action)} |`),
          ]
          : ['- No required review items from this all-suite local matrix.']),
        '',
        '## Full Suite Detail',
        ...suites.flatMap((suite) => [
          `### ${suite.preset.label}`,
          `Status: ${suite.status}`,
          `Score: ${suite.score}/${suite.rows.length}`,
          `Next: ${suite.nextAction}`,
          '| Scenario | Result | Evidence | Action |',
          '|---|---|---|---|',
          ...suite.rows.map((row) => `| ${toMarkdownTableCell(row.label)} | ${toMarkdownTableCell(row.status)} | ${toMarkdownTableCell(row.evidence)} | ${toMarkdownTableCell(row.action)} |`),
          '',
        ]),
        '## No-Model Boundary',
        'This Spiralist AI all-suite matrix is a browser-local text review. It does not execute the prompt, call an AI model, validate real-world claims, import memory, certify safety, endorse a package, sync data, or prove receiving-runtime behavior.',
      ].join('\n');
    };
    const normalizePersonaLabHistorySettings = (settings = {}) => ({
      mode: getModeId(settings.mode || selectedMode),
      warmth: toCleanString(settings.warmth, 80) || 'balanced',
      directness: Math.max(1, Math.min(5, Number.parseInt(settings.directness, 10) || 4)),
      symbolicDensity: Math.max(1, Math.min(5, Number.parseInt(settings.symbolicDensity, 10) || 3)),
      boundaryStrength: Math.max(1, Math.min(5, Number.parseInt(settings.boundaryStrength, 10) || 5)),
      memoryPolicy: toCleanString(settings.memoryPolicy, 240) || 'explicit user-provided memory only',
      outputContract: toCleanString(settings.outputContract, 240) || 'role, scope, boundaries, response contract, first message',
      frameworkId: personaLabFrameworks[settings.frameworkId] ? settings.frameworkId : 'traits-first',
      frameworkLabel: toCleanString(settings.frameworkLabel, 160) || getPersonaLabFramework(settings.frameworkId).label,
      socialDynamicsId: personaLabSocialDynamics[settings.socialDynamicsId] ? settings.socialDynamicsId : 'none',
      socialDynamicsLabel: toCleanString(settings.socialDynamicsLabel, 160) || getPersonaLabSocialDynamics(settings.socialDynamicsId).label,
      runtimeFitId: personaLabRuntimeFits[settings.runtimeFitId] ? settings.runtimeFitId : 'universal',
      runtimeFitLabel: toCleanString(settings.runtimeFitLabel, 160) || getPersonaLabRuntimeFit(settings.runtimeFitId).label,
      engagementPatternId: personaLabEngagementPatterns[settings.engagementPatternId] ? settings.engagementPatternId : 'curiosity-ladder',
      engagementPatternLabel: toCleanString(settings.engagementPatternLabel, 160) || getPersonaLabEngagementPattern(settings.engagementPatternId).label,
    });
    const normalizePersonaLabHistoryItem = (item) => {
      if (!item || typeof item !== 'object') {
        return null;
      }

      const prompt = toCleanString(item.prompt, 50000);
      if (!prompt) {
        return null;
      }

      const now = new Date().toISOString();
      const title = toCleanString(item.title, 140) || extractPromptTitle(prompt, 'Spiralist AI Persona Profile');

      return {
        id: toCleanString(item.id, 120) || `persona-history-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
        title,
        prompt,
        source: toCleanString(item.source, 120) || 'Spiralist AI Persona Lab',
        createdAt: toCleanString(item.createdAt, 80) || now,
        updatedAt: toCleanString(item.updatedAt, 80) || now,
        setupUrl: toCleanString(item.setupUrl, 1200),
        settings: normalizePersonaLabHistorySettings(item.settings || {}),
      };
    };
    const readPersonaLabHistory = () => {
      const raw = getStorageValue(personaLabHistoryKey, '[]');
      let parsed = [];
      try {
        parsed = JSON.parse(raw);
      } catch (error) {
        parsed = [];
      }

      return Array.isArray(parsed)
        ? parsed.map(normalizePersonaLabHistoryItem).filter(Boolean)
        : [];
    };
    const writePersonaLabHistory = (items) => setStorageValue(personaLabHistoryKey, JSON.stringify(items));
    const createPersonaLabHistoryButton = (id, action, label) => {
      const button = document.createElement('button');
      button.className = 'spiralist-button spiralist-button--secondary';
      button.type = 'button';
      button.dataset.personaLabHistoryAction = action;
      button.dataset.personaLabHistoryId = id;
      button.textContent = label;

      return button;
    };
    const getPersonaLabHistoryMeta = (item) => {
      const settings = item.settings || {};
      const framework = toCleanString(settings.frameworkLabel, 160);
      const social = toCleanString(settings.socialDynamicsLabel, 160);
      const runtime = toCleanString(settings.runtimeFitLabel, 160);
      const engagement = toCleanString(settings.engagementPatternLabel, 160);
      return [item.source, getPromptDraftDate(item.createdAt), framework, social, runtime, engagement]
        .filter(Boolean)
        .join(' - ');
    };
    const getPersonaLabHistoryFilterState = (container) => {
      const search = container ? container.querySelector('[data-persona-lab-history-search]') : null;
      const filter = container ? container.querySelector('[data-persona-lab-history-filter]') : null;

      return {
        search: search instanceof HTMLInputElement ? toCleanString(search.value, 160).toLowerCase() : '',
        filter: filter instanceof HTMLSelectElement ? toCleanString(filter.value, 80) || 'all' : 'all',
      };
    };
    const isPersonaLabHistoryFilterActive = (filters) => Boolean(filters.search || (filters.filter && filters.filter !== 'all'));
    const matchPersonaLabHistorySearch = (item, search) => {
      if (!search) {
        return true;
      }

      const settings = item.settings || {};
      const haystack = [
        item.title,
        item.source,
        item.prompt,
        settings.frameworkId,
        settings.frameworkLabel,
        settings.socialDynamicsId,
        settings.socialDynamicsLabel,
        settings.runtimeFitId,
        settings.runtimeFitLabel,
        settings.engagementPatternId,
        settings.engagementPatternLabel,
        getPromptDraftDate(item.createdAt),
      ].map((value) => toCleanString(value, 5000).toLowerCase()).join(' ');

      return haystack.includes(search);
    };
    const matchPersonaLabHistoryFilter = (item, filter) => {
      if (!filter || filter === 'all') {
        return true;
      }

      const source = toCleanString(item.source, 160).toLowerCase();
      const settings = item.settings || {};
      const frameworkId = toCleanString(settings.frameworkId, 80);
      const socialDynamicsId = toCleanString(settings.socialDynamicsId, 80);
      const engagementPatternId = toCleanString(settings.engagementPatternId, 80);

      if (filter === 'package-exports') {
        return /export|download|uaix|zip|txt|markdown card/.test(source);
      }
      if (filter === 'profile-saves') {
        return /profile save|profile saved|save queued|saved/.test(source);
      }
      if (filter === 'restores-reviews') {
        return /restore|review|compare|staged/.test(source);
      }
      if (filter === 'big-five-hexaco') {
        return frameworkId === 'big-five-hexaco';
      }
      if (filter === 'clique-risk-audit') {
        return socialDynamicsId === 'clique-risk-audit';
      }
      if (filter === 'playful-friction') {
        return engagementPatternId === 'playful-friction';
      }

      return true;
    };
    const renderPersonaLabHistory = (message = '') => {
      const items = readPersonaLabHistory();