@fuad24/gitbridge 0.1.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 +21 -0
- package/README.md +223 -0
- package/dist/bin/gb.js +3275 -0
- package/dist/bin/gitbridge.js +3275 -0
- package/dist/cli/commands/account.d.ts +3 -0
- package/dist/cli/commands/auth.d.ts +7 -0
- package/dist/cli/commands/context.d.ts +2 -0
- package/dist/cli/commands/credential.d.ts +18 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/enable.d.ts +3 -0
- package/dist/cli/commands/hook.d.ts +1 -0
- package/dist/cli/commands/identity.d.ts +11 -0
- package/dist/cli/commands/provider.d.ts +1 -0
- package/dist/cli/commands/push.d.ts +5 -0
- package/dist/cli/commands/remote.d.ts +5 -0
- package/dist/cli/commands/repo.d.ts +2 -0
- package/dist/cli/commands/rule.d.ts +8 -0
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/switch.d.ts +4 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/ui/banners.d.ts +2 -0
- package/dist/cli/ui/prompts.d.ts +31 -0
- package/dist/cli/ui/tables.d.ts +6 -0
- package/dist/core/config/config-store.d.ts +56 -0
- package/dist/core/config/path-resolver.d.ts +20 -0
- package/dist/core/config/schema.d.ts +461 -0
- package/dist/core/git/config-generator.d.ts +12 -0
- package/dist/core/git/git-cli.d.ts +32 -0
- package/dist/core/git/gitconfig-injector.d.ts +14 -0
- package/dist/core/git/url-parser.d.ts +16 -0
- package/dist/core/identity/identity-resolver.d.ts +23 -0
- package/dist/core/providers/bitbucket.provider.d.ts +12 -0
- package/dist/core/providers/github.provider.d.ts +15 -0
- package/dist/core/providers/gitlab.provider.d.ts +12 -0
- package/dist/core/providers/provider-registry.d.ts +11 -0
- package/dist/core/providers/provider.interface.d.ts +50 -0
- package/dist/core/safety/identity-guard.d.ts +18 -0
- package/dist/core/ssh/ssh-config-generator.d.ts +6 -0
- package/dist/core/ssh/ssh-injector.d.ts +14 -0
- package/dist/core/ssh/ssh-key-detector.d.ts +10 -0
- package/dist/core/storage/credential-store.d.ts +7 -0
- package/dist/core/storage/encrypted-vault.d.ts +16 -0
- package/dist/core/storage/linux-keyring.d.ts +8 -0
- package/dist/core/storage/macos-keychain.d.ts +8 -0
- package/dist/core/storage/store-factory.d.ts +5 -0
- package/dist/core/storage/windows-cred.d.ts +9 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +3356 -0
- package/dist/index.js.map +7 -0
- package/dist/utils/errors.d.ts +22 -0
- package/dist/utils/http.d.ts +10 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/platform.d.ts +8 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fuad Tesfaye
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
# π `GitBridge`
|
|
6
|
+
### *Universal Git Identity, Multi-Account & Provider Management Layer*
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<b>Seamlessly manage identities, provider accounts, and SSH keys across Git workflows without wrapping or replacing native Git.</b>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://github.com/FuadTesfaye/gitbridge/actions"><img src="https://img.shields.io/badge/Tests-44%2F44%20Passed-2ea44f?style=for-the-badge&logo=githubactions&logoColor=white" alt="Tests" /></a>
|
|
14
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.8-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" /></a>
|
|
15
|
+
<a href="https://bun.sh/"><img src="https://img.shields.io/badge/Bun-1.3-fbf0df?style=for-the-badge&logo=bun&logoColor=black" alt="Bun" /></a>
|
|
16
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-f1c40f?style=for-the-badge" alt="License: MIT" /></a>
|
|
17
|
+
<a href="./extension"><img src="https://img.shields.io/badge/IDE-VS%20Code%20%7C%20Cursor%20%7C%20Antigravity-8a2be2?style=for-the-badge&logo=visualstudiocode&logoColor=white" alt="IDE Extension" /></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="#-quick-start"><b>β‘ Quick Start</b></a> β’
|
|
22
|
+
<a href="#-why-gitbridge"><b>π‘ Why GitBridge?</b></a> β’
|
|
23
|
+
<a href="#-fast-command-matrix-gitbridge--gb"><b>β¨οΈ Fast Commands</b></a> β’
|
|
24
|
+
<a href="#-ide-extension-vs-code-cursor--antigravity"><b>π₯οΈ IDE Extension</b></a> β’
|
|
25
|
+
<a href="#-security-model--local-only-architecture"><b>π Security</b></a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<br />
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Developer / IDE (VS Code, Cursor, Antigravity)
|
|
32
|
+
β
|
|
33
|
+
(Standard git commands)
|
|
34
|
+
βΌ
|
|
35
|
+
Native Git
|
|
36
|
+
β
|
|
37
|
+
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββ
|
|
38
|
+
β β β
|
|
39
|
+
[includeIf / .gitconfig] [credential.helper] [~/.ssh/config]
|
|
40
|
+
β β β
|
|
41
|
+
βΌ βΌ βΌ
|
|
42
|
+
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
43
|
+
βIdentity Engineβ βSecure Keyring β βSSH Host Routerβ
|
|
44
|
+
βpersonal vsworkβ βmacOS/Linux/Winβ βgithub.com-workβ
|
|
45
|
+
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## π‘ Why GitBridge?
|
|
53
|
+
|
|
54
|
+
| The Problem Without GitBridge β | The Solution With GitBridge β‘ |
|
|
55
|
+
|---|---|
|
|
56
|
+
| **Accidental Leaks**: Committing with your personal email in company repos or your corporate email in open-source projects. | **Automatic Context Routing**: Enter `~/Personal` and Git automatically signs as personal; enter `~/Projects/work` and it seamlessly switches identities via `includeIf`. |
|
|
57
|
+
| **SSH Collision Hell**: Pushing to multiple GitHub accounts fails or attempts the wrong SSH key. | **Isolated SSH Routing**: Generates discrete `Host github.com-<account>` aliases with `IdentitiesOnly yes` automatically. |
|
|
58
|
+
| **Plaintext Tokens**: Personal access tokens written in plaintext files or cleartext git configs. | **Hardware Keyring Integration**: Tokens are stored 100% locally in **Linux Secret Service**, **macOS Keychain**, or **Windows Credential Manager**. |
|
|
59
|
+
| **Bloated CLI Wrappers**: Tools that alias or intercept `git` add runtime latency and break editor tools. | **Native-First Architecture**: 0ms overhead. VS Code, Cursor, JetBrains, and terminal execute pure native Git. |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## β‘ Quick Start
|
|
64
|
+
|
|
65
|
+
### 1. Global Installation
|
|
66
|
+
```bash
|
|
67
|
+
# Via Bun (Fastest)
|
|
68
|
+
bun add -g @fuad24/gitbridge
|
|
69
|
+
|
|
70
|
+
# Or via npm
|
|
71
|
+
npm install -g @fuad24/gitbridge
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. Run the 60-Second Setup Wizard
|
|
75
|
+
```bash
|
|
76
|
+
gb setup
|
|
77
|
+
```
|
|
78
|
+
The interactive setup will guide you through:
|
|
79
|
+
1. Configuring your **Personal** and **Work** identities.
|
|
80
|
+
2. Connecting your provider accounts (**GitHub Device Flow**, **GitLab**, or **Bitbucket**).
|
|
81
|
+
3. Defining workspace directory routing rules (e.g. `~/Projects/work/**` $\to$ `work`).
|
|
82
|
+
4. Activating Git and SSH integration points.
|
|
83
|
+
|
|
84
|
+
### 3. Verify Health & Connectivity
|
|
85
|
+
```bash
|
|
86
|
+
gb doc
|
|
87
|
+
```
|
|
88
|
+
Runs comprehensive diagnostics for your Git toolchain, OS keyring, SSH keys, and provider API reachability.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## β¨οΈ Fast Command Matrix (`gitbridge` / `gb`)
|
|
93
|
+
|
|
94
|
+
GitBridge provides dual binaries (`gitbridge` and `gb`) with identical high-speed execution and short aliases:
|
|
95
|
+
|
|
96
|
+
| Category | Fast Command | Full Command | Action |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| π **Overview** | `gb st` | `gitbridge status` | Display dashboard of identities, accounts, rules & status |
|
|
99
|
+
| π **Context** | `gb ctx` | `gitbridge context` | Inspect active identity and email mismatch warnings for current folder |
|
|
100
|
+
| π **Switch** | `gb sw [id]` | `gitbridge switch [id]` | Switch Git identity for the current repo (or `-g` for global default) |
|
|
101
|
+
| π οΈ **Init** | `gb init` | `gitbridge init` | Initialize repository profile & pre-commit safety guard |
|
|
102
|
+
| π€ **Identities** | `gb id ls` | `gitbridge identity list` | List all configured commit identities |
|
|
103
|
+
| | `gb id add` | `gitbridge identity add` | Create a new Git identity (interactive or with `--name`, `--email`) |
|
|
104
|
+
| | `gb id use <id>` | `gitbridge identity use <id>` | Set an identity as global default |
|
|
105
|
+
| | `gb id rm <id>` | `gitbridge identity remove <id>` | Remove an identity |
|
|
106
|
+
| π **Accounts** | `gb acc ls` | `gitbridge account list` | List authenticated Git provider accounts |
|
|
107
|
+
| | `gb acc rm <id>` | `gitbridge account remove <id>` | Remove account and wipe tokens from OS keyring |
|
|
108
|
+
| π **Auth** | `gb auth login` | `gitbridge auth login [prov]` | Authenticate with GitHub (Web Browser/PAT), GitLab, or Bitbucket |
|
|
109
|
+
| | `gb auth logout`| `gitbridge auth logout <prov>`| Revoke tokens and log out |
|
|
110
|
+
| π **Rules** | `gb rules ls` | `gitbridge rule list` | List directory routing rules |
|
|
111
|
+
| | `gb rule add` | `gitbridge rule add [dir] [id]` | Map a workspace folder path to a Git identity |
|
|
112
|
+
| | `gb rule rm` | `gitbridge rule remove <id>` | Delete a directory routing rule |
|
|
113
|
+
| π **Remotes** | `gb rem ls` | `gitbridge remote list` | List remotes configured for current repository |
|
|
114
|
+
| | `gb rem add` | `gitbridge remote add <n> <u>` | Add remote with automatic SSH account host routing |
|
|
115
|
+
| π **Multi-Push** | `gb push --all` | `gitbridge push --all` | Push active branch to all configured remotes simultaneously |
|
|
116
|
+
| βοΈ **Integrations**| `gb enable` | `gitbridge enable` | Safely inject GitBridge managed blocks into Git & SSH configs |
|
|
117
|
+
| | `gb disable` | `gitbridge disable` | Safely remove GitBridge blocks and restore original configs |
|
|
118
|
+
| π©Ί **Doctor** | `gb doc` | `gitbridge doctor` | Run full diagnostics (Git CLI, Keyring, SSH Keys, Provider APIs) |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## π₯οΈ IDE Extension (VS Code, Cursor & Antigravity)
|
|
123
|
+
|
|
124
|
+
GitBridge includes a built-in extension in [`extension/`](./extension) compatible with **VS Code**, **Cursor**, **Windsurf**, and **Google Antigravity IDE**:
|
|
125
|
+
|
|
126
|
+
<div align="center">
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
130
|
+
β Activity Bar β GitBridge Explorer (Sidebar) β
|
|
131
|
+
β βββββββββββββ β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
132
|
+
β π GitBridge β βΌ ACTIVE CONTEXT β
|
|
133
|
+
β β π Repository: my-awesome-app β
|
|
134
|
+
β β π€ Identity: Fuad Tesfaye <personal@example.com> β
|
|
135
|
+
β β π·οΈ Source: Directory Rule (~/Personal) β
|
|
136
|
+
β β π Account: @FuadTesfaye (GitHub) β
|
|
137
|
+
β β π Remote: origin (git@github.com:...) β
|
|
138
|
+
β β β
|
|
139
|
+
β β βΌ IDENTITIES [+] β
|
|
140
|
+
β β β personal (Fuad Tesfaye <personal@example.com>) β
|
|
141
|
+
β β β work (Fuad Tesfaye <work@company.com>) β
|
|
142
|
+
β β β
|
|
143
|
+
β β βΌ ACCOUNTS & PROVIDERS [+] β
|
|
144
|
+
β β π GitHub: @FuadTesfaye (OAuth Keyring) β
|
|
145
|
+
β β π¦ GitLab: @fuad_corp (PAT) β
|
|
146
|
+
β β β
|
|
147
|
+
β β βΌ DIRECTORY RULES [+] β
|
|
148
|
+
β β π ~/Personal β personal β
|
|
149
|
+
β β π ~/Projects/work β work β
|
|
150
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
151
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
152
|
+
β Status Bar: [$(person) personal: Fuad Tesfaye] [$(github) @FuadTesfaye] β
|
|
153
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
### Extension Highlights:
|
|
159
|
+
- π€ **Live Status Bar Widget**: Shows active identity badge and provider account at all times.
|
|
160
|
+
- π **Real-Time State Watcher**: Run `gb sw work` in your terminal and the IDE status bar and explorer update instantly without an editor reload.
|
|
161
|
+
- β οΈ **Mismatch Warning**: Highlights mismatched `.git/config` emails before you commit.
|
|
162
|
+
- π **One-Click Multi-Push**: Trigger parallel pushes directly from the sidebar.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## π Security Model & Local-Only Architecture
|
|
167
|
+
|
|
168
|
+
GitBridge is engineered with a **zero-trust, local-only security architecture**:
|
|
169
|
+
|
|
170
|
+
- π‘οΈ **100% Local Execution**: GitBridge operates exclusively on your local machine. It has **no telemetry, no tracking, and no external cloud servers**. Requests are made only directly to the Git providers you configure (GitHub, GitLab, Bitbucket).
|
|
171
|
+
- π **Hardware-Backed OS Keychains**: Access tokens and passwords are **never written to plain JSON files, logs, or git config files**. They are stored directly in your operating system's native secure keyring:
|
|
172
|
+
- **Linux**: Linux Secret Service (`secret-tool` / libsecret / DBus Session Keyring).
|
|
173
|
+
- **macOS**: Apple Keychain Services (`/usr/bin/security` backed by Secure Enclave).
|
|
174
|
+
- **Windows**: Windows Credential Manager (DPAPI-encrypted).
|
|
175
|
+
- π **Air-Gapped / Headless Fallback**: In environments without a graphical keychain daemon (e.g. CI containers), credentials are encrypted in `~/.gitbridge/vault.enc` using **AES-256-GCM** with a **PBKDF2** machine-unique derivation key (100,000 rounds of SHA-256 with cryptographically random salt and 12-byte IV).
|
|
176
|
+
- π **Restricted POSIX Permissions**: All configuration and generated files enforce strict permission modes:
|
|
177
|
+
- `~/.gitbridge/` directory: `0700` (`rwx------`, owner only)
|
|
178
|
+
- Config, key & vault files: `0600` (`rw-------`, owner only)
|
|
179
|
+
- ποΈ **SSH Key Isolation**: Dedicated `Host <host>-<account_id>` blocks enforce `IdentitiesOnly yes`, ensuring the SSH agent only presents the specific key mapped to that accountβpreventing cross-account identity leaks.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## ποΈ Identity Resolution Precedence
|
|
184
|
+
|
|
185
|
+
When Git or GitBridge resolves an identity for any directory:
|
|
186
|
+
|
|
187
|
+
$$\text{Local Repository Profile} \succ \text{Directory Rule (includeIf)} \succ \text{Global Default Identity} \succ \text{System Git Config}$$
|
|
188
|
+
|
|
189
|
+
```mermaid
|
|
190
|
+
flowchart TD
|
|
191
|
+
Start["Git Action Triggered (commit / push / clone)"] --> CheckRepo{"Explicit Repo Profile in .git/config?"}
|
|
192
|
+
CheckRepo -- Yes --> ApplyRepo["Apply Repository Identity"]
|
|
193
|
+
CheckRepo -- No --> CheckRule{"Matches Directory includeIf Rule?"}
|
|
194
|
+
CheckRule -- Yes --> ApplyRule["Apply Directory Rule Identity"]
|
|
195
|
+
CheckRule -- No --> CheckGlobal{"GitBridge Default Identity?"}
|
|
196
|
+
CheckGlobal -- Yes --> ApplyGlobal["Apply GitBridge Global Default"]
|
|
197
|
+
CheckGlobal -- No --> ApplySystem["Fallback to System Git Config"]
|
|
198
|
+
|
|
199
|
+
ApplyRepo --> Exec["Execute Native Git Command Seamlessly"]
|
|
200
|
+
ApplyRule --> Exec
|
|
201
|
+
ApplyGlobal --> Exec
|
|
202
|
+
ApplySystem --> Exec
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## π§ͺ Testing & Verification
|
|
208
|
+
|
|
209
|
+
GitBridge is verified with a comprehensive automated test suite covering unit schemas, credential stores, injectors, URL parsers, and full Git lifecycle integrations:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Run all 37 unit & integration tests
|
|
213
|
+
bun test
|
|
214
|
+
|
|
215
|
+
# Run strict TypeScript typechecks
|
|
216
|
+
bun run typecheck
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## π License
|
|
222
|
+
|
|
223
|
+
MIT Β© [Fuad Tesfaye](https://github.com/FuadTesfaye)
|