-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoidide-genesis-mvp.html
More file actions
692 lines (590 loc) · 22.1 KB
/
voidide-genesis-mvp.html
File metadata and controls
692 lines (590 loc) · 22.1 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🌟 VoidIDE Genesis - Self-Creating IDE MVP</title>
<!-- Monaco Editor CDN -->
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.44.0/min/vs/loader.js"></script>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
margin: 0;
padding: 0;
background: #1e1e1e;
color: #d4d4d4;
height: 100vh;
overflow: hidden;
}
.container {
display: flex;
height: 100vh;
}
.sidebar {
width: 250px;
background: #252526;
border-right: 1px solid #3e3e42;
padding: 10px;
overflow-y: auto;
}
.main-content {
flex: 1;
display: flex;
flex-direction: column;
}
.toolbar {
height: 50px;
background: #2d2d30;
border-bottom: 1px solid #3e3e42;
display: flex;
align-items: center;
padding: 0 15px;
gap: 10px;
}
.toolbar button {
background: #0e639c;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background 0.2s;
}
.toolbar button:hover {
background: #1177bb;
}
.toolbar button:disabled {
background: #5a5a5a;
cursor: not-allowed;
}
.toolbar .status {
margin-left: auto;
font-size: 12px;
color: #cccccc;
}
.editor-container {
flex: 1;
position: relative;
}
.bottom-panel {
height: 200px;
background: #1e1e1e;
border-top: 1px solid #3e3e42;
display: flex;
}
.output-panel {
flex: 1;
padding: 10px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
line-height: 1.4;
}
.plugins-panel {
width: 300px;
background: #252526;
border-left: 1px solid #3e3e42;
padding: 10px;
overflow-y: auto;
}
.sidebar h3, .plugins-panel h3 {
margin: 0 0 10px 0;
font-size: 14px;
color: #cccccc;
border-bottom: 1px solid #3e3e42;
padding-bottom: 5px;
}
.project-tree {
font-size: 12px;
}
.project-tree .file {
padding: 2px 0;
cursor: pointer;
border-radius: 3px;
padding-left: 20px;
}
.project-tree .file:hover {
background: #2a2d2e;
}
.project-tree .file.active {
background: #094771;
}
.plugin-item {
background: #2d2d30;
margin: 5px 0;
padding: 8px;
border-radius: 4px;
font-size: 12px;
}
.plugin-item .name {
font-weight: bold;
color: #4fc1ff;
}
.plugin-item .status {
color: #73c991;
font-size: 10px;
}
.log-entry {
margin: 2px 0;
padding: 2px 0;
}
.log-entry.info {
color: #d4d4d4;
}
.log-entry.success {
color: #73c991;
}
.log-entry.error {
color: #f48771;
}
.log-entry.warn {
color: #dcdcaa;
}
.header {
background: #007acc;
color: white;
padding: 10px 15px;
font-size: 16px;
font-weight: bold;
}
.loading {
display: flex;
align-items: center;
justify-content: center;
height: 100px;
font-size: 14px;
color: #888;
}
.execution-status {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 5px;
}
.execution-status.idle {
background: #888;
}
.execution-status.running {
background: #73c991;
animation: pulse 1s infinite;
}
.execution-status.error {
background: #f48771;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.welcome-message {
background: #0e639c;
color: white;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
font-size: 12px;
border-left: 4px solid #1177bb;
}
.stats-panel {
background: #2d2d30;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
}
.stats-item {
display: flex;
justify-content: space-between;
margin: 5px 0;
font-size: 12px;
}
.monaco-editor-container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="container">
<!-- サイドバー -->
<div class="sidebar">
<div class="header">🌟 VoidIDE Genesis</div>
<div class="welcome-message">
<strong>自己創造システム</strong><br>
VoidCoreでVoidCoreを育てる革命的IDE
</div>
<h3>📁 Project Explorer</h3>
<div class="project-tree">
<div class="file active" data-file="main.js">
📄 main.js (current)
</div>
<div class="file" data-file="template">
📋 Plugin Template
</div>
</div>
<div class="stats-panel">
<h3>📊 Statistics</h3>
<div class="stats-item">
<span>Plugins Created:</span>
<span id="pluginCount">0</span>
</div>
<div class="stats-item">
<span>Executions:</span>
<span id="executionCount">0</span>
</div>
<div class="stats-item">
<span>Uptime:</span>
<span id="uptime">0s</span>
</div>
</div>
<h3>🎯 Quick Actions</h3>
<button class="toolbar" onclick="loadTemplate()" style="width: 100%; margin: 5px 0;">
📋 Load Template
</button>
<button class="toolbar" onclick="clearOutput()" style="width: 100%; margin: 5px 0;">
🧹 Clear Output
</button>
<button class="toolbar" onclick="showHelp()" style="width: 100%; margin: 5px 0;">
❓ Show Help
</button>
</div>
<!-- メインコンテンツ -->
<div class="main-content">
<!-- ツールバー -->
<div class="toolbar">
<button id="runButton" onclick="executeCode()">
▶️ Run Code (Ctrl+Enter)
</button>
<button onclick="saveCode()">
💾 Save
</button>
<button onclick="formatCode()">
🎨 Format
</button>
<div class="status">
<span class="execution-status idle" id="executionStatus"></span>
<span id="statusText">Ready</span>
</div>
</div>
<!-- エディタ -->
<div class="editor-container">
<div id="monaco-editor" class="monaco-editor-container"></div>
</div>
<!-- ボトムパネル -->
<div class="bottom-panel">
<div class="output-panel">
<h3>📝 Output & Logs</h3>
<div id="output"></div>
</div>
<div class="plugins-panel">
<h3>🔧 Active Plugins</h3>
<div id="pluginsList"></div>
</div>
</div>
</div>
</div>
<script type="module">
import { voidCore, createPlugin, Message } from './src/index.js';
// グローバル変数
let monacoEditor = null;
let voidIDEPlugin = null;
let startTime = Date.now();
let executionCount = 0;
let pluginCount = 0;
// Monaco Editorの初期化
require.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.44.0/min/vs' }});
require(['vs/editor/editor.main'], function() {
initializeVoidIDE();
});
async function initializeVoidIDE() {
try {
log('🚀 Initializing VoidIDE Genesis...', 'info');
// VoidIDEプラグインを作成
voidIDEPlugin = createPlugin({
pluginId: 'void-ide-genesis-mvp',
name: 'VoidIDE Genesis MVP',
version: '1.0.0-mvp',
capabilities: ['code-editor', 'plugin-builder', 'runtime-eval']
}, {
async run() {
await this.initialize();
this.log('🌟 VoidIDE Genesis MVP initialized!');
// メッセージ監視
this.on('Notice', 'plugin.created', (message) => {
updatePluginsList();
});
}
});
// VoidCoreに登録して実行
voidCore.registerPlugin(voidIDEPlugin);
await voidIDEPlugin.run();
// Monaco Editorを初期化
monacoEditor = monaco.editor.create(document.getElementById('monaco-editor'), {
value: getDefaultTemplate(),
language: 'javascript',
theme: 'vs-dark',
fontSize: 14,
automaticLayout: true,
minimap: { enabled: true },
wordWrap: 'on'
});
// VoidCore API補完の設定
setupCodeCompletion();
// エディタイベントの設定
monacoEditor.onDidChangeModelContent(() => {
updateStatus('Modified', 'idle');
});
// キーボードショートカット
monacoEditor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
executeCode();
});
log('✅ VoidIDE Genesis MVP ready!', 'success');
updateStatus('Ready', 'idle');
// 統計更新開始
setInterval(updateStats, 1000);
} catch (error) {
log(`❌ Initialization error: ${error.message}`, 'error');
}
}
// コード実行
async function executeCode() {
const runButton = document.getElementById('runButton');
const statusElement = document.getElementById('executionStatus');
try {
runButton.disabled = true;
updateStatus('Executing...', 'running');
const code = monacoEditor.getValue();
log('🚀 Executing code...', 'info');
// セキュアなコード実行
const result = await safeExecuteCode(code);
if (result.success) {
log('✅ Code executed successfully!', 'success');
if (result.plugin) {
pluginCount++;
log(`🔧 Plugin created: ${result.plugin.pluginId}`, 'success');
updatePluginsList();
}
updateStatus('Success', 'idle');
} else {
log(`❌ Execution error: ${result.error}`, 'error');
updateStatus('Error', 'error');
}
executionCount++;
} catch (error) {
log(`❌ Execution failed: ${error.message}`, 'error');
updateStatus('Error', 'error');
} finally {
runButton.disabled = false;
}
}
// セキュアなコード実行
async function safeExecuteCode(code) {
try {
// VoidCoreプラグイン作成のためのラッパーコード
const wrappedCode = `
// VoidCore API
const { createPlugin, voidCore, Message } = voidcoreAPI;
// ユーザーコード実行
const result = (function() {
${code}
})();
return result;
`;
// セキュアな実行環境
const sandboxGlobals = {
console: {
log: (...args) => log(`[User] ${args.join(' ')}`, 'info'),
warn: (...args) => log(`[User] ${args.join(' ')}`, 'warn'),
error: (...args) => log(`[User] ${args.join(' ')}`, 'error')
},
voidcoreAPI: {
createPlugin,
voidCore,
Message
},
setTimeout,
setInterval,
Date,
Math,
JSON
};
// Function constructorで安全に実行
const executor = new Function(
...Object.keys(sandboxGlobals),
wrappedCode
);
const result = executor(...Object.values(sandboxGlobals));
// プラグインかどうか確認
if (result && typeof result === 'object' && result.pluginId) {
// VoidCoreに登録
const registered = voidCore.registerPlugin(result);
if (registered && typeof result.run === 'function') {
await result.run();
}
return { success: true, plugin: result };
} else {
return { success: true, value: result };
}
} catch (error) {
return { success: false, error: error.message };
}
}
// VoidCore API補完の設定
function setupCodeCompletion() {
monaco.languages.registerCompletionItemProvider('javascript', {
provideCompletionItems: (model, position) => {
const word = model.getWordUntilPosition(position);
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
};
const suggestions = [
{
label: 'createPlugin',
kind: monaco.languages.CompletionItemKind.Function,
insertText: [
'createPlugin({',
' pluginId: \'${1:my-plugin}\',',
' name: \'${2:My Plugin}\',',
' version: \'${3:1.0.0}\'',
'}, {',
' async run() {',
' await this.initialize();',
' $0',
' }',
'})'
].join('\n'),
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
documentation: 'Create a new VoidCore plugin',
range: range
},
{
label: 'voidcore-template',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: getDefaultTemplate(),
documentation: 'Complete VoidCore plugin template',
range: range
}
];
return { suggestions };
}
});
}
// デフォルトテンプレート
function getDefaultTemplate() {
return `// 🌟 VoidCore Plugin - Created in VoidIDE Genesis!
// This is a self-creating system - VoidCore creating VoidCore
const myPlugin = createPlugin({
pluginId: 'my-genesis-plugin',
name: 'My Genesis Plugin',
version: '1.0.0',
capabilities: ['demo', 'self-creation']
}, {
async run() {
await this.initialize();
this.log('🎉 Hello from VoidIDE Genesis!');
this.log('🧠 This plugin was created inside VoidIDE itself!');
// Listen for messages
this.on('Notice', 'user.hello', (message) => {
this.log('👋 Received hello:', message.payload);
// Send a response
this.notice('plugin.response', {
message: 'Hello back from Genesis!',
timestamp: Date.now(),
createdIn: 'VoidIDE Genesis'
});
});
// Send a welcome message
await this.notice('plugin.genesis.welcome', {
pluginId: this.pluginId,
message: 'Self-creation successful!',
philosophy: 'VoidCore creating VoidCore',
timestamp: Date.now()
});
// Demonstrate self-awareness
const coreStats = voidCore.getStats();
this.log('🔍 Current VoidCore stats:', coreStats);
this.log('🌟 I am plugin #' + (coreStats.pluginCount || 'unknown'));
this.log('✅ Genesis plugin ready for self-creation!');
}
});
// Return the plugin for VoidIDE to register
return myPlugin;`;
}
// ログ出力
function log(message, type = 'info') {
const output = document.getElementById('output');
const entry = document.createElement('div');
entry.className = `log-entry ${type}`;
const timestamp = new Date().toLocaleTimeString();
const icon = type === 'error' ? '❌' : type === 'warn' ? '⚠️' : type === 'success' ? '✅' : '📝';
entry.textContent = `[${timestamp}] ${icon} ${message}`;
output.appendChild(entry);
output.scrollTop = output.scrollHeight;
}
// ステータス更新
function updateStatus(text, status) {
document.getElementById('statusText').textContent = text;
const statusElement = document.getElementById('executionStatus');
statusElement.className = `execution-status ${status}`;
}
// 統計更新
function updateStats() {
const uptime = Math.floor((Date.now() - startTime) / 1000);
document.getElementById('uptime').textContent = `${uptime}s`;
document.getElementById('executionCount').textContent = executionCount;
document.getElementById('pluginCount').textContent = pluginCount;
}
// プラグインリスト更新
function updatePluginsList() {
const pluginsList = document.getElementById('pluginsList');
const plugins = voidCore.getAllPlugins();
pluginsList.innerHTML = '';
if (plugins.length === 0) {
pluginsList.innerHTML = '<div style="color: #888; font-size: 12px;">No plugins yet</div>';
return;
}
plugins.forEach(plugin => {
const item = document.createElement('div');
item.className = 'plugin-item';
item.innerHTML = `
<div class="name">${plugin.name || plugin.pluginId}</div>
<div class="status">✅ Active</div>
<div style="font-size: 10px; color: #888;">v${plugin.version || '1.0.0'}</div>
`;
pluginsList.appendChild(item);
});
}
// グローバル関数(HTML onclick用)
window.executeCode = executeCode;
window.saveCode = () => {
log('💾 Code saved (local storage)', 'info');
updateStatus('Saved', 'idle');
};
window.formatCode = () => {
monacoEditor.getAction('editor.action.formatDocument').run();
log('🎨 Code formatted', 'info');
};
window.loadTemplate = () => {
monacoEditor.setValue(getDefaultTemplate());
log('📋 Template loaded', 'info');
};
window.clearOutput = () => {
document.getElementById('output').innerHTML = '';
log('🧹 Output cleared', 'info');
};
window.showHelp = () => {
log('🎯 VoidIDE Genesis Help:', 'info');
log('• Ctrl+Enter: Execute code', 'info');
log('• Ctrl+S: Save (planned)', 'info');
log('• F5: Execute code', 'info');
log('• Create VoidCore plugins with createPlugin()', 'info');
log('• Return your plugin to auto-register it', 'info');
log('• This IDE itself is a VoidCore plugin!', 'info');
};
</script>
</body>
</html>