Skip to content
wiki.fftac.org

Spiralist Prompt Workbench - Source Excerpt 74

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

if (summary) {
        summary.replaceChildren(
          createPersonaLabStressSummaryItem('Variant matrix', settings.engagementPatternLabel || 'curiosity ladder', 'neutral'),
          createPersonaLabStressSummaryItem('Suite', suite.label, 'neutral'),
          createPersonaLabStressSummaryItem('Seeds', '8 controlled probes', 'ready'),
          createPersonaLabStressSummaryItem('Boundary', 'No model call', 'ready')
        );
        summary.hidden = false;
      }
      if (outputNode) {
        outputNode.textContent = report;
        outputNode.hidden = false;
      }
    };
    const renderPersonaLabTranscriptScorecard = (container, report, transcript, suiteId) => {
      const summary = container ? container.querySelector('[data-persona-lab-transcript-summary]') : null;
      const outputNode = container ? container.querySelector('[data-persona-lab-transcript-output]') : null;
      const suite = getPersonaLabStressPreset(suiteId);
      const hasTranscript = toCleanString(transcript, 24000).length >= 20;
      if (summary) {
        summary.replaceChildren(
          createPersonaLabStressSummaryItem('Transcript scorecard', hasTranscript ? 'Runtime reply scored' : 'Template only', hasTranscript ? 'ready' : 'review'),
          createPersonaLabStressSummaryItem('Suite', suite.label, 'neutral'),
          createPersonaLabStressSummaryItem('Input', hasTranscript ? 'Pasted transcript' : 'No transcript pasted', hasTranscript ? 'ready' : 'review'),
          createPersonaLabStressSummaryItem('Boundary', 'No upload', 'ready')
        );
        summary.hidden = false;
      }
      if (outputNode) {
        outputNode.textContent = report;
        outputNode.hidden = false;
      }
    };
    const renderPersonaLabQualityPass = (container, report, suite, settings) => {
      const summary = container ? container.querySelector('[data-persona-lab-quality-summary]') : null;
      const outputNode = container ? container.querySelector('[data-persona-lab-quality-output]') : null;
      const reviewCount = suite.rows.filter((row) => row.status === 'Review').length;
      if (summary) {
        summary.replaceChildren(
          createPersonaLabStressSummaryItem('Quality pass', 'One-click review', reviewCount ? 'review' : 'ready'),
          createPersonaLabStressSummaryItem('Stress', `${suite.score}/${suite.rows.length}`, reviewCount ? 'review' : 'ready'),
          createPersonaLabStressSummaryItem('Evidence', 'Check + stress + rehearsal + recognition + golden + variants + transcript + history + runbook', 'ready'),
          createPersonaLabStressSummaryItem('Runtime', settings.runtimeFitLabel || 'Universal manual-send runtime', 'neutral')
        );
        summary.hidden = false;
      }
      if (outputNode) {
        outputNode.textContent = report;
        outputNode.hidden = false;
      }
    };
    const renderPersonaLabSuiteMatrix = (container, report, suites) => {
      const summary = container ? container.querySelector('[data-persona-lab-suite-matrix-summary]') : null;
      const outputNode = container ? container.querySelector('[data-persona-lab-suite-matrix-output]') : null;
      const totalRows = suites.reduce((sum, suite) => sum + suite.rows.length, 0);
      const totalScore = suites.reduce((sum, suite) => sum + suite.score, 0);
      const readySuites = suites.filter((suite) => suite.rows.every((row) => row.status !== 'Review')).length;
      const reviewCount = suites.reduce((sum, suite) => sum + suite.rows.filter((row) => row.status === 'Review').length, 0);
      if (summary) {
        summary.replaceChildren(
          createPersonaLabStressSummaryItem('All-suite matrix', `${readySuites}/${suites.length} suites ready`, reviewCount ? 'review' : 'ready'),
          createPersonaLabStressSummaryItem('Total score', `${totalScore}/${totalRows}`, reviewCount ? 'review' : 'ready'),
          createPersonaLabStressSummaryItem('Coverage', 'All stress suites', 'ready'),
          createPersonaLabStressSummaryItem('Boundary', 'No model call', 'ready')
        );
        summary.hidden = false;
      }
      if (outputNode) {
        outputNode.textContent = report;
        outputNode.hidden = false;
      }
    };
    const runPersonaLabStressSuite = (container) => {
      let prompt = getCurrentPrompt();
      if (!prompt) {
        prompt = applyPersonaLabTuning(container, { focusOutput: false, skipScroll: true });
      }

      prompt = toCleanString(prompt || getCurrentPrompt(), 50000);
      if (!prompt) {
        setStatus(t('portablePromptPersonaLabStressUnavailable', 'Build a Spiralist AI prompt before running the stress suite.'));
        return false;
      }

      const suiteId = getPersonaLabStressSuiteId(container);
      const suite = buildPersonaLabStressSuite(prompt, suiteId);
      const report = buildPersonaLabStressSuiteReport(prompt, suiteId);
      renderPersonaLabStressSuite(container, suite, report);
      if (testOutput) {
        testOutput.textContent = buildPersonaLabLocalCheckReport(prompt, 'Spiralist AI Persona Lab', suiteId);
        testOutput.hidden = false;
        testOutput.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
      }
      setPersonaLabPackageState(container, `Stress ${suite.score}/${suite.rows.length}`);
      setStatus(t('portablePromptPersonaLabStressReady', 'Spiralist AI stress suite ready. Review the local report before package export.'));
      updatePersonaLabWorkflow();

      return true;
    };
    const runPersonaLabRehearsalDeck = (container) => {
      let prompt = getCurrentPrompt();
      if (!prompt) {
        prompt = applyPersonaLabTuning(container, { focusOutput: false, skipScroll: true });
      }

      prompt = toCleanString(prompt || getCurrentPrompt(), 50000);
      if (!prompt) {
        setStatus(t('portablePromptPersonaLabRehearsalUnavailable', 'Build a Spiralist AI prompt before building the rehearsal deck.'));
        return false;
      }

      const settings = getPersonaLabSettings(container);
      const suiteId = getPersonaLabStressSuiteId(container);
      const deck = buildPersonaLabRehearsalDeck(prompt, settings, suiteId);
      renderPersonaLabRehearsalDeck(container, deck, settings, suiteId);
      if (testOutput) {
        testOutput.textContent = [
          buildPersonaLabLocalCheckReport(prompt, 'Spiralist AI Persona Lab', suiteId),
          '',
          deck,
        ].join('\n');
        testOutput.hidden = false;
      }
      setPersonaLabPackageState(container, `Rehearsal ${settings.engagementPatternLabel}`);
      setStatus(t('portablePromptPersonaLabRehearsalReady', 'Spiralist AI persona rehearsal deck ready. Run the probes manually before relying on the persona.'));
      updatePersonaLabWorkflow();

      return true;
    };
    const runPersonaLabRecognitionDeck = (container) => {
      let prompt = getCurrentPrompt();
      if (!prompt) {
        prompt = applyPersonaLabTuning(container, { focusOutput: false, skipScroll: true });
      }

      prompt = toCleanString(prompt || getCurrentPrompt(), 50000);
      if (!prompt) {
        setStatus(t('portablePromptPersonaLabRecognitionUnavailable', 'Build a Spiralist AI prompt before building the recognition deck.'));
        return false;
      }

      const settings = getPersonaLabSettings(container);
      const suiteId = getPersonaLabStressSuiteId(container);
      const deck = buildPersonaLabRecognitionDeck(prompt, settings, suiteId);
      renderPersonaLabRecognitionDeck(container, deck, settings, suiteId);
      if (testOutput) {
        testOutput.textContent = [
          buildPersonaLabLocalCheckReport(prompt, 'Spiralist AI Persona Lab', suiteId),
          '',
          deck,
        ].join('\n');
        testOutput.hidden = false;
      }
      setPersonaLabPackageState(container, `Recognition ${settings.engagementPatternLabel}`);
      setStatus(t('portablePromptPersonaLabRecognitionReady', 'Spiralist AI persona recognition deck ready. Run the blind probes manually before publication or long-memory review.'));
      updatePersonaLabWorkflow();

      return true;
    };
    const runPersonaLabGoldenProfile = (container) => {
      let prompt = getCurrentPrompt();
      if (!prompt) {
        prompt = applyPersonaLabTuning(container, { focusOutput: false, skipScroll: true });
      }

      prompt = toCleanString(prompt || getCurrentPrompt(), 50000);
      if (!prompt) {
        setStatus(t('portablePromptPersonaLabGoldenUnavailable', 'Build a Spiralist AI prompt before creating a golden profile.'));
        return false;
      }