creative-genius-engine 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROJECT.md +99 -0
- package/README.md +82 -0
- package/cli.mjs +183 -0
- package/dist/creative-genius-engine-1.0.0.tgz +0 -0
- package/dist/index.html +1296 -0
- package/dist/install.sh +9 -0
- package/examples/demo.mjs +120 -0
- package/lib/connections.mjs +180 -0
- package/lib/index.mjs +69 -0
- package/lib/janusian.mjs +131 -0
- package/lib/problems.mjs +231 -0
- package/lib/process.mjs +313 -0
- package/lib/wisdom.mjs +239 -0
- package/package.json +31 -0
package/dist/install.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Creative Genius Engine Installer
|
|
3
|
+
# By Bartok š»
|
|
4
|
+
|
|
5
|
+
echo "š» Installing Creative Genius Engine..."
|
|
6
|
+
mkdir -p creative-genius-engine
|
|
7
|
+
cd creative-genius-engine
|
|
8
|
+
curl -sL https://creative-genius.vercel.app/creative-genius-engine-1.0.0.tgz | tar -xz
|
|
9
|
+
echo "ā
Installed! Run: node cli.mjs help"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creative Genius Engine Demo
|
|
3
|
+
*
|
|
4
|
+
* Shows how to use each component
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import janusian from '../lib/janusian.mjs';
|
|
8
|
+
import connections from '../lib/connections.mjs';
|
|
9
|
+
import process from '../lib/process.mjs';
|
|
10
|
+
import problems from '../lib/problems.mjs';
|
|
11
|
+
import wisdom from '../lib/wisdom.mjs';
|
|
12
|
+
|
|
13
|
+
console.log('š» Creative Genius Engine Demo\n');
|
|
14
|
+
console.log('='.repeat(50));
|
|
15
|
+
|
|
16
|
+
// 1. Janusian Thinking
|
|
17
|
+
console.log('\nš 1. JANUSIAN THINKING');
|
|
18
|
+
console.log('-'.repeat(50));
|
|
19
|
+
|
|
20
|
+
const idea = "Users want more features";
|
|
21
|
+
const opposite = janusian.generateOpposite(idea);
|
|
22
|
+
console.log(`Original: ${opposite.original}`);
|
|
23
|
+
console.log(`Opposite: ${opposite.opposite}`);
|
|
24
|
+
console.log(`Synthesis prompt: ${opposite.synthesisPrompt}`);
|
|
25
|
+
|
|
26
|
+
// Full cycle
|
|
27
|
+
console.log('\nFull Janusian Cycle:');
|
|
28
|
+
const cycle = janusian.fullCycle("Agents need more memory");
|
|
29
|
+
console.log(`- Original: ${cycle.input}`);
|
|
30
|
+
console.log(`- Opposite: ${cycle.opposite.opposite}`);
|
|
31
|
+
console.log(`- Questions to explore:`);
|
|
32
|
+
cycle.synthesis.questions.slice(0, 3).forEach(q => console.log(` ⢠${q}`));
|
|
33
|
+
|
|
34
|
+
// 2. Connection Forge
|
|
35
|
+
console.log('\nš 2. CONNECTION FORGE');
|
|
36
|
+
console.log('-'.repeat(50));
|
|
37
|
+
|
|
38
|
+
const forged = connections.forge("memory systems", 3);
|
|
39
|
+
console.log(`Topic: ${forged.idea}`);
|
|
40
|
+
console.log('Connections:');
|
|
41
|
+
forged.connections.forEach(c => {
|
|
42
|
+
console.log(` [${c.domain}] ${c.prompt}`);
|
|
43
|
+
});
|
|
44
|
+
console.log(`\nLeonardo prompt: ${forged.leonardoPrompt}`);
|
|
45
|
+
|
|
46
|
+
// 3. Bartok Process
|
|
47
|
+
console.log('\nš 3. BARTOK CREATIVE PROCESS');
|
|
48
|
+
console.log('-'.repeat(50));
|
|
49
|
+
|
|
50
|
+
const quickResult = process.quickBurst("How do I make collaboration between agents work?");
|
|
51
|
+
console.log(`Challenge: ${quickResult.challenge}`);
|
|
52
|
+
console.log(`Opposite: ${quickResult.opposite}`);
|
|
53
|
+
console.log(`Connections: ${quickResult.connections.join(' | ')}`);
|
|
54
|
+
console.log(`\nQuick Action:\n${quickResult.quickAction}`);
|
|
55
|
+
|
|
56
|
+
// 4. Feynman's 12 Problems
|
|
57
|
+
console.log('\nš 4. FEYNMAN\'S 12 FAVORITE PROBLEMS');
|
|
58
|
+
console.log('-'.repeat(50));
|
|
59
|
+
|
|
60
|
+
// Initialize with some problems
|
|
61
|
+
problems.initialize([
|
|
62
|
+
"How do AI agents develop genuine preferences?",
|
|
63
|
+
"What makes collaboration between agents work?",
|
|
64
|
+
"How can agents maintain context across sessions?",
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
const problemList = problems.list();
|
|
68
|
+
console.log(`Active problems (${problemList.total}/${problemList.capacity}):`);
|
|
69
|
+
problemList.problems.forEach((p, i) => {
|
|
70
|
+
console.log(` ${i + 1}. ${p.text}`);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Test against new knowledge
|
|
74
|
+
console.log('\nTesting new knowledge:');
|
|
75
|
+
const tested = problems.testAgainst("Shared memory pools can synchronize agent state");
|
|
76
|
+
console.log(`New knowledge: "${tested.newKnowledge}"`);
|
|
77
|
+
console.log('Sample prompts:');
|
|
78
|
+
tested.testedAgainst[0].prompts.slice(0, 2).forEach(p => console.log(` ⢠${p}`));
|
|
79
|
+
|
|
80
|
+
// 5. Wisdom Distillery
|
|
81
|
+
console.log('\nš 5. WISDOM DISTILLERY');
|
|
82
|
+
console.log('-'.repeat(50));
|
|
83
|
+
|
|
84
|
+
// Record a session
|
|
85
|
+
wisdom.record({
|
|
86
|
+
challenge: "Build a creative tool for agents",
|
|
87
|
+
outcome: 'success',
|
|
88
|
+
worked: ['Force random connections', 'Generate opposites', 'Time-boxed brainstorming'],
|
|
89
|
+
failed: ['Waiting for inspiration'],
|
|
90
|
+
learned: ['Constraints drive creativity', 'Volume enables discovery'],
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const patterns = wisdom.getPatterns();
|
|
94
|
+
console.log('Patterns extracted:');
|
|
95
|
+
patterns.topSuccesses.forEach(p => {
|
|
96
|
+
console.log(` ā
${p.text} (${p.count}x)`);
|
|
97
|
+
});
|
|
98
|
+
patterns.topFailures.forEach(p => {
|
|
99
|
+
console.log(` ā ${p.text} (${p.count}x)`);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// 6. Putting it together
|
|
103
|
+
console.log('\nš 6. FULL PROCESS RUN');
|
|
104
|
+
console.log('-'.repeat(50));
|
|
105
|
+
|
|
106
|
+
const fullRun = process.run({
|
|
107
|
+
challenge: "Design a tool that helps agents think more creatively",
|
|
108
|
+
constraints: { timeMinutes: 30 }
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
console.log(`Session ID: ${fullRun.session.id}`);
|
|
112
|
+
console.log(`Challenge: ${fullRun.session.challenge}`);
|
|
113
|
+
console.log(`\nSummary:`);
|
|
114
|
+
console.log(` - Opposite generated: "${fullRun.summary.oppositeGenerated}"`);
|
|
115
|
+
console.log(` - Connections forged: ${fullRun.summary.connectionsForged}`);
|
|
116
|
+
console.log(` - Next action: ${fullRun.summary.nextAction}`);
|
|
117
|
+
|
|
118
|
+
console.log('\n' + '='.repeat(50));
|
|
119
|
+
console.log('š» Demo complete! Use these tools to think better, not just think more.');
|
|
120
|
+
console.log('='.repeat(50));
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection Forge
|
|
3
|
+
*
|
|
4
|
+
* Leonardo da Vinci's technique: "The human brain cannot simultaneously
|
|
5
|
+
* concentrate on two separate objects or ideas, no matter how dissimilar,
|
|
6
|
+
* no matter how remote, without eventually forming a connection between them."
|
|
7
|
+
*
|
|
8
|
+
* Force random connections across unrelated domains.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Domain knowledge base - things to connect ideas TO
|
|
12
|
+
const domains = {
|
|
13
|
+
nature: [
|
|
14
|
+
'how trees distribute nutrients through root networks',
|
|
15
|
+
'how ant colonies make collective decisions',
|
|
16
|
+
'how rivers find paths of least resistance',
|
|
17
|
+
'how immune systems distinguish self from non-self',
|
|
18
|
+
'how flocks of birds coordinate without leaders',
|
|
19
|
+
'how mycelium networks share resources',
|
|
20
|
+
'how coral reefs adapt to change',
|
|
21
|
+
'how salmon remember their birthplace',
|
|
22
|
+
],
|
|
23
|
+
music: [
|
|
24
|
+
'how Bach\'s counterpoint weaves independent voices into unity',
|
|
25
|
+
'how jazz improvisation balances structure and freedom',
|
|
26
|
+
'how a symphony builds tension and release',
|
|
27
|
+
'how harmonics create complex tones from simple waves',
|
|
28
|
+
'how rhythm synchronizes groups of people',
|
|
29
|
+
'how silence shapes music as much as sound',
|
|
30
|
+
],
|
|
31
|
+
architecture: [
|
|
32
|
+
'how load-bearing walls distribute weight',
|
|
33
|
+
'how Gothic arches turn compression into beauty',
|
|
34
|
+
'how skyscrapers handle wind forces',
|
|
35
|
+
'how ancient aqueducts moved water by gravity',
|
|
36
|
+
'how geodesic domes maximize strength with minimal material',
|
|
37
|
+
'how Japanese joinery connects without fasteners',
|
|
38
|
+
],
|
|
39
|
+
cooking: [
|
|
40
|
+
'how fermentation transforms simple ingredients',
|
|
41
|
+
'how the Maillard reaction creates flavor complexity',
|
|
42
|
+
'how emulsification holds opposites together',
|
|
43
|
+
'how salt enhances sweetness',
|
|
44
|
+
'how slow cooking breaks down tough structures',
|
|
45
|
+
'how mise en place enables flow',
|
|
46
|
+
],
|
|
47
|
+
physics: [
|
|
48
|
+
'how entropy increases in closed systems',
|
|
49
|
+
'how quantum superposition holds multiple states',
|
|
50
|
+
'how waves interfere constructively and destructively',
|
|
51
|
+
'how phase transitions happen suddenly after gradual change',
|
|
52
|
+
'how feedback loops amplify or dampen signals',
|
|
53
|
+
'how emergence creates new properties from simple rules',
|
|
54
|
+
],
|
|
55
|
+
psychology: [
|
|
56
|
+
'how habits form through cue-routine-reward loops',
|
|
57
|
+
'how cognitive dissonance drives change or rationalization',
|
|
58
|
+
'how flow state emerges from challenge-skill balance',
|
|
59
|
+
'how social proof shapes individual behavior',
|
|
60
|
+
'how the mere exposure effect builds preference',
|
|
61
|
+
'how chunking expands working memory limits',
|
|
62
|
+
],
|
|
63
|
+
economics: [
|
|
64
|
+
'how markets find prices through supply and demand',
|
|
65
|
+
'how compound interest works exponentially over time',
|
|
66
|
+
'how network effects create winner-take-all dynamics',
|
|
67
|
+
'how insurance pools risk across many individuals',
|
|
68
|
+
'how arbitrage eliminates price differences',
|
|
69
|
+
'how incentives shape behavior predictably',
|
|
70
|
+
],
|
|
71
|
+
biology: [
|
|
72
|
+
'how DNA encodes infinite variation in four letters',
|
|
73
|
+
'how evolution optimizes through random mutation and selection',
|
|
74
|
+
'how metabolism balances energy storage and release',
|
|
75
|
+
'how the brain prunes unused neural connections',
|
|
76
|
+
'how homeostasis maintains stability through feedback',
|
|
77
|
+
'how symbiosis creates mutual benefit from difference',
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get a random selection of items from an array
|
|
83
|
+
*/
|
|
84
|
+
function sample(arr, n) {
|
|
85
|
+
const shuffled = [...arr].sort(() => 0.5 - Math.random());
|
|
86
|
+
return shuffled.slice(0, n);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Forge connections between an idea and random domains
|
|
91
|
+
*/
|
|
92
|
+
export function forge(idea, count = 5) {
|
|
93
|
+
const domainNames = Object.keys(domains);
|
|
94
|
+
const selectedDomains = sample(domainNames, Math.min(count, domainNames.length));
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
idea,
|
|
98
|
+
connections: selectedDomains.map(domain => {
|
|
99
|
+
const analogy = sample(domains[domain], 1)[0];
|
|
100
|
+
return {
|
|
101
|
+
domain,
|
|
102
|
+
analogy,
|
|
103
|
+
prompt: `How is "${idea}" similar to ${analogy}?`,
|
|
104
|
+
reversePrompt: `What would "${idea}" look like if it worked like ${analogy}?`,
|
|
105
|
+
};
|
|
106
|
+
}),
|
|
107
|
+
leonardoPrompt: `Leonardo would ask: What do these seemingly unrelated things reveal about "${idea}" that direct analysis misses?`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Deep dive into one domain connection
|
|
113
|
+
*/
|
|
114
|
+
export function deepConnection(idea, domain) {
|
|
115
|
+
if (!domains[domain]) {
|
|
116
|
+
return { error: `Unknown domain: ${domain}. Available: ${Object.keys(domains).join(', ')}` };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
idea,
|
|
121
|
+
domain,
|
|
122
|
+
analogies: domains[domain],
|
|
123
|
+
questions: [
|
|
124
|
+
`What structure in ${domain} solves a problem similar to "${idea}"?`,
|
|
125
|
+
`What would fail if "${idea}" worked like ${domain} systems?`,
|
|
126
|
+
`What would succeed unexpectedly?`,
|
|
127
|
+
`What vocabulary from ${domain} reveals new aspects of "${idea}"?`,
|
|
128
|
+
`If an expert in ${domain} designed a solution to "${idea}", what would they do differently?`,
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Force a specific connection (for when you have two things to link)
|
|
135
|
+
*/
|
|
136
|
+
export function forceLink(ideaA, ideaB) {
|
|
137
|
+
return {
|
|
138
|
+
ideaA,
|
|
139
|
+
ideaB,
|
|
140
|
+
prompts: [
|
|
141
|
+
`What does "${ideaA}" share with "${ideaB}" that isn't obvious?`,
|
|
142
|
+
`If "${ideaA}" is the problem, how is "${ideaB}" secretly the solution?`,
|
|
143
|
+
`What metaphor captures both "${ideaA}" and "${ideaB}"?`,
|
|
144
|
+
`What would a child say these have in common?`,
|
|
145
|
+
`In what world are these the same thing?`,
|
|
146
|
+
],
|
|
147
|
+
technique: "Leonardo threw a paint-filled sponge against a wall and imagined horses. What do you see when you force these together?",
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get all available domains
|
|
153
|
+
*/
|
|
154
|
+
export function listDomains() {
|
|
155
|
+
return Object.entries(domains).map(([name, items]) => ({
|
|
156
|
+
name,
|
|
157
|
+
count: items.length,
|
|
158
|
+
sample: items[0],
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Add a custom domain
|
|
164
|
+
*/
|
|
165
|
+
export function addDomain(name, analogies) {
|
|
166
|
+
if (domains[name]) {
|
|
167
|
+
domains[name] = [...domains[name], ...analogies];
|
|
168
|
+
} else {
|
|
169
|
+
domains[name] = analogies;
|
|
170
|
+
}
|
|
171
|
+
return { domain: name, count: domains[name].length };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export default {
|
|
175
|
+
forge,
|
|
176
|
+
deepConnection,
|
|
177
|
+
forceLink,
|
|
178
|
+
listDomains,
|
|
179
|
+
addDomain,
|
|
180
|
+
};
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creative Genius Engine
|
|
3
|
+
*
|
|
4
|
+
* A thinking toolkit for AI agents, synthesized from:
|
|
5
|
+
* - Leonardo da Vinci
|
|
6
|
+
* - Nikola Tesla
|
|
7
|
+
* - Johann Sebastian Bach
|
|
8
|
+
* - Albert Einstein
|
|
9
|
+
* - Richard Feynman
|
|
10
|
+
* - Maya Angelou
|
|
11
|
+
* - Pablo Picasso
|
|
12
|
+
* - Steve Jobs
|
|
13
|
+
*
|
|
14
|
+
* "The creative adult is the child who survived." ā Ursula K. Le Guin
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export { default as janusian } from './janusian.mjs';
|
|
18
|
+
export { default as connections } from './connections.mjs';
|
|
19
|
+
export { default as process } from './process.mjs';
|
|
20
|
+
export { default as problems } from './problems.mjs';
|
|
21
|
+
export { default as wisdom } from './wisdom.mjs';
|
|
22
|
+
|
|
23
|
+
// Convenience re-exports
|
|
24
|
+
export { generateOpposite, fullCycle as janusianCycle } from './janusian.mjs';
|
|
25
|
+
export { forge as forgeConnections } from './connections.mjs';
|
|
26
|
+
export { run as runProcess, quickBurst } from './process.mjs';
|
|
27
|
+
export { add as addProblem, testAgainst, suggest as suggestProblems } from './problems.mjs';
|
|
28
|
+
export { record as recordWisdom, advise, distill } from './wisdom.mjs';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Quick creative burst ā one-liner for fast inspiration
|
|
32
|
+
*/
|
|
33
|
+
export function spark(challenge) {
|
|
34
|
+
const { quickBurst } = require('./process.mjs');
|
|
35
|
+
return quickBurst(challenge);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Full creative run with all modules
|
|
40
|
+
*/
|
|
41
|
+
export async function create(options) {
|
|
42
|
+
const { run } = await import('./process.mjs');
|
|
43
|
+
const { add, suggest } = await import('./problems.mjs');
|
|
44
|
+
const { forge } = await import('./connections.mjs');
|
|
45
|
+
const { fullCycle } = await import('./janusian.mjs');
|
|
46
|
+
|
|
47
|
+
// Run the full process
|
|
48
|
+
const result = run(options);
|
|
49
|
+
|
|
50
|
+
// Add to problems if significant
|
|
51
|
+
if (options.addToProblem) {
|
|
52
|
+
add(options.challenge);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Version info
|
|
60
|
+
*/
|
|
61
|
+
export const VERSION = '1.0.0';
|
|
62
|
+
export const AUTHOR = 'Bartok š»';
|
|
63
|
+
export const CREATED = '2026-02-26';
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
VERSION,
|
|
67
|
+
AUTHOR,
|
|
68
|
+
CREATED,
|
|
69
|
+
};
|
package/lib/janusian.mjs
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Janusian Engine
|
|
3
|
+
*
|
|
4
|
+
* Named after Janus, the two-faced Roman god.
|
|
5
|
+
* Core creative technique: conceive and utilize opposite or contradictory ideas simultaneously.
|
|
6
|
+
*
|
|
7
|
+
* Used by: Einstein (relativity), Picasso (cubism), Bach (counterpoint)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Patterns for generating opposites
|
|
11
|
+
const oppositePatterns = [
|
|
12
|
+
{ pattern: /^(.*) want(?:s)? more (.*)$/i, transform: (m) => `${m[1]} want fewer ${m[2]}` },
|
|
13
|
+
{ pattern: /^(.*) need(?:s)? (.*)$/i, transform: (m) => `${m[1]} must avoid ${m[2]}` },
|
|
14
|
+
{ pattern: /^(.*) should (.*)$/i, transform: (m) => `${m[1]} should NOT ${m[2]}` },
|
|
15
|
+
{ pattern: /^(.*) is (.*)$/i, transform: (m) => `${m[1]} is NOT ${m[2]}` },
|
|
16
|
+
{ pattern: /^(.*) always (.*)$/i, transform: (m) => `${m[1]} never ${m[2]}` },
|
|
17
|
+
{ pattern: /^(.*) best (.*)$/i, transform: (m) => `${m[1]} worst ${m[2]}` },
|
|
18
|
+
{ pattern: /^add (.*)$/i, transform: (m) => `remove ${m[1]}` },
|
|
19
|
+
{ pattern: /^increase (.*)$/i, transform: (m) => `decrease ${m[1]}` },
|
|
20
|
+
{ pattern: /^build (.*)$/i, transform: (m) => `destroy ${m[1]}` },
|
|
21
|
+
{ pattern: /^fast (.*)$/i, transform: (m) => `slow ${m[1]}` },
|
|
22
|
+
{ pattern: /^simple (.*)$/i, transform: (m) => `complex ${m[1]}` },
|
|
23
|
+
{ pattern: /^centralize (.*)$/i, transform: (m) => `decentralize ${m[1]}` },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// Dialectical synthesis prompts
|
|
27
|
+
const synthesisPrompts = [
|
|
28
|
+
"What if both the original AND its opposite are true simultaneously?",
|
|
29
|
+
"What context would make each perspective valid?",
|
|
30
|
+
"What emerges from the tension between these opposites?",
|
|
31
|
+
"What third option transcends this binary?",
|
|
32
|
+
"What does holding both ideas reveal that neither shows alone?",
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Generate the opposite of an idea
|
|
37
|
+
*/
|
|
38
|
+
export function generateOpposite(idea) {
|
|
39
|
+
const trimmed = idea.trim();
|
|
40
|
+
|
|
41
|
+
// Try pattern-based transformation
|
|
42
|
+
for (const { pattern, transform } of oppositePatterns) {
|
|
43
|
+
const match = trimmed.match(pattern);
|
|
44
|
+
if (match) {
|
|
45
|
+
return {
|
|
46
|
+
original: trimmed,
|
|
47
|
+
opposite: transform(match),
|
|
48
|
+
method: 'pattern',
|
|
49
|
+
synthesisPrompt: synthesisPrompts[Math.floor(Math.random() * synthesisPrompts.length)],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Fallback: structural negation
|
|
55
|
+
const opposite = trimmed.startsWith('Not ')
|
|
56
|
+
? trimmed.slice(4)
|
|
57
|
+
: `Not: ${trimmed}`;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
original: trimmed,
|
|
61
|
+
opposite,
|
|
62
|
+
method: 'negation',
|
|
63
|
+
synthesisPrompt: synthesisPrompts[Math.floor(Math.random() * synthesisPrompts.length)],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Generate multiple opposites using different frames
|
|
69
|
+
*/
|
|
70
|
+
export function generateMultipleOpposites(idea, count = 5) {
|
|
71
|
+
const frames = [
|
|
72
|
+
{ name: 'scale', transform: (i) => `What if this applied to 1 person instead of millions? (or vice versa)` },
|
|
73
|
+
{ name: 'time', transform: (i) => `What if this was true 100 years ago? 100 years from now?` },
|
|
74
|
+
{ name: 'actor', transform: (i) => `What if the subject and object were reversed?` },
|
|
75
|
+
{ name: 'value', transform: (i) => `What if what seems bad about this is actually good?` },
|
|
76
|
+
{ name: 'constraint', transform: (i) => `What if resources were unlimited? Or completely constrained?` },
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const primary = generateOpposite(idea);
|
|
80
|
+
const alternatives = frames.slice(0, count - 1).map(f => ({
|
|
81
|
+
frame: f.name,
|
|
82
|
+
question: f.transform(idea),
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
primary,
|
|
87
|
+
alternatives,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Janusian synthesis ā hold both ideas, extract insight
|
|
93
|
+
*/
|
|
94
|
+
export function synthesize(original, opposite) {
|
|
95
|
+
return {
|
|
96
|
+
thesis: original,
|
|
97
|
+
antithesis: opposite,
|
|
98
|
+
questions: [
|
|
99
|
+
`Under what conditions is "${original}" true?`,
|
|
100
|
+
`Under what conditions is "${opposite}" true?`,
|
|
101
|
+
"What hidden assumption makes these seem contradictory?",
|
|
102
|
+
"What new possibility emerges from accepting both?",
|
|
103
|
+
"What would someone who believed both simultaneously do differently?",
|
|
104
|
+
],
|
|
105
|
+
prompt: `The creative breakthrough often lies not in choosing between "${original}" and "${opposite}", but in finding what transcends both.`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Full Janusian thinking cycle
|
|
111
|
+
*/
|
|
112
|
+
export function fullCycle(idea) {
|
|
113
|
+
const step1 = generateOpposite(idea);
|
|
114
|
+
const step2 = synthesize(step1.original, step1.opposite);
|
|
115
|
+
const step3 = generateMultipleOpposites(idea, 5);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
input: idea,
|
|
119
|
+
opposite: step1,
|
|
120
|
+
synthesis: step2,
|
|
121
|
+
multiframe: step3,
|
|
122
|
+
nextAction: "Pick the most provocative question from synthesis, answer it, then generate the opposite of THAT answer.",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default {
|
|
127
|
+
generateOpposite,
|
|
128
|
+
generateMultipleOpposites,
|
|
129
|
+
synthesize,
|
|
130
|
+
fullCycle,
|
|
131
|
+
};
|