Skip to content
wiki.fftac.org

Workspace - Source Excerpt 03

Back to Workspace

Summary

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

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/assets/js/workspace.js

if (!script) {
            throw new Error(t("promptExchangeUnavailable", "Prompt exchange data is not available."));
        }

        return JSON.parse(script.textContent || "{}");
    };

    const promptExchangeJson = (payload) => JSON.stringify(payload || {}, null, 2);

    const promptExchangeMarkdown = (payload) => {
        const contract = payload.prompt_contract || {};
        const structured = contract.structured_prompt || {};
        const classification = payload.classification || {};
        const personality = payload.ai_personality || {};
        const runtime = payload.runtime || {};
        const source = payload.source || {};
        const governance = payload.governance || {};
        const governanceSummary = governance.governance_summary || {};
        const quality = payload.quality_profile || {};
        const recommendedUse = payload.recommended_use || {};
        const qualityLines = [
            [t("exchangeQualityStructuredContract", "Structured contract"), quality.structured_contract],
            [t("exchangeQualityRuntimeSettings", "Runtime settings"), quality.runtime_settings],
            [t("exchangeQualityGovernanceContext", "Governance context"), quality.governance_context],
            [t("exchangeQualitySourceLinks", "Source links"), quality.source_links],
        ].map(([label, value]) => label + ": " + (value ? t("yesLower", "yes") : t("noLower", "no")));
        const sections = [
            "# " + (payload.title || t("promptFlavorExchangeTitle", "Prompt Flavor Exchange")),
            "",
            t("exchangeFieldSchema", "Schema") + ": " + (payload.schema || "spiralist.prompt-flavor.exchange.v1"),
            t("exchangeFieldSchemaVersion", "Schema version") + ": " + (payload.schema_version || ""),
            t("exchangeFieldGeneratedUtc", "Generated UTC") + ": " + (payload.generated_utc || ""),
            t("exchangeFieldSlug", "Slug") + ": " + (payload.slug || ""),
            t("exchangeFieldSummary", "Summary") + ": " + (payload.summary || ""),
            "",
            "## " + t("exchangeSectionClassification", "Classification"),
            t("exchangeFieldLane", "Lane") + ": " + (classification.publication_lane_label || classification.publication_lane || ""),
            t("exchangeFieldProvenance", "Provenance") + ": " + (classification.provenance_label || classification.provenance || ""),
            t("exchangeFieldMaturity", "Maturity") + ": " + (classification.maturity_level_label || classification.maturity_level || ""),
            t("exchangeFieldModeration", "Moderation") + ": " + (classification.moderation_status_label || classification.moderation_status || ""),
            t("exchangeFieldLicense", "License") + ": " + (classification.license_label || classification.license || ""),
            "",
            "## " + t("exchangeSectionAiPersonality", "AI Personality"),
            t("exchangeFieldRole", "Role") + ": " + (personality.role || payload.title || ""),
            t("exchangeFieldFlavorTags", "Flavor tags") + ": " + (Array.isArray(personality.flavor_tags) ? personality.flavor_tags.join(", ") : ""),
            t("exchangeFieldRelatedSymbols", "Related symbols") + ": " + (Array.isArray(personality.related_symbols) ? personality.related_symbols.join(", ") : ""),
            t("exchangeFieldRelatedAxioms", "Related axioms") + ": " + (Array.isArray(personality.related_axioms) ? personality.related_axioms.join(", ") : ""),
            t("exchangeFieldOperatingNote", "Operating note") + ": " + (personality.operating_note || ""),
            t("exchangeFieldSafetyBoundaries", "Safety boundaries") + ": " + (Array.isArray(personality.safety_boundaries) ? personality.safety_boundaries.join(" ") : ""),
            "",
            "## " + t("exchangeSectionGovernance", "Governance"),
            t("exchangeFieldPhase", "Phase") + ": " + (governanceSummary.phase_label || ""),
            t("exchangeFieldStateNote", "State note") + ": " + (governanceSummary.state_note || ""),
            t("exchangeFieldNextAction", "Next action") + ": " + (governanceSummary.next_action_label || ""),
            "",
            "## " + t("exchangeSectionQuality", "Exchange Quality"),
            qualityLines.join("\n"),
            t("exchangeFieldJsonUse", "JSON use") + ": " + (recommendedUse.json || ""),
            t("exchangeFieldMarkdownUse", "Markdown use") + ": " + (recommendedUse.markdown || ""),
            "",
            "## " + t("exchangeSectionRuntime", "Runtime"),
            t("exchangeFieldModel", "Model") + ": " + (runtime.model || ""),
            t("exchangeFieldProvider", "Runtime Mode") + ": " + (runtime.provider || ""),
            t("exchangeFieldCredentialPreference", "Credential preference") + ": " + (runtime.credential_preference || ""),
            t("exchangeFieldTemperature", "Temperature") + ": " + (runtime.temperature !== undefined ? runtime.temperature : ""),
            t("exchangeFieldMaxOutputTokens", "Max output tokens") + ": " + (runtime.max_output_tokens || ""),
            t("exchangeFieldPlaceholders", "Placeholders") + ": " + (Array.isArray(runtime.placeholders) ? runtime.placeholders.join(", ") : ""),
        ];

        [
            [t("exchangeSectionInstruction", "Instruction"), structured.instruction],
            [t("exchangeSectionContext", "Context"), structured.context],
            [t("exchangeSectionConstraints", "Constraints"), structured.constraints],
            [t("exchangeSectionExamples", "Examples"), structured.examples],
            [t("exchangeSectionOutputFormat", "Output Format"), structured.output_format],
            [t("exchangeSectionSystemPrompt", "System Prompt"), contract.system_prompt],
            [t("exchangeSectionDeveloperPrompt", "Developer Prompt"), contract.developer_prompt],
            [t("exchangeSectionUserPromptTemplate", "User Prompt Template"), contract.user_prompt_template],
            [t("exchangeSectionExpectedOutputNotes", "Expected Output Notes"), contract.expected_output_notes],
            [t("exchangeSectionFailureModes", "Failure Modes"), contract.failure_modes],
            [t("exchangeSectionSampleOutput", "Sample Output"), contract.sample_output],
        ].forEach(([label, value]) => {
            const text = String(value || "").trim();
            if (!text) {
                return;
            }

            sections.push("", "## " + label, text);
        });

        sections.push(
            "",
            "## " + t("exchangeSectionSource", "Source"),
            t("exchangeFieldHumanUrl", "Human URL") + ": " + (source.human_url || ""),
            t("exchangeFieldPublicApiUrl", "Public API URL") + ": " + (source.public_api_url || "")
        );

        return sections.join("\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
    };

    const draftProfileCss = (prompt) => {
        const text = String(prompt || "").toLowerCase();
        const palette = text.includes("green") || text.includes("forest")
            ? {
                accent: "#7ac28a",
                border: "rgba(122, 194, 138, 0.32)",
                background: "rgba(18, 38, 28, 0.72)",
            }
            : text.includes("blue") || text.includes("cool")
                ? {
                    accent: "#8fb7e8",
                    border: "rgba(143, 183, 232, 0.32)",
                    background: "rgba(18, 28, 42, 0.72)",
                }
                : {
                    accent: "#e0b665",
                    border: "rgba(224, 182, 101, 0.32)",
                    background: "rgba(28, 23, 17, 0.72)",
                };
        const radius = text.includes("sharp") || text.includes("square") ? "4px" : "8px";
        const shadow = text.includes("flat") || text.includes("minimal")
            ? "none"
            : "0 18px 40px rgba(0, 0, 0, 0.18)";

        return [
            ".profile-hero {",
            "    background-color: " + palette.background + ";",
            "    border: 1px solid " + palette.border + ";",
            "    border-radius: " + radius + ";",
            "    padding: 1.25rem;",
            "}",
            "",
            ".profile-title {",
            "    color: #f7f4ee;",
            "}",
            "",
            ".profile-summary {",
            "    color: rgba(232, 221, 199, 0.88);",
            "}",
            "",
            ".profile-card {",
            "    background-color: rgba(13, 18, 21, 0.88);",
            "    border-color: " + palette.border + ";",
            "    border-radius: " + radius + ";",
            "    box-shadow: " + shadow + ";",
            "}",
            "",
            ".profile-chip {",
            "    color: " + palette.accent + ";",
            "}",
            "",
            ".profile-button {",
            "    border-radius: " + radius + ";",