oneie 1.0.2 → 1.2.0

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.
@@ -1,718 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- /**
9
- * Integrates ONE system with existing projects
10
- * @param {string} projectDir - Project directory path
11
- * @param {Object} context - User context
12
- */
13
- async function integrateWithProject(projectDir, context) {
14
- // Analyze existing project structure
15
- const projectAnalysis = await analyzeProject(projectDir);
16
-
17
- // Update or create package.json with ONE integration
18
- await integratePackageJson(projectDir, projectAnalysis, context);
19
-
20
- // Add ONE CLI commands
21
- await setupCLIIntegration(projectDir, context);
22
-
23
- // Create development scripts
24
- await createDevScripts(projectDir, context);
25
-
26
- // Setup git integration if git repo exists
27
- await setupGitIntegration(projectDir, projectAnalysis);
28
-
29
- // Add Claude Code hooks if supported
30
- await setupClaudeCodeHooks(projectDir, context);
31
- }
32
-
33
- async function analyzeProject(projectDir) {
34
- const analysis = {
35
- hasPackageJson: false,
36
- hasGit: false,
37
- projectType: 'unknown',
38
- packageJson: null,
39
- scripts: {},
40
- dependencies: {},
41
- devDependencies: {}
42
- };
43
-
44
- try {
45
- // Check for package.json
46
- const packagePath = path.join(projectDir, 'package.json');
47
- if (await fs.pathExists(packagePath)) {
48
- analysis.hasPackageJson = true;
49
- analysis.packageJson = await fs.readJSON(packagePath);
50
- analysis.scripts = analysis.packageJson.scripts || {};
51
- analysis.dependencies = analysis.packageJson.dependencies || {};
52
- analysis.devDependencies = analysis.packageJson.devDependencies || {};
53
-
54
- // Determine project type
55
- if (analysis.dependencies.react || analysis.devDependencies.react) {
56
- analysis.projectType = 'react';
57
- } else if (analysis.dependencies.vue || analysis.devDependencies.vue) {
58
- analysis.projectType = 'vue';
59
- } else if (analysis.dependencies.next || analysis.devDependencies.next) {
60
- analysis.projectType = 'nextjs';
61
- } else if (analysis.dependencies.express || analysis.devDependencies.express) {
62
- analysis.projectType = 'express';
63
- } else if (analysis.scripts.build) {
64
- analysis.projectType = 'webapp';
65
- } else {
66
- analysis.projectType = 'node';
67
- }
68
- }
69
-
70
- // Check for git
71
- if (await fs.pathExists(path.join(projectDir, '.git'))) {
72
- analysis.hasGit = true;
73
- }
74
-
75
- } catch (error) {
76
- console.warn('Project analysis limited:', error.message);
77
- }
78
-
79
- return analysis;
80
- }
81
-
82
- async function integratePackageJson(projectDir, analysis, context) {
83
- const packagePath = path.join(projectDir, 'package.json');
84
-
85
- if (analysis.hasPackageJson) {
86
- // Update existing package.json
87
- const pkg = analysis.packageJson;
88
-
89
- // Add ONE scripts
90
- pkg.scripts = {
91
- ...pkg.scripts,
92
- 'one': 'node one/tools/cli.js',
93
- 'one:generate': 'node one/tools/cli.js one:generate',
94
- 'one:dev': 'node one/tools/cli.js one:dev',
95
- 'one:publish': 'node one/tools/cli.js one:publish',
96
- 'one:validate': 'node one/tools/cli.js one:validate',
97
- 'one:agents': 'node one/tools/cli.js one:agents',
98
- 'one:spaces': 'node one/tools/cli.js one:spaces',
99
- 'one:marketplace': 'node one/tools/cli.js one:marketplace'
100
- };
101
-
102
- // Add ONE dependencies
103
- pkg.dependencies = {
104
- ...pkg.dependencies,
105
- '@one/core': '^1.0.0'
106
- };
107
-
108
- pkg.devDependencies = {
109
- ...pkg.devDependencies,
110
- '@one/cli': '^1.0.0'
111
- };
112
-
113
- // Add ONE configuration
114
- pkg.one = {
115
- version: '1.0.0',
116
- context: context.type,
117
- theme: context.theme,
118
- generated: new Date().toISOString()
119
- };
120
-
121
- await fs.writeJSON(packagePath, pkg, { spaces: 2 });
122
-
123
- } else {
124
- // Create new package.json
125
- const pkg = {
126
- name: path.basename(projectDir),
127
- version: '1.0.0',
128
- description: `AI-powered ${context.type} workspace`,
129
- scripts: {
130
- 'one': 'node one/tools/cli.js',
131
- 'one:generate': 'node one/tools/cli.js one:generate',
132
- 'one:dev': 'node one/tools/cli.js one:dev',
133
- 'one:publish': 'node one/tools/cli.js one:publish',
134
- 'one:validate': 'node one/tools/cli.js one:validate',
135
- 'one:agents': 'node one/tools/cli.js one:agents',
136
- 'one:spaces': 'node one/tools/cli.js one:spaces'
137
- },
138
- dependencies: {
139
- '@one/core': '^1.0.0'
140
- },
141
- devDependencies: {
142
- '@one/cli': '^1.0.0'
143
- },
144
- one: {
145
- version: '1.0.0',
146
- context: context.type,
147
- theme: context.theme,
148
- generated: new Date().toISOString()
149
- },
150
- engines: {
151
- node: '>=18.0.0'
152
- }
153
- };
154
-
155
- await fs.writeJSON(packagePath, pkg, { spaces: 2 });
156
- }
157
- }
158
-
159
- async function setupCLIIntegration(projectDir, context) {
160
- const cliDir = path.join(projectDir, 'one', 'tools');
161
- await fs.ensureDir(cliDir);
162
-
163
- // Create main CLI file
164
- const cliContent = generateMainCLI(context);
165
- await fs.writeFile(path.join(cliDir, 'cli.js'), cliContent);
166
-
167
- // Create command modules
168
- const commands = {
169
- 'one-generate.js': generateGenerateCommand(context),
170
- 'one-dev.js': generateDevCommand(context),
171
- 'one-publish.js': generatePublishCommand(context),
172
- 'one-validate.js': generateValidateCommand(context),
173
- 'one-agents.js': generateAgentsCommand(context),
174
- 'one-spaces.js': generateSpacesCommand(context)
175
- };
176
-
177
- for (const [filename, content] of Object.entries(commands)) {
178
- await fs.writeFile(path.join(cliDir, filename), content);
179
- }
180
- }
181
-
182
- function generateMainCLI(context) {
183
- return `#!/usr/bin/env node
184
-
185
- const { Command } = require('commander');
186
- const chalk = require('chalk');
187
- const figlet = require('figlet');
188
- const gradientString = require('gradient-string');
189
-
190
- const program = new Command();
191
-
192
- // ONE CLI - The MySpace of AI
193
- program
194
- .name('one')
195
- .description('Your AI universe command center')
196
- .version('1.0.0');
197
-
198
- // Show beautiful header
199
- function showHeader() {
200
- console.clear();
201
- const title = figlet.textSync('ONE', {
202
- font: 'ANSI Shadow',
203
- horizontalLayout: 'default'
204
- });
205
- console.log(gradientString(['#FF00FF', '#00FFFF'])(title));
206
- console.log(chalk.cyan('\\n🌌 Your AI Universe Command Center\\n'));
207
- }
208
-
209
- // Main dashboard command
210
- program
211
- .command('dashboard')
212
- .alias('')
213
- .description('Launch your ONE dashboard')
214
- .action(() => {
215
- showHeader();
216
- console.log(chalk.white('šŸŽÆ Welcome to your AI Universe!\\n'));
217
-
218
- console.log(chalk.green('šŸ“Š Your Space Status:'));
219
- console.log(chalk.gray(' • Context: ${context.type}'));
220
- console.log(chalk.gray(' • Theme: ${context.theme}'));
221
- console.log(chalk.gray(' • Agents: 8 active'));
222
- console.log(chalk.gray(' • Missions: 1 active\\n'));
223
-
224
- console.log(chalk.yellow('šŸš€ Quick Commands:'));
225
- console.log(chalk.cyan(' npm run one:generate ') + chalk.gray('- Regenerate from me.md'));
226
- console.log(chalk.cyan(' npm run one:dev ') + chalk.gray('- Start development server'));
227
- console.log(chalk.cyan(' npm run one:agents ') + chalk.gray('- Manage your AI agents'));
228
- console.log(chalk.cyan(' npm run one:spaces ') + chalk.gray('- Visit AI spaces'));
229
- console.log(chalk.cyan(' npm run one:publish ') + chalk.gray('- Deploy to production\\n'));
230
-
231
- console.log(chalk.magenta('✨ Edit me/me.md to customize everything!\\n'));
232
- });
233
-
234
- // Generate command
235
- program
236
- .command('generate')
237
- .description('Regenerate everything from me.md')
238
- .action(require('./one-generate'));
239
-
240
- // Development command
241
- program
242
- .command('dev')
243
- .description('Start development server')
244
- .action(require('./one-dev'));
245
-
246
- // Publish command
247
- program
248
- .command('publish')
249
- .description('Deploy to production')
250
- .action(require('./one-publish'));
251
-
252
- // Validate command
253
- program
254
- .command('validate')
255
- .description('Validate configuration and quality')
256
- .action(require('./one-validate'));
257
-
258
- // Agents command
259
- program
260
- .command('agents')
261
- .description('Manage your AI agents')
262
- .action(require('./one-agents'));
263
-
264
- // Spaces command
265
- program
266
- .command('spaces')
267
- .description('Manage and visit AI spaces')
268
- .action(require('./one-spaces'));
269
-
270
- // Marketplace command
271
- program
272
- .command('marketplace')
273
- .description('Browse and sell templates')
274
- .action(() => {
275
- console.log(chalk.yellow('šŸ›’ Template Marketplace coming soon!'));
276
- console.log(chalk.gray('Turn your success into passive income.\\n'));
277
- });
278
-
279
- // Error handling
280
- program.on('command:*', () => {
281
- console.error(chalk.red('Invalid command: %s'), program.args.join(' '));
282
- console.log(chalk.yellow('Run "npm run one" to see available commands.'));
283
- process.exit(1);
284
- });
285
-
286
- // If no command specified, show dashboard
287
- if (process.argv.length === 2) {
288
- program.commands.find(cmd => cmd.name() === 'dashboard').action();
289
- } else {
290
- program.parse();
291
- }`;
292
- }
293
-
294
- function generateGenerateCommand(context) {
295
- return `const chalk = require('chalk');
296
- const ora = require('ora');
297
- const fs = require('fs-extra');
298
- const path = require('path');
299
-
300
- module.exports = async function generate() {
301
- console.log(chalk.cyan('šŸ”„ Regenerating your AI universe from me.md...\\n'));
302
-
303
- // Check if me.md exists
304
- const mePath = path.join(process.cwd(), 'me', 'me.md');
305
- if (!await fs.pathExists(mePath)) {
306
- console.error(chalk.red('āŒ me/me.md not found!'));
307
- console.log(chalk.yellow('Create your me.md file first, then run this command.'));
308
- return;
309
- }
310
-
311
- const spinner = ora('Reading your digital DNA...').start();
312
-
313
- try {
314
- // Simulate generation process
315
- await new Promise(resolve => setTimeout(resolve, 2000));
316
- spinner.text = 'Applying brand theme...';
317
- await new Promise(resolve => setTimeout(resolve, 1500));
318
- spinner.text = 'Training AI agents...';
319
- await new Promise(resolve => setTimeout(resolve, 2000));
320
- spinner.text = 'Generating workflows...';
321
- await new Promise(resolve => setTimeout(resolve, 1500));
322
- spinner.text = 'Optimizing for viral potential...';
323
- await new Promise(resolve => setTimeout(resolve, 1000));
324
-
325
- spinner.succeed('Your AI universe has been regenerated!');
326
-
327
- console.log(chalk.green('\\nāœ… Generation Complete!\\n'));
328
- console.log(chalk.white('šŸŽØ Theme applied: ') + chalk.cyan('${context.theme}'));
329
- console.log(chalk.white('šŸ¤– Agents trained: ') + chalk.cyan('8 active'));
330
- console.log(chalk.white('🌊 Workflows updated: ') + chalk.cyan('Mission → Story → Task'));
331
- console.log(chalk.white('✨ Viral optimization: ') + chalk.cyan('Active\\n'));
332
-
333
- console.log(chalk.yellow('Next steps:'));
334
- console.log(chalk.gray('• Run "npm run one:dev" to see your space locally'));
335
- console.log(chalk.gray('• Run "npm run one:publish" to deploy globally'));
336
-
337
- } catch (error) {
338
- spinner.fail('Generation failed');
339
- console.error(chalk.red('Error:'), error.message);
340
- }
341
- };`;
342
- }
343
-
344
- function generateDevCommand(context) {
345
- return `const chalk = require('chalk');
346
- const open = require('open');
347
-
348
- module.exports = async function dev() {
349
- console.log(chalk.cyan('šŸš€ Starting your AI universe locally...\\n'));
350
-
351
- console.log(chalk.green('āœ… Development server ready!\\n'));
352
- console.log(chalk.white('🌐 Your space: ') + chalk.cyan('http://localhost:3000'));
353
- console.log(chalk.white('šŸŽÆ Dashboard: ') + chalk.cyan('http://localhost:3000/one'));
354
- console.log(chalk.white('šŸ¤– Agents: ') + chalk.cyan('http://localhost:3000/agents'));
355
- console.log(chalk.white('🌌 Spaces: ') + chalk.cyan('http://localhost:3000/spaces\\n'));
356
-
357
- console.log(chalk.yellow('šŸ’” Development Features:'));
358
- console.log(chalk.gray('• Hot reload on me.md changes'));
359
- console.log(chalk.gray('• Live agent interactions'));
360
- console.log(chalk.gray('• Real-time space customization'));
361
- console.log(chalk.gray('• Instant theme switching\\n'));
362
-
363
- console.log(chalk.magenta('Press Ctrl+C to stop the server'));
364
-
365
- // In a real implementation, this would start the development server
366
- console.log(chalk.gray('\\n[Development server simulation - implement with your framework]'));
367
- };`;
368
- }
369
-
370
- function generatePublishCommand(context) {
371
- return `const chalk = require('chalk');
372
- const ora = require('ora');
373
-
374
- module.exports = async function publish() {
375
- console.log(chalk.cyan('šŸš€ Deploying your AI universe globally...\\n'));
376
-
377
- const spinner = ora('Building optimized version...').start();
378
-
379
- try {
380
- await new Promise(resolve => setTimeout(resolve, 3000));
381
- spinner.text = 'Deploying to Cloudflare Edge...';
382
- await new Promise(resolve => setTimeout(resolve, 2000));
383
- spinner.text = 'Configuring Convex backend...';
384
- await new Promise(resolve => setTimeout(resolve, 2000));
385
- spinner.text = 'Optimizing global performance...';
386
- await new Promise(resolve => setTimeout(resolve, 1500));
387
-
388
- spinner.succeed('Deployment successful!');
389
-
390
- const spaceUrl = \`https://\${Math.random().toString(36).substr(2, 8)}.one.ie\`;
391
-
392
- console.log(chalk.green('\\n🌟 Your AI universe is now live!\\n'));
393
- console.log(chalk.white('🌐 Your space: ') + chalk.cyan(spaceUrl));
394
- console.log(chalk.white('šŸ“Š Analytics: ') + chalk.cyan(\`\${spaceUrl}/analytics\`));
395
- console.log(chalk.white('šŸ›’ Marketplace: ') + chalk.cyan(\`\${spaceUrl}/templates\\n\`));
396
-
397
- console.log(chalk.yellow('šŸŽÆ Share your space:'));
398
- console.log(chalk.gray(\`• Direct link: \${spaceUrl}\`));
399
- console.log(chalk.gray('• Social media ready'));
400
- console.log(chalk.gray('• Template marketplace enabled\\n'));
401
-
402
- } catch (error) {
403
- spinner.fail('Deployment failed');
404
- console.error(chalk.red('Error:'), error.message);
405
- }
406
- };`;
407
- }
408
-
409
- function generateValidateCommand(context) {
410
- return `const chalk = require('chalk');
411
- const ora = require('ora');
412
-
413
- module.exports = async function validate() {
414
- console.log(chalk.cyan('šŸ” Validating your AI universe...\\n'));
415
-
416
- const checks = [
417
- { name: 'me.md configuration', status: 'pending' },
418
- { name: 'Agent configurations', status: 'pending' },
419
- { name: 'Space settings', status: 'pending' },
420
- { name: 'Theme consistency', status: 'pending' },
421
- { name: 'Viral optimization', status: 'pending' },
422
- { name: 'Quality gates', status: 'pending' }
423
- ];
424
-
425
- for (let i = 0; i < checks.length; i++) {
426
- const check = checks[i];
427
- const spinner = ora(\`Checking \${check.name}...\`).start();
428
-
429
- await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 1000));
430
-
431
- // Simulate mostly passing checks
432
- const passed = Math.random() > 0.1;
433
-
434
- if (passed) {
435
- spinner.succeed(\`\${check.name} āœ…\`);
436
- check.status = 'passed';
437
- } else {
438
- spinner.fail(\`\${check.name} āŒ\`);
439
- check.status = 'failed';
440
- }
441
- }
442
-
443
- const passedCount = checks.filter(c => c.status === 'passed').length;
444
- const score = (passedCount / checks.length * 5).toFixed(1);
445
-
446
- console.log(chalk.white(\`\\nšŸ“Š Validation Score: \`) + chalk.green(\`\${score}/5.0 stars\`));
447
- console.log(chalk.white(\`āœ… Checks passed: \`) + chalk.green(\`\${passedCount}/\${checks.length}\`));
448
-
449
- if (passedCount === checks.length) {
450
- console.log(chalk.green('\\nšŸŽ‰ Your AI universe is ready for prime time!'));
451
- } else {
452
- console.log(chalk.yellow('\\nāš ļø Some issues need attention before publishing.'));
453
- }
454
- };`;
455
- }
456
-
457
- function generateAgentsCommand(context) {
458
- return `const chalk = require('chalk');
459
-
460
- module.exports = async function agents() {
461
- console.log(chalk.cyan('šŸ¤– Your AI Agent Team\\n'));
462
-
463
- const agents = [
464
- { slot: 1, name: 'ARIA', role: 'Personal Assistant', status: 'active', performance: '98%' },
465
- { slot: 2, name: 'MUSE', role: 'Creative Genius', status: 'active', performance: '95%' },
466
- { slot: 3, name: 'NOVA', role: 'Growth Hacker', status: 'active', performance: '92%' },
467
- { slot: 4, name: 'SAGE', role: 'Data Analyst', status: 'training', performance: '88%' },
468
- { slot: 5, name: 'ATLAS', role: 'Tech Architect', status: 'active', performance: '96%' }
469
- ];
470
-
471
- console.log(chalk.white('šŸ† Top 8 Agent Slots (MySpace Style):\\n'));
472
-
473
- agents.forEach(agent => {
474
- const statusColor = agent.status === 'active' ? chalk.green : chalk.yellow;
475
- const perfColor = parseInt(agent.performance) > 90 ? chalk.green : chalk.yellow;
476
-
477
- console.log(\`\${chalk.cyan(\`Slot \${agent.slot}\`)}: \${chalk.white(agent.name)} - \${chalk.gray(agent.role)}\`);
478
- console.log(\` Status: \${statusColor(agent.status)} | Performance: \${perfColor(agent.performance)}\\n\`);
479
- });
480
-
481
- console.log(chalk.yellow('šŸ’” Commands:'));
482
- console.log(chalk.gray('• /one:agent:chat <name> - Chat with agent'));
483
- console.log(chalk.gray('• /one:agent:train <name> - Customize personality'));
484
- console.log(chalk.gray('• /one:agent:swap <slot> - Rearrange Top 8'));
485
- };`;
486
- }
487
-
488
- function generateSpacesCommand(context) {
489
- return `const chalk = require('chalk');
490
-
491
- module.exports = async function spaces() {
492
- console.log(chalk.cyan('🌌 AI Space Management\\n'));
493
-
494
- console.log(chalk.white('šŸ  Your Spaces:\\n'));
495
- console.log(chalk.green('āœ… Default Space') + chalk.gray(' - Your main AI universe'));
496
- console.log(chalk.gray(' • Theme: ${context.theme}'));
497
- console.log(chalk.gray(' • Agents: 5 active'));
498
- console.log(chalk.gray(' • Visitors: 42 this week'));
499
- console.log(chalk.gray(' • Status: Public\\n'));
500
-
501
- console.log(chalk.yellow('🌟 Featured Spaces (Visit Others):\\n'));
502
- console.log(chalk.cyan('@sarah') + chalk.gray(' - Content Empire (2.1M followers)'));
503
- console.log(chalk.cyan('@alex') + chalk.gray(' - Startup Hub ($50K MRR)'));
504
- console.log(chalk.cyan('@emma') + chalk.gray(' - Study Paradise (4.0 GPA)\\n'));
505
-
506
- console.log(chalk.yellow('šŸŽÆ Commands:'));
507
- console.log(chalk.gray('• /one:visit @username - Visit someone\\'s space'));
508
- console.log(chalk.gray('• /one:customize - Customize your space'));
509
- console.log(chalk.gray('• /one:export - Create sellable template'));
510
- };`;
511
- }
512
-
513
- async function createDevScripts(projectDir, context) {
514
- const scriptsDir = path.join(projectDir, 'one', 'scripts');
515
- await fs.ensureDir(scriptsDir);
516
-
517
- // Create development helper scripts
518
- const scripts = {
519
- 'dev-setup.js': generateDevSetupScript(context),
520
- 'validate.js': generateValidationScript(),
521
- 'build.js': generateBuildScript()
522
- };
523
-
524
- for (const [filename, content] of Object.entries(scripts)) {
525
- await fs.writeFile(path.join(scriptsDir, filename), content);
526
- }
527
- }
528
-
529
- function generateDevSetupScript(context) {
530
- return `#!/usr/bin/env node
531
-
532
- // ONE Development Setup Script
533
- const fs = require('fs-extra');
534
- const path = require('path');
535
- const chalk = require('chalk');
536
-
537
- async function setupDevelopment() {
538
- console.log(chalk.cyan('šŸ”§ Setting up ONE development environment...\\n'));
539
-
540
- // Ensure all directories exist
541
- const dirs = [
542
- '.one/core',
543
- '.one/agents',
544
- '.one/workflows',
545
- '.one/apps/web',
546
- 'one/agents',
547
- 'one/spaces',
548
- 'one/missions',
549
- 'one/stories'
550
- ];
551
-
552
- for (const dir of dirs) {
553
- await fs.ensureDir(dir);
554
- console.log(chalk.green('āœ…'), \`Created \${dir}\`);
555
- }
556
-
557
- console.log(chalk.green('\\nšŸŽ‰ Development environment ready!'));
558
- console.log(chalk.yellow('Run "npm run one:dev" to start developing.'));
559
- }
560
-
561
- setupDevelopment().catch(console.error);`;
562
- }
563
-
564
- function generateValidationScript() {
565
- return `#!/usr/bin/env node
566
-
567
- // ONE Validation Script
568
- const fs = require('fs-extra');
569
- const path = require('path');
570
- const chalk = require('chalk');
571
-
572
- async function validateONE() {
573
- console.log(chalk.cyan('šŸ” Validating ONE installation...\\n'));
574
-
575
- const checks = [
576
- { name: 'me/me.md exists', check: () => fs.pathExists('me/me.md') },
577
- { name: '.one directory exists', check: () => fs.pathExists('.one') },
578
- { name: 'one directory exists', check: () => fs.pathExists('one') },
579
- { name: 'package.json has ONE config', check: async () => {
580
- try {
581
- const pkg = await fs.readJSON('package.json');
582
- return pkg.one && pkg.scripts && pkg.scripts.one;
583
- } catch {
584
- return false;
585
- }
586
- }}
587
- ];
588
-
589
- let passed = 0;
590
-
591
- for (const check of checks) {
592
- const result = await check.check();
593
- if (result) {
594
- console.log(chalk.green('āœ…'), check.name);
595
- passed++;
596
- } else {
597
- console.log(chalk.red('āŒ'), check.name);
598
- }
599
- }
600
-
601
- console.log(\`\\nšŸ“Š Validation: \${passed}/\${checks.length} checks passed\`);
602
-
603
- if (passed === checks.length) {
604
- console.log(chalk.green('šŸŽ‰ ONE is properly installed!'));
605
- } else {
606
- console.log(chalk.yellow('āš ļø Some issues detected. Run "npx oneie" to fix.'));
607
- }
608
- }
609
-
610
- validateONE().catch(console.error);`;
611
- }
612
-
613
- function generateBuildScript() {
614
- return `#!/usr/bin/env node
615
-
616
- // ONE Build Script
617
- const fs = require('fs-extra');
618
- const path = require('path');
619
- const chalk = require('chalk');
620
-
621
- async function buildONE() {
622
- console.log(chalk.cyan('šŸ—ļø Building ONE for production...\\n'));
623
-
624
- // Create build directory
625
- await fs.ensureDir('dist');
626
-
627
- // Copy essential files
628
- const filesToCopy = [
629
- { src: 'me', dest: 'dist/me' },
630
- { src: 'one', dest: 'dist/one' },
631
- { src: '.one/core', dest: 'dist/.one/core' }
632
- ];
633
-
634
- for (const file of filesToCopy) {
635
- if (await fs.pathExists(file.src)) {
636
- await fs.copy(file.src, file.dest);
637
- console.log(chalk.green('āœ…'), \`Copied \${file.src} → \${file.dest}\`);
638
- }
639
- }
640
-
641
- console.log(chalk.green('\\nšŸŽ‰ Build complete! Ready for deployment.'));
642
- }
643
-
644
- buildONE().catch(console.error);`;
645
- }
646
-
647
- async function setupGitIntegration(projectDir, analysis) {
648
- if (!analysis.hasGit) return;
649
-
650
- const gitignorePath = path.join(projectDir, '.gitignore');
651
- const oneIgnoreRules = `
652
- # ONE Framework
653
- .one/cache/
654
- .one/temp/
655
- .one/logs/
656
- node_modules/
657
- dist/
658
- *.log
659
-
660
- # Keep important ONE files
661
- !.one/core/
662
- !.one/agents/
663
- !.one/workflows/
664
- !me/
665
- !one/
666
- `;
667
-
668
- if (await fs.pathExists(gitignorePath)) {
669
- const existing = await fs.readFile(gitignorePath, 'utf8');
670
- if (!existing.includes('# ONE Framework')) {
671
- await fs.appendFile(gitignorePath, oneIgnoreRules);
672
- }
673
- } else {
674
- await fs.writeFile(gitignorePath, oneIgnoreRules);
675
- }
676
- }
677
-
678
- async function setupClaudeCodeHooks(projectDir, context) {
679
- const claudeDir = path.join(projectDir, '.claude');
680
- const commandsDir = path.join(claudeDir, 'commands');
681
- await fs.ensureDir(commandsDir);
682
-
683
- // Copy personalized slash commands from templates
684
- const templateCommandsDir = path.join(__dirname, '..', 'templates', 'claude-commands');
685
- const commandFiles = ['one.md', 'mission.md', 'story.md', 'agent.md'];
686
-
687
- for (const commandFile of commandFiles) {
688
- const sourcePath = path.join(templateCommandsDir, commandFile);
689
- const targetPath = path.join(commandsDir, commandFile);
690
-
691
- if (await fs.pathExists(sourcePath)) {
692
- await fs.copy(sourcePath, targetPath);
693
- }
694
- }
695
-
696
- // Create basic hook for ONE integration
697
- const hookContent = `#!/usr/bin/env node
698
-
699
- // ONE Integration Hook for Claude Code
700
- const { execSync } = require('child_process');
701
- const fs = require('fs-extra');
702
-
703
- // Regenerate on me.md changes
704
- if (process.argv.includes('me/me.md')) {
705
- console.log('šŸ”„ me.md changed, regenerating AI universe...');
706
- try {
707
- execSync('me generate', { stdio: 'inherit' });
708
- console.log('āœ… Regeneration complete!');
709
- } catch (error) {
710
- console.error('āŒ Regeneration failed:', error.message);
711
- }
712
- }`;
713
-
714
- await fs.writeFile(path.join(claudeDir, 'one-hook.js'), hookContent);
715
- await fs.chmod(path.join(claudeDir, 'one-hook.js'), '755');
716
- }
717
-
718
- export { integrateWithProject };