creative-patterns.ts•6.18 kB
/**
* Creative Patterns Module
* Provides utilities for generating creative perspectives and connections
*/
import { KnowledgeCategory, StructuredPerspective } from './ucpf-core.js';
/**
* Represents a creative connection between concepts
*/
export interface CreativeConnection {
type: 'metaphor' | 'analogy' | 'reframing' | 'combination' | 'inversion';
description: string;
source: string;
target: string;
insight: string;
}
/**
* Represents a novel perspective on a problem
*/
export interface CreativePerspective {
viewpoint: string;
rationale: string;
implications: string[];
limitingBeliefs: string[];
potentialOutcomes: string[];
}
/**
* CreativePatterns class that provides creativity-enhancing methods
*/
export class CreativePatterns {
/**
* Generate novel perspectives based on input
*/
public generatePerspectives(input: string, count: number = 3): CreativePerspective[] {
// In a real implementation, this would use more sophisticated pattern generation
// This is a simplified placeholder
const perspectives: CreativePerspective[] = [];
// Generate perspectives based on different creative patterns
const basePatterns = [
'Inversion (What if the opposite were true?)',
'First Principles (What are the fundamental truths?)',
'Analogical (How is this like something else?)',
'Systems Thinking (How do the parts interact?)',
'Temporal Shift (How will this look in the future?)'
];
// Use at most the requested number of perspectives
const patternCount = Math.min(count, basePatterns.length);
for (let i = 0; i < patternCount; i++) {
perspectives.push({
viewpoint: basePatterns[i],
rationale: `Perspective based on ${basePatterns[i].split(' ')[0]} thinking`,
implications: [],
limitingBeliefs: [],
potentialOutcomes: []
});
}
return perspectives;
}
/**
* Generate creative connections between concepts
*/
public generateConnections(
concepts: string[],
count: number = 3
): CreativeConnection[] {
// In a real implementation, this would find meaningful connections
// This is a simplified placeholder
const connections: CreativeConnection[] = [];
const connectionTypes: CreativeConnection['type'][] = [
'metaphor', 'analogy', 'reframing', 'combination', 'inversion'
];
// Generate a few sample connections if concepts are provided
if (concepts.length >= 2) {
const numConnections = Math.min(count,
Math.floor(concepts.length * (concepts.length - 1) / 2));
for (let i = 0; i < numConnections; i++) {
const sourceIdx = i % concepts.length;
const targetIdx = (i + 1) % concepts.length;
const typeIdx = i % connectionTypes.length;
connections.push({
type: connectionTypes[typeIdx],
description: `A ${connectionTypes[typeIdx]} between concepts`,
source: concepts[sourceIdx],
target: concepts[targetIdx],
insight: `Insight from connecting ${concepts[sourceIdx]} and ${concepts[targetIdx]}`
});
}
}
return connections;
}
/**
* Enhance structured perspectives with creative insights
*/
public enhancePerspectives(
perspectives: StructuredPerspective[],
input: string
): StructuredPerspective[] {
// Add creative viewpoints to existing perspectives
return perspectives.map(perspective => {
// Generate creative insights based on the knowledge category
const creativeInsights = this.generateInsightsForCategory(
perspective.category,
input
);
// Merge existing insights with new creative ones
return {
...perspective,
insights: [...perspective.insights, ...creativeInsights]
};
});
}
/**
* Generate creative insights for a specific knowledge category
*/
private generateInsightsForCategory(
category: KnowledgeCategory,
input: string
): string[] {
// In a real implementation, this would generate tailored insights
// This is a simplified placeholder that returns generic insights
const insights: string[] = [];
// Generate different insights based on the category type
const { awareness, content, accessibility } = category.dimension;
if (awareness === 'Known' && content === 'Known') {
insights.push(
"Consider how established information might be recontextualized"
);
} else if (awareness === 'Known' && content === 'Unknown') {
insights.push(
"Explore how identifying specific questions creates opportunities"
);
} else if (awareness === 'Unknown' && content === 'Known') {
insights.push(
"Investigate potential implicit knowledge that could be surfaced"
);
} else if (awareness === 'Unknown' && content === 'Unknown') {
insights.push(
"Consider what completely novel discoveries might transform understanding"
);
}
if (accessibility === 'Knowable') {
insights.push(
"Explore methods to actively expand understanding in this area"
);
} else if (accessibility === 'Unknowable') {
insights.push(
"Consider how acknowledging fundamental limits creates new perspectives"
);
}
return insights;
}
/**
* Apply metaphorical thinking to a problem
*/
public generateMetaphors(input: string, count: number = 3): string[] {
// In a real implementation, this would create meaningful metaphors
// This is a simplified placeholder
const baseMetaphors = [
"This problem is like a puzzle with missing pieces",
"This situation resembles an ecosystem seeking balance",
"The challenge is similar to navigating a maze with changing walls",
"This process mirrors a chemical reaction needing a catalyst",
"The situation is like a story with parallel plotlines"
];
// Return a subset of the available metaphors
return baseMetaphors.slice(0, Math.min(count, baseMetaphors.length));
}
}