-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
191 lines (178 loc) · 8.39 KB
/
App.tsx
File metadata and controls
191 lines (178 loc) · 8.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import React, { useState } from 'react';
import { EngineType, AppStatus, RunResult, EngineSpecification } from './types';
import { runEngine } from './services/geminiService';
import EngineCard from './components/EngineCard';
import EngineHeader from './components/EngineHeader';
import ResultView from './components/ResultView';
const ENGINES: EngineSpecification[] = [
{
name: "Constraint Engine",
type: EngineType.CONSTRAINT,
purpose: "Exposes goals that cannot be simultaneously satisfied.",
useWhen: ["You suspect hidden conflicts", "Stakes are high or irreversible", "Trade-offs feel 'hand-wavy'"],
doNotUseWhen: ["You want a recommendation", "You expect a best answer", "You're still exploring ideas"],
cta: "Run Constraint Simulation"
},
{
name: "Assumption Engine",
type: EngineType.ASSUMPTION,
purpose: "Reveals fragile or hidden assumptions behind a conclusion.",
useWhen: ["A plan 'sounds right' too easily", "You want to stress-test beliefs", "You suspect blind spots"],
doNotUseWhen: ["You need to resolve conflicts", "You want to explore alternatives", "You want final decisions"],
cta: "Surface Assumptions"
},
{
name: "Decision Framing Engine",
type: EngineType.DECISION_FRAMING,
purpose: "Clarifies what decision is actually being made.",
useWhen: ["You feel stuck or overwhelmed", "The decision feels fuzzy", "Timing or reversibility is unclear"],
doNotUseWhen: ["You want ideas", "You want trade-off analysis", "You want AI opinions"],
cta: "Frame the Decision"
},
{
name: "Exploration Engine",
type: EngineType.EXPLORATION,
purpose: "Expands the space of possibilities without judgment.",
useWhen: ["You don't yet know what you want", "You're early in the process", "Creativity > rigor"],
doNotUseWhen: ["Stakes are high", "You need safety or guarantees", "You are close to commitment"],
cta: "Explore Possibilities"
}
];
const App: React.FC = () => {
const [status, setStatus] = useState<AppStatus>(AppStatus.IDLE);
const [selectedEngine, setSelectedEngine] = useState<EngineSpecification | null>(null);
const [goal, setGoal] = useState('');
const [context, setContext] = useState('');
const [failure, setFailure] = useState('');
const [result, setResult] = useState<RunResult | null>(null);
const handleSelectEngine = (engine: EngineSpecification) => {
setSelectedEngine(engine);
setStatus(AppStatus.ENGINE_SELECTED);
};
const handleReset = () => {
setStatus(AppStatus.IDLE);
setSelectedEngine(null);
setGoal('');
setContext('');
setFailure('');
setResult(null);
};
const handleRun = async () => {
if (!selectedEngine) return;
setStatus(AppStatus.PROCESSING);
try {
const output = await runEngine(selectedEngine.type, goal, context, failure);
setResult({
engineType: selectedEngine.type,
timestamp: Date.now(),
input: { goal, context, unacceptableFailure: failure },
output
});
setStatus(AppStatus.COMPLETE);
} catch (e) {
alert("Simulation error. Check parameters.");
setStatus(AppStatus.ENGINE_SELECTED);
}
};
if (status === AppStatus.IDLE) {
return (
<div className="h-screen bg-slate-50 p-8 md:p-12 flex flex-col items-center overflow-y-auto">
<header className="text-center mb-12 max-w-2xl shrink-0">
<h1 className="text-4xl font-black text-slate-900 tracking-tighter mb-4 uppercase">First Principles Studio</h1>
<p className="text-slate-500 font-bold uppercase tracking-widest text-xs">Mechanistic Reasoning Matrix used to force First Principles clarity.</p>
<h2 className="text-xl font-bold text-slate-900 mt-12 mb-2">What kind of thinking does this problem require?</h2>
</header>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 w-full max-w-7xl shrink-0">
{ENGINES.map(e => (
<EngineCard key={e.type} spec={e} onSelect={() => handleSelectEngine(e)} />
))}
</div>
</div>
);
}
return (
<div className="h-screen bg-white flex flex-col overflow-hidden">
<EngineHeader
engineName={selectedEngine?.name || ''}
onReset={handleReset}
isLocked={status !== AppStatus.IDLE}
/>
<main className="flex-1 flex overflow-hidden">
{/* Input Zone */}
<div className="w-full md:w-5/12 p-8 border-r border-slate-100 overflow-y-auto bg-white">
<div className="max-w-md mx-auto space-y-8">
<div>
<label className="block text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] mb-3">Goal / Primary Question</label>
<textarea
className="w-full h-32 p-4 bg-slate-50 border border-slate-200 rounded font-mono text-sm focus:ring-1 focus:ring-slate-900 outline-none transition-all"
placeholder="State clearly what you want to achieve..."
value={goal}
onChange={e => setGoal(e.target.value)}
disabled={status === AppStatus.PROCESSING || status === AppStatus.COMPLETE}
/>
</div>
<div>
<label className="block text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] mb-3">Context / Constraints / Known Facts</label>
<textarea
className="w-full h-32 p-4 bg-slate-50 border border-slate-200 rounded font-mono text-sm focus:ring-1 focus:ring-slate-900 outline-none transition-all"
placeholder="Provide necessary background parameters..."
value={context}
onChange={e => setContext(e.target.value)}
disabled={status === AppStatus.PROCESSING || status === AppStatus.COMPLETE}
/>
</div>
{selectedEngine?.type === EngineType.CONSTRAINT && (
<div>
<label className="block text-[10px] font-black text-slate-400 uppercase tracking-[0.2em] mb-3">What failure would be unacceptable?</label>
<textarea
className="w-full h-24 p-4 bg-slate-50 border border-slate-200 rounded font-mono text-sm focus:ring-1 focus:ring-slate-900 outline-none transition-all"
placeholder="Define the boundary that must not be crossed..."
value={failure}
onChange={e => setFailure(e.target.value)}
disabled={status === AppStatus.PROCESSING || status === AppStatus.COMPLETE}
/>
</div>
)}
<div className="pt-6">
<button
onClick={handleRun}
disabled={status === AppStatus.PROCESSING || status === AppStatus.COMPLETE || !goal}
className={`w-full py-4 font-black text-xs uppercase tracking-[0.3em] rounded border shadow-xl transition-all ${
status === AppStatus.PROCESSING || status === AppStatus.COMPLETE || !goal
? 'bg-slate-100 text-slate-300 border-slate-100 cursor-not-allowed'
: 'bg-slate-900 text-white hover:bg-black active:scale-[0.98] border-slate-900'
}`}
>
{status === AppStatus.PROCESSING ? 'Processing Matrix...' : selectedEngine?.cta}
</button>
</div>
</div>
</div>
{/* Result Zone */}
<div className="w-full md:w-7/12 bg-slate-50 overflow-y-auto">
{status === AppStatus.PROCESSING ? (
<div className="flex flex-col items-center justify-center h-full">
<div className="w-16 h-1 bg-slate-200 relative overflow-hidden mb-4">
<div className="absolute inset-0 bg-slate-900 animate-[loading_1.5s_infinite]"></div>
</div>
<p className="text-[10px] font-black uppercase tracking-[0.4em] text-slate-900">Executing Reasoning Protocol</p>
</div>
) : result ? (
<ResultView result={result} />
) : (
<div className="flex items-center justify-center h-full text-slate-300">
<p className="text-[10px] font-black uppercase tracking-[0.3em]">Ready for input simulation</p>
</div>
)}
</div>
</main>
<style>{`
@keyframes loading {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
`}</style>
</div>
);
};
export default App;