maiass 5.9.7 → 5.9.10

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/lib/commit.js CHANGED
@@ -1002,6 +1002,7 @@ export async function commitThis(options = {}) {
1002
1002
 
1003
1003
  // Export individual functions for testing and reuse
1004
1004
  export {
1005
+ createAnonymousSubscriptionIfNeeded,
1005
1006
  getCommitMessage,
1006
1007
  handleStagedCommit,
1007
1008
  getAICommitSuggestion,
@@ -1,6 +1,7 @@
1
1
  import { log, logger } from './logger.js';
2
2
  import { SYMBOLS } from './symbols.js';
3
3
  import { runMaiassPipeline } from './maiass-pipeline.js';
4
+ import { createAnonymousSubscriptionIfNeeded } from './commit.js';
4
5
  import colors from './colors.js';
5
6
 
6
7
  /**
@@ -33,6 +34,13 @@ export async function handleMaiassCommand(args) {
33
34
  logger.header('', 'MAIASS - Modular AI-Assisted Semantic Scribe');
34
35
 
35
36
  try {
37
+ // Create anonymous subscription if needed (matches bashmaiass behavior)
38
+ // This ensures free credits are allocated on first run
39
+ const aiMode = process.env.MAIASS_AI_MODE || 'ask';
40
+ if (aiMode !== 'off') {
41
+ await createAnonymousSubscriptionIfNeeded();
42
+ }
43
+
36
44
  // Run the complete MAIASS pipeline
37
45
  const result = await runMaiassPipeline({
38
46
  commitsOnly,
@@ -516,21 +516,96 @@ function updateWordPressVersions(newVersion, projectPath = process.cwd()) {
516
516
  }
517
517
 
518
518
  /**
519
- * Detect version files in the current directory
519
+ * Extract version from a file using type and line-start pattern (matches bashmaiass behavior)
520
+ * @param {string} content - File content
521
+ * @param {string} type - File type: 'json', 'txt', 'text', 'php', 'pattern'
522
+ * @param {string} lineStart - Line start pattern for txt type
523
+ * @returns {string|null} Extracted version or null
524
+ */
525
+ function extractVersionByType(content, type, lineStart) {
526
+ if (type === 'json') {
527
+ return VERSION_FILE_TYPES.json.extract(content);
528
+ }
529
+
530
+ if (type === 'txt' || type === 'text') {
531
+ if (lineStart) {
532
+ for (const line of content.split('\n')) {
533
+ if (line.trim().startsWith(lineStart)) {
534
+ const match = line.match(/(\d+\.\d+\.\d+)/);
535
+ if (match) return match[1];
536
+ }
537
+ }
538
+ return null;
539
+ }
540
+ return VERSION_FILE_TYPES.text.extract(content);
541
+ }
542
+
543
+ if (type === 'php' || type === 'pattern') {
544
+ return VERSION_FILE_TYPES.php.extract(content);
545
+ }
546
+
547
+ // Unknown type - try generic version extraction
548
+ const match = content.match(/(\d+\.\d+\.\d+)/);
549
+ return match ? match[1] : null;
550
+ }
551
+
552
+ /**
553
+ * Detect version files in the current directory.
554
+ * Checks MAIASS_VERSION_PRIMARY_FILE env var first (from .env.maiass),
555
+ * then falls back to scanning common version file patterns.
520
556
  * @param {string} projectPath - Path to project directory
521
557
  * @returns {Array} Array of detected version files
522
558
  */
523
559
  export function detectVersionFiles(projectPath = process.cwd()) {
524
560
  const versionFiles = [];
525
561
 
526
- // Common version file patterns to check
562
+ // Check for custom primary version file from .env.maiass first
563
+ const primaryFile = process.env.MAIASS_VERSION_PRIMARY_FILE;
564
+ const primaryType = process.env.MAIASS_VERSION_PRIMARY_TYPE || 'txt';
565
+ const primaryLineStart = process.env.MAIASS_VERSION_PRIMARY_LINE_START || '';
566
+
567
+ if (primaryFile) {
568
+ logger.debug(`Custom primary version file configured: ${primaryFile} (type: ${primaryType})`);
569
+ const filePath = path.isAbsolute(primaryFile)
570
+ ? primaryFile
571
+ : path.join(projectPath, primaryFile);
572
+
573
+ if (fs.existsSync(filePath)) {
574
+ try {
575
+ const content = fs.readFileSync(filePath, 'utf8');
576
+ const version = extractVersionByType(content, primaryType, primaryLineStart);
577
+
578
+ if (version) {
579
+ logger.debug(`Found version ${version} in custom primary file: ${primaryFile}`);
580
+ versionFiles.push({
581
+ path: filePath,
582
+ filename: path.basename(filePath),
583
+ type: primaryType,
584
+ currentVersion: version,
585
+ content,
586
+ isPrimary: true,
587
+ lineStart: primaryLineStart
588
+ });
589
+ return versionFiles;
590
+ } else {
591
+ logger.warning(SYMBOLS.WARNING, `Could not extract version from custom primary file: ${primaryFile}`);
592
+ }
593
+ } catch (error) {
594
+ logger.error(SYMBOLS.CROSS, `Error reading custom primary version file ${primaryFile}: ${error.message}`);
595
+ }
596
+ } else {
597
+ logger.warning(SYMBOLS.WARNING, `Custom primary version file not found: ${filePath}`);
598
+ }
599
+ }
600
+
601
+ // Fallback: scan common version file patterns in project root
527
602
  const filesToCheck = [
528
603
  'package.json',
529
604
  'composer.json',
530
605
  'VERSION',
531
606
  'version.txt',
532
- 'style.css', // WordPress themes
533
- 'plugin.php', // WordPress plugins
607
+ 'style.css',
608
+ 'plugin.php',
534
609
  'functions.php'
535
610
  ];
536
611
 
@@ -542,7 +617,6 @@ export function detectVersionFiles(projectPath = process.cwd()) {
542
617
  const content = fs.readFileSync(filePath, 'utf8');
543
618
  const ext = path.extname(filename);
544
619
 
545
- // Determine file type and check if it contains version info
546
620
  for (const [typeName, typeConfig] of Object.entries(VERSION_FILE_TYPES)) {
547
621
  if (typeConfig.extensions.includes(ext) || typeConfig.extensions.includes('')) {
548
622
  if (typeConfig.detect(content, filename)) {
@@ -555,13 +629,12 @@ export function detectVersionFiles(projectPath = process.cwd()) {
555
629
  currentVersion: version,
556
630
  content
557
631
  });
558
- break; // Found matching type, move to next file
632
+ break;
559
633
  }
560
634
  }
561
635
  }
562
636
  }
563
637
  } catch (error) {
564
- // Skip files that can't be read
565
638
  continue;
566
639
  }
567
640
  }
