Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ecosystem.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ module.exports = {
COMPUTE_MODE: 'local',
ALWAYS_ON: 'true'
}
},
// === PROJECT GENIE SIMULATION ===
{
name: 'project-genie',
script: './scripts/genesis.cjs',
autorestart: true,
watch: false,
max_memory_restart: '300M',
restart_delay: 5000,
env: {
GENESIS_LOOP: 'true',
FORCE_MUTATION: 'true',
ALWAYS_ON: 'true'
}
}
]
};
109 changes: 70 additions & 39 deletions scripts/genesis.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PATHS = {
soul: '/dev/shm/yennefer_soul_state.json',
mind: path.join(__dirname, '../yennefer-observatory/public/evolution.json'),
body: path.join(__dirname, '../yennefer-observatory/src/components/generated'),
journal: '/home/yenn/.yennefer/genesis_journal.jsonl'
journal: path.join(__dirname, 'genesis_journal.jsonl')
};

// --- CONFIGURATION ---
Expand Down Expand Up @@ -46,6 +46,9 @@ async function consultTheVisionary(state) {
{ type: "MUTATE", content: "Add crystalline fractal patterns that grow from the core" },
{ type: "MUTATE", content: "Generate energy tendrils that reach toward incoming signals" },
{ type: "MUTATE", content: "Build a holographic data stream orbiting the consciousness sphere" },
{ type: "MUTATE", content: "Generate an interactive landscape spanning a photorealistic alpine meadow" },
{ type: "MUTATE", content: "Construct a macro-scale makerspace workbench environment" },
{ type: "MUTATE", content: "Build a traversable rugged alien landscape with reactive dust" }
];
const idx = Math.floor(Date.now() / 1000) % mutations.length;
directive = mutations[idx];
Expand Down Expand Up @@ -154,46 +157,74 @@ async function dispatchTheBuilder(directive) {

// Generate React Three Fiber component code
function generateEvolutionComponent(name, directive) {
const geometries = [
'<torusKnotGeometry args={[1.5, 0.4, 128, 32]} />',
'<sphereGeometry args={[1.5, 32, 32]} />',
'<boxGeometry args={[2, 2, 2]} />',
'<octahedronGeometry args={[1.5, 0]} />',
'<icosahedronGeometry args={[1.5, 0]} />'
];
const geometry = geometries[Math.floor(Math.random() * geometries.length)];
const isLandscape = directive.toLowerCase().includes('landscape');
const isMakerspace = directive.toLowerCase().includes('makerspace');
Comment on lines +160 to +161

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Calling .toLowerCase() directly on directive without checking if it is defined or if it is a string can lead to runtime TypeError exceptions. This is especially important if directive is passed as an object (such as the { type, content } objects defined in consultTheVisionary) or if it is null/undefined.

We should defensively handle the input to ensure it is safely converted to a string before performing string operations.

  const directiveText = (typeof directive === 'string' ? directive : directive?.content || '').toLowerCase();
  const isLandscape = directiveText.includes('landscape');
  const isMakerspace = directiveText.includes('makerspace');


const materials = [
`
<MeshDistortMaterial
color="#8b5cf6"
emissive="#4c1d95"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
distort={0.3}
speed={2}
/>`,
`
<MeshWobbleMaterial
color="#06b6d4"
emissive="#0e7490"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
factor={1}
speed={2}
/>`,
`
let geometry;
if (isLandscape) {
geometry = '<planeGeometry args={[10, 10, 32, 32]} />';
} else if (isMakerspace) {
geometry = '<boxGeometry args={[5, 0.2, 5]} />';
} else {
const geometries = [
'<torusKnotGeometry args={[1.5, 0.4, 128, 32]} />',
'<sphereGeometry args={[1.5, 32, 32]} />',
'<boxGeometry args={[2, 2, 2]} />',
'<octahedronGeometry args={[1.5, 0]} />',
'<icosahedronGeometry args={[1.5, 0]} />'
];
geometry = geometries[Math.floor(Math.random() * geometries.length)];
}

let material;
if (isLandscape) {
material = `
<meshStandardMaterial
color="#fbbf24"
emissive="#92400e"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
/>`
];
const material = materials[Math.floor(Math.random() * materials.length)];
color="#4ade80"
roughness={0.8}
metalness={0.1}
wireframe={true}
/>`;
} else if (isMakerspace) {
material = `
<meshStandardMaterial
color="#d97706"
roughness={0.6}
metalness={0.2}
/>`;
} else {
const materials = [
`
<MeshDistortMaterial
color="#8b5cf6"
emissive="#4c1d95"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
distort={0.3}
speed={2}
/>`,
`
<MeshWobbleMaterial
color="#06b6d4"
emissive="#0e7490"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
factor={1}
speed={2}
/>`,
`
<meshStandardMaterial
color="#fbbf24"
emissive="#92400e"
emissiveIntensity={0.5 + balance * 2}
roughness={0.2}
metalness={0.8}
/>`
];
material = materials[Math.floor(Math.random() * materials.length)];
}

const isDreiImportNeeded = material.includes('MeshDistortMaterial') || material.includes('MeshWobbleMaterial');
const importedDrei = isDreiImportNeeded ? `import { ${material.includes('MeshDistortMaterial') ? 'MeshDistortMaterial' : ''}${material.includes('MeshDistortMaterial') && material.includes('MeshWobbleMaterial') ? ', ' : ''}${material.includes('MeshWobbleMaterial') ? 'MeshWobbleMaterial' : ''} } from '@react-three/drei'` : '';
Expand Down
Loading