gthinking 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.
Files changed (53) hide show
  1. package/README.md +283 -0
  2. package/analysis.ts +986 -0
  3. package/creativity.ts +1002 -0
  4. package/dist/analysis.d.ts +52 -0
  5. package/dist/analysis.d.ts.map +1 -0
  6. package/dist/analysis.js +792 -0
  7. package/dist/analysis.js.map +1 -0
  8. package/dist/creativity.d.ts +80 -0
  9. package/dist/creativity.d.ts.map +1 -0
  10. package/dist/creativity.js +778 -0
  11. package/dist/creativity.js.map +1 -0
  12. package/dist/engine.d.ts +76 -0
  13. package/dist/engine.d.ts.map +1 -0
  14. package/dist/engine.js +675 -0
  15. package/dist/engine.js.map +1 -0
  16. package/dist/examples.d.ts +7 -0
  17. package/dist/examples.d.ts.map +1 -0
  18. package/dist/examples.js +506 -0
  19. package/dist/examples.js.map +1 -0
  20. package/dist/index.d.ts +38 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +126 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/learning.d.ts +72 -0
  25. package/dist/learning.d.ts.map +1 -0
  26. package/dist/learning.js +615 -0
  27. package/dist/learning.js.map +1 -0
  28. package/dist/planning.d.ts +58 -0
  29. package/dist/planning.d.ts.map +1 -0
  30. package/dist/planning.js +824 -0
  31. package/dist/planning.js.map +1 -0
  32. package/dist/reasoning.d.ts +72 -0
  33. package/dist/reasoning.d.ts.map +1 -0
  34. package/dist/reasoning.js +792 -0
  35. package/dist/reasoning.js.map +1 -0
  36. package/dist/search-discovery.d.ts +73 -0
  37. package/dist/search-discovery.d.ts.map +1 -0
  38. package/dist/search-discovery.js +505 -0
  39. package/dist/search-discovery.js.map +1 -0
  40. package/dist/types.d.ts +535 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +77 -0
  43. package/dist/types.js.map +1 -0
  44. package/engine.ts +928 -0
  45. package/examples.ts +717 -0
  46. package/index.ts +106 -0
  47. package/learning.ts +779 -0
  48. package/package.json +51 -0
  49. package/planning.ts +1028 -0
  50. package/reasoning.ts +1019 -0
  51. package/search-discovery.ts +654 -0
  52. package/tsconfig.json +25 -0
  53. package/types.ts +674 -0
