refactor: Cross-platform build scripts and session format cleanup

- Add scripts/set-version.mjs for cross-platform VITE_APP_VERSION setting
  (replaces bash-specific env var syntax that failed on Windows)
- Extract magic numbers into CLAUDE_SESSION_PARSE_LIMITS and CLAUDE_PRICING
  constants for better maintainability
- Remove legacy session format migration code - sessions now require aiTabs
- Fix session ID regex patterns to properly parse -ai-{tabId} format
- Remove deprecated aiLogs fallbacks - logs are exclusively in aiTabs now

Claude ID: bfd92ffb-a375-47be-94c5-fe4186325092
Maestro ID: b9bc0d08-5be2-4fdf-93cd-5618a8d53b35
This commit is contained in:
Pedram Amini
2025-12-01 07:24:13 -06:00
parent 509fcf61db
commit 6fc1455c53
9 changed files with 279 additions and 268 deletions

56
scripts/set-version.mjs Normal file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env node
/**
* Cross-platform script to set VITE_APP_VERSION environment variable
* with the local git hash. Works on Windows, macOS, and Linux.
*
* Usage: node scripts/set-version.mjs <command> [args...]
* Example: node scripts/set-version.mjs npm run build
*/
import { execFileSync, spawn } from 'child_process';
import process from 'process';
function getGitHash() {
try {
const hash = execFileSync('git', ['rev-parse', '--short=8', 'HEAD'], {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe']
}).trim();
return hash;
} catch {
return 'unknown';
}
}
const gitHash = getGitHash();
const version = `LOCAL ${gitHash}`;
// Set environment variable
process.env.VITE_APP_VERSION = version;
// Get the command and args to run
const [,, ...args] = process.argv;
if (args.length === 0) {
console.log(`VITE_APP_VERSION=${version}`);
process.exit(0);
}
// Run the command with the environment variable set
const command = args[0];
const commandArgs = args.slice(1);
const child = spawn(command, commandArgs, {
stdio: 'inherit',
shell: true,
env: { ...process.env, VITE_APP_VERSION: version }
});
child.on('close', (code) => {
process.exit(code ?? 0);
});
child.on('error', (err) => {
console.error(`Failed to run command: ${err.message}`);
process.exit(1);
});