oneie 1.0.0 → 1.0.1

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.
package/bin/install.js ADDED
@@ -0,0 +1,425 @@
1
+ #!/usr/bin/env node
2
+
3
+ import path from 'path';
4
+ import fs from 'fs-extra';
5
+ import chalk from 'chalk';
6
+ import ora from 'ora';
7
+ import figlet from 'figlet';
8
+ import gradientString from 'gradient-string';
9
+ import { readFile } from 'fs/promises';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+
15
+ // Get version from package.json
16
+ const packageJson = JSON.parse(await readFile(path.join(__dirname, '../package.json'), 'utf8'));
17
+ const ONE_VERSION = packageJson.version;
18
+
19
+ /**
20
+ * Production-ready ONE installer
21
+ * Core workflow: Install → Configure → Ready
22
+ */
23
+ async function main() {
24
+ try {
25
+ console.clear();
26
+
27
+ // 1. Welcome & System Check
28
+ await showWelcome();
29
+ const context = await detectEnvironment();
30
+
31
+ // 2. Core Installation
32
+ const spinner = ora('Installing ONE Universal AI System...').start();
33
+
34
+ await sleep(1000);
35
+ spinner.text = 'Creating AI universe structure...';
36
+ await createCoreStructure(context);
37
+
38
+ await sleep(500);
39
+ spinner.text = 'Generating your digital DNA (me.md)...';
40
+ await generateMeFile(context);
41
+
42
+ await sleep(500);
43
+ spinner.text = 'Setting up command interface...';
44
+ await setupCommandInterface();
45
+
46
+ await sleep(500);
47
+ spinner.text = 'Validating installation...';
48
+ const validation = await validateInstallation();
49
+
50
+ spinner.succeed('ONE installed successfully!');
51
+
52
+ // 3. Success & Next Steps
53
+ await showSuccessMessage(context, validation);
54
+
55
+ } catch (error) {
56
+ console.error(chalk.red('\n💥 Installation failed:'), error.message);
57
+ showTroubleshootingHelp(error);
58
+ process.exit(1);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Show welcome message with version info
64
+ */
65
+ async function showWelcome() {
66
+ const title = await promisify(figlet)('ONE', { font: 'ANSI Shadow' });
67
+ const gradient = gradientString(['#FF6B6B', '#4ECDC4', '#45B7D1']);
68
+
69
+ console.log(gradient(title));
70
+ console.log(chalk.cyan(`
71
+ ╔══════════════════════════════════════════════════════════════════════════════╗
72
+ ║ ║
73
+ ║ 🌟 ONE Universal AI System v${ONE_VERSION.padEnd(35)}║
74
+ ║ Simple blocks. Infinite possibilities. ║
75
+ ║ ║
76
+ ║ From homework to world domination - same system, infinite scale. ║
77
+ ║ ║
78
+ ╚══════════════════════════════════════════════════════════════════════════════╝
79
+ `));
80
+
81
+ console.log(chalk.yellow('🔍 Detecting your environment...'));
82
+ await sleep(1500);
83
+ }
84
+
85
+ /**
86
+ * Detect user environment and context
87
+ */
88
+ async function detectEnvironment() {
89
+ const cwd = process.cwd();
90
+ const context = {
91
+ directory: path.basename(cwd),
92
+ hasPackageJson: await fs.pathExists(path.join(cwd, 'package.json')),
93
+ hasGit: await fs.pathExists(path.join(cwd, '.git')),
94
+ nodeVersion: process.version,
95
+ platform: process.platform,
96
+ type: 'universal'
97
+ };
98
+
99
+ // Detect context from directory name and contents
100
+ const dirName = context.directory.toLowerCase();
101
+ if (dirName.includes('homework') || dirName.includes('school') || dirName.includes('study')) {
102
+ context.type = 'student';
103
+ } else if (context.hasPackageJson) {
104
+ context.type = 'professional';
105
+ } else if (dirName.includes('enterprise') || dirName.includes('company')) {
106
+ context.type = 'enterprise';
107
+ }
108
+
109
+ console.log(chalk.green(`✅ Detected: ${context.type} environment in "${context.directory}"`));
110
+ return context;
111
+ }
112
+
113
+ /**
114
+ * Create the core ONE directory structure
115
+ */
116
+ async function createCoreStructure(context) {
117
+ const oneDir = path.join(process.cwd(), 'one');
118
+ const dotOneDir = path.join(process.cwd(), '.one');
119
+
120
+ // Create main directories
121
+ await fs.ensureDir(oneDir);
122
+ await fs.ensureDir(dotOneDir);
123
+
124
+ // Create core subdirectories
125
+ const coreDirectories = [
126
+ // User-customizable directories
127
+ path.join(oneDir, 'me'),
128
+ path.join(oneDir, 'missions'),
129
+ path.join(oneDir, 'stories'),
130
+ path.join(oneDir, 'tasks'),
131
+ path.join(oneDir, 'agents'),
132
+ path.join(oneDir, 'teams'),
133
+ path.join(oneDir, 'spaces'),
134
+
135
+ // System directories
136
+ path.join(dotOneDir, 'core'),
137
+ path.join(dotOneDir, 'templates'),
138
+ path.join(dotOneDir, 'workflows')
139
+ ];
140
+
141
+ for (const dir of coreDirectories) {
142
+ await fs.ensureDir(dir);
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Generate the magical me.md file based on context
148
+ */
149
+ async function generateMeFile(context) {
150
+ const meFilePath = path.join(process.cwd(), 'one', 'me', 'me.md');
151
+
152
+ const meContent = generateContextualMeContent(context);
153
+ await fs.writeFile(meFilePath, meContent, 'utf8');
154
+ }
155
+
156
+ /**
157
+ * Generate contextual me.md content
158
+ */
159
+ function generateContextualMeContent(context) {
160
+ const contextMessages = {
161
+ student: {
162
+ name: `${context.directory} Study Universe`,
163
+ tagline: 'AI-powered learning that actually works',
164
+ story: 'I use AI to master subjects faster and get better grades.',
165
+ voice: 'Encouraging, patient, and focused on learning success'
166
+ },
167
+ professional: {
168
+ name: `${context.directory} AI Workspace`,
169
+ tagline: 'Professional productivity amplified by AI',
170
+ story: 'I leverage AI agents to achieve professional goals efficiently.',
171
+ voice: 'Professional, efficient, and results-driven'
172
+ },
173
+ enterprise: {
174
+ name: `${context.directory} Enterprise Hub`,
175
+ tagline: 'Enterprise-scale AI collaboration',
176
+ story: 'We deploy AI at scale to transform business operations.',
177
+ voice: 'Strategic, scalable, and compliance-focused'
178
+ },
179
+ universal: {
180
+ name: `${context.directory} AI Universe`,
181
+ tagline: 'Building the future with AI',
182
+ story: 'I believe AI should amplify human potential.',
183
+ voice: 'Professional, helpful, engaging'
184
+ }
185
+ };
186
+
187
+ const config = contextMessages[context.type];
188
+
189
+ return `---
190
+ name: "${config.name}"
191
+ tagline: "${config.tagline}"
192
+ story: "${config.story}"
193
+
194
+ brand:
195
+ theme: professional
196
+ colors:
197
+ - "#2563EB"
198
+ - "#64748B"
199
+ - "#FFFFFF"
200
+ voice: "${config.voice}"
201
+ font: Inter
202
+ cursor: default
203
+
204
+ top_agents:
205
+ - slot: 1
206
+ name: "ARIA"
207
+ base: "personal-assistant"
208
+ role: "Personal Assistant & Digital Twin"
209
+ personality: "Your voice, optimized for productivity"
210
+ catchphrase: "I am you, but optimized"
211
+
212
+ spaces:
213
+ - id: "main"
214
+ title: "${config.name}"
215
+ vibe: "Productive workspace with AI superpowers"
216
+ public: false
217
+ features:
218
+ - agents
219
+ - missions
220
+
221
+ goals:
222
+ - "Master the ONE system"
223
+ - "Achieve my objectives with AI"
224
+
225
+ style:
226
+ profile_song: false
227
+ visitor_counter: false
228
+ guestbook: false
229
+ animations: subtle
230
+ widgets:
231
+ - top_8_agents
232
+ ---
233
+
234
+ # About Me
235
+
236
+ ${config.story}
237
+
238
+ My AI agents aren't just tools—they're intelligent collaborators trained to help me succeed. Together, we turn simple blocks into extraordinary results.
239
+
240
+ Welcome to my universe. Let's build something amazing.
241
+ `;
242
+ }
243
+
244
+ /**
245
+ * Setup command interface for /one
246
+ */
247
+ async function setupCommandInterface() {
248
+ // Create a simple, self-contained command script
249
+ const commandScript = path.join(process.cwd(), '.one', 'one-command.js');
250
+
251
+ const scriptContent = `#!/usr/bin/env node
252
+
253
+ // ONE Mission Control Dashboard
254
+ console.log(\`
255
+ ╔══════════════════════════════════════════════════════════════════════════════╗
256
+ ║ ║
257
+ ║ 🌟 ONE MISSION CONTROL - Your AI Universe Dashboard ║
258
+ ║ Simple blocks. Infinite possibilities. ║
259
+ ║ ║
260
+ ╚══════════════════════════════════════════════════════════════════════════════╝
261
+
262
+ 📊 MISSION STATUS: Active (\${new Date().toLocaleDateString()})
263
+
264
+ 🎯 SPECIALIZED TEAMS:
265
+ 📊 Research Team - Market intelligence & analysis
266
+ 📝 Content Team - Content creation & management
267
+ 📈 Marketing Team - Growth & engagement strategies
268
+ 💼 Sales Team - Revenue & conversion optimization
269
+ 🎧 Service Team - Customer success & support
270
+ 🎨 Design Team - Visual identity & user experience
271
+ ⚡ Engineering Team - Technical implementation & architecture
272
+ 🎓 Education Team - Learning & knowledge management
273
+ 🕵️ Intelligence Team - Strategic insights & competitive analysis
274
+
275
+ 🚀 CASCADE COMMANDERS:
276
+ /commander - Mission Commander (Strategic Planning Specialist)
277
+ /storyteller - Story Teller (Engineering Narrative Expert)
278
+ /taskmaster - Task Master (Execution Coordination Master)
279
+
280
+ 💡 QUICK ACTIONS:
281
+ me validate - Validate your digital DNA
282
+ me generate - Regenerate universe from me.md
283
+ me sample - Generate sample configurations
284
+
285
+ 📁 YOUR UNIVERSE:
286
+ 📄 Digital DNA: one/me/me.md
287
+ 🎯 Missions: one/missions/
288
+ 📖 Stories: one/stories/
289
+ ✅ Tasks: one/tasks/
290
+ 🤖 Agents: one/agents/
291
+
292
+ ✨ Your AI universe is operational! Edit one/me/me.md to customize.
293
+ \`);
294
+ `;
295
+
296
+ await fs.writeFile(commandScript, scriptContent, 'utf8');
297
+ await fs.chmod(commandScript, '755');
298
+ }
299
+
300
+ /**
301
+ * Validate the installation
302
+ */
303
+ async function validateInstallation() {
304
+ const checks = [
305
+ { name: 'ONE directory', path: 'one', type: 'directory' },
306
+ { name: 'System directory', path: '.one', type: 'directory' },
307
+ { name: 'Me file', path: 'one/me/me.md', type: 'file' },
308
+ { name: 'Command interface', path: '.one/one-command.js', type: 'file' }
309
+ ];
310
+
311
+ const results = [];
312
+
313
+ for (const check of checks) {
314
+ const fullPath = path.join(process.cwd(), check.path);
315
+ const exists = await fs.pathExists(fullPath);
316
+ const stat = exists ? await fs.stat(fullPath) : null;
317
+
318
+ const isValid = exists && (
319
+ (check.type === 'directory' && stat.isDirectory()) ||
320
+ (check.type === 'file' && stat.isFile())
321
+ );
322
+
323
+ results.push({
324
+ name: check.name,
325
+ path: check.path,
326
+ valid: isValid,
327
+ exists
328
+ });
329
+ }
330
+
331
+ return results;
332
+ }
333
+
334
+ /**
335
+ * Show success message and next steps
336
+ */
337
+ async function showSuccessMessage(context, validation) {
338
+ console.log(chalk.green('\n🎉 Installation Complete!'));
339
+
340
+ // Show validation results
341
+ console.log(chalk.cyan('\n📋 Installation Summary:'));
342
+ for (const result of validation) {
343
+ const icon = result.valid ? '✅' : '❌';
344
+ console.log(` ${icon} ${result.name}`);
345
+ }
346
+
347
+ const failedChecks = validation.filter(r => !r.valid);
348
+ if (failedChecks.length > 0) {
349
+ console.log(chalk.yellow('\n⚠️ Some components may need attention:'));
350
+ for (const failed of failedChecks) {
351
+ console.log(` ${failed.name}: ${failed.path}`);
352
+ }
353
+ }
354
+
355
+ // Next steps based on context
356
+ console.log(chalk.magenta('\n🚀 Next Steps:'));
357
+
358
+ if (context.type === 'student') {
359
+ console.log(' 1. 📚 Start with: "Create study plan for [subject]"');
360
+ console.log(' 2. 🤖 Your AI study buddy is ready in: one/agents/');
361
+ console.log(' 3. ✅ Track progress with missions and tasks');
362
+ } else if (context.type === 'professional') {
363
+ console.log(' 1. 🎯 Edit your goals in: one/me/me.md');
364
+ console.log(' 2. 🚀 Create your first mission');
365
+ console.log(' 3. 🤖 Your AI team is ready to help');
366
+ } else {
367
+ console.log(' 1. ✏️ Customize your AI: one/me/me.md');
368
+ console.log(' 2. 🎯 Create your first mission');
369
+ console.log(' 3. 🤖 Start collaborating with AI agents');
370
+ }
371
+
372
+ console.log(chalk.cyan('\n💡 Key Files:'));
373
+ console.log(` 📄 Your DNA: ${chalk.yellow('one/me/me.md')}`);
374
+ console.log(` 🎯 Missions: ${chalk.yellow('one/missions/')}`);
375
+ console.log(` 📖 Stories: ${chalk.yellow('one/stories/')}`);
376
+ console.log(` 🤖 Agents: ${chalk.yellow('one/agents/')}`);
377
+
378
+ console.log(chalk.green('\n✨ Your AI universe is ready!'));
379
+ console.log(chalk.magenta('\n🎮 Ready to start? Try these commands:'));
380
+ console.log(chalk.cyan(' me validate ') + chalk.gray('# Validate your me.md configuration'));
381
+ console.log(chalk.cyan(' me generate ') + chalk.gray('# Generate your universe from me.md'));
382
+ console.log(chalk.cyan(' node .one/one-command.js ') + chalk.gray('# Launch mission control dashboard'));
383
+
384
+ console.log(chalk.yellow('\n💡 Pro tip: ') + 'Edit one/me/me.md to customize your AI universe, then run "me generate"');
385
+ }
386
+
387
+ /**
388
+ * Show troubleshooting help
389
+ */
390
+ function showTroubleshootingHelp(error) {
391
+ console.log(chalk.yellow('\n🔧 Troubleshooting:'));
392
+ console.log(' • Ensure Node.js 18+ is installed');
393
+ console.log(' • Check write permissions in current directory');
394
+ console.log(' • Ensure sufficient disk space');
395
+
396
+ if (error.code === 'EACCES') {
397
+ console.log(' • Permission denied - try running as administrator');
398
+ } else if (error.code === 'ENOSPC') {
399
+ console.log(' • Insufficient disk space');
400
+ } else if (error.code === 'ENOTDIR') {
401
+ console.log(' • Invalid directory structure');
402
+ }
403
+
404
+ console.log('\n💬 Need help? Visit: https://one.ie/help');
405
+ }
406
+
407
+ // Utilities
408
+ function sleep(ms) {
409
+ return new Promise(resolve => setTimeout(resolve, ms));
410
+ }
411
+
412
+ function promisify(fn) {
413
+ return (...args) => new Promise((resolve, reject) => {
414
+ fn(...args, (err, result) => {
415
+ if (err) reject(err);
416
+ else resolve(result);
417
+ });
418
+ });
419
+ }
420
+
421
+ // Run installer
422
+ main().catch(error => {
423
+ console.error(chalk.red('\n💥 Fatal error:'), error);
424
+ process.exit(1);
425
+ });