@@ -603,18 +676,24 @@ export async function getCurrentVersion(projectPath = process.cwd()) {
603
676
  let primaryVersion = null;
604
677
  let primarySource = null;
605
678
 
606
- // Prioritize package.json if it exists
607
- const packageJson = versionFiles.find(f => f.filename === 'package.json');
608
- if (packageJson) {
609
- primaryVersion = packageJson.currentVersion;
610
- primarySource = 'package.json';
611
- } else if (versionFiles.length > 0) {
612
- // Use first detected version file
613
- primaryVersion = versionFiles[0].currentVersion;
614
- primarySource = versionFiles[0].filename;
615
- } else if (tagVersion) {
616
- primaryVersion = tagVersion;
617
- primarySource = 'git tags';
679
+ // Prioritize custom primary file from .env.maiass if present
680
+ const customPrimary = versionFiles.find(f => f.isPrimary);
681
+ if (customPrimary) {
682
+ primaryVersion = customPrimary.currentVersion;
683
+ primarySource = process.env.MAIASS_VERSION_PRIMARY_FILE || customPrimary.filename;
684
+ } else {
685
+ // Fallback: prioritize package.json
686
+ const packageJson = versionFiles.find(f => f.filename === 'package.json');
687
+ if (packageJson) {
688
+ primaryVersion = packageJson.currentVersion;
689
+ primarySource = 'package.json';
690
+ } else if (versionFiles.length > 0) {
691
+ primaryVersion = versionFiles[0].currentVersion;
692
+ primarySource = versionFiles[0].filename;
693
+ } else if (tagVersion) {
694
+ primaryVersion = tagVersion;
695
+ primarySource = 'git tags';
696
+ }
618
697
  }
619
698
 
620
699
  return {
@@ -765,8 +844,27 @@ export async function updateVersionFiles(newVersion, versionFiles, dryRun = fals
765
844
  // Update primary version files
766
845
  for (const file of versionFiles) {
767
846
  try {
768
- const typeConfig = VERSION_FILE_TYPES[file.type];
769
- const updatedContent = typeConfig.update(file.content, newVersion);
847
+ let updatedContent = null;
848
+
849
+ // Custom primary file with lineStart pattern needs special handling
850
+ if (file.isPrimary && file.lineStart && (file.type === 'txt' || file.type === 'text')) {
851
+ const lines = file.content.split('\n');
852
+ for (let i = 0; i < lines.length; i++) {
853
+ if (lines[i].trim().startsWith(file.lineStart)) {
854
+ lines[i] = lines[i].replace(/\d+\.\d+\.\d+/, newVersion);
855
+ }
856
+ }
857
+ updatedContent = lines.join('\n');
858
+ } else {
859
+ // Map env types to VERSION_FILE_TYPES keys
860
+ const typeKey = (file.type === 'txt' || file.type === 'text') ? 'text'
861
+ : (file.type === 'pattern') ? 'php'
862
+ : file.type;
863
+ const typeConfig = VERSION_FILE_TYPES[typeKey];
864
+ if (typeConfig) {
865
+ updatedContent = typeConfig.update(file.content, newVersion);
866
+ }
867
+ }
770
868
 
771
869
  if (!updatedContent) {
772
870
  results.failed.push({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maiass",
3
3
  "type": "module",
4
- "version": "5.9.7",
4
+ "version": "5.9.10",
5
5
  "description": "MAIASS - Modular AI-Augmented Semantic Scribe - Intelligent Git workflow automation",
6
6
  "main": "maiass.mjs",
7
7
  "bin": {