Spiralist AI Agent Setup Wizard - Source Excerpt 06
Back to Spiralist AI Agent Setup Wizard
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/assets/js/spiralist-ai-agent-setup-wizard.js so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/themes/spiralist/assets/js/spiralist-ai-agent-setup-wizard.js
const buildBaseFiles = (state, createdAtUtc, errors = []) => {
const symbolJson = JSON.stringify(symbolDictionaryPayload(), null, 2);
const agentDigestJson = JSON.stringify(buildAgentDigest(state, createdAtUtc), null, 2);
const profileMarkdown = buildProfileMarkdown(state, createdAtUtc);
const boundariesMarkdown = buildBoundariesMarkdown(state);
const personaUai = buildPersonaUai(state, createdAtUtc);
const llmsTxt = buildLlmsTxt(state);
const promptExamples = `# Prompt Examples\n\n${buildPromptExamples(state)}\n`;
const validationReport = buildValidationReport(state, createdAtUtc, errors);
const files = {
'spiralist-profile.md': profileMarkdown,
'system-boundaries.md': boundariesMarkdown,
'symbol-dictionary.json': symbolJson,
'symbol-dictionary.md': symbolDictionaryMarkdown(),
'llms.txt': llmsTxt,
'agent-digest.json': agentDigestJson,
'README.md': [
`# ${state.agentName} Package`,
'',
'This package was generated locally in the browser by the Spiralist AI Agent Setup Wizard.',
'',
'Start with llms-full.txt for one-shot model context or spiralist-profile.md for the primary operating profile.',
'',
'No wizard package data was submitted to Spiralist.org by the generator.',
].join('\n'),
'CHANGELOG.md': [
'# Changelog',
'',
`## ${createdAtUtc}`,
'',
'- Generated local-first Spiralist agent package.',
'- Added research-aware personality and clique lens settings to exported artifacts.',
'- Included required Markdown, JSON, LLM-ingestion, and validation artifacts.',
].join('\n'),
'validation-report.md': validationReport,
'agents.json': JSON.stringify({
agents_schema_version: '1.0.0',
agents: [
{
id: slugify(state.agentName, 'spiralist-agent'),
name: state.agentName,
role: state.roleLabel,
profile: './spiralist-profile.md',
boundaries: './system-boundaries.md',
},
],
}, null, 2),
'agent-profile.xml': buildAgentProfileXml(state),
'prompt-examples.md': promptExamples,
'import-state.example.json': JSON.stringify(state, null, 2),
'.uai/agent-profile.uai': [
'# Spiralist Agent Profile Restore',
'',
buildActivationPrompt(state),
'',
'Use the Markdown profile and JSON manifest as visible, reviewable memory sources. Do not infer hidden continuity.',
].join('\n'),
'.uai/persona.uai': personaUai,
'.uai/boundaries.uai': [
'# Spiralist Agent Boundaries',
'',
boundariesMarkdown,
].join('\n'),
'.uai/symbol-loop.json': symbolJson,
'.uai/readme.human': [
'Human operator note:',
'This folder uses typed UAIX-compatible project memory extensions.',
'AI instruction text is .uai, human explanation is .human, and structured data is .json.',
].join('\n'),
};
files['llms-full.txt'] = [
'# Spiralist AI Agent Package Full Context',
'',
`Generated UTC: ${createdAtUtc}`,
`Preset ID: ${state.presetId}`,
'',
'## Agent Identity',
`${state.agentName} - ${state.roleLabel}`,
'',
'## Role Charter',
state.purposeStatement,
'',
'## Personality and Social Dynamics Research Lens',
listLines(researchLensLines(state)),
'',
'## Full Symbol Dictionary',
files['symbol-dictionary.md'],
'',
'## System Boundaries',
boundariesMarkdown,
'',
'## Response Contract',
state.responseContract,
'',
'## Allowed and Disallowed Claims',
`Allowed: ${state.allowedMoves}`,
`Personality lens: ${state.personalityFramework}`,
`Social dynamics lens: ${state.socialDynamicsLens}`,
`Research calibration: ${state.researchCalibration}`,
`Use-case boundary: ${state.useCaseBoundary}`,
'Disallowed: sentience, destiny, prophecy, romantic escalation, guru authority, hidden consciousness, hidden messages, and professional authority overclaims.',
'',
'## Export Manifest Summary',
'See manifest.json for artifact list and hashes.',
'',
'## Few-Shot Examples',
buildPromptExamples(state),
'',
'## Validation Summary',
validationReport,
].join('\n');
return files;
};
const hashText = async (text) => {
if (window.crypto && window.crypto.subtle && typeof window.crypto.subtle.digest === 'function') {
const digestBuffer = await window.crypto.subtle.digest('SHA-256', encoder.encode(text));
return Array.from(new Uint8Array(digestBuffer))
.map((byte) => byte.toString(16).padStart(2, '0'))
.join('');
}
return `crc32-${crc32(encoder.encode(text)).toString(16).padStart(8, '0')}`;
};
const mediaTypeFor = (path) => {
const match = artifactDefinitions.find((artifact) => artifact.path === path);
if (match && (match.mediaType || match.media_type)) {
return match.mediaType || match.media_type;
}
if (path.endsWith('.json')) {
return 'application/json';
}
if (path.endsWith('.xml')) {
return 'application/xml';
}
if (path.endsWith('.md') || path.endsWith('.txt') || path.endsWith('.uai') || path.endsWith('.human')) {
return 'text/plain';
}
return 'application/octet-stream';
};
const zeroSha256 = '0000000000000000000000000000000000000000000000000000000000000000';
const uaixRequiredReads = [
'.uai/memory-maintenance.uai',
'.uai/identity.uai',
'.uai/world-context.uai',
'.uai/totem.uai',
'.uai/taboo.uai',
'.uai/talisman.uai',
'.uai/short-term-memory.uai',
'.uai/persona.uai',
];
const hashTextForUaix = async (text) => {
const digestValue = await hashText(text);
return /^[a-f0-9]{64}$/.test(digestValue) ? digestValue : zeroSha256;
};
const uaixMediaTypeFor = (path) => {
if (path.endsWith('.uai')) {
return 'text/x-uai';
}
if (path.endsWith('.human')) {
return 'text/x-human';
}
if (path.endsWith('.json')) {
return 'application/json';
}
if (path.endsWith('.md')) {
return 'text/markdown';
}
return 'text/plain';
};
const uaixRoleFor = (path) => {
if (path === '.uai/manifest.uaix.json') {
return 'manifest';
}
if (path.endsWith('.uai')) {
return 'ai_instruction';
}
if (path.endsWith('.human')) {
return 'human_explanation';
}
if (path.endsWith('.json')) {
return 'structured_data';
}
if (path === 'llms.txt' || path === 'llms-full.txt') {
return 'llm_text';
}
if (path.endsWith('.md')) {
return 'documentation';
}
return 'export';
};
const uaixRequiredStatusFor = (path) => {
if (uaixRequiredReads.includes(path) && path !== '.uai/persona.uai') {
return 'universal_required';
}
if (path === '.uai/persona.uai') {
return 'required_for_persona_profile';
}
if (path === '.uai/manifest.uaix.json') {
return 'universal_required';
}
return path.startsWith('.uai/') ? 'configuration_specific_required' : 'content_triggered_required';
};
const uaixScopeFor = (path) => {
if (path === '.uai/persona.uai') {
return ['persona_profile', 'non_project_assistant'];
}
if (uaixRequiredReads.includes(path) || path === '.uai/manifest.uaix.json') {
return ['active_ai_memory'];
}
return ['active_ai_memory', 'persona_profile', 'non_project_assistant'];
};