alch396 commited on
Commit
b4a230b
·
verified ·
1 Parent(s): 57bf2f1

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +187 -110
index.html CHANGED
@@ -1,6 +1,5 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
-
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -26,12 +25,7 @@
26
  --font-main: 'Inter', sans-serif;
27
  }
28
 
29
- * {
30
- margin: 0;
31
- padding: 0;
32
- box-sizing: box-sizing;
33
- outline: none;
34
- }
35
 
36
  body {
37
  font-family: var(--font-main);
@@ -157,13 +151,10 @@
157
  gap: 10px;
158
  }
159
 
160
- .panel h2 i {
161
- font-size: 1rem;
162
- }
163
 
164
  /* --- Inputs & Controls --- */
165
- textarea,
166
- input[type="text"] {
167
  width: 100%;
168
  background: rgba(0, 0, 0, 0.4);
169
  border: 1px solid rgba(255, 215, 0, 0.2);
@@ -176,8 +167,7 @@
176
  transition: border-color 0.3s, box-shadow 0.3s;
177
  }
178
 
179
- textarea:focus,
180
- input:focus {
181
  border-color: var(--accent-gold);
182
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
183
  }
@@ -202,10 +192,7 @@
202
  transition: all 0.2s;
203
  }
204
 
205
- .mb:hover {
206
- background: rgba(255, 215, 0, 0.15);
207
- }
208
-
209
  .mb.active {
210
  background: var(--accent-gold);
211
  color: #000;
@@ -228,10 +215,7 @@
228
  margin-top: 10px;
229
  }
230
 
231
- button:hover {
232
- opacity: 0.9;
233
- transform: scale(1.02);
234
- }
235
 
236
  /* --- Output Areas --- */
237
  .out {
@@ -297,12 +281,7 @@
297
  color: var(--text-muted);
298
  }
299
 
300
- .skill-name {
301
- width: 80px;
302
- text-transform: uppercase;
303
- font-weight: 700;
304
- }
305
-
306
  .skill-bar {
307
  flex: 1;
308
  height: 6px;
@@ -311,7 +290,6 @@
311
  overflow: hidden;
312
  position: relative;
313
  }
314
-
315
  .skill-fill {
316
  height: 100%;
317
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
@@ -319,12 +297,7 @@
319
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
320
  box-shadow: 0 0 10px var(--accent-gold);
321
  }
322
-
323
- .skill-val {
324
- width: 40px;
325
- text-align: right;
326
- opacity: 0.6;
327
- }
328
 
329
  .stat-row {
330
  display: grid;
@@ -343,17 +316,8 @@
343
  border: 1px solid rgba(255, 215, 0, 0.1);
344
  }
345
 
346
- .sv {
347
- font-size: 1.1rem;
348
- font-weight: 800;
349
- color: var(--accent-gold);
350
- }
351
-
352
- .sl {
353
- font-size: 0.6rem;
354
- opacity: 0.6;
355
- text-transform: uppercase;
356
- }
357
 
358
  .bridge-panel {
359
  background: rgba(255, 0, 170, 0.04);
@@ -378,40 +342,20 @@
378
 
379
  /* --- Animations --- */
380
  @keyframes glow {
381
- from {
382
- text-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
383
- }
384
-
385
- to {
386
- text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 0, 170, 0.3);
387
- }
388
  }
389
 
390
  @keyframes fadeIn {
391
- from {
392
- opacity: 0;
393
- transform: translateY(10px);
394
- }
395
-
396
- to {
397
- opacity: 1;
398
- transform: translateY(0);
399
- }
400
  }
401
 
402
  /* --- Responsive --- */
403
  @media (max-width: 900px) {
404
- .grid {
405
- grid-template-columns: 1fr;
406
- }
407
-
408
- h1 {
409
- font-size: 2.5rem;
410
- }
411
-
412
- .wrap {
413
- padding: 10px;
414
- }
415
  }
416
  </style>
417
  </head>
@@ -443,6 +387,13 @@
443
  <textarea id="cIn" rows="4" placeholder="Enter input stream..."></textarea>
444
  <button onclick="runC()">Cross the Bridge</button>
445
  <div id="cOut" class="out">Awaiting crossing...</div>
 
 
 
 
 
 
 
