maiass 5.9.21 → 5.9.22

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
@@ -252,6 +252,9 @@ async function createAnonymousSubscriptionIfNeeded() {
252
252
  if (subscriptionId) {
253
253
  process.env.MAIASS_SUBSCRIPTION_ID = subscriptionId;
254
254
  }
255
+ if (credits !== undefined && credits !== null) {
256
+ process.env.MAIASS_CREDITS_REMAINING = String(credits);
257
+ }
255
258
 
256
259
  return apiKey;
257
260
  }
@@ -539,6 +542,11 @@ ${gitDiff}`;
539
542
  log.info(SYMBOLS.INFO, `Total Tokens: ${totalTokens} (${promptTokens} + ${completionTokens})`);
540
543
  }
541
544
 
545
+ // Keep env updated so pipeline end can always read current balance
546
+ if (creditsRemaining !== undefined) {
547
+ process.env.MAIASS_CREDITS_REMAINING = String(creditsRemaining);
548
+ }
549
+
542
550
  return {
543
551
  suggestion,
544
552
  creditsUsed,
@@ -694,15 +702,6 @@ async function getCommitMessage(gitInfo, options = {}) {
694
702
  if (aiResult && aiResult.suggestion) {
695
703
  aiSuggestion = aiResult.suggestion;
696
704
 
697
- // Display credits used and remaining (matching bashmaiass)
698
- if (aiResult.creditsUsed !== undefined) {
699
- log.branded(`Credits used: ${aiResult.creditsUsed}`, colors.White);
700
- }
701
- if (aiResult.creditsRemaining !== undefined) {
702
- const creditColor = getCreditColor(aiResult.creditsRemaining);
703
- console.log(`${colors.BSoftPink('|))')} ${creditColor(`${aiResult.creditsRemaining} Credits left`)}`);
704
- }
705
-
706
705
  // Display AI suggestion with gradient lines (matching bashmaiass)
707
706
  console.log(`${colors.BSoftPink('|))')} ${colors.BMagenta('Commit message suggestion from MAIASS:')}`);
708
707
  printGradientLine(60);
@@ -25,7 +25,10 @@ export async function handleMaiassCommand(args) {
25
25
  if (positionalArgs.length > 0 && !bumpType) {
26
26
  bumpType = positionalArgs[0];
27
27
  }
28
-
28
+
29
+ // Track whether the user explicitly requested a version bump
30
+ const versionBumpExplicit = !!bumpType;
31
+
29
32
  // Default to 'patch' if no version bump specified and not commits-only
30
33
  if (!bumpType && !commitsOnly) {
31
34
  bumpType = 'patch';
@@ -46,6 +49,7 @@ export async function handleMaiassCommand(args) {
46
49
  commitsOnly,
47
50
  autoStage,
48
51
  versionBump: bumpType,
52
+ versionBumpExplicit,
49
53
  dryRun,
50
54
  tag,
51
55
  force,
@@ -452,7 +452,7 @@ function shouldTagRelease(versionBump, forceTag = false) {
452
452
  * @returns {Promise<Object>} Version management result
453
453
  */
454
454
  async function handleVersionManagement(branchInfo, mergeResult, options = {}) {
455
- const { versionBump, dryRun = false, tag = false, force = false, silent = false, originalGitInfo = null } = options;
455
+ const { versionBump, versionBumpExplicit = false, dryRun = false, tag = false, force = false, silent = false, originalGitInfo = null } = options;
456
456
  const { developBranch } = branchInfo;
457
457
 
458
458
  logger.header(SYMBOLS.INFO, 'Version Management Phase');
@@ -461,8 +461,11 @@ async function handleVersionManagement(branchInfo, mergeResult, options = {}) {
461
461
  const versionInfo = await getCurrentVersion();
462
462
 
463
463
  if (!versionInfo.hasVersionFiles) {
464
- log.warning(SYMBOLS.WARNING, 'No version files detected');
465
- log.blue(SYMBOLS.INFO, 'Skipping version management');
464
+ // Only warn if the user explicitly asked for a version bump
465
+ if (versionBumpExplicit) {
466
+ log.warning(SYMBOLS.WARNING, 'No version files detected');
467
+ }
468
+ logger.debug('No version files — skipping version management');
466
469
  return { success: true, skipped: true };
467
470
  }
468
471
 
@@ -793,6 +796,7 @@ export async function runMaiassPipeline(options = {}) {
793
796
  commitsOnly = false,
794
797
  autoStage = false,
795
798
  versionBump = null,
799
+ versionBumpExplicit = false,
796
800
  dryRun = false,
797
801
  tag = false,
798
802
  force = false,
@@ -883,13 +887,14 @@ export async function runMaiassPipeline(options = {}) {
883
887
 
884
888
  // Phase 4: Version Management
885
889
  log.blue(SYMBOLS.INFO, 'Phase 4: Version Management');
886
- const versionResult = await handleVersionManagement(branchInfo, mergeResult, {
887
- versionBump,
888
- dryRun,
889
- tag,
890
- force,
890
+ const versionResult = await handleVersionManagement(branchInfo, mergeResult, {
891
+ versionBump,
892
+ versionBumpExplicit,
893
+ dryRun,
894
+ tag,
895
+ force,
891
896
  silent,
892
- originalGitInfo
897
+ originalGitInfo
893
898
  });
894
899
 
895
900
  if (!versionResult.success) {
@@ -904,30 +909,27 @@ export async function runMaiassPipeline(options = {}) {
904
909
  // Match bashmaiass colors: green checkmark, aqua text, bold white branch
905
910
  console.log(`${colors.BSoftPink('|))')} ${colors.BGreen('✅ Done!')} ${colors.Aqua('You are on')} ${colors.BWhite(finalBranch)} ${colors.Aqua('branch')}`);
906
911
 
907
- // Display credit summary if AI was used
908
- const subscriptionId = process.env.MAIASS_SUBSCRIPTION_ID;
909
- if (commitResult && commitResult.aiUsed) {
910
- console.log('📊 Credit Summary:');
911
- if (commitResult.creditsUsed) {
912
- console.log(` Credits used this session: ${colors.SoftPink(commitResult.creditsUsed)} (${commitResult.aiModel || 'gpt-3.5-turbo'})`);
913
- }
914
- if (commitResult.creditsRemaining !== undefined) {
915
- const creditColor = getCreditColor(commitResult.creditsRemaining);
916
- console.log(`${creditColor(`Credits remaining: ${commitResult.creditsRemaining}`)}`);
917
- }
918
- console.log('');
919
- }
920
-
921
- // Display thank you message with top-up link
912
+ // Display thank you message
922
913
  console.log(colors.Cyan('═'.repeat(40)));
923
914
  console.log(`${colors.BSoftPink('|))')} Thank you for using MAIASS! ✨`);
924
915
  console.log(colors.Cyan('═'.repeat(40)));
925
-
926
- // Show top-up link if we have a subscription ID
916
+
917
+ // Show credit balance — use post-AI value if available, else initial subscription value
918
+ const subscriptionId = process.env.MAIASS_SUBSCRIPTION_ID;
919
+ const creditsRemaining = commitResult?.creditsRemaining ?? (
920
+ process.env.MAIASS_CREDITS_REMAINING !== undefined
921
+ ? parseFloat(process.env.MAIASS_CREDITS_REMAINING)
922
+ : undefined
923
+ );
924
+ if (creditsRemaining !== undefined) {
925
+ const creditColor = getCreditColor(creditsRemaining);
926
+ console.log(`${creditColor(`💳 Credits remaining: ${creditsRemaining}`)}`);
927
+ }
928
+
929
+ // Show top-up link for anonymous subscriptions
927
930
  if (subscriptionId && subscriptionId.startsWith('sub_anon_')) {
928
- console.log(`💳 ${colors.BMagenta('Need more credits?')}`);
929
931
  const topupEndpoint = process.env.MAIASS_TOPUP_ENDPOINT || 'https://maiass.net/top-up';
930
- console.log(colors.Blue(`${topupEndpoint}/${subscriptionId}`));
932
+ console.log(`${colors.BMagenta('Credit top-up link:')} ${colors.Blue(`${topupEndpoint}/${subscriptionId}`)}`);
931
933
  }
932
934
 
933
935
  return {
package/maiass.mjs CHANGED
@@ -38,7 +38,7 @@ import { handleVersionCommand } from './lib/version-command.js';
38
38
  import { handleMaiassCommand } from './lib/maiass-command.js';
39
39
  import { handleAccountInfoCommand } from './lib/account-info.js';
40
40
  import { SYMBOLS } from './lib/symbols.js';
41
- import { bootstrapProject, needsBootstrap } from './lib/bootstrap.js';
41
+ import { bootstrapProject } from './lib/bootstrap.js';
42
42
 
43
43
  // Simple CLI setup for pkg compatibility
44
44
  const args = process.argv.slice(2);
@@ -178,15 +178,48 @@ if (args.includes('--help') || args.includes('-h') || command === 'help') {
178
178
 
179
179
  // Command routing (wrapped in async IIFE to handle async commands)
180
180
  (async () => {
181
- // Run bootstrap if needed (first-time setup)
182
- if (needsBootstrap()) {
183
- const completed = await bootstrapProject();
184
- if (completed) {
185
- // Bootstrap completed, exit so user can run maiass again
186
- process.exit(0);
181
+ // --setup/--bootstrap: run the full interactive wizard and exit
182
+ if (process.env.MAIASS_FORCE_BOOTSTRAP === 'true') {
183
+ await bootstrapProject();
184
+ process.exit(0);
185
+ }
186
+
187
+ // First run (no .env.maiass and no .env.maiass.local): initialise and show welcome.
188
+ // We create .env.maiass.local as a marker so this only runs once per project.
189
+ if (!fs.existsSync('.env.maiass') && !fs.existsSync('.env.maiass.local')) {
190
+ // Create .env.maiass.local as a first-run marker (personal settings file)
191
+ fs.writeFileSync(
192
+ '.env.maiass.local',
193
+ `# .env.maiass.local — personal/local MAIASS settings (never committed)\n` +
194
+ `# Generated on first run: ${new Date().toISOString()}\n` +
195
+ `# Override any .env.maiass value here, e.g. MAIASS_AI_HOST=http://localhost:8787\n`,
196
+ 'utf8'
197
+ );
198
+
199
+ // Add MAIASS entries to .gitignore if one already exists — avoids dirtying
200
+ // repos that don't have a .gitignore yet
201
+ if (fs.existsSync('.gitignore')) {
202
+ let gitignore = fs.readFileSync('.gitignore', 'utf8');
203
+ const needed = ['.env.maiass.local', 'maiass.log'].filter(p => !gitignore.includes(p));
204
+ if (needed.length > 0) {
205
+ if (!gitignore.endsWith('\n')) gitignore += '\n';
206
+ gitignore += `\n# MAIASS\n${needed.join('\n')}\n`;
207
+ fs.writeFileSync('.gitignore', gitignore, 'utf8');
208
+ }
187
209
  }
210
+
211
+ // Show what defaults are active so the user knows what they're getting
212
+ const aiMode = process.env.MAIASS_AI_MODE || 'ask';
213
+ console.log('');
214
+ console.log(colors.BCyan('👋 Welcome to MAIASS!'));
215
+ console.log(colors.Gray(' Running with smart defaults:'));
216
+ console.log(colors.Gray(` • AI commit messages: ${aiMode}`));
217
+ console.log(colors.Gray(' • Version management: off'));
218
+ console.log(colors.Gray(' • Changelogging: off'));
219
+ console.log(colors.Gray(' Run maiass --setup to configure for this project.'));
220
+ console.log('');
188
221
  }
189
-
222
+
190
223
  switch (command) {
191
224
  case 'hello':
192
225
  console.log(colors.BCyan('Hello from MAIASS!'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maiass",
3
3
  "type": "module",
4
- "version": "5.9.21",
4
+ "version": "5.9.22",
5
5
  "description": "MAIASS - Modular AI-Augmented Semantic Scribe - Intelligent Git workflow automation",
6
6
  "main": "maiass.mjs",
7
7
  "bin": {