Author SHA1 Message Date
s41r4j 5357cbf683 Merge branch 'main' of github.com:s41r4j/gims
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-01-29 00:21:10 +05:30
s41r4j 593421d9a3 chore: remove legacy VERSION file 2026-01-29 00:17:23 +05:30
s41r4j 56d1631e95 fix(cli): resolve syntax error in gims.js 2026-01-29 00:15:37 +05:30
s41r4j 9f7522039e fix(cli): make 'fix --ai' command provider-agnostic 2026-01-29 00:15:07 +05:30
s41r4j 12021869a9 feat: add 'w' alias for whoami, enhance 'fix --ai' with smart provider analysis, update readme S4 link 2026-01-29 00:13:50 +05:30
s41r4j 14e5dfa754 docs: update README with S4 versioning system details and new commands 2026-01-29 00:09:10 +05:30
s41r4j ffade4e0ab style: refine version info display format and clean up whoami 2026-01-29 00:07:18 +05:30
s41r4j bf9b8a010b style: improve date formatting in version info and whoami output 2026-01-29 00:05:26 +05:30
s41r4j bc10b3a074 chore: enable dynamic version check from git tags in whoami 2026-01-29 00:03:04 +05:30
s41r4j af80f34310 refactor: switch S4 to use Git Tags as SSOT, remove VERSION file 2026-01-29 00:01:19 +05:30
Sairaj Jawalikar 90559c15a1 Update README.md 2025-12-30 23:56:39 +05:30
6 changed files with 285 additions and 98 deletions

No files matched your search