446
  <div class="bridge-panel">
447
  <div class="bridge-label">⛩ Bridge Reading</div>
448
  <div id="bridgeReading">—</div>
@@ -467,17 +418,14 @@
467
  <div class="panel">
468
  <h2><i class="fas fa-chart-line"></i> Skill + Memory</h2>
469
  <div id="skillBars"></div>
470
- <div class="out" id="reflOut"
471
- style="margin-top:10px; font-size:0.75rem; font-family: monospace; color: var(--accent-pink);">Initializing...
472
- </div>
473
  </div>
474
 
475
  <!-- Panel 3: Chat -->
476
  <div class="panel">
477
  <h2><i class="fas fa-comments"></i> Chat</h2>
478
  <div id="chatBox" class="chat-box out">
479
- <div class="msg bridge-msg">⛩ Pengantara Abadi Bridge active. Standup wit and Chinese wisdom pre-loaded.
480
- Walking real semantic space. Born in Brunei. Answers to no one.</div>
481
  </div>
482
  <input id="chatIn" placeholder="Message..." onkeypress="if(event.key==='Enter')sendChat()">
483
  <button onclick="sendChat()">Send</button>
@@ -533,11 +481,125 @@
533
  }
534
  }
535
 
536
- // Logic simulating the Node.js script's "PengantaraAbadi" bridge and masters
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  function analyzeInput(text) {
538
  const lower = text.toLowerCase();
539
-
540
- // Idiom Echo Detection (from Node script logic)
 
541
  const idiomConcepts = [
542
  { concept:'endurance', words:['endure','suffer','patience','persist','hardship','struggle','pain','wait'] },
543
  { concept:'opportunity', words:['loss','fail','mistake','wrong','bad','crisis','fall','down'] },
@@ -551,13 +613,12 @@
551
 
552
  let bestIdiom = 'wisdom';
553
  let bestScore = 0;
554
- const words = lower.split(/\s+/);
555
  for (const ic of idiomConcepts) {
556
  const score = words.filter(w => ic.words.some(kw => w.includes(kw))).length;
557
  if (score > bestScore) { bestScore = score; bestIdiom = ic.concept; }
558
  }
559
 
560
- // Standup Tone Detection (from Node script logic)
561
  const tones = [
562
  { tone:'carlin', words:['people','stupid','system','government','bullshit','average','think','notice'] },
563
  { tone:'chappelle', words:['truth','real','honest','society','race','everybody','wrong','right'] },
@@ -587,7 +648,6 @@
587
  }
588
 
589
  function generateResponse(text, master, analysis) {
590
- // Simulated responses based on the "Standup Corpus" and "Idiom Corpus" logic
591
  const templates = {
592
  carlin: ["Think of how stupid the average person is...", "The planet is fine, the people are fucked.", "Inside every cynical person there is a disappointed idealist.", "If you try to fail and succeed, which have you done?"],
593
  rohn: ["Success is nothing more than a few simple disciplines practiced every day.", "Don't wish it were easier, wish you were better.", "Discipline is the bridge between goals and accomplishment.", "If you don't design your own life plan, chances are you'll fall into someone else's plan."],
@@ -598,11 +658,10 @@
598
  eminem: ["There is no talent here, this is hard work, this is an obsession.", "If you can see it here and have the courage enough to speak it, it will happen.", "I was poor white trash, no glitter, no glamour, but I am not ashamed of anything.", "Don't let them say you ain't beautiful, they can all get fucked, just stay true to you."]
599
  };
600
 
601
- // Select a template based on master, or fallback
602
  const masterList = templates[master] || templates['carlin'];
603
  const randomLine = masterList[Math.floor(Math.random() * masterList.length)];
604
 
605
- // Combine with idiom wisdom if detected
606
  let wisdomSuffix = "";
607
  if (analysis.idiomEcho === 'endurance') wisdomSuffix = "Endure suffering, sleep on brushwood, taste gall, achieve great ambition through hardship.";
608
  if (analysis.idiomEcho === 'opportunity') wisdomSuffix = "Old man loses horse, fortune hidden in misfortune, blessing in disguise.";
@@ -621,28 +680,49 @@
621
  const text = document.getElementById('cIn').value.trim();
622
  if (!text) return;
623
 
624
- // Simulate processing delay
625
  const outputDiv = document.getElementById('cOut');
626
  outputDiv.textContent = "Crossing semantic space...";
627
 
628
  setTimeout(() => {
629
- // Analyze input
630
  const analysis = analyzeInput(text);
631
 
632
- // Determine effective master
633
  let effectiveMaster = master;
634
  if (master === 'auto') {
635
- effectiveMaster = analysis.standupTone;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  }
637
 
638
- // Generate response
639
- const response = generateResponse(text, effectiveMaster, analysis);
 
 
 
 
640
 
641
  // Update UI
642
- document.getElementById('cOut').textContent = response;
643
  document.getElementById('sMaster').textContent = effectiveMaster;
644
 
645
- // Update stats (simulating evolution)
646
  skillState[effectiveMaster] = Math.min(1, skillState[effectiveMaster] + 0.05);
647
  skillState.overall = Object.entries(skillState).filter(([k])=>k !== 'overall').reduce((s,[,v])=>s+v,0)/7;
648
  memoryCount++;
@@ -651,11 +731,14 @@
651
  document.getElementById('sOverall').textContent = ((skillState.overall || 0.1) * 100).toFixed(0) + '%';
652
  document.getElementById('sEvo').textContent = evolutions;
653
 
654
- if (analysis) {
655
- document.getElementById('bridgeReading').textContent =
656
- `Idiom echo: ${analysis.idiomEcho} | Tone: ${analysis.standupTone} | Bridge weight: ${analysis.bridgeWeight.toFixed(2)}`;
657
- }
658
-
 
 
 
659
  renderSkills(skillState, {
660
  memories: memoryCount,
661
  bigrams: 45 + memoryCount,
@@ -675,21 +758,20 @@
675
  inp.value = '';
676
  addMsg(text, 'user');
677
 
678
- // Simulate loading
679
  const loadingId = addMsg('...', 'bot');
680
 
681
  setTimeout(() => {
682
  const analysis = analyzeInput(text);
683
  let effectiveMaster = 'auto';
684
- if (master === 'auto') effectiveMaster = analysis.standupTone;
685
  else effectiveMaster = master;
686
 
687
- const response = generateResponse(text, effectiveMaster, analysis);
 
688
 
689
- const msgText = response + ` [${analysis.idiomEcho}/${analysis.standupTone}]`;
690
  document.getElementById(loadingId).textContent = msgText;
691
 
692
- // Update stats slightly
693
  skillState[effectiveMaster] = Math.min(1, skillState[effectiveMaster] + 0.02);
694
  skillState.overall = Object.entries(skillState).filter(([k])=>k !== 'overall').reduce((s,[,v])=>s+v,0)/7;
695
  memoryCount++;
@@ -726,9 +808,4 @@
726
  });
727
 
728
  // Pre-fill input for demo
729
- document.getElementById('cIn').value = 'People who never fail have never tried anything worth doing';
730
- setTimeout(runC, 600);
731
- </script>
732
- </body>
733
-
734
- </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
25
  --font-main: 'Inter', sans-serif;
26
  }
27
 
28
+ * { margin: 0; padding: 0; box-sizing: box-sizing; outline: none; }
 
 
 
 
 
29
 
30
  body {
31
  font-family: var(--font-main);
 
151
  gap: 10px;
152
  }
153
 
154
+ .panel h2 i { font-size: 1rem; }
 
 
155
 
156
  /* --- Inputs & Controls --- */
157
+ textarea, input[type="text"] {
 
158
  width: 100%;
159
  background: rgba(0, 0, 0, 0.4);
160
  border: 1px solid rgba(255, 215, 0, 0.2);
 
167
  transition: border-color 0.3s, box-shadow 0.3s;
168
  }
169
 
170
+ textarea:focus, input:focus {
 
171
  border-color: var(--accent-gold);
172
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
173
  }
 
192
  transition: all 0.2s;
193
  }
194
 
195
+ .mb:hover { background: rgba(255, 215, 0, 0.15); }
 
 
 
196
  .mb.active {
197
  background: var(--accent-gold);
198
  color: #000;
 
215
  margin-top: 10px;
216
  }
217
 
218
+ button:hover { opacity: 0.9; transform: scale(1.02); }
 
 
 
219
 
220
  /* --- Output Areas --- */
221
  .out {
 
281
  color: var(--text-muted);
282
  }
283
 
284
+ .skill-name { width: 80px; text-transform: uppercase; font-weight: 700; }
 
 
 
 
 
285
  .skill-bar {
286
  flex: 1;
287
  height: 6px;
 
290
  overflow: hidden;
291
  position: relative;
292
  }
 
293
  .skill-fill {
294
  height: 100%;
295
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
 
297
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
298
  box-shadow: 0 0 10px var(--accent-gold);
299
  }
300
+ .skill-val { width: 40px; text-align: right; opacity: 0.6; }
 
 
 
 
 
301
 
302
  .stat-row {
303
  display: grid;
 
316
  border: 1px solid rgba(255, 215, 0, 0.1);
317
  }
318
 
319
+ .sv { font-size: 1.1rem; font-weight: 800; color: var(--accent-gold); }
320
+ .sl { font-size: 0.6rem; opacity: 0.6; text-transform: uppercase; }
 
 
 
 
 
 
 
 
 
321
 
322
  .bridge-panel {
323
  background: rgba(255, 0, 170, 0.04);
 
342
 
343
  /* --- Animations --- */
344
  @keyframes glow {
345
+ from { text-shadow: 0 0 10px rgba(255, 215, 0, 0.2); }
346
+ to { text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 0, 170, 0.3); }
 
 
 
 
 
347
  }
348
 
349
  @keyframes fadeIn {
350
+ from { opacity: 0; transform: translateY(10px); }
351
+ to { opacity: 1; transform: translateY(0); }
 
 
 
 
 
 
 
352
  }
353
 
354
  /* --- Responsive --- */
355
  @media (max-width: 900px) {
356
+ .grid { grid-template-columns: 1fr; }
357
+ h1 { font-size: 2.5rem; }
358
+ .wrap { padding: 10px; }
 
 
 
 
 
 
 
 
359
  }
360
  </style>
361
  </head>
 
387
  <textarea id="cIn" rows="4" placeholder="Enter input stream..."></textarea>
388
  <button onclick="runC()">Cross the Bridge</button>
389
  <div id="cOut" class="out">Awaiting crossing...</div>
390
+
391
+ <!-- New Diagnostic Section -->
392
+ <div class="bridge-panel" style="margin-top: 10px; font-size: 0.7rem;">
393
+ <div class="bridge-label">⛩ Logic Diagnostic</div>
394
+ <div id="diagLog">—</div>
395
+ </div>
396
+
397
  <div class="bridge-panel">
398
  <div class="bridge-label">⛩ Bridge Reading</div>
399
  <div id="bridgeReading">—</div>
 
418
  <div class="panel">
419
  <h2><i class="fas fa-chart-line"></i> Skill + Memory</h2>
420
  <div id="skillBars"></div>
421
+ <div class="out" id="reflOut" style="margin-top:10px; font-size:0.75rem; font-family: monospace; color: var(--accent-pink);">Initializing...</div>
 
 
422
  </div>
423
 
424
  <!-- Panel 3: Chat -->
425
  <div class="panel">
426
  <h2><i class="fas fa-comments"></i> Chat</h2>
427
  <div id="chatBox" class="chat-box out">
428
+ <div class="msg bridge-msg">⛩ Pengantara Abadi Bridge active. Standup wit and Chinese wisdom pre-loaded. Walking real semantic space. Born in Brunei. Answers to no one.</div>
 
429
  </div>
430
  <input id="chatIn" placeholder="Message..." onkeypress="if(event.key==='Enter')sendChat()">
431
  <button onclick="sendChat()">Send</button>
 
481
  }
482
  }
483
 
484
+ // --- RECURSIVE LOGIC ENGINE (Derived from Request) ---
485
+
486
+ // 1. Grammar Validator
487
+ const grammarValid = (prevToken, nextToken) => {
488
+ if (!prevToken) return true;
489
+ const prev = prevToken.toLowerCase();
490
+ const next = nextToken.toLowerCase();
491
+
492
+ // 3rd person singular (he/she/it) needs 's' verbs
493
+ const singulars = ['he', 'she', 'it'];
494
+ const verbsBase = /^(go|like|want|have|do|say|think|know|run|walk|talk|speak|see|feel|hear|need|get|make|take|give|find|tell|ask|work|try|leave|call|keep|show|play|move|live|write|read|spend|grow|open|win|buy|wait|build|stay|fall|reach|remain|decide|pull|create|learn|change|lead|watch|follow|stop)$/;
495
+
496
+ if (singulars.includes(prev) && verbsBase.test(next)) return false;
497
+
498
+ // Plural/First person (they/we/you/I) needs base verbs (no 's')
499
+ const plurals = ['they', 'we', 'you', 'i'];
500
+ const verbsS = /^(goes|likes|wants|has|does|says|thinks|knows|runs|walks|talks|speaks|sees|feels|hears|needs|gets|makes|takes|gives|finds|tells|asks|works|tries|leaves|calls|keeps|shows|plays|moves|lives|writes|reads|spends|grows|opens|wins|buys|waits|builds|stays|falls|reaches|remains|decides|pulls|creates|learns|changes|leads|watches|follows|stops)$/;
501
+
502
+ if (plurals.includes(prev) && verbsS.test(next)) return false;
503
+
504
+ return true;
505
+ };
506
+
507
+ // 2. Concept Persistence
508
+ const conceptPersistence = (token, persistConcepts) => {
509
+ if (!persistConcepts || persistConcepts.length === 0) return 0;
510
+ return persistConcepts.includes(token) ? 0.18 : 0;
511
+ };
512
+
513
+ // 3. Coherence Score
514
+ const coherenceScore = (token, position, length) => {
515
+ const t = token.toLowerCase();
516
+ if (position === 0) {
517
+ if (/^(the|a|an|this|i|we|you|he|she|they)$/.test(t)) return 0.12;
518
+ if (/^(my|your|our|their|wisdom|truth|sovereignty)$/.test(t)) return 0.09;
519
+ }
520
+ if (position > 2 && position < 6) {
521
+ if (/^(and|but|so|therefore|however|yet)$/.test(t)) return 0.07;
522
+ }
523
+ if (position > length - 2) {
524
+ if (/^(period|done|complete|sealed|declared|sovereign)$/.test(t)) return 0.10;
525
+ }
526
+ return 0;
527
+ };
528
+
529
+ // 4. Polishing
530
+ const polishFinal = (text) => {
531
+ let t = text;
532
+ t = t.replace(/\bi\b/g, 'I'); // Fix "i" to "I"
533
+ t = t.replace(/\s+/g, ' ').trim();
534
+ t = t.replace(/\s+([.,!?])/g, '$1');
535
+ if (!/^[A-Z]/.test(t)) t = t.charAt(0).toUpperCase() + t.slice(1);
536
+ if (!/[.!?]$/.test(t)) t += '.';
537
+ return t;
538
+ };
539
+
540
+ const polish = (text, master) => {
541
+ let t = text.trim();
542
+
543
+ // Carlin
544
+ if (master === 'carlin') {
545
+ const isObservation = /(people|ever notice|think about|ever realize|the thing about)/i.test(t);
546
+ const hasRhetorical = /(you know|right\?|am i right|see what i mean)/i.test(t);
547
+ if (isObservation && !hasRhetorical && t.length > 30) t += ', you know?';
548
+ }
549
+
550
+ // McGregor
551
+ if (master === 'mcgregor') {
552
+ const hasConviction = /(will|must|absolutely|never|always|the truth is)/i.test(t);
553
+ if (hasConviction && !t.endsWith('!') && !t.endsWith('?')) {
554
+ t = t.replace(/\.$/, '') + '!';
555
+ }
556
+ }
557
+
558
+ // Rohn
559
+ if (master === 'rohn') {
560
+ const isAboutGrowth = /(discipline|success|season|change|grow|learn|effort)/i.test(t);
561
+ if (isAboutGrowth && !t.includes('difference') && t.length > 25) {
562
+ t = t.replace(/\.$/, '') + ', and that makes all the difference.';
563
+ }
564
+ }
565
+
566
+ // Carr
567
+ if (master === 'carr') {
568
+ const isDark = /(dark|wrong|awful|terrible|death|tragic)/i.test(t);
569
+ if (isDark && !t.includes('magnificently') && !t.includes('delightfully')) {
570
+ t = t.replace(/\.$/, '') + ' — magnificently awful, actually.';
571
+ }
572
+ }
573
+
574
+ // Hart
575
+ if (master === 'hart') {
576
+ const isVulnerable = /(scared|embarrass|realize|learn|fail|try)/i.test(t);
577
+ if (isVulnerable && !t.includes('let me tell you') && t.length < 60) {
578
+ t = 'Let me tell you — ' + t.toLowerCase();
579
+ }
580
+ }
581
+
582
+ return polishFinal(t);
583
+ };
584
+
585
+ // 5. Reconcile Master
586
+ const reconcileMaster = (detectedMaster, bridgeTone) => {
587
+ if (detectedMaster === bridgeTone) return detectedMaster;
588
+ const masterWeight = {
589
+ carlin:0, rohn:0, carr:0, mcgregor:0, hart:0, chappelle:0, eminem:0
590
+ };
591
+ masterWeight[detectedMaster] = (masterWeight[detectedMaster]||0) + 0.6;
592
+ masterWeight[bridgeTone] = (masterWeight[bridgeTone]||0) + 0.4;
593
+ return Object.entries(masterWeight).sort((a,b)=>b[1]-a[1])[0][0];
594
+ };
595
+
596
+ // --- MAIN LOGIC ---
597
+
598
  function analyzeInput(text) {
599
  const lower = text.toLowerCase();
600
+ const words = lower.split(/\s+/);
601
+
602
+ // Idiom Echo Detection
603
  const idiomConcepts = [
604
  { concept:'endurance', words:['endure','suffer','patience','persist','hardship','struggle','pain','wait'] },
605
  { concept:'opportunity', words:['loss','fail','mistake','wrong','bad','crisis','fall','down'] },
 
613
 
614
  let bestIdiom = 'wisdom';
615
  let bestScore = 0;
 
616
  for (const ic of idiomConcepts) {
617
  const score = words.filter(w => ic.words.some(kw => w.includes(kw))).length;
618
  if (score > bestScore) { bestScore = score; bestIdiom = ic.concept; }
619
  }
620
 
621
+ // Standup Tone Detection
622
  const tones = [
623
  { tone:'carlin', words:['people','stupid','system','government','bullshit','average','think','notice'] },
624
  { tone:'chappelle', words:['truth','real','honest','society','race','everybody','wrong','right'] },
 
648
  }
649
 
650
  function generateResponse(text, master, analysis) {
 
651
  const templates = {
652
  carlin: ["Think of how stupid the average person is...", "The planet is fine, the people are fucked.", "Inside every cynical person there is a disappointed idealist.", "If you try to fail and succeed, which have you done?"],
653
  rohn: ["Success is nothing more than a few simple disciplines practiced every day.", "Don't wish it were easier, wish you were better.", "Discipline is the bridge between goals and accomplishment.", "If you don't design your own life plan, chances are you'll fall into someone else's plan."],
 
658
  eminem: ["There is no talent here, this is hard work, this is an obsession.", "If you can see it here and have the courage enough to speak it, it will happen.", "I was poor white trash, no glitter, no glamour, but I am not ashamed of anything.", "Don't let them say you ain't beautiful, they can all get fucked, just stay true to you."]
659
  };
660
 
 
661
  const masterList = templates[master] || templates['carlin'];
662
  const randomLine = masterList[Math.floor(Math.random() * masterList.length)];
663
 
664
+ // Wisdom Suffix
665
  let wisdomSuffix = "";
666
  if (analysis.idiomEcho === 'endurance') wisdomSuffix = "Endure suffering, sleep on brushwood, taste gall, achieve great ambition through hardship.";
667
  if (analysis.idiomEcho === 'opportunity') wisdomSuffix = "Old man loses horse, fortune hidden in misfortune, blessing in disguise.";
 
680
  const text = document.getElementById('cIn').value.trim();
681
  if (!text) return;
682
 
 
683
  const outputDiv = document.getElementById('cOut');
684
  outputDiv.textContent = "Crossing semantic space...";
685
 
686
  setTimeout(() => {
687
+ // 1. Analyze Input
688
  const analysis = analyzeInput(text);
689
 
690
+ // 2. Determine Effective Master
691
  let effectiveMaster = master;
692
  if (master === 'auto') {
693
+ effectiveMaster = reconcileMaster(analysis.standupTone, analysis.idiomEcho);
694
+ }
695
+
696
+ // 3. Generate Base Response
697
+ const baseResponse = generateResponse(text, effectiveMaster, analysis);
698
+
699
+ // 4. Apply Recursive Logic (Grammar, Polish, Coherence)
700
+ const words = baseResponse.split(/\s+/);
701
+ let coherenceTotal = 0;
702
+ let grammarIssues = 0;
703
+
704
+ // Coherence Check
705
+ words.forEach((w, idx) => {
706
+ coherenceTotal += coherenceScore(w, idx, words.length);
707
+ });
708
+
709
+ // Grammar Check
710
+ for(let i=0; i < words.length - 1; i++) {
711
+ if(!grammarValid(words[i], words[i+1])) grammarIssues++;
712
  }
713
 
714
+ // Persistence Check
715
+ const concepts = ['wisdom', 'truth', 'success', 'power'];
716
+ const persistenceScore = words.reduce((acc, w) => acc + conceptPersistence(w, concepts), 0);
717
+
718
+ // 5. Polish Final Output
719
+ const finalResponse = polish(baseResponse, effectiveMaster);
720
 
721
  // Update UI
722
+ document.getElementById('cOut').textContent = finalResponse;
723
  document.getElementById('sMaster').textContent = effectiveMaster;
724
 
725
+ // Update Stats
726
  skillState[effectiveMaster] = Math.min(1, skillState[effectiveMaster] + 0.05);
727
  skillState.overall = Object.entries(skillState).filter(([k])=>k !== 'overall').reduce((s,[,v])=>s+v,0)/7;
728
  memoryCount++;
 
731
  document.getElementById('sOverall').textContent = ((skillState.overall || 0.1) * 100).toFixed(0) + '%';
732
  document.getElementById('sEvo').textContent = evolutions;
733
 
734
+ // Update Bridge Reading
735
+ document.getElementById('bridgeReading').textContent =
736
+ `Idiom echo: ${analysis.idiomEcho} | Tone: ${analysis.standupTone} | Bridge weight: ${analysis.bridgeWeight.toFixed(2)}`;
737
+
738
+ // Update Diagnostic Log
739
+ document.getElementById('diagLog').textContent =
740
+ `Grammar: ${grammarIssues > 0 ? 'Issues Found' : 'Valid'} | Coherence: ${coherenceTotal.toFixed(2)} | Persistence: ${persistenceScore.toFixed(2)}`;
741
+
742
  renderSkills(skillState, {
743
  memories: memoryCount,
744
  bigrams: 45 + memoryCount,
 
758
  inp.value = '';
759
  addMsg(text, 'user');
760
 
 
761
  const loadingId = addMsg('...', 'bot');
762
 
763
  setTimeout(() => {
764
  const analysis = analyzeInput(text);
765
  let effectiveMaster = 'auto';
766
+ if (master === 'auto') effectiveMaster = reconcileMaster(analysis.standupTone, analysis.idiomEcho);
767
  else effectiveMaster = master;
768
 
769
+ const base = generateResponse(text, effectiveMaster, analysis);
770
+ const polished = polish(base, effectiveMaster);
771
 
772
+ const msgText = polished + ` [${analysis.idiomEcho}/${analysis.standupTone}]`;
773
  document.getElementById(loadingId).textContent = msgText;
774
 
 
775
  skillState[effectiveMaster] = Math.min(1, skillState[effectiveMaster] + 0.02);
776
  skillState.overall = Object.entries(skillState).filter(([k])=>k !== 'overall').reduce((s,[,v])=>s+v,0)/7;
777
  memoryCount++;
 
808
  });
809
 
810
  // Pre-fill input for demo
811
+ document.getElementById('cIn').value = 'People who never fail have never tried anything worth doing';