@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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +223 -0
  3. package/dist/bin/gb.js +3275 -0
  4. package/dist/bin/gitbridge.js +3275 -0
  5. package/dist/cli/commands/account.d.ts +3 -0
  6. package/dist/cli/commands/auth.d.ts +7 -0
  7. package/dist/cli/commands/context.d.ts +2 -0
  8. package/dist/cli/commands/credential.d.ts +18 -0
  9. package/dist/cli/commands/doctor.d.ts +2 -0
  10. package/dist/cli/commands/enable.d.ts +3 -0
  11. package/dist/cli/commands/hook.d.ts +1 -0
  12. package/dist/cli/commands/identity.d.ts +11 -0
  13. package/dist/cli/commands/provider.d.ts +1 -0
  14. package/dist/cli/commands/push.d.ts +5 -0
  15. package/dist/cli/commands/remote.d.ts +5 -0
  16. package/dist/cli/commands/repo.d.ts +2 -0
  17. package/dist/cli/commands/rule.d.ts +8 -0
  18. package/dist/cli/commands/setup.d.ts +2 -0
  19. package/dist/cli/commands/status.d.ts +2 -0
  20. package/dist/cli/commands/switch.d.ts +4 -0
  21. package/dist/cli/index.d.ts +2 -0
  22. package/dist/cli/ui/banners.d.ts +2 -0
  23. package/dist/cli/ui/prompts.d.ts +31 -0
  24. package/dist/cli/ui/tables.d.ts +6 -0
  25. package/dist/core/config/config-store.d.ts +56 -0
  26. package/dist/core/config/path-resolver.d.ts +20 -0
  27. package/dist/core/config/schema.d.ts +461 -0
  28. package/dist/core/git/config-generator.d.ts +12 -0
  29. package/dist/core/git/git-cli.d.ts +32 -0
  30. package/dist/core/git/gitconfig-injector.d.ts +14 -0
  31. package/dist/core/git/url-parser.d.ts +16 -0
  32. package/dist/core/identity/identity-resolver.d.ts +23 -0
  33. package/dist/core/providers/bitbucket.provider.d.ts +12 -0
  34. package/dist/core/providers/github.provider.d.ts +15 -0
  35. package/dist/core/providers/gitlab.provider.d.ts +12 -0
  36. package/dist/core/providers/provider-registry.d.ts +11 -0
  37. package/dist/core/providers/provider.interface.d.ts +50 -0
  38. package/dist/core/safety/identity-guard.d.ts +18 -0
  39. package/dist/core/ssh/ssh-config-generator.d.ts +6 -0
  40. package/dist/core/ssh/ssh-injector.d.ts +14 -0
  41. package/dist/core/ssh/ssh-key-detector.d.ts +10 -0
  42. package/dist/core/storage/credential-store.d.ts +7 -0
  43. package/dist/core/storage/encrypted-vault.d.ts +16 -0
  44. package/dist/core/storage/linux-keyring.d.ts +8 -0
  45. package/dist/core/storage/macos-keychain.d.ts +8 -0
  46. package/dist/core/storage/store-factory.d.ts +5 -0
  47. package/dist/core/storage/windows-cred.d.ts +9 -0
  48. package/dist/index.d.ts +20 -0
  49. package/dist/index.js +3356 -0
  50. package/dist/index.js.map +7 -0
  51. package/dist/utils/errors.d.ts +22 -0
  52. package/dist/utils/http.d.ts +10 -0
  53. package/dist/utils/logger.d.ts +15 -0
  54. package/dist/utils/platform.d.ts +8 -0
  55. 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)