maiass 5.8.9 → 5.9.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/README.md CHANGED
@@ -48,7 +48,7 @@ maiass --dry-run
48
48
  ```bash
49
49
  # Enable AI features
50
50
  maiass config set maiass_token "your_api_key"
51
- maiass config set ai_mode "ask"
51
+ maiass config set ai_mode "ask" (or "always" or "off")
52
52
 
53
53
  # MAIASS will now suggest intelligent commit messages
54
54
  maiass
package/lib/bootstrap.js CHANGED
@@ -158,6 +158,11 @@ export async function bootstrapProject() {
158
158
  // Step 7: Save configuration
159
159
  await saveConfiguration(config);
160
160
 
161
+ // Step 8: Initialize branch structure if needed (full mode only)
162
+ if (config.features === 'full') {
163
+ await initializeBranchStructure(config.branches);
164
+ }
165
+
161
166
  console.log('');
162
167
  log.success(SYMBOLS.CHECKMARK, 'Project setup complete!');
163
168
  log.info(SYMBOLS.INFO, 'You can modify these settings anytime by editing .env.maiass');
@@ -534,6 +539,119 @@ MAIASS_STAGINGBRANCH=${config.branches.staging}
534
539
  await ensureGitignore();
535
540
  }
536
541
 
542
+ /**
543
+ * Step 8: Initialize branch structure for new repositories
544
+ */
545
+ async function initializeBranchStructure(branchConfig) {
546
+ const { execSync } = await import('child_process');
547
+
548
+ // Check if we're in a git repo
549
+ try {
550
+ execSync('git rev-parse --is-inside-work-tree', { stdio: 'pipe' });
551
+ } catch {
552
+ // Not a git repo, skip
553
+ return;
554
+ }
555
+
556
+ // Check if there are any commits
557
+ let hasCommits = false;
558
+ try {
559
+ execSync('git rev-parse HEAD', { stdio: 'pipe' });
560
+ hasCommits = true;
561
+ } catch {
562
+ // No commits yet
563
+ hasCommits = false;
564
+ }
565
+
566
+ // If there are already commits, check if develop branch exists
567
+ if (hasCommits) {
568
+ try {
569
+ execSync(`git rev-parse --verify ${branchConfig.develop}`, { stdio: 'pipe' });
570
+ // Develop branch exists, nothing to do
571
+ return;
572
+ } catch {
573
+ // Develop branch doesn't exist, offer to create it
574
+ console.log('');
575
+ console.log(colors.BCyan('🌿 Branch Structure Setup'));
576
+ console.log('');
577
+ console.log(`${SYMBOLS.INFO} Your repository has commits but no ${colors.BGreen(branchConfig.develop)} branch.`);
578
+ console.log(`${SYMBOLS.INFO} MAIASS works best with a ${colors.BGreen(branchConfig.develop)} branch for version management.`);
579
+ console.log('');
580
+
581
+ const createBranch = await getSingleCharInput(`Create ${branchConfig.develop} branch from current branch? [Y/n]: `);
582
+ if (createBranch !== 'n') {
583
+ try {
584
+ execSync(`git checkout -b ${branchConfig.develop}`, { stdio: 'inherit' });
585
+ log.success(SYMBOLS.CHECKMARK, `Created and switched to ${colors.BGreen(branchConfig.develop)} branch`);
586
+ } catch (error) {
587
+ log.warning(SYMBOLS.WARNING, `Could not create ${branchConfig.develop} branch: ${error.message}`);
588
+ }
589
+ }
590
+ return;
591
+ }
592
+ }
593
+
594
+ // No commits yet - this is a brand new repo
595
+ console.log('');
596
+ console.log(colors.BCyan('🌿 Branch Structure Setup'));
597
+ console.log('');
598
+ console.log(`${SYMBOLS.INFO} This appears to be a new repository with no commits yet.`);
599
+ console.log(`${SYMBOLS.INFO} MAIASS can set up the recommended branch structure for you:`);
600
+ console.log('');
601
+ console.log(` 1. Create initial commit on ${colors.BGreen(branchConfig.main)} branch`);
602
+ console.log(` 2. Create ${colors.BGreen(branchConfig.develop)} branch from ${branchConfig.main}`);
603
+ console.log(` 3. Switch to ${colors.BGreen(branchConfig.develop)} for development`);
604
+ console.log('');
605
+ console.log(colors.Gray('This ensures MAIASS has the proper branch structure for version management.'));
606
+ console.log('');
607
+
608
+ const setupBranches = await getSingleCharInput('Set up branch structure now? [Y/n]: ');
609
+ if (setupBranches === 'n') {
610
+ log.info(SYMBOLS.INFO, 'Skipping branch setup. You can create branches manually later.');
611
+ return;
612
+ }
613
+
614
+ try {
615
+ // Check if we're on a branch or in detached HEAD
616
+ let currentBranch;
617
+ try {
618
+ currentBranch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8', stdio: 'pipe' }).trim();
619
+ } catch {
620
+ currentBranch = null;
621
+ }
622
+
623
+ // If not on a branch or on wrong branch, create/switch to main
624
+ if (!currentBranch || currentBranch === 'HEAD' || currentBranch !== branchConfig.main) {
625
+ log.info(SYMBOLS.INFO, `Creating ${colors.BGreen(branchConfig.main)} branch...`);
626
+ execSync(`git checkout -b ${branchConfig.main}`, { stdio: 'pipe' });
627
+ }
628
+
629
+ // Create initial commit with the config files
630
+ log.info(SYMBOLS.INFO, 'Creating initial commit...');
631
+ execSync('git add .env.maiass .env.maiass.local .gitignore', { stdio: 'pipe' });
632
+ execSync('git commit -m "Initial commit: MAIASS configuration"', { stdio: 'inherit' });
633
+ log.success(SYMBOLS.CHECKMARK, `Initial commit created on ${colors.BGreen(branchConfig.main)}`);
634
+
635
+ // Create develop branch
636
+ log.info(SYMBOLS.INFO, `Creating ${colors.BGreen(branchConfig.develop)} branch...`);
637
+ execSync(`git checkout -b ${branchConfig.develop}`, { stdio: 'pipe' });
638
+ log.success(SYMBOLS.CHECKMARK, `Created and switched to ${colors.BGreen(branchConfig.develop)} branch`);
639
+
640
+ console.log('');
641
+ log.success(SYMBOLS.CHECKMARK, 'Branch structure initialized successfully!');
642
+ log.info(SYMBOLS.INFO, `You are now on the ${colors.BGreen(branchConfig.develop)} branch and ready to start development.`);
643
+
644
+ } catch (error) {
645
+ console.log('');
646
+ log.warning(SYMBOLS.WARNING, 'Could not automatically set up branch structure');
647
+ log.info(SYMBOLS.INFO, 'You can create branches manually:');
648
+ console.log(` ${colors.Gray(`git checkout -b ${branchConfig.main}`)}`);
649
+ console.log(` ${colors.Gray('git add .')}`);
650
+ console.log(` ${colors.Gray('git commit -m "Initial commit"')}`);
651
+ console.log(` ${colors.Gray(`git checkout -b ${branchConfig.develop}`)}`);
652
+ }
653
+ }
654
+
537
655
  /**
538
656
  * Ensure .gitignore includes necessary patterns
539
657
  */
@@ -551,6 +551,12 @@ async function handleMergeToDevelop(branchInfo, commitResult, options = {}) {
551
551
  const { force = false, silent = false, originalGitInfo = null, autoSwitch = true, versionBump = null, tag = false } = options;
552
552
  const { currentBranch, developBranch, originalBranch } = branchInfo;
553
553
 
554
+ // If no current branch (new repo with no commits), skip merge
555
+ if (!currentBranch || currentBranch === 'null') {
556
+ log.blue(SYMBOLS.INFO, 'New repository with no branch yet, skipping merge workflow');
557
+ return { success: true, skipped: true, newRepo: true };
558
+ }
559
+
554
560
  // If we're already on develop or this was commits-only, skip merge
555
561
  if (currentBranch === developBranch || originalBranch === developBranch) {
556
562
  log.blue(SYMBOLS.INFO, `Already on ${developBranch} branch, skipping merge`);
package/maiass.mjs CHANGED
@@ -51,6 +51,7 @@ if (args.includes('--setup') || args.includes('--bootstrap')) {
51
51
 
52
52
  // Check if first argument is a version bump type
53
53
  const versionBumpTypes = ['major', 'minor', 'patch'];
54
+ const validCommands = ['hello', 'env', 'git-info', 'config', 'version', 'account-info', 'maiass', 'help'];
54
55
  let command = 'maiass'; // Default to maiass workflow
55
56
  let versionBump = null;
56
57
 
@@ -59,10 +60,22 @@ if (firstArg && versionBumpTypes.includes(firstArg)) {
59
60
  versionBump = firstArg;
60
61
  command = 'maiass';
61
62
  } else if (firstArg && !firstArg.startsWith('-')) {
62
- // First arg is a command
63
+ // First arg is a command - validate it
64
+ if (!validCommands.includes(firstArg)) {
65
+ console.error(colors.Red(`${SYMBOLS.CROSS} Error: Unknown command '${firstArg}'`));
66
+ console.log('');
67
+ console.log('Valid commands:');
68
+ console.log(' ' + validCommands.join(', '));
69
+ console.log('');
70
+ console.log('Version bump types:');
71
+ console.log(' ' + versionBumpTypes.join(', '));
72
+ console.log('');
73
+ console.log(`Run 'nma --help' for more information.`);
74
+ process.exit(1);
75
+ }
63
76
  command = firstArg;
64
- } else {
65
- // No command specified or starts with flag, default to maiass
77
+ } else if (!firstArg) {
78
+ // No command specified, default to maiass
66
79
  command = 'maiass';
67
80
  }
68
81
 
@@ -85,6 +98,54 @@ if (args.includes('--version') || args.includes('-v')) {
85
98
  process.exit(0);
86
99
  }
87
100
 
101
+ // Handle --account-info flag (before help to allow it to work)
102
+ if (args.includes('--account-info')) {
103
+ command = 'account-info';
104
+ }
105
+
106
+ // Validate flags - check for unrecognized options
107
+ const validFlags = [
108
+ '--help', '-h',
109
+ '--version', '-v',
110
+ '--account-info',
111
+ '--auto', '-a',
112
+ '--commits-only', '-c',
113
+ '--auto-stage',
114
+ '--setup', '--bootstrap',
115
+ '--dry-run', '-d',
116
+ '--force', '-f',
117
+ '--silent', '-s',
118
+ '--json',
119
+ '--tag', '-t'
120
+ ];
121
+
122
+ // Check for unrecognized flags
123
+ for (const arg of args) {
124
+ if (arg.startsWith('-')) {
125
+ // Check if it's a flag with value (e.g., --tag=value or --tag value)
126
+ const flagName = arg.split('=')[0];
127
+ if (!validFlags.includes(flagName) && !validFlags.includes(arg)) {
128
+ console.error(colors.Red(`${SYMBOLS.CROSS} Error: Unrecognized option '${arg}'`));
129
+ console.log('');
130
+ console.log('Valid flags:');
131
+ // Group flags by category for better readability
132
+ const helpFlags = validFlags.filter(f => f.includes('help') || f.includes('version'));
133
+ const commandFlags = validFlags.filter(f => f.includes('account') || f.includes('setup') || f.includes('bootstrap'));
134
+ const workflowFlags = validFlags.filter(f => !helpFlags.includes(f) && !commandFlags.includes(f));
135
+
136
+ console.log(' Help & Info:');
137
+ console.log(' ' + helpFlags.join(', '));
138
+ console.log(' Commands:');
139
+ console.log(' ' + commandFlags.join(', '));
140
+ console.log(' Workflow Options:');
141
+ console.log(' ' + workflowFlags.join(', '));
142
+ console.log('');
143
+ console.log(`Run 'nma --help' for detailed information.`);
144
+ process.exit(1);
145
+ }
146
+ }
147
+ }
148
+
88
149
  // Handle help flag
89
150
  if (args.includes('--help') || args.includes('-h') || command === 'help') {
90
151
  console.log(`\nMAIASS v${version}`);
@@ -102,6 +163,7 @@ if (args.includes('--help') || args.includes('-h') || command === 'help') {
102
163
  console.log(' version Manage version information');
103
164
  console.log(' account-info Show your account status (masked token)');
104
165
  console.log('\nOptions:');
166
+ console.log(' --account-info Show your account status (masked token)');
105
167
  console.log(' --auto Enable all auto-yes functionality (non-interactive mode)');
106
168
  console.log(' --commits-only, -c Generate AI commits without version management');
107
169
  console.log(' --auto-stage Automatically stage all changes');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maiass",
3
3
  "type": "module",
4
- "version": "5.8.9",
4
+ "version": "5.9.1",
5
5
  "description": "MAIASS - Modular AI-Augmented Semantic Scribe - Intelligent Git workflow automation",
6
6
  "main": "maiass.mjs",
7
7
  "bin": {