@freetison/git-super 0.2.0
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/LICENSE +201 -0
- package/README.md +384 -0
- package/bin/git-super.mjs +576 -0
- package/lib/ARCHITECTURE.md +254 -0
- package/lib/auth/auth-strategy.mjs +132 -0
- package/lib/auth/credential-store.mjs +222 -0
- package/lib/auth/oauth-flows.mjs +266 -0
- package/lib/auth/token-manager.mjs +246 -0
- package/lib/cli/auth-commands.mjs +327 -0
- package/lib/config/config-loader.mjs +167 -0
- package/lib/fallback/add-files-strategy.mjs +15 -0
- package/lib/fallback/base-fallback-strategy.mjs +34 -0
- package/lib/fallback/delete-files-strategy.mjs +15 -0
- package/lib/fallback/fallback-resolver.mjs +54 -0
- package/lib/fallback/modify-files-strategy.mjs +15 -0
- package/lib/providers/anthropic-provider.mjs +44 -0
- package/lib/providers/azure-openai-provider.mjs +185 -0
- package/lib/providers/base-oauth-provider.mjs +62 -0
- package/lib/providers/base-provider.mjs +29 -0
- package/lib/providers/generic-oidc-provider.mjs +144 -0
- package/lib/providers/github-copilot-provider.mjs +113 -0
- package/lib/providers/ollama-provider.mjs +109 -0
- package/lib/providers/openai-provider.mjs +44 -0
- package/lib/providers/provider-registry.mjs +99 -0
- package/package.json +59 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry - Factory/Registry Pattern
|
|
3
|
+
* Manages AI provider instances and resolves them by name
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { OllamaProvider } from './ollama-provider.mjs';
|
|
7
|
+
import { AnthropicProvider } from './anthropic-provider.mjs';
|
|
8
|
+
import { OpenAIProvider } from './openai-provider.mjs';
|
|
9
|
+
import { GitHubCopilotProvider } from './github-copilot-provider.mjs';
|
|
10
|
+
import { AzureOpenAIProvider } from './azure-openai-provider.mjs';
|
|
11
|
+
import { GenericOIDCProvider } from './generic-oidc-provider.mjs';
|
|
12
|
+
|
|
13
|
+
export class ProviderRegistry {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.providers = new Map();
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.initializeProviders();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Initialize all available providers
|
|
22
|
+
*/
|
|
23
|
+
initializeProviders() {
|
|
24
|
+
// API Key based providers
|
|
25
|
+
this.register('ollama', new OllamaProvider(this.config));
|
|
26
|
+
this.register('anthropic', new AnthropicProvider(this.config));
|
|
27
|
+
this.register('openai', new OpenAIProvider(this.config));
|
|
28
|
+
|
|
29
|
+
// OAuth/SSO providers (lazy initialization to avoid errors if not configured)
|
|
30
|
+
try {
|
|
31
|
+
if (this.config.githubClientId || this.config.githubOrg) {
|
|
32
|
+
this.register('github-copilot', new GitHubCopilotProvider(this.config));
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// GitHub Copilot not configured, skip
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
if (this.config.azureClientId && this.config.azureResourceEndpoint) {
|
|
40
|
+
this.register('azure-openai', new AzureOpenAIProvider(this.config));
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// Azure OpenAI not configured, skip
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
if (this.config.oidcIssuer && this.config.oidcClientId) {
|
|
48
|
+
this.register('generic-oidc', new GenericOIDCProvider(this.config));
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
// Generic OIDC not configured, skip
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Register a provider with a name
|
|
57
|
+
* @param {string} name - Provider identifier
|
|
58
|
+
* @param {BaseAIProvider} provider - Provider instance
|
|
59
|
+
*/
|
|
60
|
+
register(name, provider) {
|
|
61
|
+
this.providers.set(name, provider);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get a provider by name
|
|
66
|
+
* @param {string} name - Provider identifier
|
|
67
|
+
* @returns {BaseAIProvider}
|
|
68
|
+
* @throws {Error} If provider not found
|
|
69
|
+
*/
|
|
70
|
+
get(name) {
|
|
71
|
+
const provider = this.providers.get(name);
|
|
72
|
+
|
|
73
|
+
if (!provider) {
|
|
74
|
+
const available = Array.from(this.providers.keys()).join(', ');
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Provider '${name}' not found. Available providers: ${available}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return provider;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Check if a provider exists
|
|
85
|
+
* @param {string} name - Provider identifier
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
has(name) {
|
|
89
|
+
return this.providers.has(name);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get all registered provider names
|
|
94
|
+
* @returns {string[]}
|
|
95
|
+
*/
|
|
96
|
+
getAvailableProviders() {
|
|
97
|
+
return Array.from(this.providers.keys());
|
|
98
|
+
}
|
|
99
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@freetison/git-super",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "AI-powered git commits with OAuth/SSO support - works with any repo, supports enterprise authentication",
|
|
5
|
+
"author": "Angel Sola",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"git-super": "./bin/git-super.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"lib",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"test:coverage": "vitest run --coverage",
|
|
20
|
+
"postinstall": "echo '💡 Run: git config --global alias.super \"!git-super\"'"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"git",
|
|
24
|
+
"ai",
|
|
25
|
+
"commit",
|
|
26
|
+
"ollama",
|
|
27
|
+
"claude",
|
|
28
|
+
"openai",
|
|
29
|
+
"azure",
|
|
30
|
+
"github-copilot",
|
|
31
|
+
"oauth",
|
|
32
|
+
"sso",
|
|
33
|
+
"enterprise",
|
|
34
|
+
"conventional-commits",
|
|
35
|
+
"cli"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"open": "^10.1.0"
|
|
42
|
+
},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"keytar": "^7.9.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"vitest": "^2.1.8",
|
|
48
|
+
"@vitest/coverage-v8": "^2.1.8"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"registry": "https://registry.npmjs.org/",
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/freetison/git-super",
|
|
57
|
+
"directory": ""
|
|
58
|
+
}
|
|
59
|
+
}
|