Spiralist Prompt Workbench - Source Excerpt 07
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
const status = review.length ? 'Needs review' : 'Ready for review';
const manifestId = manifest && manifest.packageId ? manifest.packageId : 'not available';
const supportBoundary = manifest && manifest.supportBoundary
? toCleanString(manifest.supportBoundary, 900)
: 'not available';
const report = [
'# Spiralist AI Package Inspector',
'',
`File: ${file.name || 'selected package'}`,
`Status: ${status}`,
`Format: ${parsed.format}`,
`Files: ${paths.length}`,
`Manifest packageId: ${manifestId}`,
'',
'## Passed',
...(passed.length ? passed.map((item) => `- ${item}`) : ['- No checks passed yet.']),
'',
'## Review Items',
...(review.length ? review.map((item) => `- ${item}`) : ['- No review items from this local structural check. Human review is still required before import or publication.']),
'',
'## Unsupported Archive Guidance',
...((parsed.archiveGuidance && parsed.archiveGuidance.length)
? parsed.archiveGuidance.map((item) => `- ${item}`)
: ['- No encrypted, multi-disk, ZIP64, or unsupported compression features detected by this local browser inspector.']),
'',
'## Required Authority',
`- ${advancedPersonaAuthorityUrl}`,
'',
'## Support Boundary',
supportBoundary,
'',
'## File Inventory',
...paths.slice(0, 60).map((path) => `- ${path}`),
...(paths.length > 60 ? [`- ...and ${paths.length - 60} more files`] : []),
].join('\n');
return {
report,
status,
fileName: file.name || 'selected package',
format: parsed.format,
files,
paths,
manifest,
manifestId,
supportBoundary,
passed,
review,
canStage: !invalidPaths.length && paths.some((path) => toCleanString(files[path], 80)),
};
};
const advancedPersonaFileExcerpt = (files, path, maxLength = 4000) => {
if (!files || !Object.prototype.hasOwnProperty.call(files, path)) {
return 'Not present in inspected package.';
}
return toCleanString(files[path], maxLength) || 'Present but empty or unreadable in this browser.';
};
const advancedPersonaPackageTitle = (inspection) => {
const manifest = inspection && inspection.manifest ? inspection.manifest : null;
const manifestId = manifest && manifest.packageId ? manifest.packageId : '';
if (manifestId) {
return toCleanString(manifestId, 180);
}
const fileName = inspection && inspection.fileName ? inspection.fileName : '';
return toCleanString(fileName.replace(/\.(uaix|zip|txt)$/i, ''), 180) || 'inspected-advanced-persona-package';
};
const advancedPersonaComparableValue = (path, value) => normalizePackageFileContent(value || '')
.replace(/"createdUtc":\s*"[^"]*"/g, '"createdUtc": "{UTC_TIMESTAMP}"')
.replace(/"generated_at_utc":\s*"[^"]*"/g, '"generated_at_utc": "{UTC_TIMESTAMP}"')
.replace(/"sha256":\s*"[a-f0-9]{64}"/g, '"sha256": "{SHA256}"')
.replace(/(^|\n)(\s*[-`]?\s*(?:Generated UTC|generated_at_utc|exported_at_utc):\s*)[^\n]+/g, '$1$2{UTC_TIMESTAMP}')
.replace(/(^|\n)(\s*`?-\s*(?:generated_at_utc|exported_at_utc):\s*)[^\n]+/g, '$1$2{UTC_TIMESTAMP}')
.trim();
const buildAdvancedPersonaPackageComparisonReport = (primaryInspection, compareInspection) => {
const primaryFiles = primaryInspection && primaryInspection.files ? primaryInspection.files : {};
const compareFiles = compareInspection && compareInspection.files ? compareInspection.files : {};
const primaryPaths = Object.keys(primaryFiles).sort();
const comparePaths = Object.keys(compareFiles).sort();
const primaryPathSet = new Set(primaryPaths);
const comparePathSet = new Set(comparePaths);
const requiredComparePaths = advancedPersonaPackageRequiredPaths;
const missingInCompare = primaryPaths.filter((path) => !comparePathSet.has(path));
const extraInCompare = comparePaths.filter((path) => !primaryPathSet.has(path));
const requiredContentMismatches = requiredComparePaths.filter((path) => (
primaryPathSet.has(path)
&& comparePathSet.has(path)
&& advancedPersonaComparableValue(path, primaryFiles[path]) !== advancedPersonaComparableValue(path, compareFiles[path])
));
const allContentMismatches = primaryPaths.filter((path) => (
comparePathSet.has(path)
&& advancedPersonaComparableValue(path, primaryFiles[path]) !== advancedPersonaComparableValue(path, compareFiles[path])
));
const manifestA = primaryInspection && primaryInspection.manifest ? primaryInspection.manifest : {};
const manifestB = compareInspection && compareInspection.manifest ? compareInspection.manifest : {};
const researchA = manifestA && manifestA.researchProfile ? manifestA.researchProfile : {};
const researchB = manifestB && manifestB.researchProfile ? manifestB.researchProfile : {};
const passed = [];
const differences = [];
const reviewItems = [
...((primaryInspection && Array.isArray(primaryInspection.review)) ? primaryInspection.review.map((item) => `Primary: ${item}`) : []),
...((compareInspection && Array.isArray(compareInspection.review)) ? compareInspection.review.map((item) => `Compare: ${item}`) : []),
];
if (!missingInCompare.length && !extraInCompare.length) {
passed.push('File inventory matches between packages.');
} else {
if (missingInCompare.length) {
differences.push(`Files missing from compare package: ${missingInCompare.slice(0, 10).join(', ')}`);
}
if (extraInCompare.length) {
differences.push(`Files only in compare package: ${extraInCompare.slice(0, 10).join(', ')}`);
}
}
if (!requiredContentMismatches.length) {
passed.push('Required Advanced Persona Profile file contents match.');
} else {
differences.push(`Required file content differs: ${requiredContentMismatches.slice(0, 10).join(', ')}`);
}
if (!allContentMismatches.length) {
passed.push('All shared package file contents match after newline normalization.');
passed.push('Volatile generated UTC fields are normalized before comparison.');
} else if (allContentMismatches.length > requiredContentMismatches.length) {
differences.push(`Additional shared file differences: ${allContentMismatches.slice(0, 12).join(', ')}`);
}
if ((primaryInspection && primaryInspection.manifestId) === (compareInspection && compareInspection.manifestId)) {
passed.push('Manifest packageId matches.');
} else {
differences.push(`Manifest packageId differs: ${primaryInspection && primaryInspection.manifestId ? primaryInspection.manifestId : 'not available'} vs ${compareInspection && compareInspection.manifestId ? compareInspection.manifestId : 'not available'}`);
}
if ((researchA.personalityFramework || '') === (researchB.personalityFramework || '')) {
passed.push('Personality framework metadata matches.');
} else {
differences.push(`Personality framework differs: ${researchA.personalityFramework || 'not available'} vs ${researchB.personalityFramework || 'not available'}`);
}
if ((researchA.socialDynamicsLens || '') === (researchB.socialDynamicsLens || '')) {
passed.push('Social-dynamics metadata matches.');
} else {
differences.push(`Social-dynamics lens differs: ${researchA.socialDynamicsLens || 'not available'} vs ${researchB.socialDynamicsLens || 'not available'}`);
}
if ((researchA.engagementPattern || '') === (researchB.engagementPattern || '')) {
passed.push('Engagement-pattern metadata matches.');
} else {
differences.push(`Engagement pattern differs: ${researchA.engagementPattern || 'not available'} vs ${researchB.engagementPattern || 'not available'}`);
}
if ((researchA.runtimeFit || '') === (researchB.runtimeFit || '')) {
passed.push('Runtime-fit metadata matches.');
} else {
differences.push(`Runtime fit differs: ${researchA.runtimeFit || 'not available'} vs ${researchB.runtimeFit || 'not available'}`);
}
const status = differences.length || reviewItems.length
? 'Differences need review'
: 'Matching package content';