Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
807d5bcb20 | ||
|
|
ff4232b212 | ||
|
|
b53f06b799 | ||
|
|
c3e0d4ab03 | ||
|
|
00217a6ac7 | ||
|
|
bd906885c2 | ||
|
|
5357cbf683 | ||
|
|
593421d9a3 | ||
|
|
56d1631e95 | ||
|
|
9f7522039e | ||
|
|
12021869a9 | ||
|
|
14e5dfa754 | ||
|
|
ffade4e0ab | ||
|
|
bf9b8a010b | ||
|
|
bc10b3a074 | ||
|
|
af80f34310 | ||
|
|
90559c15a1 |
No files matched your search
+23
@@ -0,0 +1,23 @@
|
|||||||
|
# NPM Ignore
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.gitignore
|
||||||
|
.DS_Store
|
||||||
|
.env*
|
||||||
|
test/
|
||||||
|
tests/
|
||||||
|
examples/
|
||||||
|
scripts/
|
||||||
|
docs/
|
||||||
|
mcp/
|
||||||
|
AI.md
|
||||||
|
*.log
|
||||||
|
coverage/
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Keep bin and library code
|
||||||
|
!bin/
|
||||||
|
!package.json
|
||||||
|
!README.md
|
||||||
|
!LICENSE
|
||||||
|
!CHANGELOG.md
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<div align="center">
|
<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" />
|
||||||
|
|
||||||
[](https://npmjs.org/package/gims)
|
[](https://npmjs.org/package/gims)
|
||||||
[](https://npmjs.org/package/gims)
|
[](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 oneshot` | `g o` | Stage all → AI commit → Push (full workflow) |
|
||||||
| `g local` | `g l` | Stage all → AI commit (no push) |
|
| `g local` | `g l` | Stage all → AI commit (no push) |
|
||||||
| `g suggest` | `g sg` | Get AI commit message suggestions |
|
| `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 |
|
| `g wip` | — | Quick work-in-progress commit |
|
||||||
|
|
||||||
### 📊 Analytics & Review
|
### 📊 Analytics & Review
|
||||||
@@ -112,6 +118,26 @@ g o # That's it. AI handles the rest.
|
|||||||
| `g undo` | `g u` | Undo last commit (keep changes) |
|
| `g undo` | `g u` | Undo last commit (keep changes) |
|
||||||
| `g delete-branch` | `g del` | Delete branch locally and remotely |
|
| `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 --undo` | Undo last version bump (delete latest tag) |
|
||||||
|
| `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
|
### 🔧 Setup & Config
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
@@ -124,6 +150,47 @@ g o # That's it. AI handles the rest.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🤖 AI-Native Integration (New)
|
||||||
|
|
||||||
|
GIMS is designed to be "AI-Native", allowing AI agents to directly understand and control your git repository.
|
||||||
|
|
||||||
|
### 1. Model Context Protocol (MCP) Server
|
||||||
|
|
||||||
|
GIMS includes a built-in [MCP](https://modelcontextprotocol.io/) server. This allows AI assistants like **Claude Desktop**, **Cursor**, and **VS Code** to directly "see" and "use" GIMS tools.
|
||||||
|
|
||||||
|
#### Available Tools
|
||||||
|
- `get_status`: Get AI-enhanced git status and insights.
|
||||||
|
- `analyze_history`: Analyze commit history and patterns.
|
||||||
|
- `version_info`: Get current S4 version details.
|
||||||
|
- `generate_commit_message`: Generate a commit message for staged changes.
|
||||||
|
- `run_git_command`: Safe execution of raw git commands.
|
||||||
|
|
||||||
|
#### Usage with Claude Desktop
|
||||||
|
Add to your `claude_desktop_config.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"gims": {
|
||||||
|
"command": "node",
|
||||||
|
"args": ["/path/to/gims/mcp/index.js"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. OpenAI / Custom Agent Integration
|
||||||
|
|
||||||
|
If you are building your own AI agent (using OpenAI, LangChain, etc.), you can plug GIMS tools directly into your `tools` array using our auto-generated schemas.
|
||||||
|
|
||||||
|
**Schema Location:** `bin/tools-schema.json`
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const tools = require('gims/bin/tools-schema.json');
|
||||||
|
// Pass 'tools' directly to OpenAI API
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🤖 AI Providers
|
## 🤖 AI Providers
|
||||||
|
|
||||||
GIMS supports multiple AI providers. Choose based on your needs:
|
GIMS supports multiple AI providers. Choose based on your needs:
|
||||||
@@ -315,4 +382,4 @@ MIT © [S41R4J](https://github.com/s41r4j)
|
|||||||
|
|
||||||
Made with ❤️ for developers who'd rather code than write commit messages
|
Made with ❤️ for developers who'd rather code than write commit messages
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
+176
-63
@@ -332,38 +332,96 @@ program.command('config')
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('quick-help').alias('q')
|
program.command('help', { isDefault: true })
|
||||||
.description('Show quick reference for main commands')
|
.description('Show structured help menu')
|
||||||
.action(() => {
|
.action(() => {
|
||||||
console.log(color.bold('🚀 GIMS Quick Reference\n'));
|
console.log(color.bold('\n🚀 GIMS - Git Made Simple\n'));
|
||||||
|
|
||||||
console.log(color.bold('Core Workflow:'));
|
const sections = [
|
||||||
console.log(` ${color.cyan('g s')} Status with AI insights`);
|
{
|
||||||
console.log(` ${color.cyan('g o')} AI commit + push`);
|
title: '🤖 AI & Core Workflow',
|
||||||
console.log(` ${color.cyan('g l')} AI commit locally`);
|
cmds: [
|
||||||
console.log(` ${color.cyan('g wip')} Quick WIP commit\n`);
|
{ name: 'g s | status', desc: 'Status with AI insights' },
|
||||||
|
{ name: 'g o | online', desc: 'Auto-stage + AI commit + Push' },
|
||||||
|
{ name: 'g l | local', desc: 'Auto-stage + AI commit (local)' },
|
||||||
|
{ name: 'g r | review', desc: 'AI Code Review detected changes' },
|
||||||
|
{ name: 'g sg | suggest', desc: 'Get AI message suggestions' },
|
||||||
|
{ name: 'g int | interactive', desc: 'Interactive commit wizard' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '🔄 Sync & Maintenance',
|
||||||
|
cmds: [
|
||||||
|
{ name: 'g sp | safe-pull', desc: 'Safe pull (stash -> pull -> pop)' },
|
||||||
|
{ name: 'g sync', desc: 'Smart sync (pull + rebase/merge)' },
|
||||||
|
{ name: 'g f | fix', desc: 'Fix branch sync issues' },
|
||||||
|
{ name: 'g main', desc: 'Switch to main & pull latest' },
|
||||||
|
{ name: 'g clean | cleanup', desc: 'Remove dead local branches' },
|
||||||
|
{ name: 'g del', desc: 'Delete branch (local + remote)' },
|
||||||
|
{ name: 'g pull', desc: 'Standard git pull' },
|
||||||
|
{ name: 'g push', desc: 'Standard git push' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '📜 History & Inspection',
|
||||||
|
cmds: [
|
||||||
|
{ name: 'g ls | list', desc: 'Compact commit history' },
|
||||||
|
{ name: 'g ll | largelist', desc: 'Detailed commit history' },
|
||||||
|
{ name: 'g last', desc: 'Show last commit diff' },
|
||||||
|
{ name: 'g t | today', desc: 'Show commits made today' },
|
||||||
|
{ name: 'g stats', desc: 'Personal commit statistics' },
|
||||||
|
{ name: 'g w | whoami', desc: 'Show system identity' },
|
||||||
|
{ name: 'g p | preview', desc: 'Preview commit message' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '📦 Stashing & Work-in-Progress',
|
||||||
|
cmds: [
|
||||||
|
{ name: 'g ss | stash-save', desc: 'Quick stash save' },
|
||||||
|
{ name: 'g pop | stash-pop', desc: 'Pop latest stash' },
|
||||||
|
{ name: 'g stash', desc: 'Enhanced stash management' },
|
||||||
|
{ name: 'g wip', desc: 'Quick work-in-progress commit' },
|
||||||
|
{ name: 'g split', desc: 'Split large changesets' },
|
||||||
|
{ name: 'g us | unstage', desc: 'Unstage all files' },
|
||||||
|
{ name: 'g x | discard', desc: 'Discard all changes' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '🌿 Branching & Undo',
|
||||||
|
cmds: [
|
||||||
|
{ name: 'g b | branch', desc: 'List or create branches' },
|
||||||
|
{ name: 'g u | undo', desc: 'Undo last commit' },
|
||||||
|
{ name: 'g a | amend', desc: 'Amend last commit' },
|
||||||
|
{ name: 'g rs | reset', desc: 'Reset branch to commit' },
|
||||||
|
{ name: 'g rv | revert', desc: 'Revert commit safely' },
|
||||||
|
{ name: 'g conflicts', desc: 'Resolve merge conflicts' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '🔧 Config & Utilities',
|
||||||
|
cmds: [
|
||||||
|
{ name: 'g v | version', desc: 'S4 Version management' },
|
||||||
|
{ name: 'g setup', desc: 'Run setup wizard' },
|
||||||
|
{ name: 'g config', desc: 'Manage configuration' },
|
||||||
|
{ name: 'g init', desc: 'Initialize new repo' },
|
||||||
|
{ name: 'g clone', desc: 'Clone a repository' },
|
||||||
|
{ name: 'g m | commit', desc: 'Commit with custom message' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
console.log(color.bold('Sync & Fix:'));
|
sections.forEach(section => {
|
||||||
console.log(` ${color.cyan('g sp')} Safe pull (stash → pull → pop)`);
|
console.log(color.cyan(color.bold(section.title)));
|
||||||
console.log(` ${color.cyan('g fix')} Fix branch sync issues`);
|
// Calculate padding dynamically based on longest command name in this section
|
||||||
console.log(` ${color.cyan('g main')} Switch to main + pull\n`);
|
const maxLen = Math.max(...section.cmds.map(c => c.name.length)) + 4;
|
||||||
|
|
||||||
console.log(color.bold('Stash:'));
|
section.cmds.forEach(cmd => {
|
||||||
console.log(` ${color.cyan('g ss')} Quick stash save`);
|
console.log(` ${cmd.name.padEnd(maxLen)} ${color.dim(cmd.desc)}`);
|
||||||
console.log(` ${color.cyan('g pop')} Pop latest stash`);
|
});
|
||||||
console.log(` ${color.cyan('g us')} Unstage all files\n`);
|
console.log('');
|
||||||
|
});
|
||||||
|
|
||||||
console.log(color.bold('Smart Commands:'));
|
console.log(color.dim('Use "g <command> --help" for more details on any command.'));
|
||||||
console.log(` ${color.cyan('g r')} AI code review`);
|
|
||||||
console.log(` ${color.cyan('g t')} Today's commits`);
|
|
||||||
console.log(` ${color.cyan('g last')} Last commit details\n`);
|
|
||||||
|
|
||||||
console.log(color.bold('History:'));
|
|
||||||
console.log(` ${color.cyan('g ls')} Commit history`);
|
|
||||||
console.log(` ${color.cyan('g a')} Amend last commit`);
|
|
||||||
console.log(` ${color.cyan('g u')} Undo last commit\n`);
|
|
||||||
|
|
||||||
console.log(`Full help: ${color.cyan('g --help')}`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('init').alias('i')
|
program.command('init').alias('i')
|
||||||
@@ -788,6 +846,10 @@ program.command('version').alias('v')
|
|||||||
.option('-s, --stage <stage>', 'Set prerelease stage (dev, alpha, beta, rc, stable)')
|
.option('-s, --stage <stage>', 'Set prerelease stage (dev, alpha, beta, rc, stable)')
|
||||||
.option('-n, --dry-run', 'Show next version without applying')
|
.option('-n, --dry-run', 'Show next version without applying')
|
||||||
.option('-i, --info', 'Show info about current version')
|
.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')
|
||||||
|
.option('-u, --undo', 'Undo the last version bump (delete latest tag)')
|
||||||
.action(async (type, options) => {
|
.action(async (type, options) => {
|
||||||
await ensureRepo();
|
await ensureRepo();
|
||||||
if (!versionCmd) initializeComponents();
|
if (!versionCmd) initializeComponents();
|
||||||
@@ -798,7 +860,7 @@ program.command('version').alias('v')
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('whoami')
|
program.command('whoami').alias('w')
|
||||||
.description('Show system and tool identity status')
|
.description('Show system and tool identity status')
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -943,11 +1005,31 @@ program.command('history').alias('h')
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('branch <c> [name]').alias('b')
|
program.command('branch [c] [name]').alias('b')
|
||||||
.description('Branch from commit/index')
|
.description('List branches or branch from commit/index')
|
||||||
.action(async (c, name) => {
|
.action(async (c, name) => {
|
||||||
await ensureRepo();
|
await ensureRepo();
|
||||||
try { const sha = await resolveCommit(c); const br = name || `branch-${sha.slice(0, 7)}`; await git.checkout(['-b', br, sha]); console.log(`Switched to branch ${br} at ${sha}`); }
|
try {
|
||||||
|
if (!c) {
|
||||||
|
// List branches
|
||||||
|
const branches = await git.branchLocal();
|
||||||
|
console.log(color.bold('\n🌿 Local Branches:\n'));
|
||||||
|
branches.all.forEach(b => {
|
||||||
|
if (b === branches.current) {
|
||||||
|
console.log(` ${color.green('* ' + b)}`);
|
||||||
|
} else {
|
||||||
|
console.log(` ${b}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log('');
|
||||||
|
} else {
|
||||||
|
// Create branch
|
||||||
|
const sha = await resolveCommit(c);
|
||||||
|
const br = name || `branch-${sha.slice(0, 7)}`;
|
||||||
|
await git.checkout(['-b', br, sha]);
|
||||||
|
console.log(`Switched to branch ${br} at ${sha}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (e) { handleError('Branch error', e); }
|
catch (e) { handleError('Branch error', e); }
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1527,7 +1609,7 @@ program.command('last')
|
|||||||
|
|
||||||
// ===== SMART SYNC FIX COMMAND =====
|
// ===== SMART SYNC FIX COMMAND =====
|
||||||
|
|
||||||
program.command('fix')
|
program.command('fix').alias('f')
|
||||||
.description('Smart fix for branch sync issues (diverged, behind, ahead)')
|
.description('Smart fix for branch sync issues (diverged, behind, ahead)')
|
||||||
.option('--local', 'Keep local changes, force push to remote')
|
.option('--local', 'Keep local changes, force push to remote')
|
||||||
.option('--remote', 'Keep remote changes, discard local')
|
.option('--remote', 'Keep remote changes, discard local')
|
||||||
@@ -1651,42 +1733,73 @@ program.command('fix')
|
|||||||
|
|
||||||
// AI recommendation
|
// AI recommendation
|
||||||
if (cmdOptions.ai) {
|
if (cmdOptions.ai) {
|
||||||
Progress.info('Analyzing best approach...');
|
Progress.start('🤖 Asking AI for the best strategy...');
|
||||||
let recommendation = '';
|
|
||||||
|
|
||||||
if (situation === 'ahead') {
|
// Gather rich context for the AI
|
||||||
recommendation = `Your local is ${ahead} commits ahead. Simply push to sync.`;
|
let aiContext = `Situation: I am on branch '${branch}'.\n`;
|
||||||
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
|
aiContext += `Remote '${remoteBranch}' exists.\n`;
|
||||||
console.log(` ${recommendation}`);
|
aiContext += `Status: ${ahead} commits ahead, ${behind} commits behind.\n`;
|
||||||
console.log(`\n Run: ${color.cyan('g push')}`);
|
aiContext += `Uncommitted changes: ${hasLocalChanges ? 'Yes' : 'No'}.\n\n`;
|
||||||
} else if (situation === 'behind') {
|
|
||||||
recommendation = `Remote has ${behind} new commits. Pull to get them.`;
|
if (behind > 0) {
|
||||||
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
|
try {
|
||||||
console.log(` ${recommendation}`);
|
const behindLog = await git.log({ from: branch, to: remoteBranch, maxCount: 5 });
|
||||||
console.log(`\n Run: ${color.cyan('g pull')} or ${color.cyan('g sp')} (if you have changes)`);
|
aiContext += `Incoming commits (latest 5):\n${behindLog.all.map(c => `- ${c.message}`).join('\n')}\n\n`;
|
||||||
} else {
|
} catch (e) { }
|
||||||
// Diverged - more complex
|
}
|
||||||
if (ahead <= 2 && behind > ahead) {
|
|
||||||
recommendation = `Small local changes (${ahead}), larger remote (${behind}). Rebase recommended for clean history.`;
|
if (ahead > 0) {
|
||||||
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
|
try {
|
||||||
console.log(` ${recommendation}`);
|
const aheadLog = await git.log({ from: remoteBranch, to: branch, maxCount: 5 });
|
||||||
console.log(`\n Run: ${color.cyan('g fix --rebase')}`);
|
aiContext += `My outgoing commits (latest 5):\n${aheadLog.all.map(c => `- ${c.message}`).join('\n')}\n`;
|
||||||
} else if (behind <= 2 && ahead > behind) {
|
} catch (e) { }
|
||||||
recommendation = `Large local changes (${ahead}), small remote (${behind}). Merge is safe.`;
|
}
|
||||||
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
|
|
||||||
console.log(` ${recommendation}`);
|
const prompt = `
|
||||||
console.log(`\n Run: ${color.cyan('g fix --merge')}`);
|
As a Git expert, analyze this situation and recommend the best command to sync my repo.
|
||||||
} else {
|
|
||||||
recommendation = `Significant divergence. Review changes first, then choose merge or rebase.`;
|
${aiContext}
|
||||||
console.log(`\n${color.bold('🤖 AI Recommendation:')}`);
|
|
||||||
console.log(` ${recommendation}`);
|
Explain "Why" briefly, then provide the exact command to run.
|
||||||
console.log(`\n View remote changes: ${color.cyan(`git log ${branch}..${remoteBranch} --oneline`)}`);
|
Output format:
|
||||||
console.log(` View local changes: ${color.cyan(`git log ${remoteBranch}..${branch} --oneline`)}`);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Show interactive menu
|
// Show interactive menu
|
||||||
console.log(color.bold('🔧 Fix Options:\n'));
|
console.log(color.bold('🔧 Fix Options:\n'));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* GIMS AI Interface Registry
|
||||||
|
*
|
||||||
|
* This module defines the "Tools" that GIMS exposes to AI systems (MCP, OpenAI, etc.).
|
||||||
|
* It serves as the Single Source of Truth for tool definitions and their schemas.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const simpleGit = require('simple-git');
|
||||||
|
const { GitAnalyzer } = require('../git/analyzer');
|
||||||
|
const { S4Versioning } = require('../utils/s4');
|
||||||
|
const { ConfigManager } = require('../config/manager');
|
||||||
|
const { AIProviderManager } = require('./providers');
|
||||||
|
|
||||||
|
// Initialize shared instances
|
||||||
|
const git = simpleGit();
|
||||||
|
const gitAnalyzer = new GitAnalyzer(git);
|
||||||
|
const configManager = new ConfigManager();
|
||||||
|
const config = configManager.load();
|
||||||
|
const aiProvider = new AIProviderManager(config);
|
||||||
|
const s4 = new S4Versioning(git);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tool Definitions
|
||||||
|
* Format:
|
||||||
|
* {
|
||||||
|
* name: "tool_name",
|
||||||
|
* description: "Description for the AI",
|
||||||
|
* inputSchema: { ...JSON Schema... },
|
||||||
|
* handler: async (args) => { ... implementation ... }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
const tools = [
|
||||||
|
{
|
||||||
|
name: "get_status",
|
||||||
|
description: "Get enhanced git status with AI insights, file modification stats, and branch context. Use this to understand the current state of the repository.",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
handler: async () => {
|
||||||
|
return await gitAnalyzer.getEnhancedStatus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "analyze_history",
|
||||||
|
description: "Analyze recent commit history, including authors, conventions, and activity patterns.",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
limit: {
|
||||||
|
type: "number",
|
||||||
|
description: "Number of commits to analyze (default: 10)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handler: async ({ limit = 10 }) => {
|
||||||
|
return await gitAnalyzer.analyzeCommitHistory(limit);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "version_info",
|
||||||
|
description: "Get current project version information using S4 versioning (Semantic + Date/Time).",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {}
|
||||||
|
},
|
||||||
|
handler: async () => {
|
||||||
|
const currentVersion = await s4.getCurrentVersion();
|
||||||
|
if (!currentVersion) return { version: "0.0.0", source: "fallback" };
|
||||||
|
return { version: currentVersion, details: S4Versioning.parse(currentVersion) };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "generate_commit_message",
|
||||||
|
description: "Generate a high-quality commit message based on currently staged changes.",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
context: {
|
||||||
|
type: "string",
|
||||||
|
description: "Optional context or user instruction for the message generation"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handler: async ({ context }) => {
|
||||||
|
const rawDiff = await git.diff(['--cached', '--no-ext-diff']);
|
||||||
|
if (!rawDiff.trim()) {
|
||||||
|
return { error: "No staged changes to generate message for." };
|
||||||
|
}
|
||||||
|
// Pass pseudo-options resembling CLI opts
|
||||||
|
const opts = { conventional: config.conventional };
|
||||||
|
const message = await aiProvider.generateCommitMessage(rawDiff, opts);
|
||||||
|
|
||||||
|
// Handle object return from provider (some return { message, usedLocal })
|
||||||
|
const msgStr = typeof message === 'string' ? message : message.message;
|
||||||
|
|
||||||
|
return {
|
||||||
|
message: msgStr,
|
||||||
|
original_diff_size: rawDiff.length
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "run_git_command",
|
||||||
|
description: "Execute a raw git command safely. Use this for standard git operations not covered by other tools.",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
command: {
|
||||||
|
type: "string",
|
||||||
|
description: "The full git command to run (e.g., 'log -n 5', 'branch --list')"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ["command"]
|
||||||
|
},
|
||||||
|
handler: async ({ command }) => {
|
||||||
|
// Safety check: block potentially destructive commands if needed,
|
||||||
|
// but for now we assume the agent is trusted or user-monitored.
|
||||||
|
// We'll strip 'git ' prefix if present.
|
||||||
|
const cleanCmd = command.replace(/^git\s+/, '').trim();
|
||||||
|
const args = cleanCmd.split(' ');
|
||||||
|
try {
|
||||||
|
const result = await git.raw(args);
|
||||||
|
return { output: result ? result.trim() : "Success" };
|
||||||
|
} catch (e) {
|
||||||
|
return { error: e.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = { tools };
|
||||||
+166
-52
@@ -12,17 +12,40 @@ class VersionCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(type = 'auto', options = {}) {
|
async run(type = 'auto', options = {}) {
|
||||||
const { info, dryRun, stage } = options;
|
const { info, dryRun, stage, list, prune, all } = options;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. Get current version
|
// --- Special Commands: List & Prune ---
|
||||||
const currentVersion = await this.getCurrentVersion();
|
if (list) {
|
||||||
|
await this.listTags(all);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prune) {
|
||||||
|
await this.pruneTags();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.undo) {
|
||||||
|
await this.undoLastBump();
|
||||||
|
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) {
|
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
|
// 2. Info mode
|
||||||
if (info) {
|
if (info) {
|
||||||
|
console.log(`Current Version: ${color.green(currentVersion)} (${source})`);
|
||||||
this.showInfo(currentVersion);
|
this.showInfo(currentVersion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,56 +64,36 @@ class VersionCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Update files
|
// 5. Execution (Tag + .env)
|
||||||
console.log(`\nBumping version: ${color.dim(currentVersion)} → ${color.green(nextVersion)}`);
|
console.log(`\nBumping version: ${color.dim(currentVersion)} → ${color.green(nextVersion)}`);
|
||||||
|
|
||||||
const updatedFiles = [];
|
const updatedFiles = [];
|
||||||
|
|
||||||
// Update package.json
|
// Update .env (Only if exists)
|
||||||
if (this.updatePackageJson(nextVersion)) updatedFiles.push('package.json');
|
|
||||||
|
|
||||||
// Update .env
|
|
||||||
const envUpdates = this.updateEnvFiles(nextVersion);
|
const envUpdates = this.updateEnvFiles(nextVersion);
|
||||||
updatedFiles.push(...envUpdates);
|
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) {
|
if (updatedFiles.length > 0) {
|
||||||
console.log(`${color.green('✔')} Updated ${updatedFiles.join(', ')}`);
|
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
|
// 6. Create Git Tag (The Truth)
|
||||||
await this.createRelease(nextVersion, updatedFiles);
|
await this.createTag(nextVersion);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Progress.error(`Version bump failed: ${error.message}`);
|
Progress.error(`Version bump failed: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCurrentVersion() {
|
getPackageJsonVersion() {
|
||||||
// Try package.json
|
|
||||||
if (fs.existsSync('package.json')) {
|
if (fs.existsSync('package.json')) {
|
||||||
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||||
if (pkg.version) return pkg.version;
|
return pkg.version;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEnvFiles(newVersion) {
|
updateEnvFiles(newVersion) {
|
||||||
@@ -102,14 +105,12 @@ class VersionCommand {
|
|||||||
let content = fs.readFileSync(file, 'utf8');
|
let content = fs.readFileSync(file, 'utf8');
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
// Match VERSION=... or APP_VERSION=...
|
// Match common version vars
|
||||||
const regex = /^(VERSION|APP_VERSION|NEXT_PUBLIC_VERSION)=(.*)$/gm;
|
const regex = /^(VERSION|APP_VERSION|NEXT_PUBLIC_VERSION|REACT_APP_VERSION|S4_VERSION)=(.*)$/gm;
|
||||||
|
|
||||||
if (regex.test(content)) {
|
if (regex.test(content)) {
|
||||||
content = content.replace(regex, `$1=${newVersion}`);
|
content = content.replace(regex, `$1=${newVersion}`);
|
||||||
changed = true;
|
changed = true;
|
||||||
} else {
|
|
||||||
// Optionally append if missing? Maybe too aggressive.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -122,25 +123,122 @@ class VersionCommand {
|
|||||||
return updates;
|
return updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createRelease(version, files) {
|
async createTag(version) {
|
||||||
try {
|
try {
|
||||||
// Stage files
|
// Create lightweight or annotated tag? S4 recommends annotated.
|
||||||
await this.git.add(files);
|
|
||||||
|
|
||||||
// Commit
|
|
||||||
const msg = `chore(release): bump to ${version}`;
|
|
||||||
await this.git.commit(msg);
|
|
||||||
|
|
||||||
// Tag
|
|
||||||
await this.git.addAnnotatedTag(version, `Release ${version}`);
|
await this.git.addAnnotatedTag(version, `Release ${version}`);
|
||||||
|
console.log(`${color.green('✔')} Created git tag: ${color.cyan(version)}`);
|
||||||
console.log(`${color.green('✔')} Created git commit and tag: ${color.cyan(version)}`);
|
console.log(`\nRun ${color.cyan('g push --tags')} to publish`);
|
||||||
console.log(`\nRun ${color.cyan('g push --follow-tags')} to publish`);
|
|
||||||
} catch (e) {
|
} 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.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
async undoLastBump() {
|
||||||
|
Progress.start('Undoing last version bump...');
|
||||||
|
|
||||||
|
// 1. Get current version (the one to delete)
|
||||||
|
const currentVersion = await this.s4.getCurrentVersion();
|
||||||
|
|
||||||
|
if (!currentVersion) {
|
||||||
|
Progress.stop('');
|
||||||
|
console.log(color.yellow('No S4 version tags found to undo.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Delete the tag
|
||||||
|
try {
|
||||||
|
await this.git.tag(['-d', currentVersion]);
|
||||||
|
Progress.stop('');
|
||||||
|
console.log(`${color.green('✔')} Deleted tag: ${color.cyan(currentVersion)}`);
|
||||||
|
} catch (e) {
|
||||||
|
Progress.error(`Failed to delete tag: ${e.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Revert .env files to *previous* version
|
||||||
|
// Now that the latest tag is gone, getCurrentVersion will return the previous one
|
||||||
|
const previousVersion = await this.s4.getCurrentVersion() || '0.0.0';
|
||||||
|
|
||||||
|
if (previousVersion) {
|
||||||
|
console.log(`Reverting environment to previous version: ${color.dim(previousVersion)}`);
|
||||||
|
const updatedFiles = this.updateEnvFiles(previousVersion);
|
||||||
|
if (updatedFiles.length > 0) {
|
||||||
|
console.log(`${color.green('✔')} Updated ${updatedFiles.join(', ')}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(color.dim('\nNote: If you already pushed the tag, you must verify deletion on remote:'));
|
||||||
|
console.log(` ${color.cyan(`git push --delete origin ${currentVersion}`)}`);
|
||||||
|
}
|
||||||
|
|
||||||
showInfo(versionStr) {
|
showInfo(versionStr) {
|
||||||
const parsed = S4Versioning.parse(versionStr);
|
const parsed = S4Versioning.parse(versionStr);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
@@ -148,13 +246,29 @@ class VersionCommand {
|
|||||||
return;
|
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(color.bold('\nS4 Version Analysis:'));
|
||||||
console.log(`Major: ${parsed.major}`);
|
console.log(`Major: ${parsed.major}`);
|
||||||
console.log(`Minor: ${parsed.minor}`);
|
console.log(`Minor: ${parsed.minor}`);
|
||||||
console.log(`Patch: ${parsed.patch}`);
|
console.log(`Patch: ${parsed.patch}`);
|
||||||
console.log(`Stage: ${color.magenta(parsed.stage)}`);
|
console.log(`Stage: ${color.magenta(parsed.stage)}`);
|
||||||
console.log(`Build: ${parsed.build}`);
|
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})`);
|
console.log(`Git: ${parsed.branch} (${parsed.commit})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ class WhoAmICommand {
|
|||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
const pkg = require('../../../package.json');
|
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 user = os.userInfo().username;
|
||||||
const hostname = os.hostname();
|
const hostname = os.hostname();
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
@@ -32,7 +38,7 @@ class WhoAmICommand {
|
|||||||
console.log(`└─ Email: ${color.cyan(gitEmail)}`);
|
console.log(`└─ Email: ${color.cyan(gitEmail)}`);
|
||||||
|
|
||||||
console.log(`\n${color.green('TOOL_METRICS')}`);
|
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(`├─ Engine: Node ${process.version}`);
|
||||||
console.log(`└─ Author: ${pkg.author}`);
|
console.log(`└─ Author: ${pkg.author}`);
|
||||||
|
|
||||||
|
|||||||
+62
-10
@@ -16,6 +16,7 @@ class S4Versioning {
|
|||||||
* Parse an S4 version string into components
|
* Parse an S4 version string into components
|
||||||
*/
|
*/
|
||||||
static parse(versionStr) {
|
static parse(versionStr) {
|
||||||
|
if (!versionStr) return null;
|
||||||
const match = versionStr.match(S4Versioning.REGEX);
|
const match = versionStr.match(S4Versioning.REGEX);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
|
|
||||||
@@ -41,6 +42,62 @@ class S4Versioning {
|
|||||||
return `${major}.${minor}.${patch}-${stage}.${build}+${date}.${time}.${commit}.${branch}`;
|
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
|
* Migrate a standard SemVer or empty version to S4
|
||||||
*/
|
*/
|
||||||
@@ -114,11 +171,7 @@ class S4Versioning {
|
|||||||
// Handle stage change
|
// Handle stage change
|
||||||
if (stageVal && stageVal !== parsed.stage) {
|
if (stageVal && stageVal !== parsed.stage) {
|
||||||
next.stage = stageVal;
|
next.stage = stageVal;
|
||||||
next.build = 1; // Stage change resets build usually? S4 "Sequence" implies uniqueness.
|
next.build = 1;
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logic for bumping
|
// Logic for bumping
|
||||||
@@ -147,14 +200,13 @@ class S4Versioning {
|
|||||||
}
|
}
|
||||||
// 2. If Date is SAME
|
// 2. If Date is SAME
|
||||||
else {
|
else {
|
||||||
// If Commit Changed -> It's a new build of the same day
|
// If Commit Changed -> new build
|
||||||
if (parsed.commit !== ctx.commit) {
|
if (parsed.commit !== ctx.commit) {
|
||||||
next.build = parsed.build + 1;
|
next.build = parsed.build + 1;
|
||||||
}
|
}
|
||||||
// If Commit is SAME and user requested bump, force build increment?
|
// If same commit & same date, usually we don't need a new tag
|
||||||
// "auto" implies we just want the "next" logical version for the current state.
|
// unless user forces it.
|
||||||
// If nothing changed, maybe we shouldn't bump?
|
// For safety, increment build to ensure uniqueness if they insisted on running `g v`.
|
||||||
// But usually CI calls this to FORCE a new version.
|
|
||||||
else {
|
else {
|
||||||
next.build = parsed.build + 1;
|
next.build = parsed.build + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "get_status",
|
||||||
|
"description": "Get enhanced git status with AI insights, file modification stats, and branch context. Use this to understand the current state of the repository.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "analyze_history",
|
||||||
|
"description": "Analyze recent commit history, including authors, conventions, and activity patterns.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"limit": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Number of commits to analyze (default: 10)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "version_info",
|
||||||
|
"description": "Get current project version information using S4 versioning (Semantic + Date/Time).",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "generate_commit_message",
|
||||||
|
"description": "Generate a high-quality commit message based on currently staged changes.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"context": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Optional context or user instruction for the message generation"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "run_git_command",
|
||||||
|
"description": "Execute a raw git command safely. Use this for standard git operations not covered by other tools.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"command": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The full git command to run (e.g., 'log -n 5', 'branch --list')"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"command"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIMS MCP Server
|
||||||
|
*
|
||||||
|
* Exposes GIMS capabilities as Model Context Protocol (MCP) tools.
|
||||||
|
* Usage: node mcp/index.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
|
||||||
|
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
||||||
|
const {
|
||||||
|
CallToolRequestSchema,
|
||||||
|
ListToolsRequestSchema,
|
||||||
|
} = require("@modelcontextprotocol/sdk/types.js");
|
||||||
|
const { tools } = require('../bin/lib/ai/interface');
|
||||||
|
|
||||||
|
// Create the server
|
||||||
|
const server = new Server(
|
||||||
|
{
|
||||||
|
name: "gims-mcp-server",
|
||||||
|
version: require('../package.json').version,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
capabilities: {
|
||||||
|
tools: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for listing available tools
|
||||||
|
*/
|
||||||
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||||
|
return {
|
||||||
|
tools: tools.map((tool) => ({
|
||||||
|
name: tool.name,
|
||||||
|
description: tool.description,
|
||||||
|
inputSchema: tool.inputSchema,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for calling tools
|
||||||
|
*/
|
||||||
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||||
|
const toolName = request.params.name;
|
||||||
|
const toolArgs = request.params.arguments;
|
||||||
|
|
||||||
|
const tool = tools.find((t) => t.name === toolName);
|
||||||
|
|
||||||
|
if (!tool) {
|
||||||
|
throw new Error(`Unknown tool: ${toolName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await tool.handler(toolArgs);
|
||||||
|
|
||||||
|
// MCP expects content to be an array of text/image objects
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: JSON.stringify(result, null, 2),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: `Error executing ${toolName}: ${error.message}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the server
|
||||||
|
*/
|
||||||
|
async function main() {
|
||||||
|
const transport = new StdioServerTransport();
|
||||||
|
await server.connect(transport);
|
||||||
|
console.error("GIMS MCP Server running on stdio");
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error("Server error:", error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Generated
+943
-10
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gims",
|
"name": "gims",
|
||||||
"version": "0.8.2-dev.2+20260128.2346.9eaa681.main",
|
"version": "0.9.1",
|
||||||
"description": "Git Made Simple – AI‑powered git helper with smart insights, stats & code review",
|
"description": "Git Made Simple – AI‑powered git helper with smart insights, stats & code review",
|
||||||
"author": "S41R4J",
|
"author": "S41R4J",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google/genai": "1.5.1",
|
"@google/genai": "1.5.1",
|
||||||
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
||||||
"clipboardy": "^3.0.0",
|
"clipboardy": "^3.0.0",
|
||||||
"commander": "^11.1.0",
|
"commander": "^11.1.0",
|
||||||
"openai": "^4.0.0",
|
"openai": "^4.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
const { OpenAI } = require('openai');
|
||||||
|
const process = require('process');
|
||||||
|
|
||||||
|
async function testOpenAI() {
|
||||||
|
console.log('Testing OpenAI connection...');
|
||||||
|
console.log('API Key present:', !!process.env.OPENAI_API_KEY);
|
||||||
|
console.log('Model:', 'gpt-5.2-2025-12-11');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
||||||
|
|
||||||
|
// Log the base URL to see if it's custom
|
||||||
|
console.log('Base URL:', openai.baseURL);
|
||||||
|
|
||||||
|
const response = await openai.chat.completions.create({
|
||||||
|
model: 'gpt-5.2-2025-12-11',
|
||||||
|
messages: [{ role: 'user', content: 'Say hello' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Success!');
|
||||||
|
console.log('Content:', response.choices[0].message.content);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('ERROR OCCURRED:');
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testOpenAI();
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { tools } = require('../bin/lib/ai/interface');
|
||||||
|
|
||||||
|
const schema = tools.map(tool => ({
|
||||||
|
type: "function",
|
||||||
|
function: {
|
||||||
|
name: tool.name,
|
||||||
|
description: tool.description,
|
||||||
|
parameters: tool.inputSchema
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
const outputPath = path.resolve(__dirname, '../bin/tools-schema.json');
|
||||||
|
fs.writeFileSync(outputPath, JSON.stringify(schema, null, 2));
|
||||||
|
|
||||||
|
console.log(`✅ Generated OpenAI-compatible tool schemas at: ${outputPath}`);
|
||||||
|
console.log(`Total tools: ${tools.length}`);
|
||||||
Whitespace-only changes.
Reference in new issue
Block a user