+27 -2
View File
@@ -1,6 +1,10 @@
<div align="center">
# 🚀 GIMS - Git Made Simple
<!--
# GIMS - Git Made Simple
-->
<img width="1658" height="609" alt="gims" src="https://github.com/user-attachments/assets/fd4ae515-9674-4cc2-8ea0-39d21e82e274" />
[![npm version](https://img.shields.io/npm/v/gims.svg)](https://npmjs.org/package/gims)
[![npm downloads](https://img.shields.io/npm/dm/gims.svg)](https://npmjs.org/package/gims)
@@ -77,6 +81,8 @@ g o # That's it. AI handles the rest.
| `g oneshot` | `g o` | Stage all → AI commit → Push (full workflow) |
| `g local` | `g l` | Stage all → AI commit (no push) |
| `g suggest` | `g sg` | Get AI commit message suggestions |
| `g version` | `g v` | Manage project version (S4 system) |
| `g whoami` | — | Show system identity & version |
| `g wip` | — | Quick work-in-progress commit |
### 📊 Analytics & Review
@@ -112,6 +118,25 @@ g o # That's it. AI handles the rest.
| `g undo` | `g u` | Undo last commit (keep changes) |
| `g delete-branch` | `g del` | Delete branch locally and remotely |
### 🔢 S4 Versioning (New)
GIMS now uses the **[S4 Versioning System](https://github.com/s41r4j/s4vs)**, a forensic-grade versioning standard stored entirely in **Git Tags**.
`MAJOR.MINOR.PATCH-STAGE.BUILD+DATE.TIME.COMMIT.BRANCH`
*(e.g., `0.8.2-dev.1+20250129.1305.af8d9c.main`)*
| Command | Description |
|---------|-------------|
| `g v` | Smart bump (resets build on new day) + Create Tag |
| `g v -n` | Dry run (preview next version) |
| `g v major` | Force major bump (`1.0.0` → `2.0.0`) |
| `g v --list` | List stable releases (hides dev tags) |
| `g v --prune` | Delete old `dev` tags (keeps last 10) |
| `g v -i` | Version analysis with timestamp |
| `g whoami` | Dynamic identity & version banner |
> **Note:** S4 uses Git Tags as the Single Source of Truth. No `VERSION` file is created. It updates your `.env` version variables if they exist.
### 🔧 Setup & Config
| Command | Description |
@@ -315,4 +340,4 @@ MIT © [S41R4J](https://github.com/s41r4j)
Made with ❤️ for developers who'd rather code than write commit messages
</div>
</div>
-1
View File
@@ -1 +0,0 @@
0.8.2-dev.2+20260128.2346.9eaa681.main
+66 -32
View File
@@ -788,6 +788,9 @@ program.command('version').alias('v')
.option('-s, --stage <stage>', 'Set prerelease stage (dev, alpha, beta, rc, stable)')
.option('-n, --dry-run', 'Show next version without applying')
.option('-i, --info', 'Show info about current version')
.option('--list', 'List S4 tags (hides dev tags by default)')
.option('--prune', 'Prune old dev tags (keeps last 10)')
.option('--all', 'Show all tags (including dev) when listing')
.action(async (type, options) => {
await ensureRepo();
if (!versionCmd) initializeComponents();
@@ -798,7 +801,7 @@ program.command('version').alias('v')
}
});
program.command('whoami')
program.command('whoami').alias('w')
.description('Show system and tool identity status')
.action(async () => {
try {
@@ -1651,42 +1654,73 @@ program.command('fix')
// AI recommendation
if (cmdOptions.ai) {
Progress.info('Analyzing best approach...');
let recommendation = '';
Progress.start('🤖 Asking AI for the best strategy...');
if (situation === 'ahead') {
recommendation = `Your local is ${ahead} commits ahead. Simply push to sync.`;
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
console.log(` ${recommendation}`);
console.log(`\n Run: ${color.cyan('g push')}`);
} else if (situation === 'behind') {
recommendation = `Remote has ${behind} new commits. Pull to get them.`;
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
console.log(` ${recommendation}`);
console.log(`\n Run: ${color.cyan('g pull')} or ${color.cyan('g sp')} (if you have changes)`);
} else {
// Diverged - more complex
if (ahead <= 2 && behind > ahead) {
recommendation = `Small local changes (${ahead}), larger remote (${behind}). Rebase recommended for clean history.`;
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
console.log(` ${recommendation}`);
console.log(`\n Run: ${color.cyan('g fix --rebase')}`);
} else if (behind <= 2 && ahead > behind) {
recommendation = `Large local changes (${ahead}), small remote (${behind}). Merge is safe.`;
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
console.log(` ${recommendation}`);
console.log(`\n Run: ${color.cyan('g fix --merge')}`);
} else {
recommendation = `Significant divergence. Review changes first, then choose merge or rebase.`;
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
console.log(` ${recommendation}`);
console.log(`\n View remote changes: ${color.cyan(`git log ${branch}..${remoteBranch} --oneline`)}`);
console.log(` View local changes: ${color.cyan(`git log ${remoteBranch}..${branch} --oneline`)}`);
}
// Gather rich context for the AI
let aiContext = `Situation: I am on branch '${branch}'.\n`;
aiContext += `Remote '${remoteBranch}' exists.\n`;
aiContext += `Status: ${ahead} commits ahead, ${behind} commits behind.\n`;
aiContext += `Uncommitted changes: ${hasLocalChanges ? 'Yes' : 'No'}.\n\n`;
if (behind > 0) {
try {
const behindLog = await git.log({ from: branch, to: remoteBranch, maxCount: 5 });
aiContext += `Incoming commits (latest 5):\n${behindLog.all.map(c => `- ${c.message}`).join('\n')}\n\n`;
} catch (e) { }
}
if (ahead > 0) {
try {
const aheadLog = await git.log({ from: remoteBranch, to: branch, maxCount: 5 });
aiContext += `My outgoing commits (latest 5):\n${aheadLog.all.map(c => `- ${c.message}`).join('\n')}\n`;
} catch (e) { }
}
const prompt = `
As a Git expert, analyze this situation and recommend the best command to sync my repo.
${aiContext}
Explain "Why" briefly, then provide the exact command to run.
Output format:
Reasoning: <brief explanation>
Recommended Command: <command>
`;
// Use preferred provider or auto-resolve
const provider = aiProvider.resolveProvider(opts.provider);
if (provider === 'none') {
Progress.stop('');
console.log(color.yellow('No AI provider configured. Falling back to simple heuristics.'));
// ... heuristic fallback ...
let rec = '';
if (ahead > 0 && behind === 0) rec = 'Push (g push)';
else if (behind > 0 && ahead === 0) rec = 'Pull (g pull)';
else rec = 'Rebase (g fix --rebase)';
console.log(`Recommendation: ${rec}`);
return;
}
try {
const response = await aiProvider.generateWithProvider(provider, prompt, { temperature: 0.3 }); // Use generic provider method
Progress.stop('');
console.log(`\n${color.bold('🤖 AI Analysis:')}`);
console.log(response.trim());
} catch (e) {
Progress.stop('');
console.log(color.yellow('AI Analysis failed, falling back to heuristics.'));
// ... heuristic fallback code ...
let rec = '';
if (ahead > 0 && behind === 0) rec = 'Push (g push)';
else if (behind > 0 && ahead === 0) rec = 'Pull (g pull)';
else rec = 'Rebase (g fix --rebase)';
console.log(`Recommendation: ${rec}`);
}
return;
}
// Show interactive menu
console.log(color.bold('🔧 Fix Options:\n'));
+123 -52
View File
@@ -12,17 +12,35 @@ class VersionCommand {
}
async run(type = 'auto', options = {}) {
const { info, dryRun, stage } = options;
const { info, dryRun, stage, list, prune, all } = options;
try {
// 1. Get current version
const currentVersion = await this.getCurrentVersion();
// --- Special Commands: List & Prune ---
if (list) {
await this.listTags(all);
return;
}
if (prune) {
await this.pruneTags();
return;
}
// --- Main Bump Logic ---
// 1. Get current version from Git Tags (SSOT)
let currentVersion = await this.s4.getCurrentVersion();
let source = 'git-tag';
// Fallback: If no tags, check package.json just for migration base
if (!currentVersion) {
throw new Error('Could not find version in package.json or VERSION file');
currentVersion = this.getPackageJsonVersion() || '0.0.0';
source = 'package.json (fallback)';
}
// 2. Info mode
if (info) {
console.log(`Current Version: ${color.green(currentVersion)} (${source})`);
this.showInfo(currentVersion);
return;
}
@@ -41,56 +59,36 @@ class VersionCommand {
return;
}
// 5. Update files
// 5. Execution (Tag + .env)
console.log(`\nBumping version: ${color.dim(currentVersion)} → ${color.green(nextVersion)}`);
const updatedFiles = [];
// Update package.json
if (this.updatePackageJson(nextVersion)) updatedFiles.push('package.json');
// Update .env
// Update .env (Only if exists)
const envUpdates = this.updateEnvFiles(nextVersion);
updatedFiles.push(...envUpdates);
// Create VERSION file if it doesn't exist or update it
fs.writeFileSync('VERSION', nextVersion);
updatedFiles.push('VERSION');
if (updatedFiles.length > 0) {
console.log(`${color.green('✔')} Updated ${updatedFiles.join(', ')}`);
// Stage .env updates if any (usually gitignored, but if not...)
// We won't auto-commit them to avoid messing with user's git config too much logic
// But usually .env is ignored.
}
// 6. Git commit and tag
await this.createRelease(nextVersion, updatedFiles);
// 6. Create Git Tag (The Truth)
await this.createTag(nextVersion);
} catch (error) {
Progress.error(`Version bump failed: ${error.message}`);
}
}
async getCurrentVersion() {
// Try package.json
getPackageJsonVersion() {
if (fs.existsSync('package.json')) {
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (pkg.version) return pkg.version;
return pkg.version;
}
// Try VERSION file
if (fs.existsSync('VERSION')) {
return fs.readFileSync('VERSION', 'utf8').trim();
}
return '0.0.0'; // Default start
}
updatePackageJson(newVersion) {
if (!fs.existsSync('package.json')) return false;
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = newVersion;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
return true;
return null;
}
updateEnvFiles(newVersion) {
@@ -102,14 +100,12 @@ class VersionCommand {
let content = fs.readFileSync(file, 'utf8');
let changed = false;
// Match VERSION=... or APP_VERSION=...
const regex = /^(VERSION|APP_VERSION|NEXT_PUBLIC_VERSION)=(.*)$/gm;
// Match common version vars
const regex = /^(VERSION|APP_VERSION|NEXT_PUBLIC_VERSION|REACT_APP_VERSION|S4_VERSION)=(.*)$/gm;
if (regex.test(content)) {
content = content.replace(regex, `$1=${newVersion}`);
changed = true;
} else {
// Optionally append if missing? Maybe too aggressive.
}
if (changed) {
@@ -122,25 +118,84 @@ class VersionCommand {
return updates;
}
async createRelease(version, files) {
async createTag(version) {
try {
// Stage files
await this.git.add(files);
// Commit
const msg = `chore(release): bump to ${version}`;
await this.git.commit(msg);
// Tag
// Create lightweight or annotated tag? S4 recommends annotated.
await this.git.addAnnotatedTag(version, `Release ${version}`);
console.log(`${color.green('✔')} Created git commit and tag: ${color.cyan(version)}`);
console.log(`\nRun ${color.cyan('g push --follow-tags')} to publish`);
console.log(`${color.green('✔')} Created git tag: ${color.cyan(version)}`);
console.log(`\nRun ${color.cyan('g push --tags')} to publish`);
} catch (e) {
console.log(color.yellow(`⚠ Git operations failed: ${e.message}`));
console.log(color.yellow(`⚠ Git tag failed: ${e.message}`));
}
}
async listTags(showAll) {
const tags = await this.git.tags();
if (!tags.all.length) {
console.log('No tags found.');
return;
}
console.log(color.bold('\nRelease History:'));
// Reverse order (newest first)
// Filter out dev tags unless --all
const filtered = tags.all.filter(t => {
if (showAll) return true;
return !t.includes('-dev.');
}).reverse();
if (filtered.length === 0) {
console.log(color.dim('No stable/beta/rc tags found. Use --all to see dev tags.'));
return;
}
filtered.forEach(t => {
console.log(`- ${t}`);
});
}
async pruneTags() {
Progress.start('Pruning old dev tags...');
const tags = await this.git.tags();
const allTags = tags.all;
// Identify dev tags
const devTags = allTags.filter(t => t.includes('-dev.'));
// Sort them ensuring we keep the newest
// (Using simple string sort works roughly if S4 format is strictly kept,
// but better to rely on S4 parse if possible. For simplicity here, we assume standard S4)
// We want to KEEP the last 10 dev tags.
if (devTags.length <= 10) {
Progress.stop('');
console.log('Fewer than 10 dev tags. No pruning needed.');
return;
}
// Identify tags to delete (older ones)
// S4 strings sort chronologically well enough lexicographically mostly,
// but let's trust the array order returned by git tags usually...
// actually git tags return is arbitrary.
// Let's use our S4 sorter from utility if possible, or just simple sort
// Assuming S4Versioning.getCurrentVersion logic uses sort, we can reuse it?
// Or just simple sort for now.
devTags.sort(); // Lexicographical sort (older dates come first: 2025... < 2026...)
const toKeep = 10;
const toDelete = devTags.slice(0, devTags.length - toKeep);
for (const tag of toDelete) {
await this.git.tag(['-d', tag]);
}
Progress.stop('');
console.log(`${color.green('✔')} Deleted ${toDelete.length} old dev tags.`);
console.log(color.dim('Kept last 10 dev tags + all stable tags.'));
}
showInfo(versionStr) {
const parsed = S4Versioning.parse(versionStr);
if (!parsed) {
@@ -148,13 +203,29 @@ class VersionCommand {
return;
}
// Format date/time
const y = parsed.date.substring(0, 4);
const m = parsed.date.substring(4, 6);
const d = parsed.date.substring(6, 8);
const H = parsed.time.substring(0, 2);
const M = parsed.time.substring(2, 4);
const dateObj = new Date(`${y}-${m}-${d}T${H}:${M}:00`);
// 12-hour format logic
let hour = parseInt(H);
const ampm = hour >= 12 ? 'PM' : 'AM';
hour = hour % 12;
hour = hour ? hour : 12; // the hour '0' should be '12'
const time12 = `${hour}:${M} ${ampm}`;
console.log(color.bold('\nS4 Version Analysis:'));
console.log(`Major: ${parsed.major}`);
console.log(`Minor: ${parsed.minor}`);
console.log(`Patch: ${parsed.patch}`);
console.log(`Stage: ${color.magenta(parsed.stage)}`);
console.log(`Build: ${parsed.build}`);
console.log(`Time: ${parsed.date} @ ${parsed.time}`);
console.log(`Date: ${dateObj.toDateString()}`);
console.log(`Time: ${time12} (${H}:${M})`);
console.log(`Git: ${parsed.branch} (${parsed.commit})`);
}
}
+7 -1
View File
@@ -8,6 +8,12 @@ class WhoAmICommand {
async run() {
const pkg = require('../../../package.json');
// Get SSOT version from S4 (Tags)
const { S4Versioning } = require('../utils/s4');
const s4 = new S4Versioning(this.git);
const version = (await s4.getCurrentVersion()) || pkg.version;
const user = os.userInfo().username;
const hostname = os.hostname();
const platform = os.platform();
@@ -32,7 +38,7 @@ class WhoAmICommand {
console.log(`└─ Email: ${color.cyan(gitEmail)}`);
console.log(`\n${color.green('TOOL_METRICS')}`);
console.log(`├─ Version: ${color.magenta(pkg.version)}`);
console.log(`├─ Version: ${color.magenta(version)}`);
console.log(`├─ Engine: Node ${process.version}`);
console.log(`└─ Author: ${pkg.author}`);
+62 -10
View File
@@ -16,6 +16,7 @@ class S4Versioning {
* Parse an S4 version string into components
*/
static parse(versionStr) {
if (!versionStr) return null;
const match = versionStr.match(S4Versioning.REGEX);
if (!match) return null;
@@ -41,6 +42,62 @@ class S4Versioning {
return `${major}.${minor}.${patch}-${stage}.${build}+${date}.${time}.${commit}.${branch}`;
}
/**
* Get the latest S4 version from Git Tags
*/
async getCurrentVersion() {
try {
// Get all tags
const tags = await this.git.tags();
if (!tags.all || tags.all.length === 0) {
return null; // No tags yet
}
// Filter and sort S4 tags
// Sorting strategy: We rely on the date+time in the S4 string for chronological order
// but S4 strings format puts SemVer first.
// Let's parse all valid S4 tags and sort them.
const parsedTags = tags.all
.map(t => ({ tag: t, parsed: S4Versioning.parse(t) }))
.filter(item => item.parsed !== null);
if (parsedTags.length === 0) return null;
// Sort logic:
// 1. Major.Minor.Patch
// 2. Date.Time
// 3. Build
parsedTags.sort((a, b) => {
const pA = a.parsed;
const pB = b.parsed;
if (pA.major !== pB.major) return pA.major - pB.major;
if (pA.minor !== pB.minor) return pA.minor - pB.minor;
if (pA.patch !== pB.patch) return pA.patch - pB.patch;
// Compare Date (YYYYMMDD)
const dateA = parseInt(pA.date);
const dateB = parseInt(pB.date);
if (dateA !== dateB) return dateA - dateB;
// Compare Time (HHMM)
const timeA = parseInt(pA.time);
const timeB = parseInt(pB.time);
if (timeA !== timeB) return timeA - timeB;
return pA.build - pB.build;
});
// Return the latest
return parsedTags[parsedTags.length - 1].tag;
} catch (e) {
return null;
}
}
/**
* Migrate a standard SemVer or empty version to S4
*/
@@ -114,11 +171,7 @@ class S4Versioning {
// Handle stage change
if (stageVal && stageVal !== parsed.stage) {
next.stage = stageVal;
next.build = 1; // Stage change resets build usually? S4 "Sequence" implies uniqueness.
// S4 doc: "When to Increment: Each new build of the same version on the same day"
// Changing stage is effectively a new version identity.
} else {
// Keep existing stage if not specified
next.build = 1;
}
// Logic for bumping
@@ -147,14 +200,13 @@ class S4Versioning {
}
// 2. If Date is SAME
else {
// If Commit Changed -> It's a new build of the same day
// If Commit Changed -> new build
if (parsed.commit !== ctx.commit) {
next.build = parsed.build + 1;
}
// If Commit is SAME and user requested bump, force build increment?
// "auto" implies we just want the "next" logical version for the current state.
// If nothing changed, maybe we shouldn't bump?
// But usually CI calls this to FORCE a new version.
// If same commit & same date, usually we don't need a new tag
// unless user forces it.
// For safety, increment build to ensure uniqueness if they insisted on running `g v`.
else {
next.build = parsed.build + 1;
}