@@ -0,0 +1,778 @@
1
+ "use strict";
2
+ /**
3
+ * Creativity Module
4
+ * Out-of-the-box thinking, idea generation, and concept connection
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.creativityEngine = exports.CreativityEngine = void 0;
8
+ const types_1 = require("./types");
9
+ const events_1 = require("events");
10
+ // ============================================================================
11
+ // BRAINSTORMING ENGINE
12
+ // ============================================================================
13
+ class BrainstormingEngine {
14
+ constructor() {
15
+ this.ideaSeeds = new Map([
16
+ ['technology', ['AI', 'blockchain', 'IoT', 'cloud', 'quantum', 'biotech', 'nanotech']],
17
+ ['business', ['subscription', 'freemium', 'marketplace', 'platform', 'ecosystem']],
18
+ ['social', ['community', 'collaboration', 'sharing', 'crowdsourcing', 'network']],
19
+ ['design', ['minimalist', 'responsive', 'adaptive', 'personalized', 'immersive']]
20
+ ]);
21
+ }
22
+ generateIdeas(prompt, count = 10) {
23
+ const ideas = [];
24
+ const domains = this.identifyDomains(prompt);
25
+ // Generate ideas using different approaches
26
+ for (let i = 0; i < count; i++) {
27
+ const technique = this.selectTechnique(i);
28
+ const idea = this.createIdea(prompt, technique, domains, i);
29
+ ideas.push(idea);
30
+ }
31
+ return ideas;
32
+ }
33
+ identifyDomains(prompt) {
34
+ const domains = [];
35
+ const promptLower = prompt.toLowerCase();
36
+ this.ideaSeeds.forEach((_, domain) => {
37
+ if (promptLower.includes(domain)) {
38
+ domains.push(domain);
39
+ }
40
+ });
41
+ return domains.length > 0 ? domains : ['general'];
42
+ }
43
+ selectTechnique(index) {
44
+ const techniques = [
45
+ 'brainstorming',
46
+ 'analogy',
47
+ 'reverse_thinking',
48
+ 'random_stimulus',
49
+ 'lateral_thinking'
50
+ ];
51
+ return techniques[index % techniques.length];
52
+ }
53
+ createIdea(prompt, technique, domains, index) {
54
+ const content = this.generateIdeaContent(prompt, technique, domains, index);
55
+ return {
56
+ id: `idea_${Date.now()}_${index}`,
57
+ content,
58
+ technique,
59
+ novelty: this.calculateNovelity(content),
60
+ feasibility: this.calculateFeasibility(content),
61
+ impact: this.calculateImpact(content),
62
+ relatedIdeas: [],
63
+ tags: this.extractTags(content),
64
+ generatedAt: new Date()
65
+ };
66
+ }
67
+ generateIdeaContent(prompt, technique, domains, index) {
68
+ switch (technique) {
69
+ case 'brainstorming':
70
+ return this.brainstorm(prompt, domains, index);
71
+ case 'analogy':
72
+ return this.useAnalogy(prompt, domains, index);
73
+ case 'reverse_thinking':
74
+ return this.reverseThink(prompt);
75
+ case 'random_stimulus':
76
+ return this.randomStimulus(prompt, domains);
77
+ case 'lateral_thinking':
78
+ return this.lateralThink(prompt, index);
79
+ default:
80
+ return `Idea ${index + 1}: ${prompt}`;
81
+ }
82
+ }
83
+ brainstorm(prompt, domains, index) {
84
+ const domain = domains[index % domains.length];
85
+ const seeds = this.ideaSeeds.get(domain) || ['innovation'];
86
+ const seed = seeds[index % seeds.length];
87
+ return `Combine ${prompt} with ${seed} to create a ${domain} solution`;
88
+ }
89
+ useAnalogy(prompt, domains, index) {
90
+ const analogies = [
91
+ 'like a nervous system for information flow',
92
+ 'like an immune system for security',
93
+ 'like an ecosystem for sustainability',
94
+ 'like a language for communication',
95
+ 'like a market for resource allocation'
96
+ ];
97
+ return `Approach ${prompt} ${analogies[index % analogies.length]}`;
98
+ }
99
+ reverseThink(prompt) {
100
+ return `Instead of ${prompt}, what if we did the opposite? ` +
101
+ `Consider: How could we achieve the inverse outcome?`;
102
+ }
103
+ randomStimulus(prompt, domains) {
104
+ const stimuli = ['nature', 'art', 'music', 'sports', 'cooking', 'architecture'];
105
+ const stimulus = stimuli[Math.floor(Math.random() * stimuli.length)];
106
+ return `Apply principles from ${stimulus} to ${prompt}`;
107
+ }
108
+ lateralThink(prompt, index) {
109
+ const perspectives = [
110
+ 'from a child\'s perspective',
111
+ 'from a future perspective (10 years ahead)',
112
+ 'from a resource-constrained perspective',
113
+ 'from a luxury perspective',
114
+ 'from a minimalist perspective'
115
+ ];
116
+ return `View ${prompt} ${perspectives[index % perspectives.length]}`;
117
+ }
118
+ calculateNovelity(content) {
119
+ // Higher novelty for more unique combinations
120
+ const uniqueTerms = new Set(content.toLowerCase().split(/\s+/)).size;
121
+ const totalTerms = content.split(/\s+/).length;
122
+ return Math.min(0.95, uniqueTerms / totalTerms + 0.3);
123
+ }
124
+ calculateFeasibility(content) {
125
+ // Lower feasibility for very abstract ideas
126
+ const abstractTerms = ['quantum', 'neural', 'blockchain', 'revolutionary', 'paradigm'];
127
+ const abstractCount = abstractTerms.filter(term => content.toLowerCase().includes(term)).length;
128
+ return Math.max(0.3, 0.9 - abstractCount * 0.1);
129
+ }
130
+ calculateImpact(content) {
131
+ // Higher impact for ideas addressing broad audiences or major problems
132
+ const impactIndicators = ['global', 'scalable', 'transform', 'revolutionary', 'fundamental'];
133
+ const matches = impactIndicators.filter(ind => content.toLowerCase().includes(ind)).length;
134
+ return Math.min(0.95, 0.5 + matches * 0.1);
135
+ }
136
+ extractTags(content) {
137
+ return content
138
+ .toLowerCase()
139
+ .match(/\b\w{5,}\b/g)
140
+ ?.filter((w, i, arr) => arr.indexOf(w) === i)
141
+ ?.slice(0, 5) || [];
142
+ }
143
+ }
144
+ class MindMappingEngine {
145
+ createMindMap(centerConcept, depth = 3) {
146
+ const root = {
147
+ id: 'root',
148
+ label: centerConcept,
149
+ children: [],
150
+ connections: []
151
+ };
152
+ this.expandNode(root, depth, 0);
153
+ return root;
154
+ }
155
+ expandNode(node, maxDepth, currentDepth) {
156
+ if (currentDepth >= maxDepth)
157
+ return;
158
+ const branches = this.generateBranches(node.label, currentDepth);
159
+ branches.forEach(branchLabel => {
160
+ const child = {
161
+ id: `node_${Date.now()}_${Math.random().toString(36).substr(2, 5)}`,
162
+ label: branchLabel,
163
+ children: [],
164
+ connections: []
165
+ };
166
+ node.children.push(child);
167
+ this.expandNode(child, maxDepth, currentDepth + 1);
168
+ });
169
+ }
170
+ generateBranches(concept, depth) {
171
+ const branchTypes = {
172
+ 0: [['What', 'Why', 'How', 'When', 'Where']],
173
+ 1: [['Components', 'Features', 'Benefits', 'Challenges']],
174
+ 2: [['Examples', 'Alternatives', 'Applications', 'Implications']]
175
+ };
176
+ const branches = branchTypes[depth] || [['Details', 'Related', 'Future']];
177
+ const selectedBranch = branches[0];
178
+ return selectedBranch.map(b => `${b} of ${concept}`);
179
+ }
180
+ findConnections(node1, node2) {
181
+ const connections = [];
182
+ const concepts1 = this.extractAllConcepts(node1);
183
+ const concepts2 = this.extractAllConcepts(node2);
184
+ concepts1.forEach(c1 => {
185
+ concepts2.forEach(c2 => {
186
+ const similarity = this.calculateConceptSimilarity(c1, c2);
187
+ if (similarity > 0.5) {
188
+ connections.push(`Connection: ${c1} ↔ ${c2}`);
189
+ }
190
+ });
191
+ });
192
+ return connections;
193
+ }
194
+ extractAllConcepts(node) {
195
+ const concepts = [node.label];
196
+ node.children.forEach(child => {
197
+ concepts.push(...this.extractAllConcepts(child));
198
+ });
199
+ return concepts;
200
+ }
201
+ calculateConceptSimilarity(c1, c2) {
202
+ const words1 = c1.toLowerCase().split(/\s+/);
203
+ const words2 = c2.toLowerCase().split(/\s+/);
204
+ const intersection = words1.filter(w => words2.includes(w));
205
+ return intersection.length / Math.max(words1.length, words2.length);
206
+ }
207
+ }
208
+ class ScamperEngine {
209
+ constructor() {
210
+ this.scamperPrompts = [
211
+ { letter: 'S', action: 'Substitute', prompt: 'What can be substituted?' },
212
+ { letter: 'C', action: 'Combine', prompt: 'What can be combined?' },
213
+ { letter: 'A', action: 'Adapt', prompt: 'What can be adapted?' },
214
+ { letter: 'M', action: 'Modify', prompt: 'What can be modified?' },
215
+ { letter: 'P', action: 'Put to other uses', prompt: 'What other uses are possible?' },
216
+ { letter: 'E', action: 'Eliminate', prompt: 'What can be eliminated?' },
217
+ { letter: 'R', action: 'Reverse/Rearrange', prompt: 'What can be reversed or rearranged?' }
218
+ ];
219
+ }
220
+ apply(problem) {
221
+ return this.scamperPrompts.map(prompt => ({
222
+ technique: `${prompt.letter} - ${prompt.action}`,
223
+ question: prompt.prompt,
224
+ idea: this.generateScamperIdea(problem, prompt)
225
+ }));
226
+ }
227
+ generateScamperIdea(problem, prompt) {
228
+ const ideaTemplates = {
229
+ 'Substitute': [
230
+ `Replace a key component of ${problem} with something unexpected`,
231
+ `Use alternative materials or methods for ${problem}`
232
+ ],
233
+ 'Combine': [
234
+ `Merge ${problem} with a completely different concept`,
235
+ `Integrate multiple versions of ${problem}`
236
+ ],
237
+ 'Adapt': [
238
+ `Apply ${problem} in a different context`,
239
+ `Borrow ideas from other fields for ${problem}`
240
+ ],
241
+ 'Modify': [
242
+ `Change the scale or magnitude of ${problem}`,
243
+ `Alter the attributes of ${problem}`
244
+ ],
245
+ 'Put to other uses': [
246
+ `How else could ${problem} be used?`,
247
+ `Who else could benefit from ${problem}?`
248
+ ],
249
+ 'Eliminate': [
250
+ `Remove unnecessary parts of ${problem}`,
251
+ `Simplify ${problem} to its essence`
252
+ ],
253
+ 'Reverse/Rearrange': [
254
+ `Do the opposite of ${problem}`,
255
+ `Change the order of steps in ${problem}`
256
+ ]
257
+ };
258
+ const templates = ideaTemplates[prompt.action] || ['Consider a new approach'];
259
+ return templates[Math.floor(Math.random() * templates.length)];
260
+ }
261
+ }
262
+ class SixThinkingHatsEngine {
263
+ constructor() {
264
+ this.hats = [
265
+ { color: 'White', perspective: 'Objective', focus: 'facts and data' },
266
+ { color: 'Red', perspective: 'Emotional', focus: 'feelings and intuition' },
267
+ { color: 'Black', perspective: 'Critical', focus: 'risks and problems' },
268
+ { color: 'Yellow', perspective: 'Optimistic', focus: 'benefits and value' },
269
+ { color: 'Green', perspective: 'Creative', focus: 'new ideas and alternatives' },
270
+ { color: 'Blue', perspective: 'Process', focus: 'overview and control' }
271
+ ];
272
+ }
273
+ analyze(topic) {
274
+ return this.hats.map(hat => ({
275
+ hat: hat.color,
276
+ perspective: hat.perspective,
277
+ insights: this.generateInsights(topic, hat)
278
+ }));
279
+ }
280
+ generateInsights(topic, hat) {
281
+ const insights = [];
282
+ switch (hat.color) {
283
+ case 'White':
284
+ insights.push(`What data do we have about ${topic}?`, `What information is missing about ${topic}?`, `What are the verifiable facts?`);
285
+ break;
286
+ case 'Red':
287
+ insights.push(`What is my gut feeling about ${topic}?`, `What emotions does ${topic} evoke?`, `What is my intuitive reaction?`);
288
+ break;
289
+ case 'Black':
290
+ insights.push(`What are the risks with ${topic}?`, `What could go wrong with ${topic}?`, `What are the potential problems?`);
291
+ break;
292
+ case 'Yellow':
293
+ insights.push(`What are the benefits of ${topic}?`, `What value does ${topic} provide?`, `What are the opportunities?`);
294
+ break;
295
+ case 'Green':
296
+ insights.push(`What creative alternatives exist for ${topic}?`, `What new ideas can we generate?`, `How can we think differently about this?`);
297
+ break;
298
+ case 'Blue':
299
+ insights.push(`What is our process for addressing ${topic}?`, `How should we organize our thinking?`, `What is the big picture?`);
300
+ break;
301
+ }
302
+ return insights;
303
+ }
304
+ }
305
+ // ============================================================================
306
+ // CONCEPT CONNECTOR
307
+ // ============================================================================
308
+ class ConceptConnector {
309
+ constructor() {
310
+ this.conceptDatabase = new Map([
311
+ ['innovation', ['change', 'progress', 'novelty', 'improvement', 'disruption']],
312
+ ['technology', ['tools', 'systems', 'automation', 'digital', 'advancement']],
313
+ ['design', ['aesthetics', 'function', 'user', 'experience', 'form']],
314
+ ['business', ['value', 'profit', 'market', 'customers', 'growth']],
315
+ ['sustainability', ['environment', 'future', 'resources', 'balance', 'responsibility']]
316
+ ]);
317
+ }
318
+ findConnections(concepts) {
319
+ const connections = [];
320
+ for (let i = 0; i < concepts.length; i++) {
321
+ for (let j = i + 1; j < concepts.length; j++) {
322
+ const connection = this.analyzeConnection(concepts[i], concepts[j]);
323
+ if (connection.strength > 0.3) {
324
+ connections.push(connection);
325
+ }
326
+ }
327
+ }
328
+ return connections.sort((a, b) => b.strength - a.strength);
329
+ }
330
+ analyzeConnection(concept1, concept2) {
331
+ const attributes1 = this.getConceptAttributes(concept1);
332
+ const attributes2 = this.getConceptAttributes(concept2);
333
+ // Find common attributes
334
+ const common = attributes1.filter(a => attributes2.includes(a));
335
+ const all = [...new Set([...attributes1, ...attributes2])];
336
+ const strength = common.length / all.length;
337
+ // Determine connection type
338
+ let connectionType = 'similarity';
339
+ if (strength > 0.7) {
340
+ connectionType = 'similarity';
341
+ }
342
+ else if (strength < 0.3) {
343
+ connectionType = 'contrast';
344
+ }
345
+ else {
346
+ connectionType = 'combination';
347
+ }
348
+ return {
349
+ id: `conn_${Date.now()}_${Math.random().toString(36).substr(2, 5)}`,
350
+ from: concept1,
351
+ to: concept2,
352
+ connectionType,
353
+ strength,
354
+ insight: this.generateInsight(concept1, concept2, common, connectionType)
355
+ };
356
+ }
357
+ getConceptAttributes(concept) {
358
+ const lowerConcept = concept.toLowerCase();
359
+ for (const [key, attributes] of this.conceptDatabase.entries()) {
360
+ if (lowerConcept.includes(key) || key.includes(lowerConcept)) {
361
+ return attributes;
362
+ }
363
+ }
364
+ // Generate attributes from concept itself
365
+ return concept.toLowerCase().split(/\s+/).filter(w => w.length > 3);
366
+ }
367
+ generateInsight(c1, c2, common, type) {
368
+ switch (type) {
369
+ case 'similarity':
370
+ return `${c1} and ${c2} share ${common.length > 0 ? `common ground in ${common.join(', ')}` : 'fundamental similarities'}`;
371
+ case 'contrast':
372
+ return `${c1} and ${c2} represent different approaches that could complement each other`;
373
+ case 'combination':
374
+ return `Combining ${c1} with ${c2} could create something unique`;
375
+ default:
376
+ return `Interesting relationship between ${c1} and ${c2}`;
377
+ }
378
+ }
379
+ generateNovelCombinations(concepts, count = 3) {
380
+ const combinations = [];
381
+ for (let i = 0; i < count; i++) {
382
+ const c1 = concepts[Math.floor(Math.random() * concepts.length)];
383
+ const c2 = concepts[Math.floor(Math.random() * concepts.length)];
384
+ if (c1 !== c2) {
385
+ combinations.push(`Combine ${c1} with ${c2} to create: ${this.generateCombinationName(c1, c2)}`);
386
+ }
387
+ }
388
+ return combinations;
389
+ }
390
+ generateCombinationName(c1, c2) {
391
+ const prefixes = ['Smart', 'Dynamic', 'Integrated', 'Adaptive', 'Holistic'];
392
+ const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
393
+ return `${prefix} ${c1.split(' ')[0]}-${c2.split(' ')[0]} Solution`;
394
+ }
395
+ }
396
+ // ============================================================================
397
+ // OUT-OF-BOX THINKING ENGINE
398
+ // ============================================================================
399
+ class OutOfBoxEngine {
400
+ constructor() {
401
+ this.perspectives = [
402
+ 'Beginner\'s mind - forget what you know',
403
+ 'Child\'s perspective - simple and curious',
404
+ 'Alien perspective - no assumptions',
405
+ 'Future perspective - 50 years ahead',
406
+ 'Resource-constrained - extreme limitations',
407
+ 'Opposite approach - do the reverse',
408
+ 'Nature-inspired - biomimicry',
409
+ 'Artistic perspective - beauty and emotion'
410
+ ];
411
+ }
412
+ reframe(problem) {
413
+ const reframedProblems = [];
414
+ this.perspectives.forEach((perspective, index) => {
415
+ const reframed = this.reframeFromPerspective(problem, perspective);
416
+ reframedProblems.push({
417
+ id: `reframe_${Date.now()}_${index}`,
418
+ perspective,
419
+ reframedStatement: reframed.statement,
420
+ assumptionsChallenged: reframed.assumptions,
421
+ newPossibilities: reframed.possibilities
422
+ });
423
+ });
424
+ const unconventionalApproaches = this.generateUnconventionalApproaches(problem);
425
+ const breakthroughPotential = this.calculateBreakthroughPotential(reframedProblems);
426
+ return {
427
+ id: `ootb_${Date.now()}`,
428
+ originalProblem: problem,
429
+ reframedProblems,
430
+ unconventionalApproaches,
431
+ breakthroughPotential
432
+ };
433
+ }
434
+ reframeFromPerspective(problem, perspective) {
435
+ const reframes = {
436
+ 'Beginner\'s mind': {
437
+ statement: `If you knew nothing about this, how would you approach: ${problem}?`,
438
+ assumptions: ['Expert knowledge is necessary', 'Current methods are optimal'],
439
+ possibilities: ['Fresh approaches', 'Questioning fundamentals']
440
+ },
441
+ 'Child\'s perspective': {
442
+ statement: `How would a 5-year-old solve: ${problem}?`,
443
+ assumptions: ['Complexity is required', 'Adult approaches are better'],
444
+ possibilities: ['Simple solutions', 'Playful approaches']
445
+ },
446
+ 'Alien perspective': {
447
+ statement: `How would beings from another planet view: ${problem}?`,
448
+ assumptions: ['Human perspective is universal', 'Our constraints are absolute'],
449
+ possibilities: ['Radically different approaches', 'Question all assumptions']
450
+ },
451
+ 'Future perspective': {
452
+ statement: `How will people in 2074 solve: ${problem}?`,
453
+ assumptions: ['Current technology limits', 'Present constraints are permanent'],
454
+ possibilities: ['Future technologies', 'Long-term thinking']
455
+ },
456
+ 'Resource-constrained': {
457
+ statement: `How would you solve ${problem} with 1% of current resources?`,
458
+ assumptions: ['Adequate resources are needed', 'Scale is important'],
459
+ possibilities: ['Minimalist solutions', 'Extreme efficiency']
460
+ },
461
+ 'Opposite approach': {
462
+ statement: `What if the solution to ${problem} is the exact opposite of what we think?`,
463
+ assumptions: ['Our direction is correct', 'Conventional wisdom applies'],
464
+ possibilities: ['Counter-intuitive solutions', 'Paradigm shifts']
465
+ },
466
+ 'Nature-inspired': {
467
+ statement: `How does nature solve problems similar to ${problem}?`,
468
+ assumptions: ['Human-designed solutions are superior', 'Technology is the answer'],
469
+ possibilities: ['Biomimicry', 'Natural patterns']
470
+ },
471
+ 'Artistic perspective': {
472
+ statement: `How would an artist approach ${problem}?`,
473
+ assumptions: ['Technical solutions only', 'Function over form'],
474
+ possibilities: ['Aesthetic solutions', 'Emotional design']
475
+ }
476
+ };
477
+ return reframes[perspective] || {
478
+ statement: `Reframe: ${problem}`,
479
+ assumptions: ['Standard approach'],
480
+ possibilities: ['Alternative approaches']
481
+ };
482
+ }
483
+ generateUnconventionalApproaches(problem) {
484
+ return [
485
+ `What if ${problem} is actually an opportunity in disguise?`,
486
+ `How can ${problem} be made worse, then reverse that?`,
487
+ `What would make ${problem} solve itself?`,
488
+ `Who benefits from ${problem} existing?`,
489
+ `What if the problem and solution are the same thing?`
490
+ ];
491
+ }
492
+ calculateBreakthroughPotential(reframedProblems) {
493
+ const totalAssumptions = reframedProblems.reduce((sum, rp) => sum + rp.assumptionsChallenged.length, 0);
494
+ const totalPossibilities = reframedProblems.reduce((sum, rp) => sum + rp.newPossibilities.length, 0);
495
+ return Math.min(0.95, (totalAssumptions * 0.05 + totalPossibilities * 0.1));
496
+ }
497
+ }
498
+ // ============================================================================
499
+ // MAIN CREATIVITY ENGINE
500
+ // ============================================================================
501
+ class CreativityEngine extends events_1.EventEmitter {
502
+ constructor() {
503
+ super();
504
+ this.sessions = new Map();
505
+ this.brainstormingEngine = new BrainstormingEngine();
506
+ this.mindMappingEngine = new MindMappingEngine();
507
+ this.scamperEngine = new ScamperEngine();
508
+ this.sixHatsEngine = new SixThinkingHatsEngine();
509
+ this.conceptConnector = new ConceptConnector();
510
+ this.outOfBoxEngine = new OutOfBoxEngine();
511
+ }
512
+ /**
513
+ * Start a creative session
514
+ */
515
+ startSession(prompt, options = {}) {
516
+ const { techniques = ['brainstorming', 'analogy', 'scamper'], ideaCount = 15, duration = 30 } = options;
517
+ const sessionId = this.generateId();
518
+ const startTime = Date.now();
519
+ this.emit('creativity_start', {
520
+ id: sessionId,
521
+ stage: types_1.ThinkingStage.CREATIVITY,
522
+ timestamp: new Date(),
523
+ data: { prompt, techniques }
524
+ });
525
+ // Generate ideas using specified techniques
526
+ const ideas = [];
527
+ techniques.forEach(technique => {
528
+ const techniqueIdeas = this.generateIdeasWithTechnique(prompt, technique, Math.ceil(ideaCount / techniques.length));
529
+ ideas.push(...techniqueIdeas);
530
+ });
531
+ // Find connections between ideas
532
+ const connections = this.findConnections(ideas);
533
+ // Divergent phase
534
+ const divergentPhase = {
535
+ startTime: new Date(startTime),
536
+ endTime: new Date(),
537
+ ideaCount: ideas.length,
538
+ explorationBreadth: techniques.length
539
+ };
540
+ // Convergent phase - select best ideas
541
+ const selectedIdeas = this.selectBestIdeas(ideas, 5);
542
+ const synthesis = this.synthesizeIdeas(selectedIdeas);
543
+ const convergentPhase = {
544
+ startTime: new Date(),
545
+ endTime: new Date(),
546
+ selectedIdeas: selectedIdeas.map(i => i.id),
547
+ synthesis,
548
+ actionItems: this.generateActionItems(selectedIdeas)
549
+ };
550
+ const session = {
551
+ id: sessionId,
552
+ prompt,
553
+ techniques,
554
+ ideas,
555
+ connections,
556
+ sessionDuration: Date.now() - startTime,
557
+ divergentPhase,
558
+ convergentPhase
559
+ };
560
+ this.sessions.set(sessionId, session);
561
+ this.emit('creativity_complete', {
562
+ id: sessionId,
563
+ stage: types_1.ThinkingStage.CREATIVITY,
564
+ timestamp: new Date(),
565
+ data: {
566
+ ideaCount: ideas.length,
567
+ connectionCount: connections.length,
568
+ topIdeas: selectedIdeas.map(i => i.content.substring(0, 50))
569
+ }
570
+ });
571
+ return session;
572
+ }
573
+ /**
574
+ * Generate ideas using a specific technique
575
+ */
576
+ generateIdeasWithTechnique(prompt, technique, count) {
577
+ switch (technique) {
578
+ case 'brainstorming':
579
+ case 'analogy':
580
+ case 'reverse_thinking':
581
+ case 'random_stimulus':
582
+ case 'lateral_thinking':
583
+ return this.brainstormingEngine.generateIdeas(prompt, count);
584
+ case 'scamper':
585
+ return this.applyScamperInternal(prompt);
586
+ case 'mind_mapping':
587
+ return this.generateFromMindMap(prompt, count);
588
+ case 'six_thinking_hats':
589
+ return this.applySixHatsInternal(prompt);
590
+ default:
591
+ return this.brainstormingEngine.generateIdeas(prompt, count);
592
+ }
593
+ }
594
+ applyScamperInternal(prompt) {
595
+ const scamperResults = this.scamperEngine.apply(prompt);
596
+ return scamperResults.map((result, index) => ({
597
+ id: `idea_scamper_${Date.now()}_${index}`,
598
+ content: `${result.technique}: ${result.idea}`,
599
+ technique: 'scamper',
600
+ novelty: 0.7,
601
+ feasibility: 0.6,
602
+ impact: 0.65,
603
+ relatedIdeas: [],
604
+ tags: ['scamper', result.technique.toLowerCase()],
605
+ generatedAt: new Date()
606
+ }));
607
+ }
608
+ generateFromMindMap(prompt, count) {
609
+ const mindMap = this.mindMappingEngine.createMindMap(prompt, 2);
610
+ const ideas = [];
611
+ const extractIdeas = (node, depth) => {
612
+ if (ideas.length >= count)
613
+ return;
614
+ ideas.push({
615
+ id: `idea_mindmap_${Date.now()}_${ideas.length}`,
616
+ content: `Explore: ${node.label}`,
617
+ technique: 'mind_mapping',
618
+ novelty: 0.6 + depth * 0.1,
619
+ feasibility: 0.7,
620
+ impact: 0.6,
621
+ relatedIdeas: [],
622
+ tags: ['mindmap', `level_${depth}`],
623
+ generatedAt: new Date()
624
+ });
625
+ node.children.forEach((child) => extractIdeas(child, depth + 1));
626
+ };
627
+ extractIdeas(mindMap, 0);
628
+ return ideas.slice(0, count);
629
+ }
630
+ applySixHatsInternal(prompt) {
631
+ const hatsResults = this.sixHatsEngine.analyze(prompt);
632
+ return hatsResults.map((result, index) => ({
633
+ id: `idea_hat_${Date.now()}_${index}`,
634
+ content: `${result.hat} Hat perspective: ${result.insights[0]}`,
635
+ technique: 'six_thinking_hats',
636
+ novelty: 0.65,
637
+ feasibility: 0.75,
638
+ impact: 0.7,
639
+ relatedIdeas: [],
640
+ tags: ['six_hats', result.hat.toLowerCase()],
641
+ generatedAt: new Date()
642
+ }));
643
+ }
644
+ /**
645
+ * Find connections between ideas
646
+ */
647
+ findConnections(ideas) {
648
+ const concepts = ideas.map(i => i.content);
649
+ return this.conceptConnector.findConnections(concepts);
650
+ }
651
+ /**
652
+ * Select best ideas based on multiple criteria
653
+ */
654
+ selectBestIdeas(ideas, count) {
655
+ return ideas
656
+ .map(idea => ({
657
+ idea,
658
+ score: idea.novelty * 0.3 + idea.feasibility * 0.4 + idea.impact * 0.3
659
+ }))
660
+ .sort((a, b) => b.score - a.score)
661
+ .slice(0, count)
662
+ .map(({ idea }) => idea);
663
+ }
664
+ /**
665
+ * Synthesize selected ideas into coherent concept
666
+ */
667
+ synthesizeIdeas(ideas) {
668
+ const themes = this.extractCommonThemes(ideas);
669
+ return `Synthesis: Combining ${ideas.length} ideas reveals ${themes.length} key themes: ` +
670
+ `${themes.join(', ')}. The integrated solution leverages the strengths of each approach.`;
671
+ }
672
+ extractCommonThemes(ideas) {
673
+ const allTags = ideas.flatMap(i => i.tags);
674
+ const tagFreq = new Map();
675
+ allTags.forEach(tag => {
676
+ tagFreq.set(tag, (tagFreq.get(tag) || 0) + 1);
677
+ });
678
+ return Array.from(tagFreq.entries())
679
+ .sort((a, b) => b[1] - a[1])
680
+ .slice(0, 3)
681
+ .map(([tag]) => tag);
682
+ }
683
+ generateActionItems(ideas) {
684
+ return ideas.slice(0, 3).map((idea, index) => `${index + 1}. Explore: ${idea.content.substring(0, 50)}...`);
685
+ }
686
+ /**
687
+ * Apply out-of-box thinking to a problem
688
+ */
689
+ thinkOutOfBox(problem) {
690
+ return this.outOfBoxEngine.reframe(problem);
691
+ }
692
+ /**
693
+ * Generate novel combinations of concepts
694
+ */
695
+ generateCombinations(concepts, count) {
696
+ return this.conceptConnector.generateNovelCombinations(concepts, count);
697
+ }
698
+ /**
699
+ * Create mind map
700
+ */
701
+ createMindMap(centerConcept, depth) {
702
+ return this.mindMappingEngine.createMindMap(centerConcept, depth);
703
+ }
704
+ /**
705
+ * Apply SCAMPER technique
706
+ */
707
+ applyScamper(problem) {
708
+ return this.scamperEngine.apply(problem);
709
+ }
710
+ /**
711
+ * Apply Six Thinking Hats
712
+ */
713
+ applySixHats(topic) {
714
+ return this.sixHatsEngine.analyze(topic);
715
+ }
716
+ /**
717
+ * Get creative session
718
+ */
719
+ getSession(sessionId) {
720
+ return this.sessions.get(sessionId);
721
+ }
722
+ generateId() {
723
+ return `creative_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
724
+ }
725
+ }
726
+ exports.CreativityEngine = CreativityEngine;
727
+ // ============================================================================
728
+ // EXPORT SINGLETON INSTANCE
729
+ // ============================================================================
730
+ exports.creativityEngine = new CreativityEngine();
731
+ // ============================================================================
732
+ // EXAMPLE USAGE
733
+ // ============================================================================
734
+ /*
735
+ // Start a creative session
736
+ const session = creativityEngine.startSession(
737
+ 'How can we improve remote team collaboration?',
738
+ {
739
+ techniques: ['brainstorming', 'scamper', 'six_thinking_hats'],
740
+ ideaCount: 20
741
+ }
742
+ );
743
+
744
+ // Out-of-box thinking
745
+ const outOfBox = creativityEngine.thinkOutOfBox(
746
+ 'Our product has low user engagement'
747
+ );
748
+
749
+ // Generate combinations
750
+ const combinations = creativityEngine.generateCombinations(
751
+ ['AI', 'collaboration', 'gamification', 'VR'],
752
+ 5
753
+ );
754
+
755
+ // Create mind map
756
+ const mindMap = creativityEngine.createMindMap('Innovation Strategy', 3);
757
+
758
+ // Apply SCAMPER
759
+ const scamperResults = creativityEngine.applyScamper(
760
+ 'Traditional education system'
761
+ );
762
+
763
+ // Apply Six Thinking Hats
764
+ const hatsAnalysis = creativityEngine.applySixHats(
765
+ 'Implementing AI in healthcare'
766
+ );
767
+
768
+ // Access generated ideas
769
+ const topIdeas = session.ideas
770
+ .sort((a, b) => (b.novelty + b.feasibility + b.impact) - (a.novelty + a.feasibility + a.impact))
771
+ .slice(0, 5);
772
+
773
+ // Get connections between ideas
774
+ const connections = session.connections
775
+ .filter(c => c.strength > 0.5)
776
+ .slice(0, 3);
777
+ */
778
+ //# sourceMappingURL=creativity.js.map