@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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/core/config/schema.ts", "../src/core/config/config-store.ts", "../src/core/config/path-resolver.ts", "../src/utils/platform.ts", "../src/utils/errors.ts", "../src/core/git/url-parser.ts", "../src/core/git/git-cli.ts", "../src/core/git/config-generator.ts", "../src/core/git/gitconfig-injector.ts", "../src/core/ssh/ssh-config-generator.ts", "../src/core/ssh/ssh-injector.ts", "../src/core/ssh/ssh-key-detector.ts", "../src/core/identity/identity-resolver.ts", "../src/utils/http.ts", "../src/core/providers/github.provider.ts", "../src/core/providers/gitlab.provider.ts", "../src/core/providers/bitbucket.provider.ts", "../src/core/providers/provider-registry.ts", "../src/core/storage/linux-keyring.ts", "../src/core/storage/macos-keychain.ts", "../src/core/storage/windows-cred.ts", "../src/core/storage/encrypted-vault.ts", "../src/core/storage/store-factory.ts", "../src/core/safety/identity-guard.ts", "../src/cli/index.ts", "../src/cli/commands/status.ts", "../src/cli/ui/banners.ts", "../src/cli/ui/tables.ts", "../src/utils/logger.ts", "../src/cli/commands/enable.ts", "../src/cli/ui/prompts.ts", "../src/cli/commands/identity.ts", "../src/cli/commands/account.ts", "../src/cli/commands/auth.ts", "../src/cli/commands/provider.ts", "../src/cli/commands/rule.ts", "../src/cli/commands/repo.ts", "../src/cli/commands/context.ts", "../src/cli/commands/remote.ts", "../src/cli/commands/push.ts", "../src/cli/commands/switch.ts", "../src/cli/commands/doctor.ts", "../src/cli/commands/setup.ts", "../src/cli/commands/credential.ts", "../src/cli/commands/hook.ts"],
4
+ "sourcesContent": ["export * from \"./core/config/schema\";\nexport * from \"./core/config/config-store\";\nexport * from \"./core/config/path-resolver\";\nexport * from \"./core/git/git-cli\";\nexport * from \"./core/git/url-parser\";\nexport * from \"./core/git/config-generator\";\nexport * from \"./core/git/gitconfig-injector\";\nexport * from \"./core/ssh/ssh-config-generator\";\nexport * from \"./core/ssh/ssh-injector\";\nexport * from \"./core/ssh/ssh-key-detector\";\nexport * from \"./core/identity/identity-resolver\";\nexport * from \"./core/providers/provider.interface\";\nexport * from \"./core/providers/provider-registry\";\nexport * from \"./core/providers/github.provider\";\nexport * from \"./core/providers/gitlab.provider\";\nexport * from \"./core/providers/bitbucket.provider\";\nexport * from \"./core/storage/credential-store\";\nexport * from \"./core/storage/store-factory\";\nexport * from \"./core/safety/identity-guard\";\nexport * from \"./cli\";\n", "import { z } from \"zod\";\n\n// Provider IDs\nexport const GitProviderTypeSchema = z.enum([\"github\", \"gitlab\", \"bitbucket\", \"gitea\", \"custom\"]);\nexport type GitProviderType = z.infer<typeof GitProviderTypeSchema>;\n\n// Auth Type\nexport const AuthTypeSchema = z.enum([\"oauth\", \"pat\", \"ssh\", \"password\"]);\nexport type AuthType = z.infer<typeof AuthTypeSchema>;\n\n// Git Identity\nexport const GitIdentitySchema = z.object({\n id: z.string().min(1),\n name: z.string().min(1),\n email: z.string().email(),\n signingKey: z.string().nullable().optional().default(null),\n isDefault: z.boolean().optional().default(false),\n createdAt: z.string().datetime().optional().default(() => new Date().toISOString()),\n});\nexport type GitIdentity = z.infer<typeof GitIdentitySchema>;\n\nexport const IdentitiesFileSchema = z.object({\n identities: z.array(GitIdentitySchema).default([]),\n});\nexport type IdentitiesFile = z.infer<typeof IdentitiesFileSchema>;\n\n// Provider Account\nexport const ProviderAccountSchema = z.object({\n id: z.string().min(1),\n providerId: GitProviderTypeSchema,\n host: z.string().min(1),\n username: z.string().min(1),\n displayName: z.string().optional(),\n authType: AuthTypeSchema,\n sshKeyPath: z.string().optional(),\n createdAt: z.string().datetime().optional().default(() => new Date().toISOString()),\n});\nexport type ProviderAccount = z.infer<typeof ProviderAccountSchema>;\n\nexport const AccountsFileSchema = z.object({\n accounts: z.array(ProviderAccountSchema).default([]),\n});\nexport type AccountsFile = z.infer<typeof AccountsFileSchema>;\n\n// Directory Routing Rule\nexport const DirectoryRuleSchema = z.object({\n id: z.string().min(1),\n path: z.string().min(1),\n identityId: z.string().min(1),\n defaultProvider: GitProviderTypeSchema.optional(),\n defaultAccountId: z.string().optional(),\n});\nexport type DirectoryRule = z.infer<typeof DirectoryRuleSchema>;\n\n// Global Settings\nexport const GitBridgeSettingsSchema = z.object({\n autoSyncGitConfig: z.boolean().default(true),\n credentialHelperEnabled: z.boolean().default(true),\n sshManagementEnabled: z.boolean().default(true),\n commitIdentitySafety: z.boolean().default(true),\n fallbackEncryptedStore: z.boolean().default(false),\n});\nexport type GitBridgeSettings = z.infer<typeof GitBridgeSettingsSchema>;\n\n// Main Configuration\nexport const MainConfigSchema = z.object({\n $schema: z.string().optional(),\n version: z.string().default(\"1.0.0\"),\n enabled: z.boolean().default(true),\n defaultIdentityId: z.string().nullable().optional().default(null),\n rules: z.array(DirectoryRuleSchema).default([]),\n settings: GitBridgeSettingsSchema.default({}),\n});\nexport type MainConfig = z.infer<typeof MainConfigSchema>;\n\n// Repository Remote\nexport const RepositoryRemoteSchema = z.object({\n name: z.string().min(1),\n providerId: GitProviderTypeSchema,\n host: z.string().min(1),\n accountId: z.string().optional(),\n url: z.string().min(1),\n rawUrl: z.string().optional(),\n});\nexport type RepositoryRemote = z.infer<typeof RepositoryRemoteSchema>;\n\n// Repository Profile\nexport const RepositoryProfileSchema = z.object({\n path: z.string().min(1),\n identityId: z.string().optional(),\n remotes: z.array(RepositoryRemoteSchema).default([]),\n safetyHookInstalled: z.boolean().optional().default(false),\n updatedAt: z.string().datetime().optional().default(() => new Date().toISOString()),\n});\nexport type RepositoryProfile = z.infer<typeof RepositoryProfileSchema>;\n\nexport const RepositoriesFileSchema = z.object({\n repositories: z.array(RepositoryProfileSchema).default([]),\n});\nexport type RepositoriesFile = z.infer<typeof RepositoriesFileSchema>;\n\n// Custom Provider definition\nexport const CustomProviderSchema = z.object({\n id: z.string().min(1),\n name: z.string().min(1),\n host: z.string().min(1),\n type: GitProviderTypeSchema.default(\"custom\"),\n apiBaseUrl: z.string().url().optional(),\n});\nexport type CustomProvider = z.infer<typeof CustomProviderSchema>;\n", "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { PathResolver, defaultPathResolver } from \"./path-resolver\";\nimport {\n MainConfigSchema,\n IdentitiesFileSchema,\n AccountsFileSchema,\n RepositoriesFileSchema,\n type MainConfig,\n type GitIdentity,\n type ProviderAccount,\n type DirectoryRule,\n type RepositoryProfile,\n type GitBridgeSettings,\n} from \"./schema\";\nimport { ConfigError } from \"@/utils/errors\";\n\nexport interface CreateIdentityInput {\n id: string;\n name: string;\n email: string;\n signingKey?: string | null;\n isDefault?: boolean;\n}\n\nexport interface CreateAccountInput {\n id: string;\n providerId: ProviderAccount[\"providerId\"];\n host: string;\n username: string;\n displayName?: string;\n authType: ProviderAccount[\"authType\"];\n sshKeyPath?: string;\n}\n\nexport interface SaveRepositoryProfileInput {\n path: string;\n identityId?: string;\n remotes?: RepositoryProfile[\"remotes\"];\n safetyHookInstalled?: boolean;\n}\n\nexport class ConfigStore {\n private paths: PathResolver;\n\n constructor(paths: PathResolver = defaultPathResolver) {\n this.paths = paths;\n }\n\n getPathResolver(): PathResolver {\n return this.paths;\n }\n\n ensureDirectories(): void {\n const dirs = [\n this.paths.getBaseDir(),\n this.paths.getGeneratedDir(),\n this.paths.getRulesDir(),\n this.paths.getBackupsDir(),\n ];\n\n for (const dir of dirs) {\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n }\n }\n\n private atomicWriteJson(filepath: string, data: unknown): void {\n this.ensureDirectories();\n const tempFile = `${filepath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;\n const content = JSON.stringify(data, null, 2);\n fs.writeFileSync(tempFile, content, { encoding: \"utf-8\", mode: 0o600 });\n fs.renameSync(tempFile, filepath);\n }\n\n // --- Main Config ---\n loadConfig(): MainConfig {\n const file = this.paths.getConfigFile();\n if (!fs.existsSync(file)) {\n return MainConfigSchema.parse({});\n }\n try {\n const raw = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n return MainConfigSchema.parse(raw);\n } catch (err: unknown) {\n throw new ConfigError(`Failed to load config from ${file}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n saveConfig(config: Partial<MainConfig>): MainConfig {\n const current = this.loadConfig();\n const merged = MainConfigSchema.parse({ ...current, ...config });\n this.atomicWriteJson(this.paths.getConfigFile(), merged);\n return merged;\n }\n\n updateSettings(settings: Partial<GitBridgeSettings>): MainConfig {\n const current = this.loadConfig();\n const updated = {\n ...current,\n settings: { ...current.settings, ...settings },\n };\n return this.saveConfig(updated);\n }\n\n setEnabled(enabled: boolean): MainConfig {\n return this.saveConfig({ enabled });\n }\n\n // --- Identities ---\n loadIdentities(): GitIdentity[] {\n const file = this.paths.getIdentitiesFile();\n if (!fs.existsSync(file)) {\n return [];\n }\n try {\n const raw = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n const parsed = IdentitiesFileSchema.parse(raw);\n return parsed.identities;\n } catch (err: unknown) {\n throw new ConfigError(`Failed to load identities from ${file}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n saveIdentities(identities: GitIdentity[]): void {\n const validated = IdentitiesFileSchema.parse({ identities });\n this.atomicWriteJson(this.paths.getIdentitiesFile(), validated);\n }\n\n getIdentity(id: string): GitIdentity | undefined {\n const list = this.loadIdentities();\n return list.find((i) => i.id === id);\n }\n\n addIdentity(identity: CreateIdentityInput): GitIdentity {\n const list = this.loadIdentities();\n if (list.some((i) => i.id === identity.id)) {\n throw new ConfigError(`Identity with ID '${identity.id}' already exists.`);\n }\n\n const isFirst = list.length === 0;\n const newIdentity: GitIdentity = {\n id: identity.id,\n name: identity.name,\n email: identity.email,\n signingKey: identity.signingKey || null,\n isDefault: identity.isDefault ?? isFirst,\n createdAt: new Date().toISOString(),\n };\n\n if (newIdentity.isDefault) {\n list.forEach((i) => {\n i.isDefault = false;\n });\n this.saveConfig({ defaultIdentityId: newIdentity.id });\n }\n\n list.push(newIdentity);\n this.saveIdentities(list);\n return newIdentity;\n }\n\n updateIdentity(id: string, updates: Partial<CreateIdentityInput>): GitIdentity {\n const list = this.loadIdentities();\n const index = list.findIndex((i) => i.id === id);\n if (index === -1) {\n throw new ConfigError(`Identity with ID '${id}' not found.`);\n }\n\n if (updates.isDefault) {\n list.forEach((i) => {\n i.isDefault = false;\n });\n this.saveConfig({ defaultIdentityId: id });\n }\n\n const updated: GitIdentity = {\n ...list[index],\n ...updates,\n signingKey: updates.signingKey !== undefined ? updates.signingKey : list[index].signingKey,\n };\n\n list[index] = updated;\n this.saveIdentities(list);\n return updated;\n }\n\n removeIdentity(id: string): boolean {\n const list = this.loadIdentities();\n const filtered = list.filter((i) => i.id !== id);\n if (filtered.length === list.length) {\n return false;\n }\n\n const config = this.loadConfig();\n if (config.defaultIdentityId === id) {\n const nextDefault = filtered[0]?.id ?? null;\n if (filtered[0]) filtered[0].isDefault = true;\n this.saveConfig({ defaultIdentityId: nextDefault });\n }\n\n this.saveIdentities(filtered);\n return true;\n }\n\n setDefaultIdentity(id: string): void {\n const list = this.loadIdentities();\n const target = list.find((i) => i.id === id);\n if (!target) {\n throw new ConfigError(`Identity with ID '${id}' not found.`);\n }\n\n list.forEach((i) => {\n i.isDefault = i.id === id;\n });\n this.saveIdentities(list);\n this.saveConfig({ defaultIdentityId: id });\n }\n\n // --- Accounts ---\n loadAccounts(): ProviderAccount[] {\n const file = this.paths.getAccountsFile();\n if (!fs.existsSync(file)) {\n return [];\n }\n try {\n const raw = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n const parsed = AccountsFileSchema.parse(raw);\n return parsed.accounts;\n } catch (err: unknown) {\n throw new ConfigError(`Failed to load accounts from ${file}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n saveAccounts(accounts: ProviderAccount[]): void {\n const validated = AccountsFileSchema.parse({ accounts });\n this.atomicWriteJson(this.paths.getAccountsFile(), validated);\n }\n\n getAccount(id: string): ProviderAccount | undefined {\n return this.loadAccounts().find((a) => a.id === id);\n }\n\n addAccount(account: CreateAccountInput): ProviderAccount {\n const list = this.loadAccounts();\n const existingIndex = list.findIndex((a) => a.id === account.id);\n const newAccount: ProviderAccount = {\n ...account,\n createdAt: new Date().toISOString(),\n };\n\n if (existingIndex >= 0) {\n list[existingIndex] = newAccount;\n } else {\n list.push(newAccount);\n }\n\n this.saveAccounts(list);\n return newAccount;\n }\n\n removeAccount(id: string): boolean {\n const list = this.loadAccounts();\n const filtered = list.filter((a) => a.id !== id);\n if (filtered.length === list.length) {\n return false;\n }\n this.saveAccounts(filtered);\n return true;\n }\n\n // --- Directory Rules ---\n loadRules(): DirectoryRule[] {\n return this.loadConfig().rules;\n }\n\n addRule(rule: DirectoryRule): DirectoryRule {\n const config = this.loadConfig();\n const existingIndex = config.rules.findIndex((r) => r.id === rule.id || r.path === rule.path);\n if (existingIndex >= 0) {\n config.rules[existingIndex] = rule;\n } else {\n config.rules.push(rule);\n }\n this.saveConfig(config);\n return rule;\n }\n\n removeRule(ruleIdOrPath: string): boolean {\n const config = this.loadConfig();\n const initialLen = config.rules.length;\n config.rules = config.rules.filter((r) => r.id !== ruleIdOrPath && r.path !== ruleIdOrPath);\n if (config.rules.length === initialLen) {\n return false;\n }\n this.saveConfig(config);\n return true;\n }\n\n // --- Repository Profiles ---\n loadRepositories(): RepositoryProfile[] {\n const file = this.paths.getReposFile();\n if (!fs.existsSync(file)) {\n return [];\n }\n try {\n const raw = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n const parsed = RepositoriesFileSchema.parse(raw);\n return parsed.repositories;\n } catch (err: unknown) {\n throw new ConfigError(`Failed to load repositories from ${file}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n saveRepositories(repositories: RepositoryProfile[]): void {\n const validated = RepositoriesFileSchema.parse({ repositories });\n this.atomicWriteJson(this.paths.getReposFile(), validated);\n }\n\n getRepository(repoPath: string): RepositoryProfile | undefined {\n const normalized = path.resolve(repoPath);\n return this.loadRepositories().find((r) => path.resolve(r.path) === normalized);\n }\n\n saveRepositoryProfile(profile: SaveRepositoryProfileInput): RepositoryProfile {\n const list = this.loadRepositories();\n const normalized = path.resolve(profile.path);\n const existingIndex = list.findIndex((r) => path.resolve(r.path) === normalized);\n const updatedProfile: RepositoryProfile = {\n path: normalized,\n identityId: profile.identityId,\n remotes: profile.remotes || [],\n safetyHookInstalled: profile.safetyHookInstalled || false,\n updatedAt: new Date().toISOString(),\n };\n\n if (existingIndex >= 0) {\n list[existingIndex] = updatedProfile;\n } else {\n list.push(updatedProfile);\n }\n\n this.saveRepositories(list);\n return updatedProfile;\n }\n\n removeRepositoryProfile(repoPath: string): boolean {\n const list = this.loadRepositories();\n const normalized = path.resolve(repoPath);\n const filtered = list.filter((r) => path.resolve(r.path) !== normalized);\n if (filtered.length === list.length) {\n return false;\n }\n this.saveRepositories(filtered);\n return true;\n }\n}\n\nexport const defaultConfigStore = new ConfigStore();\n", "import path from \"node:path\";\nimport { getHomeDir, expandTilde } from \"@/utils/platform\";\n\nexport class PathResolver {\n private baseDir: string;\n\n constructor(customBaseDir?: string) {\n if (customBaseDir) {\n this.baseDir = expandTilde(customBaseDir);\n } else if (process.env.GITBRIDGE_HOME) {\n this.baseDir = expandTilde(process.env.GITBRIDGE_HOME);\n } else if (process.env.XDG_CONFIG_HOME) {\n this.baseDir = path.join(expandTilde(process.env.XDG_CONFIG_HOME), \"gitbridge\");\n } else {\n this.baseDir = path.join(getHomeDir(), \".gitbridge\");\n }\n }\n\n getBaseDir(): string {\n return this.baseDir;\n }\n\n getConfigFile(): string {\n return path.join(this.baseDir, \"config.json\");\n }\n\n getIdentitiesFile(): string {\n return path.join(this.baseDir, \"identities.json\");\n }\n\n getAccountsFile(): string {\n return path.join(this.baseDir, \"accounts.json\");\n }\n\n getReposFile(): string {\n return path.join(this.baseDir, \"repos.json\");\n }\n\n getGeneratedDir(): string {\n return path.join(this.baseDir, \"generated\");\n }\n\n getMainGitConfigFile(): string {\n return path.join(this.getGeneratedDir(), \"main.gitconfig\");\n }\n\n getGeneratedSshConfigFile(): string {\n return path.join(this.getGeneratedDir(), \"ssh_config\");\n }\n\n getRulesDir(): string {\n return path.join(this.getGeneratedDir(), \"rules\");\n }\n\n getRuleGitConfigFile(ruleId: string): string {\n const sanitized = ruleId.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n return path.join(this.getRulesDir(), `${sanitized}.gitconfig`);\n }\n\n getBackupsDir(): string {\n return path.join(this.baseDir, \"backups\");\n }\n\n getEncryptedVaultFile(): string {\n return path.join(this.baseDir, \"vault.enc\");\n }\n\n getUserGitConfigFile(): string {\n return path.join(getHomeDir(), \".gitconfig\");\n }\n\n getUserSshConfigFile(): string {\n return path.join(getHomeDir(), \".ssh\", \"config\");\n }\n\n getUserSshDir(): string {\n return path.join(getHomeDir(), \".ssh\");\n }\n}\n\nexport const defaultPathResolver = new PathResolver();\n", "import os from \"node:os\";\nimport path from \"node:path\";\n\nexport type SupportedPlatform = \"linux\" | \"darwin\" | \"win32\" | \"unknown\";\n\nexport function getPlatform(): SupportedPlatform {\n const p = process.platform;\n if (p === \"linux\" || p === \"darwin\" || p === \"win32\") {\n return p;\n }\n return \"unknown\";\n}\n\nexport function isLinux(): boolean {\n return getPlatform() === \"linux\";\n}\n\nexport function isMacOS(): boolean {\n return getPlatform() === \"darwin\";\n}\n\nexport function isWindows(): boolean {\n return getPlatform() === \"win32\";\n}\n\nexport function getHomeDir(): string {\n return os.homedir();\n}\n\nexport function expandTilde(filepath: string): string {\n if (!filepath) return filepath;\n if (filepath.startsWith(\"~/\") || filepath === \"~\") {\n return path.join(getHomeDir(), filepath.slice(1));\n }\n return filepath;\n}\n\nexport function collapseTilde(filepath: string): string {\n if (!filepath) return filepath;\n const home = getHomeDir();\n if (filepath === home) return \"~\";\n if (filepath.startsWith(home + path.sep)) {\n return `~${filepath.slice(home.length)}`;\n }\n return filepath;\n}\n", "export class GitBridgeError extends Error {\n constructor(message: string, public readonly code?: string) {\n super(message);\n this.name = \"GitBridgeError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ConfigError extends GitBridgeError {\n constructor(message: string) {\n super(message, \"CONFIG_ERROR\");\n this.name = \"ConfigError\";\n }\n}\n\nexport class AuthError extends GitBridgeError {\n constructor(message: string) {\n super(message, \"AUTH_ERROR\");\n this.name = \"AuthError\";\n }\n}\n\nexport class ProviderError extends GitBridgeError {\n constructor(message: string, public readonly provider: string) {\n super(`[${provider}] ${message}`, \"PROVIDER_ERROR\");\n this.name = \"ProviderError\";\n }\n}\n\nexport class GitCliError extends GitBridgeError {\n constructor(message: string, public readonly exitCode: number, public readonly stderr: string) {\n super(`Git error (${exitCode}): ${message}`, \"GIT_CLI_ERROR\");\n this.name = \"GitCliError\";\n }\n}\n\nexport class CredentialStoreError extends GitBridgeError {\n constructor(message: string) {\n super(message, \"CREDENTIAL_STORE_ERROR\");\n this.name = \"CredentialStoreError\";\n }\n}\n", "import type { GitProviderType } from \"../config/schema\";\n\nexport interface ParsedRemoteUrl {\n rawUrl: string;\n protocol: \"ssh\" | \"https\" | \"file\" | \"unknown\";\n providerId: GitProviderType;\n host: string;\n rawHost: string;\n accountAlias?: string;\n owner: string;\n repo: string;\n fullName: string;\n}\n\nexport function detectProviderType(host: string): GitProviderType {\n const cleanHost = host.toLowerCase();\n if (cleanHost.includes(\"github.com\") || cleanHost === \"github\") {\n return \"github\";\n }\n if (cleanHost.includes(\"gitlab.com\") || cleanHost === \"gitlab\") {\n return \"gitlab\";\n }\n if (cleanHost.includes(\"bitbucket.org\") || cleanHost === \"bitbucket\") {\n return \"bitbucket\";\n }\n if (cleanHost.includes(\"gitea\") || cleanHost.includes(\"codeberg\")) {\n return \"gitea\";\n }\n return \"custom\";\n}\n\n/**\n * Extracts real host and optional GitBridge account alias from raw host string.\n * Example: github.com-work -> host: github.com, alias: work\n * Example: gitlab.com-personal -> host: gitlab.com, alias: personal\n * Example: my-corp-domain.net -> host: my-corp-domain.net, alias: undefined\n */\nfunction extractHostAndAlias(rawHost: string): { host: string; accountAlias?: string } {\n const knownDomains = [\".com-\", \".org-\", \".net-\", \".io-\", \".dev-\", \".co-\"];\n for (const kd of knownDomains) {\n const idx = rawHost.indexOf(kd);\n if (idx !== -1) {\n const extLen = kd.length - 1; // without '-'\n const host = rawHost.substring(0, idx + extLen);\n const accountAlias = rawHost.substring(idx + kd.length);\n if (accountAlias) {\n return { host, accountAlias };\n }\n }\n }\n\n // Check for short prefixes like github-work or gitlab-personal\n const shortPrefixes = [\"github-\", \"gitlab-\", \"bitbucket-\"];\n for (const sp of shortPrefixes) {\n if (rawHost.startsWith(sp)) {\n const provider = sp.slice(0, -1);\n const host = provider === \"bitbucket\" ? \"bitbucket.org\" : `${provider}.com`;\n const accountAlias = rawHost.slice(sp.length);\n return { host, accountAlias };\n }\n }\n\n return { host: rawHost };\n}\n\nexport function parseRemoteUrl(url: string): ParsedRemoteUrl | null {\n if (!url || typeof url !== \"string\") return null;\n const trimmed = url.trim();\n\n // 1. Check for scp-like SSH: git@host:owner/repo.git or user@host-alias:owner/repo.git\n const scpMatch = trimmed.match(/^(?:([a-zA-Z0-9._-]+)@)?([^:]+):(.+)$/);\n if (\n scpMatch &&\n !trimmed.startsWith(\"http://\") &&\n !trimmed.startsWith(\"https://\") &&\n !trimmed.startsWith(\"ssh://\") &&\n !trimmed.startsWith(\"file://\")\n ) {\n const [, , rawHost, pathPart] = scpMatch;\n const { host, accountAlias } = extractHostAndAlias(rawHost);\n\n const cleanPath = pathPart.replace(/^\\/+/, \"\").replace(/\\.git$/, \"\");\n const pathSegments = cleanPath.split(\"/\");\n const repo = pathSegments.pop() || \"\";\n const owner = pathSegments.join(\"/\");\n\n return {\n rawUrl: trimmed,\n protocol: \"ssh\",\n providerId: detectProviderType(host),\n host,\n rawHost,\n accountAlias,\n owner,\n repo,\n fullName: owner ? `${owner}/${repo}` : repo,\n };\n }\n\n // 2. Check for URL with protocol: https://, ssh://, git://, file://\n try {\n const parsed = new URL(trimmed);\n const rawHost = parsed.hostname;\n const { host, accountAlias } = extractHostAndAlias(rawHost);\n\n let protocol: ParsedRemoteUrl[\"protocol\"] = \"unknown\";\n if (parsed.protocol === \"https:\" || parsed.protocol === \"http:\") {\n protocol = \"https\";\n } else if (parsed.protocol === \"ssh:\" || parsed.protocol === \"git+ssh:\") {\n protocol = \"ssh\";\n } else if (parsed.protocol === \"file:\") {\n protocol = \"file\";\n }\n\n const cleanPath = parsed.pathname.replace(/^\\/+/, \"\").replace(/\\.git$/, \"\");\n const pathSegments = cleanPath.split(\"/\");\n const repo = pathSegments.pop() || \"\";\n const owner = pathSegments.join(\"/\");\n\n return {\n rawUrl: trimmed,\n protocol,\n providerId: detectProviderType(host),\n host,\n rawHost,\n accountAlias,\n owner,\n repo,\n fullName: owner ? `${owner}/${repo}` : repo,\n };\n } catch {\n return null;\n }\n}\n\nexport function buildSshUrl(host: string, owner: string, repo: string, accountId?: string): string {\n const targetHost = accountId ? `${host}-${accountId}` : host;\n const cleanRepo = repo.endsWith(\".git\") ? repo : `${repo}.git`;\n return `git@${targetHost}:${owner}/${cleanRepo}`;\n}\n\nexport function buildHttpsUrl(host: string, owner: string, repo: string): string {\n const cleanRepo = repo.endsWith(\".git\") ? repo : `${repo}.git`;\n return `https://${host}/${owner}/${cleanRepo}`;\n}\n", "import { GitCliError } from \"@/utils/errors\";\nimport { parseRemoteUrl, type ParsedRemoteUrl } from \"./url-parser\";\n\nexport interface GitExecResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport interface GitRemoteInfo {\n name: string;\n fetchUrl: string;\n pushUrl: string;\n parsedFetch: ParsedRemoteUrl | null;\n parsedPush: ParsedRemoteUrl | null;\n}\n\nexport class GitCli {\n private cwd: string;\n\n constructor(cwd: string = process.cwd()) {\n this.cwd = cwd;\n }\n\n getCwd(): string {\n return this.cwd;\n }\n\n async exec(args: string[], options: { cwd?: string; allowFailure?: boolean; env?: Record<string, string> } = {}): Promise<GitExecResult> {\n const targetCwd = options.cwd ?? this.cwd;\n try {\n const proc = Bun.spawn([\"git\", ...args], {\n cwd: targetCwd,\n stdout: \"pipe\",\n stderr: \"pipe\",\n env: { ...process.env, ...options.env },\n });\n\n const [stdout, stderr] = await Promise.all([\n new Response(proc.stdout).text(),\n new Response(proc.stderr).text(),\n ]);\n\n const exitCode = await proc.exited;\n\n if (exitCode !== 0 && !options.allowFailure) {\n throw new GitCliError(\n stderr.trim() || stdout.trim() || `git ${args.join(\" \")} failed`,\n exitCode,\n stderr.trim()\n );\n }\n\n return {\n stdout: stdout.trim(),\n stderr: stderr.trim(),\n exitCode,\n };\n } catch (err: unknown) {\n if (err instanceof GitCliError) throw err;\n throw new GitCliError(\n `Failed to run 'git ${args.join(\" \")}': ${err instanceof Error ? err.message : String(err)}`,\n 1,\n String(err)\n );\n }\n }\n\n async isGitRepo(): Promise<boolean> {\n try {\n const res = await this.exec([\"rev-parse\", \"--is-inside-work-tree\"], { allowFailure: true });\n return res.exitCode === 0 && res.stdout === \"true\";\n } catch {\n return false;\n }\n }\n\n async getRepoRoot(): Promise<string | null> {\n try {\n const res = await this.exec([\"rev-parse\", \"--show-toplevel\"], { allowFailure: true });\n if (res.exitCode === 0 && res.stdout) {\n return res.stdout.trim();\n }\n return null;\n } catch {\n return null;\n }\n }\n\n async getConfig(key: string, scope?: \"local\" | \"global\" | \"system\"): Promise<string | null> {\n const args = [\"config\"];\n if (scope) args.push(`--${scope}`);\n args.push(\"--get\", key);\n\n const res = await this.exec(args, { allowFailure: true });\n if (res.exitCode === 0 && res.stdout) {\n return res.stdout.trim();\n }\n return null;\n }\n\n async setConfig(key: string, value: string, scope: \"local\" | \"global\" = \"local\"): Promise<void> {\n await this.exec([\"config\", `--${scope}`, key, value]);\n }\n\n async unsetConfig(key: string, scope: \"local\" | \"global\" = \"local\"): Promise<void> {\n await this.exec([\"config\", `--${scope}`, \"--unset\", key], { allowFailure: true });\n }\n\n async getRemotes(): Promise<GitRemoteInfo[]> {\n const res = await this.exec([\"remote\", \"-v\"], { allowFailure: true });\n if (res.exitCode !== 0 || !res.stdout) return [];\n\n const lines = res.stdout.split(\"\\n\");\n const remoteMap = new Map<string, { fetchUrl: string; pushUrl: string }>();\n\n for (const line of lines) {\n const match = line.match(/^(\\S+)\\s+(\\S+)\\s+\\((fetch|push)\\)$/);\n if (match) {\n const [, name, url, type] = match;\n const current = remoteMap.get(name) || { fetchUrl: \"\", pushUrl: \"\" };\n if (type === \"fetch\") current.fetchUrl = url;\n if (type === \"push\") current.pushUrl = url;\n remoteMap.set(name, current);\n }\n }\n\n const result: GitRemoteInfo[] = [];\n for (const [name, urls] of remoteMap.entries()) {\n result.push({\n name,\n fetchUrl: urls.fetchUrl,\n pushUrl: urls.pushUrl,\n parsedFetch: parseRemoteUrl(urls.fetchUrl),\n parsedPush: parseRemoteUrl(urls.pushUrl),\n });\n }\n\n return result;\n }\n\n async setRemoteUrl(name: string, url: string): Promise<void> {\n const remotes = await this.getRemotes();\n const exists = remotes.some((r) => r.name === name);\n if (exists) {\n await this.exec([\"remote\", \"set-url\", name, url]);\n } else {\n await this.exec([\"remote\", \"add\", name, url]);\n }\n }\n\n async getCurrentBranch(): Promise<string | null> {\n const res = await this.exec([\"branch\", \"--show-current\"], { allowFailure: true });\n if (res.exitCode === 0 && res.stdout) {\n return res.stdout.trim();\n }\n return null;\n }\n\n async getGitVersion(): Promise<string | null> {\n const res = await this.exec([\"--version\"], { allowFailure: true });\n if (res.exitCode === 0 && res.stdout) {\n const match = res.stdout.match(/git version ([\\d.]+)/);\n return match ? match[1] : res.stdout;\n }\n return null;\n }\n}\n", "import fs from \"node:fs\";\nimport { ConfigStore } from \"../config/config-store\";\nimport { expandTilde } from \"@/utils/platform\";\n\nexport class GitConfigGenerator {\n private store: ConfigStore;\n\n constructor(store: ConfigStore) {\n this.store = store;\n }\n\n /**\n * Generates all Git configuration files into ~/.gitbridge/generated/\n */\n generate(): { mainConfigPath: string; generatedRules: string[] } {\n this.store.ensureDirectories();\n const config = this.store.loadConfig();\n const identities = this.store.loadIdentities();\n const accounts = this.store.loadAccounts();\n const paths = this.store.getPathResolver();\n\n const defaultIdentity = identities.find((i) => i.id === config.defaultIdentityId) || identities.find((i) => i.isDefault) || identities[0];\n\n const ruleFiles: string[] = [];\n\n // 1. Generate individual rule files\n for (const rule of config.rules) {\n const ruleIdentity = identities.find((i) => i.id === rule.identityId);\n const ruleFile = paths.getRuleGitConfigFile(rule.id);\n\n let ruleContent = `# Managed by GitBridge for rule: ${rule.id}\\n`;\n if (ruleIdentity) {\n ruleContent += `[user]\\n`;\n ruleContent += ` name = ${ruleIdentity.name}\\n`;\n ruleContent += ` email = ${ruleIdentity.email}\\n`;\n if (ruleIdentity.signingKey) {\n ruleContent += ` signingkey = ${ruleIdentity.signingKey}\\n`;\n ruleContent += ` # format = ssh or gpg\\n`;\n }\n }\n\n // Check if rule specifies an account with SSH rewrite\n if (rule.defaultAccountId) {\n const account = accounts.find((a) => a.id === rule.defaultAccountId);\n if (account && account.host) {\n const aliasHost = `${account.host}-${account.id}`;\n // e.g. insteadOf = git@github.com:\n ruleContent += `\\n[url \"git@${aliasHost}:\"]\\n`;\n ruleContent += ` insteadOf = git@${account.host}:\\n`;\n }\n }\n\n fs.writeFileSync(ruleFile, ruleContent, { encoding: \"utf-8\", mode: 0o644 });\n ruleFiles.push(ruleFile);\n }\n\n // 2. Generate main.gitconfig\n let mainContent = `# Auto-generated by GitBridge. DO NOT EDIT DIRECTLY.\\n`;\n mainContent += `# Generated at: ${new Date().toISOString()}\\n\\n`;\n\n if (defaultIdentity) {\n mainContent += `# Default Identity\\n`;\n mainContent += `[user]\\n`;\n mainContent += ` name = ${defaultIdentity.name}\\n`;\n mainContent += ` email = ${defaultIdentity.email}\\n`;\n if (defaultIdentity.signingKey) {\n mainContent += ` signingkey = ${defaultIdentity.signingKey}\\n`;\n }\n mainContent += `\\n`;\n }\n\n if (config.settings.credentialHelperEnabled) {\n mainContent += `# Git Credential Helper Bridge\\n`;\n mainContent += `[credential]\\n`;\n mainContent += ` helper = gitbridge credential\\n\\n`;\n }\n\n if (config.rules.length > 0) {\n mainContent += `# Directory-Based Conditional Includes\\n`;\n for (const rule of config.rules) {\n const ruleFile = paths.getRuleGitConfigFile(rule.id);\n const expandedRulePath = expandTilde(rule.path);\n // gitdir format requires trailing slash for directories\n const gitDirPattern = expandedRulePath.endsWith(\"/\") ? `${expandedRulePath}**` : `${expandedRulePath}/**`;\n mainContent += `[includeIf \"gitdir:${gitDirPattern}\"]\\n`;\n mainContent += ` path = ${ruleFile}\\n\\n`;\n }\n }\n\n const mainFile = paths.getMainGitConfigFile();\n fs.writeFileSync(mainFile, mainContent, { encoding: \"utf-8\", mode: 0o644 });\n\n return {\n mainConfigPath: mainFile,\n generatedRules: ruleFiles,\n };\n }\n}\n", "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ConfigStore } from \"../config/config-store\";\nimport { GitConfigGenerator } from \"./config-generator\";\n\nexport const GITCONFIG_BLOCK_START = \"# --- BEGIN GITBRIDGE MANAGED BLOCK ---\";\nexport const GITCONFIG_BLOCK_END = \"# --- END GITBRIDGE MANAGED BLOCK ---\";\n\nexport class GitConfigInjector {\n private store: ConfigStore;\n\n constructor(store: ConfigStore) {\n this.store = store;\n }\n\n isInstalled(targetFile?: string): boolean {\n const gitConfigFile = targetFile || this.store.getPathResolver().getUserGitConfigFile();\n if (!fs.existsSync(gitConfigFile)) return false;\n const content = fs.readFileSync(gitConfigFile, \"utf-8\");\n return content.includes(GITCONFIG_BLOCK_START) && content.includes(GITCONFIG_BLOCK_END);\n }\n\n private createBackup(gitConfigFile: string): string | null {\n if (!fs.existsSync(gitConfigFile)) return null;\n\n const backupsDir = this.store.getPathResolver().getBackupsDir();\n if (!fs.existsSync(backupsDir)) {\n fs.mkdirSync(backupsDir, { recursive: true });\n }\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupFile = path.join(backupsDir, `gitconfig.${timestamp}.bak`);\n fs.copyFileSync(gitConfigFile, backupFile);\n\n // Also maintain primary .bak\n const primaryBak = `${gitConfigFile}.gitbridge.bak`;\n if (!fs.existsSync(primaryBak)) {\n fs.copyFileSync(gitConfigFile, primaryBak);\n }\n\n return backupFile;\n }\n\n inject(targetFile?: string): { success: boolean; backupPath: string | null } {\n const generator = new GitConfigGenerator(this.store);\n const { mainConfigPath } = generator.generate();\n\n const gitConfigFile = targetFile || this.store.getPathResolver().getUserGitConfigFile();\n const backupPath = this.createBackup(gitConfigFile);\n\n let originalContent = \"\";\n if (fs.existsSync(gitConfigFile)) {\n originalContent = fs.readFileSync(gitConfigFile, \"utf-8\");\n }\n\n const blockContent = [\n GITCONFIG_BLOCK_START,\n `# Do not edit this block directly. Manage via: gitbridge / gb`,\n `[include]`,\n ` path = ${mainConfigPath}`,\n GITCONFIG_BLOCK_END,\n ].join(\"\\n\");\n\n let newContent: string;\n\n if (originalContent.includes(GITCONFIG_BLOCK_START) && originalContent.includes(GITCONFIG_BLOCK_END)) {\n // Replace existing block\n const before = originalContent.substring(0, originalContent.indexOf(GITCONFIG_BLOCK_START));\n const after = originalContent.substring(originalContent.indexOf(GITCONFIG_BLOCK_END) + GITCONFIG_BLOCK_END.length);\n newContent = `${before.trimEnd()}\\n\\n${blockContent}\\n\\n${after.trimStart()}`.trim() + \"\\n\";\n } else {\n // Append block\n newContent = `${originalContent.trimEnd()}\\n\\n${blockContent}\\n`.trimStart();\n }\n\n fs.writeFileSync(gitConfigFile, newContent, { encoding: \"utf-8\", mode: 0o644 });\n return { success: true, backupPath };\n }\n\n remove(targetFile?: string): boolean {\n const gitConfigFile = targetFile || this.store.getPathResolver().getUserGitConfigFile();\n if (!fs.existsSync(gitConfigFile)) return true;\n\n const originalContent = fs.readFileSync(gitConfigFile, \"utf-8\");\n if (!originalContent.includes(GITCONFIG_BLOCK_START)) return true;\n\n const before = originalContent.substring(0, originalContent.indexOf(GITCONFIG_BLOCK_START));\n const after = originalContent.substring(originalContent.indexOf(GITCONFIG_BLOCK_END) + GITCONFIG_BLOCK_END.length);\n const cleaned = `${before.trimEnd()}\\n${after.trimStart()}`.trim();\n\n if (cleaned.length === 0) {\n // If the file only contained the GitBridge block, we can either empty it or remove it\n fs.writeFileSync(gitConfigFile, \"\", { encoding: \"utf-8\", mode: 0o644 });\n } else {\n fs.writeFileSync(gitConfigFile, `${cleaned}\\n`, { encoding: \"utf-8\", mode: 0o644 });\n }\n\n return true;\n }\n}\n", "import fs from \"node:fs\";\nimport { ConfigStore } from \"../config/config-store\";\nimport { expandTilde } from \"@/utils/platform\";\n\nexport class SshConfigGenerator {\n private store: ConfigStore;\n\n constructor(store: ConfigStore) {\n this.store = store;\n }\n\n generate(): string {\n this.store.ensureDirectories();\n const accounts = this.store.loadAccounts();\n const paths = this.store.getPathResolver();\n const generatedSshFile = paths.getGeneratedSshConfigFile();\n\n let content = `# Auto-generated by GitBridge. DO NOT EDIT DIRECTLY.\\n`;\n content += `# Generated at: ${new Date().toISOString()}\\n\\n`;\n\n // Filter accounts with SSH key configured\n const sshAccounts = accounts.filter((a) => a.sshKeyPath);\n\n if (sshAccounts.length === 0) {\n content += `# No accounts currently configured with custom SSH keys.\\n`;\n } else {\n for (const account of sshAccounts) {\n const hostAlias = `${account.host}-${account.id}`;\n const keyPath = expandTilde(account.sshKeyPath!);\n\n content += `# Account: ${account.displayName || account.username} (${account.providerId})\\n`;\n content += `Host ${hostAlias}\\n`;\n content += ` HostName ${account.host}\\n`;\n content += ` User git\\n`;\n content += ` IdentityFile ${keyPath}\\n`;\n content += ` IdentitiesOnly yes\\n\\n`;\n }\n }\n\n fs.writeFileSync(generatedSshFile, content, { encoding: \"utf-8\", mode: 0o600 });\n return generatedSshFile;\n }\n}\n", "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ConfigStore } from \"../config/config-store\";\nimport { SshConfigGenerator } from \"./ssh-config-generator\";\nimport { collapseTilde } from \"@/utils/platform\";\n\nexport const SSH_BLOCK_START = \"# --- BEGIN GITBRIDGE MANAGED BLOCK ---\";\nexport const SSH_BLOCK_END = \"# --- END GITBRIDGE MANAGED BLOCK ---\";\n\nexport class SshInjector {\n private store: ConfigStore;\n\n constructor(store: ConfigStore) {\n this.store = store;\n }\n\n isInstalled(targetFile?: string): boolean {\n const sshConfigFile = targetFile || this.store.getPathResolver().getUserSshConfigFile();\n if (!fs.existsSync(sshConfigFile)) return false;\n const content = fs.readFileSync(sshConfigFile, \"utf-8\");\n return content.includes(SSH_BLOCK_START) && content.includes(SSH_BLOCK_END);\n }\n\n private createBackup(sshConfigFile: string): string | null {\n if (!fs.existsSync(sshConfigFile)) return null;\n\n const backupsDir = this.store.getPathResolver().getBackupsDir();\n if (!fs.existsSync(backupsDir)) {\n fs.mkdirSync(backupsDir, { recursive: true });\n }\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupFile = path.join(backupsDir, `ssh_config.${timestamp}.bak`);\n fs.copyFileSync(sshConfigFile, backupFile);\n\n const primaryBak = `${sshConfigFile}.gitbridge.bak`;\n if (!fs.existsSync(primaryBak)) {\n fs.copyFileSync(sshConfigFile, primaryBak);\n }\n\n return backupFile;\n }\n\n inject(targetFile?: string): { success: boolean; backupPath: string | null } {\n const generator = new SshConfigGenerator(this.store);\n const generatedPath = generator.generate();\n\n const sshConfigFile = targetFile || this.store.getPathResolver().getUserSshConfigFile();\n const sshDir = path.dirname(sshConfigFile);\n if (!fs.existsSync(sshDir)) {\n fs.mkdirSync(sshDir, { recursive: true, mode: 0o700 });\n }\n\n const backupPath = this.createBackup(sshConfigFile);\n\n let originalContent = \"\";\n if (fs.existsSync(sshConfigFile)) {\n originalContent = fs.readFileSync(sshConfigFile, \"utf-8\");\n }\n\n const includePath = collapseTilde(generatedPath);\n const blockContent = [\n SSH_BLOCK_START,\n `# Do not edit this block directly. Manage via: gitbridge / gb`,\n `Include ${includePath}`,\n SSH_BLOCK_END,\n ].join(\"\\n\");\n\n let newContent: string;\n\n if (originalContent.includes(SSH_BLOCK_START) && originalContent.includes(SSH_BLOCK_END)) {\n const before = originalContent.substring(0, originalContent.indexOf(SSH_BLOCK_START));\n const after = originalContent.substring(originalContent.indexOf(SSH_BLOCK_END) + SSH_BLOCK_END.length);\n newContent = `${blockContent}\\n\\n${before.trim()}\\n${after.trim()}`.trim() + \"\\n\";\n } else {\n // Put Include block at the very top of SSH config so aliases have precedence\n newContent = `${blockContent}\\n\\n${originalContent.trim()}`.trim() + \"\\n\";\n }\n\n fs.writeFileSync(sshConfigFile, newContent, { encoding: \"utf-8\", mode: 0o600 });\n return { success: true, backupPath };\n }\n\n remove(targetFile?: string): boolean {\n const sshConfigFile = targetFile || this.store.getPathResolver().getUserSshConfigFile();\n if (!fs.existsSync(sshConfigFile)) return true;\n\n const originalContent = fs.readFileSync(sshConfigFile, \"utf-8\");\n if (!originalContent.includes(SSH_BLOCK_START)) return true;\n\n const before = originalContent.substring(0, originalContent.indexOf(SSH_BLOCK_START));\n const after = originalContent.substring(originalContent.indexOf(SSH_BLOCK_END) + SSH_BLOCK_END.length);\n const cleaned = `${before.trim()}\\n${after.trim()}`.trim();\n\n if (cleaned.length === 0) {\n fs.writeFileSync(sshConfigFile, \"\", { encoding: \"utf-8\", mode: 0o600 });\n } else {\n fs.writeFileSync(sshConfigFile, `${cleaned}\\n`, { encoding: \"utf-8\", mode: 0o600 });\n }\n\n return true;\n }\n}\n", "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getHomeDir, collapseTilde } from \"@/utils/platform\";\n\nexport interface SshKeyInfo {\n name: string;\n privateKeyPath: string;\n publicKeyPath: string;\n type: string;\n comment?: string;\n}\n\nexport class SshKeyDetector {\n static listAvailableKeys(sshDir?: string): SshKeyInfo[] {\n const targetDir = sshDir || path.join(getHomeDir(), \".ssh\");\n if (!fs.existsSync(targetDir)) {\n return [];\n }\n\n const files = fs.readdirSync(targetDir);\n const pubFiles = files.filter((f) => f.endsWith(\".pub\"));\n const keys: SshKeyInfo[] = [];\n\n for (const pub of pubFiles) {\n const pubPath = path.join(targetDir, pub);\n const privName = pub.slice(0, -4);\n const privPath = path.join(targetDir, privName);\n\n try {\n const content = fs.readFileSync(pubPath, \"utf-8\").trim();\n const parts = content.split(/\\s+/);\n const type = parts[0] || \"unknown\";\n const comment = parts.length > 2 ? parts.slice(2).join(\" \") : undefined;\n\n keys.push({\n name: privName,\n privateKeyPath: collapseTilde(privPath),\n publicKeyPath: collapseTilde(pubPath),\n type,\n comment,\n });\n } catch {\n // Skip unreadable files\n }\n }\n\n return keys;\n }\n}\n", "import path from \"node:path\";\nimport { ConfigStore } from \"../config/config-store\";\nimport { GitCli, type GitRemoteInfo } from \"../git/git-cli\";\nimport { expandTilde } from \"@/utils/platform\";\nimport type { GitIdentity, ProviderAccount, DirectoryRule, RepositoryProfile } from \"../config/schema\";\n\nexport type ResolutionSource = \"repo_profile\" | \"directory_rule\" | \"global_default\" | \"system_fallback\" | \"unconfigured\";\n\nexport interface ResolvedContext {\n cwd: string;\n isGitRepo: boolean;\n repoRoot: string | null;\n source: ResolutionSource;\n identity: GitIdentity | null;\n account: ProviderAccount | null;\n matchedRule: DirectoryRule | null;\n repoProfile: RepositoryProfile | null;\n remotes: GitRemoteInfo[];\n localGitEmail: string | null;\n localGitName: string | null;\n isMismatched: boolean;\n}\n\nexport class IdentityResolver {\n private store: ConfigStore;\n\n constructor(store: ConfigStore) {\n this.store = store;\n }\n\n async resolve(cwd: string = process.cwd()): Promise<ResolvedContext> {\n const git = new GitCli(cwd);\n const isGitRepo = await git.isGitRepo();\n const repoRoot = isGitRepo ? await git.getRepoRoot() : null;\n const targetPath = repoRoot || path.resolve(cwd);\n\n const identities = this.store.loadIdentities();\n const accounts = this.store.loadAccounts();\n const rules = this.store.loadRules();\n const config = this.store.loadConfig();\n\n let localGitEmail: string | null = null;\n let localGitName: string | null = null;\n let remotes: GitRemoteInfo[] = [];\n\n if (isGitRepo) {\n localGitEmail = await git.getConfig(\"user.email\");\n localGitName = await git.getConfig(\"user.name\");\n remotes = await git.getRemotes();\n }\n\n let resolvedIdentity: GitIdentity | null = null;\n let resolvedAccount: ProviderAccount | null = null;\n let matchedRule: DirectoryRule | null = null;\n let repoProfile: RepositoryProfile | null = null;\n let source: ResolutionSource = \"unconfigured\";\n\n // 1. Check Repository Profile (explicitly saved in repos.json for targetPath or repoRoot)\n repoProfile = this.store.getRepository(targetPath) || (repoRoot ? this.store.getRepository(repoRoot) : null) || null;\n if (repoProfile && repoProfile.identityId) {\n const found = identities.find((i) => i.id === repoProfile!.identityId);\n if (found) {\n resolvedIdentity = found;\n source = \"repo_profile\";\n }\n }\n\n // 2. Check Directory Rules (longest prefix match)\n if (!resolvedIdentity) {\n let bestMatchLength = -1;\n for (const rule of rules) {\n const expandedRulePath = path.resolve(expandTilde(rule.path));\n if (targetPath === expandedRulePath || targetPath.startsWith(expandedRulePath + path.sep)) {\n if (expandedRulePath.length > bestMatchLength) {\n bestMatchLength = expandedRulePath.length;\n matchedRule = rule;\n }\n }\n }\n\n if (matchedRule) {\n const found = identities.find((i) => i.id === matchedRule!.identityId);\n if (found) {\n resolvedIdentity = found;\n source = \"directory_rule\";\n if (matchedRule.defaultAccountId) {\n resolvedAccount = accounts.find((a) => a.id === matchedRule!.defaultAccountId) || null;\n }\n }\n }\n }\n\n // 3. Check Global Default Identity\n if (!resolvedIdentity) {\n const defaultId = config.defaultIdentityId || identities.find((i) => i.isDefault)?.id;\n if (defaultId) {\n resolvedIdentity = identities.find((i) => i.id === defaultId) || null;\n if (resolvedIdentity) {\n source = \"global_default\";\n }\n }\n }\n\n // 4. If no identity is found, check if Git has a system/user identity configured\n if (!resolvedIdentity && localGitEmail) {\n source = \"system_fallback\";\n }\n\n // Resolve Account if not resolved yet\n if (!resolvedAccount && remotes.length > 0) {\n // Find account matching the first remote's host or account alias\n const firstRemote = remotes[0];\n const parsed = firstRemote.parsedPush || firstRemote.parsedFetch;\n if (parsed) {\n if (parsed.accountAlias) {\n resolvedAccount = accounts.find((a) => a.id === parsed.accountAlias || a.username === parsed.accountAlias) || null;\n }\n if (!resolvedAccount) {\n resolvedAccount = accounts.find((a) => a.host === parsed.host) || null;\n }\n }\n }\n\n // Check for mismatch (e.g. if localGitEmail is set and differs from resolved identity)\n let isMismatched = false;\n if (resolvedIdentity && localGitEmail && localGitEmail !== resolvedIdentity.email) {\n isMismatched = true;\n }\n\n return {\n cwd,\n isGitRepo,\n repoRoot,\n source,\n identity: resolvedIdentity,\n account: resolvedAccount,\n matchedRule,\n repoProfile,\n remotes,\n localGitEmail,\n localGitName,\n isMismatched,\n };\n }\n}\n", "export interface HttpRequestOptions {\n headers?: Record<string, string>;\n timeoutMs?: number;\n params?: Record<string, string | number | boolean | undefined>;\n}\n\nexport async function requestJson<T>(\n url: string,\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\" = \"GET\",\n body?: unknown,\n options: HttpRequestOptions = {}\n): Promise<{ data: T; status: number; headers: Headers }> {\n let targetUrl = url;\n if (options.params) {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(options.params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n const queryString = searchParams.toString();\n if (queryString) {\n targetUrl += (url.includes(\"?\") ? \"&\" : \"?\") + queryString;\n }\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? 15000);\n\n try {\n const headers: Record<string, string> = {\n \"User-Agent\": \"GitBridge-CLI/0.1.0\",\n Accept: \"application/json\",\n ...options.headers,\n };\n\n let serializedBody: string | undefined;\n if (body !== undefined) {\n if (typeof body === \"string\") {\n serializedBody = body;\n } else {\n serializedBody = JSON.stringify(body);\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n }\n }\n\n const res = await fetch(targetUrl, {\n method,\n headers,\n body: serializedBody,\n signal: controller.signal,\n });\n\n clearTimeout(timeout);\n\n let responseData: unknown;\n const contentType = res.headers.get(\"content-type\") || \"\";\n if (contentType.includes(\"application/json\")) {\n responseData = await res.json();\n } else {\n const text = await res.text();\n try {\n responseData = JSON.parse(text);\n } catch {\n responseData = text;\n }\n }\n\n return {\n data: responseData as T,\n status: res.status,\n headers: res.headers,\n };\n } catch (err: unknown) {\n clearTimeout(timeout);\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new Error(`Request to ${url} timed out after ${options.timeoutMs ?? 15000}ms`);\n }\n throw err;\n }\n}\n", "import type {\n GitProvider,\n ProviderUser,\n RemoteRepository,\n HealthCheckResult,\n DeviceCodeResponse,\n} from \"./provider.interface\";\nimport { requestJson } from \"@/utils/http\";\nimport { ProviderError } from \"@/utils/errors\";\n\nconst GITHUB_CLIENT_ID = process.env.GITBRIDGE_GITHUB_CLIENT_ID || \"Iv1.b507a08c87ecfe98\";\n\nexport class GitHubProvider implements GitProvider {\n readonly id = \"github\" as const;\n readonly name = \"GitHub\";\n readonly defaultHost = \"github.com\";\n\n private getApiUrl(host?: string): string {\n const targetHost = host || this.defaultHost;\n if (targetHost === \"github.com\") {\n return \"https://api.github.com\";\n }\n // GitHub Enterprise Server\n return `https://${targetHost}/api/v3`;\n }\n\n async validateToken(token: string, host?: string): Promise<boolean> {\n try {\n const api = this.getApiUrl(host);\n const res = await requestJson(`${api}/user`, \"GET\", undefined, {\n headers: {\n Authorization: `Bearer ${token}`,\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n });\n return res.status === 200;\n } catch {\n return false;\n }\n }\n\n async getUser(token: string, host?: string): Promise<ProviderUser> {\n const api = this.getApiUrl(host);\n const res = await requestJson<{\n id: number;\n login: string;\n name?: string;\n email?: string;\n avatar_url?: string;\n message?: string;\n }>(`${api}/user`, \"GET\", undefined, {\n headers: {\n Authorization: `Bearer ${token}`,\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n });\n\n if (res.status !== 200 || !res.data.login) {\n throw new ProviderError(res.data.message || `Failed to fetch user (status: ${res.status})`, this.name);\n }\n\n return {\n id: String(res.data.id),\n username: res.data.login,\n displayName: res.data.name || res.data.login,\n email: res.data.email,\n avatarUrl: res.data.avatar_url,\n };\n }\n\n async listRepositories(token: string, host?: string): Promise<RemoteRepository[]> {\n const api = this.getApiUrl(host);\n const res = await requestJson<\n Array<{\n id: number;\n name: string;\n full_name: string;\n ssh_url: string;\n clone_url: string;\n private: boolean;\n default_branch: string;\n html_url: string;\n }>\n >(`${api}/user/repos?per_page=50&sort=updated`, \"GET\", undefined, {\n headers: {\n Authorization: `Bearer ${token}`,\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n });\n\n if (res.status !== 200 || !Array.isArray(res.data)) {\n throw new ProviderError(`Failed to fetch repositories (status: ${res.status})`, this.name);\n }\n\n return res.data.map((r) => ({\n id: String(r.id),\n name: r.name,\n fullName: r.full_name,\n sshUrl: r.ssh_url,\n httpsUrl: r.clone_url,\n isPrivate: r.private,\n defaultBranch: r.default_branch || \"main\",\n htmlUrl: r.html_url,\n }));\n }\n\n async checkHealth(host?: string): Promise<HealthCheckResult> {\n const api = this.getApiUrl(host);\n const start = Date.now();\n try {\n const res = await requestJson(`${api}/rate_limit`, \"GET\", undefined, { timeoutMs: 8000 });\n const pingMs = Date.now() - start;\n return {\n apiOk: res.status === 200 || res.status === 401 || res.status === 403,\n pingMs,\n message: \"GitHub API reachable\",\n };\n } catch (err: unknown) {\n return {\n apiOk: false,\n pingMs: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n async startDeviceFlow(): Promise<DeviceCodeResponse> {\n const res = await requestJson<{\n device_code: string;\n user_code: string;\n verification_uri: string;\n expires_in: number;\n interval: number;\n error?: string;\n }>(\"https://github.com/login/device/code\", \"POST\", {\n client_id: GITHUB_CLIENT_ID,\n scope: \"repo,read:user,user:email\",\n });\n\n if (!res.data.device_code) {\n throw new ProviderError(res.data.error || \"Failed to start GitHub device flow\", this.name);\n }\n\n return {\n deviceCode: res.data.device_code,\n userCode: res.data.user_code,\n verificationUri: res.data.verification_uri,\n expiresIn: res.data.expires_in,\n interval: res.data.interval || 5,\n };\n }\n\n async pollDeviceFlow(deviceCode: string, interval = 5): Promise<{ token: string }> {\n const pollIntervalMs = (interval + 1) * 1000;\n const maxAttempts = 60;\n\n for (let i = 0; i < maxAttempts; i++) {\n await new Promise((r) => setTimeout(r, pollIntervalMs));\n\n const res = await requestJson<{\n access_token?: string;\n error?: string;\n error_description?: string;\n }>(\"https://github.com/login/oauth/access_token\", \"POST\", {\n client_id: GITHUB_CLIENT_ID,\n device_code: deviceCode,\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n });\n\n if (res.data.access_token) {\n return { token: res.data.access_token };\n }\n\n if (res.data.error === \"authorization_pending\") {\n continue;\n }\n\n if (res.data.error === \"slow_down\") {\n await new Promise((r) => setTimeout(r, 5000));\n continue;\n }\n\n if (res.data.error) {\n throw new ProviderError(res.data.error_description || res.data.error, this.name);\n }\n }\n\n throw new ProviderError(\"Device authorization timed out.\", this.name);\n }\n}\n", "import type {\n GitProvider,\n ProviderUser,\n RemoteRepository,\n HealthCheckResult,\n} from \"./provider.interface\";\nimport { requestJson } from \"@/utils/http\";\nimport { ProviderError } from \"@/utils/errors\";\n\nexport class GitLabProvider implements GitProvider {\n readonly id = \"gitlab\" as const;\n readonly name = \"GitLab\";\n readonly defaultHost = \"gitlab.com\";\n\n private getApiUrl(host?: string): string {\n const targetHost = host || this.defaultHost;\n return `https://${targetHost}/api/v4`;\n }\n\n private getAuthHeader(token: string): Record<string, string> {\n // GitLab tokens starting with glpat- or standard PATs can use PRIVATE-TOKEN or Bearer\n if (token.startsWith(\"glpat-\") || token.length < 30) {\n return { \"PRIVATE-TOKEN\": token };\n }\n return { Authorization: `Bearer ${token}` };\n }\n\n async validateToken(token: string, host?: string): Promise<boolean> {\n try {\n const api = this.getApiUrl(host);\n const res = await requestJson(`${api}/user`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n return res.status === 200;\n } catch {\n return false;\n }\n }\n\n async getUser(token: string, host?: string): Promise<ProviderUser> {\n const api = this.getApiUrl(host);\n const res = await requestJson<{\n id: number;\n username: string;\n name?: string;\n email?: string;\n avatar_url?: string;\n message?: string;\n }>(`${api}/user`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n\n if (res.status !== 200 || !res.data.username) {\n throw new ProviderError(res.data.message || `Failed to fetch GitLab user (status: ${res.status})`, this.name);\n }\n\n return {\n id: String(res.data.id),\n username: res.data.username,\n displayName: res.data.name || res.data.username,\n email: res.data.email,\n avatarUrl: res.data.avatar_url,\n };\n }\n\n async listRepositories(token: string, host?: string): Promise<RemoteRepository[]> {\n const api = this.getApiUrl(host);\n const res = await requestJson<\n Array<{\n id: number;\n name: string;\n path_with_namespace: string;\n ssh_url_to_repo: string;\n http_url_to_repo: string;\n visibility: string;\n default_branch: string;\n web_url: string;\n }>\n >(`${api}/projects?membership=true&simple=true&per_page=50&order_by=updated_at`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n\n if (res.status !== 200 || !Array.isArray(res.data)) {\n throw new ProviderError(`Failed to fetch GitLab projects (status: ${res.status})`, this.name);\n }\n\n return res.data.map((r) => ({\n id: String(r.id),\n name: r.name,\n fullName: r.path_with_namespace,\n sshUrl: r.ssh_url_to_repo,\n httpsUrl: r.http_url_to_repo,\n isPrivate: r.visibility === \"private\",\n defaultBranch: r.default_branch || \"main\",\n htmlUrl: r.web_url,\n }));\n }\n\n async checkHealth(host?: string): Promise<HealthCheckResult> {\n const api = this.getApiUrl(host);\n const start = Date.now();\n try {\n const res = await requestJson(`${api}/version`, \"GET\", undefined, { timeoutMs: 8000 });\n const pingMs = Date.now() - start;\n return {\n apiOk: res.status === 200 || res.status === 401, // 401 means API endpoint reached but unauthenticated\n pingMs,\n message: \"GitLab API reachable\",\n };\n } catch (err: unknown) {\n return {\n apiOk: false,\n pingMs: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n}\n", "import type {\n GitProvider,\n ProviderUser,\n RemoteRepository,\n HealthCheckResult,\n} from \"./provider.interface\";\nimport { requestJson } from \"@/utils/http\";\nimport { ProviderError } from \"@/utils/errors\";\n\nexport class BitbucketProvider implements GitProvider {\n readonly id = \"bitbucket\" as const;\n readonly name = \"Bitbucket\";\n readonly defaultHost = \"bitbucket.org\";\n\n private getApiUrl(host?: string): string {\n const targetHost = host || this.defaultHost;\n if (targetHost === \"bitbucket.org\") {\n return \"https://api.bitbucket.org/2.0\";\n }\n // Bitbucket Server / Data Center\n return `https://${targetHost}/rest/api/1.0`;\n }\n\n private getAuthHeader(token: string): Record<string, string> {\n if (token.includes(\":\")) {\n // Username:AppPassword format\n const encoded = Buffer.from(token).toString(\"base64\");\n return { Authorization: `Basic ${encoded}` };\n }\n return { Authorization: `Bearer ${token}` };\n }\n\n async validateToken(token: string, host?: string): Promise<boolean> {\n try {\n const api = this.getApiUrl(host);\n const res = await requestJson(`${api}/user`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n return res.status === 200;\n } catch {\n return false;\n }\n }\n\n async getUser(token: string, host?: string): Promise<ProviderUser> {\n const api = this.getApiUrl(host);\n const res = await requestJson<{\n account_id?: string;\n uuid?: string;\n username?: string;\n display_name?: string;\n links?: { avatar?: { href?: string } };\n error?: { message?: string };\n }>(`${api}/user`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n\n if (res.status !== 200 || (!res.data.username && !res.data.display_name)) {\n throw new ProviderError(res.data.error?.message || `Failed to fetch Bitbucket user`, this.name);\n }\n\n const username = res.data.username || res.data.display_name?.replace(/\\s+/g, \"\").toLowerCase() || \"user\";\n return {\n id: res.data.account_id || res.data.uuid || username,\n username,\n displayName: res.data.display_name || username,\n avatarUrl: res.data.links?.avatar?.href,\n };\n }\n\n async listRepositories(token: string, host?: string): Promise<RemoteRepository[]> {\n const user = await this.getUser(token, host);\n const api = this.getApiUrl(host);\n const res = await requestJson<{\n values?: Array<{\n uuid: string;\n name: string;\n full_name: string;\n is_private: boolean;\n mainbranch?: { name: string };\n links?: {\n html?: { href: string };\n clone?: Array<{ name: string; href: string }>;\n };\n }>;\n }>(`${api}/repositories/${user.username}?pagelen=50&sort=-updated_on`, \"GET\", undefined, {\n headers: this.getAuthHeader(token),\n });\n\n if (res.status !== 200 || !res.data.values) {\n return [];\n }\n\n return res.data.values.map((r) => {\n const sshClone = r.links?.clone?.find((c) => c.name === \"ssh\")?.href || `git@bitbucket.org:${r.full_name}.git`;\n const httpsClone = r.links?.clone?.find((c) => c.name === \"https\")?.href || `https://bitbucket.org/${r.full_name}.git`;\n return {\n id: r.uuid,\n name: r.name,\n fullName: r.full_name,\n sshUrl: sshClone,\n httpsUrl: httpsClone,\n isPrivate: r.is_private,\n defaultBranch: r.mainbranch?.name || \"main\",\n htmlUrl: r.links?.html?.href,\n };\n });\n }\n\n async checkHealth(host?: string): Promise<HealthCheckResult> {\n const api = this.getApiUrl(host);\n const start = Date.now();\n try {\n const res = await requestJson(`${api}/user`, \"GET\", undefined, { timeoutMs: 8000 });\n const pingMs = Date.now() - start;\n return {\n apiOk: res.status === 200 || res.status === 401,\n pingMs,\n message: \"Bitbucket API reachable\",\n };\n } catch (err: unknown) {\n return {\n apiOk: false,\n pingMs: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n}\n", "import type { GitProvider } from \"./provider.interface\";\nimport type { GitProviderType } from \"../config/schema\";\nimport { GitHubProvider } from \"./github.provider\";\nimport { GitLabProvider } from \"./gitlab.provider\";\nimport { BitbucketProvider } from \"./bitbucket.provider\";\n\nexport class ProviderRegistry {\n private providers = new Map<string, GitProvider>();\n\n constructor() {\n this.register(new GitHubProvider());\n this.register(new GitLabProvider());\n this.register(new BitbucketProvider());\n }\n\n register(provider: GitProvider): void {\n this.providers.set(provider.id, provider);\n }\n\n get(idOrType: GitProviderType | string): GitProvider | undefined {\n return this.providers.get(idOrType);\n }\n\n getByHost(host: string): GitProvider | undefined {\n const clean = host.toLowerCase();\n if (clean.includes(\"github.com\") || clean.startsWith(\"github\")) {\n return this.providers.get(\"github\");\n }\n if (clean.includes(\"gitlab.com\") || clean.startsWith(\"gitlab\")) {\n return this.providers.get(\"gitlab\");\n }\n if (clean.includes(\"bitbucket.org\") || clean.startsWith(\"bitbucket\")) {\n return this.providers.get(\"bitbucket\");\n }\n // Search custom registered hosts\n for (const provider of this.providers.values()) {\n if (provider.defaultHost === host) {\n return provider;\n }\n }\n return undefined;\n }\n\n list(): GitProvider[] {\n return Array.from(this.providers.values());\n }\n}\n\nexport const defaultProviderRegistry = new ProviderRegistry();\n", "import type { CredentialStore } from \"./credential-store\";\nimport { CredentialStoreError } from \"@/utils/errors\";\n\nexport class LinuxKeyringCredentialStore implements CredentialStore {\n readonly name = \"Linux Secret Service (secret-tool)\";\n\n async isAvailable(): Promise<boolean> {\n try {\n const proc = Bun.spawn([\"which\", \"secret-tool\"], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n const code = await proc.exited;\n return code === 0;\n } catch {\n return false;\n }\n }\n\n async set(service: string, account: string, secret: string): Promise<void> {\n try {\n const proc = Bun.spawn(\n [\"secret-tool\", \"store\", \"--label\", `GitBridge (${service}:${account})`, \"service\", service, \"account\", account],\n {\n stdin: \"pipe\",\n stdout: \"pipe\",\n stderr: \"pipe\",\n }\n );\n\n proc.stdin.write(secret);\n proc.stdin.end();\n\n const code = await proc.exited;\n if (code !== 0) {\n const stderr = await new Response(proc.stderr).text();\n throw new Error(stderr.trim() || `secret-tool store exited with code ${code}`);\n }\n } catch (err: unknown) {\n throw new CredentialStoreError(\n `Failed to store credential in Linux Keyring: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n async get(service: string, account: string): Promise<string | null> {\n try {\n const proc = Bun.spawn([\"secret-tool\", \"lookup\", \"service\", service, \"account\", account], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const stdout = await new Response(proc.stdout).text();\n const code = await proc.exited;\n\n if (code === 0 && stdout.trim().length > 0) {\n return stdout.trim();\n }\n return null;\n } catch {\n return null;\n }\n }\n\n async delete(service: string, account: string): Promise<void> {\n try {\n const proc = Bun.spawn([\"secret-tool\", \"clear\", \"service\", service, \"account\", account], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n await proc.exited;\n } catch {\n // ignore deletion errors\n }\n }\n}\n", "import type { CredentialStore } from \"./credential-store\";\nimport { CredentialStoreError } from \"@/utils/errors\";\n\nexport class MacOSKeychainCredentialStore implements CredentialStore {\n readonly name = \"macOS Keychain\";\n\n async isAvailable(): Promise<boolean> {\n if (process.platform !== \"darwin\") return false;\n try {\n const proc = Bun.spawn([\"which\", \"security\"], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n const code = await proc.exited;\n return code === 0;\n } catch {\n return false;\n }\n }\n\n async set(service: string, account: string, secret: string): Promise<void> {\n try {\n // First delete existing if any (-U updates or adds)\n await this.delete(service, account);\n\n const proc = Bun.spawn(\n [\"security\", \"add-generic-password\", \"-a\", account, \"-s\", service, \"-w\", secret, \"-U\"],\n {\n stdout: \"pipe\",\n stderr: \"pipe\",\n }\n );\n\n const code = await proc.exited;\n if (code !== 0) {\n const stderr = await new Response(proc.stderr).text();\n throw new Error(stderr.trim() || `security add-generic-password exited with code ${code}`);\n }\n } catch (err: unknown) {\n throw new CredentialStoreError(\n `Failed to store credential in macOS Keychain: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n async get(service: string, account: string): Promise<string | null> {\n try {\n const proc = Bun.spawn([\"security\", \"find-generic-password\", \"-a\", account, \"-s\", service, \"-w\"], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const stdout = await new Response(proc.stdout).text();\n const code = await proc.exited;\n\n if (code === 0 && stdout.trim().length > 0) {\n return stdout.trim();\n }\n return null;\n } catch {\n return null;\n }\n }\n\n async delete(service: string, account: string): Promise<void> {\n try {\n const proc = Bun.spawn([\"security\", \"delete-generic-password\", \"-a\", account, \"-s\", service], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n await proc.exited;\n } catch {\n // ignore\n }\n }\n}\n", "import type { CredentialStore } from \"./credential-store\";\nimport { CredentialStoreError } from \"@/utils/errors\";\n\nexport class WindowsCredentialStore implements CredentialStore {\n readonly name = \"Windows Credential Manager\";\n\n async isAvailable(): Promise<boolean> {\n return process.platform === \"win32\";\n }\n\n private targetName(service: string, account: string): string {\n return `gitbridge:${service}:${account}`;\n }\n\n async set(service: string, account: string, secret: string): Promise<void> {\n const target = this.targetName(service, account);\n try {\n const proc = Bun.spawn([\"cmdkey\", `/generic:${target}`, `/user:${account}`, `/pass:${secret}`], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const code = await proc.exited;\n if (code !== 0) {\n const stderr = await new Response(proc.stderr).text();\n throw new Error(stderr.trim() || `cmdkey exited with code ${code}`);\n }\n } catch (err: unknown) {\n throw new CredentialStoreError(\n `Failed to store credential in Windows Credential Manager: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n async get(service: string, account: string): Promise<string | null> {\n const target = this.targetName(service, account);\n // PowerShell query script using Windows Credential API or cmdkey check\n try {\n const script = `\n Add-Type -AssemblyName System.Security\n $target = \"${target}\"\n $cred = [System.Net.CredentialCache]::DefaultCredentials\n # Note: full extraction on Windows uses powershell credential lookup\n `;\n const proc = Bun.spawn([\"powershell\", \"-NoProfile\", \"-NonInteractive\", \"-Command\", script], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n const stdout = await new Response(proc.stdout).text();\n const code = await proc.exited;\n if (code === 0 && stdout.trim()) {\n return stdout.trim();\n }\n return null;\n } catch {\n return null;\n }\n }\n\n async delete(service: string, account: string): Promise<void> {\n const target = this.targetName(service, account);\n try {\n const proc = Bun.spawn([\"cmdkey\", `/delete:${target}`], {\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n await proc.exited;\n } catch {\n // ignore\n }\n }\n}\n", "import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport type { CredentialStore } from \"./credential-store\";\nimport { CredentialStoreError } from \"@/utils/errors\";\nimport type { PathResolver } from \"../config/path-resolver\";\n\nexport class EncryptedVaultCredentialStore implements CredentialStore {\n readonly name = \"Encrypted Vault (AES-256-GCM)\";\n private paths: PathResolver;\n\n constructor(paths: PathResolver) {\n this.paths = paths;\n }\n\n async isAvailable(): Promise<boolean> {\n return true;\n }\n\n private getMachineSecret(): string {\n const hostname = os.hostname();\n const user = os.userInfo().username;\n const homedir = os.homedir();\n return `gitbridge-vault-key:${hostname}:${user}:${homedir}`;\n }\n\n private deriveKey(salt: Buffer): Buffer {\n const secret = this.getMachineSecret();\n return crypto.pbkdf2Sync(secret, salt, 100_000, 32, \"sha256\");\n }\n\n private readVault(): Record<string, string> {\n const file = this.paths.getEncryptedVaultFile();\n if (!fs.existsSync(file)) {\n return {};\n }\n\n try {\n const buffer = fs.readFileSync(file);\n if (buffer.length < 16 + 12 + 16) {\n return {};\n }\n\n const salt = buffer.subarray(0, 16);\n const iv = buffer.subarray(16, 28);\n const tag = buffer.subarray(28, 44);\n const ciphertext = buffer.subarray(44);\n\n const key = this.deriveKey(salt);\n const decipher = crypto.createDecipheriv(\"aes-256-gcm\", key, iv);\n decipher.setAuthTag(tag);\n\n const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n return JSON.parse(decrypted.toString(\"utf-8\"));\n } catch {\n return {};\n }\n }\n\n private writeVault(data: Record<string, string>): void {\n const file = this.paths.getEncryptedVaultFile();\n try {\n const dir = path.dirname(file);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n\n const salt = crypto.randomBytes(16);\n const iv = crypto.randomBytes(12);\n const key = this.deriveKey(salt);\n\n const cipher = crypto.createCipheriv(\"aes-256-gcm\", key, iv);\n const plaintext = Buffer.from(JSON.stringify(data), \"utf-8\");\n const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);\n const tag = cipher.getAuthTag();\n\n // Combine: [salt][iv][tag][ciphertext]\n const payload = Buffer.concat([salt, iv, tag, ciphertext]);\n\n const tempFile = `${file}.tmp.${Date.now()}`;\n fs.writeFileSync(tempFile, payload, { mode: 0o600 });\n fs.renameSync(tempFile, file);\n } catch (err: unknown) {\n throw new CredentialStoreError(\n `Failed to write encrypted vault: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n private makeKey(service: string, account: string): string {\n return `${service}:::${account}`;\n }\n\n async set(service: string, account: string, secret: string): Promise<void> {\n const vault = this.readVault();\n vault[this.makeKey(service, account)] = secret;\n this.writeVault(vault);\n }\n\n async get(service: string, account: string): Promise<string | null> {\n const vault = this.readVault();\n return vault[this.makeKey(service, account)] ?? null;\n }\n\n async delete(service: string, account: string): Promise<void> {\n const vault = this.readVault();\n delete vault[this.makeKey(service, account)];\n this.writeVault(vault);\n }\n}\n", "import type { CredentialStore } from \"./credential-store\";\nimport { LinuxKeyringCredentialStore } from \"./linux-keyring\";\nimport { MacOSKeychainCredentialStore } from \"./macos-keychain\";\nimport { WindowsCredentialStore } from \"./windows-cred\";\nimport { EncryptedVaultCredentialStore } from \"./encrypted-vault\";\nimport { PathResolver, defaultPathResolver } from \"../config/path-resolver\";\n\nclass CompositeCredentialStore implements CredentialStore {\n readonly name: string;\n private primary: CredentialStore;\n private fallback: EncryptedVaultCredentialStore;\n\n constructor(primary: CredentialStore, fallback: EncryptedVaultCredentialStore) {\n this.primary = primary;\n this.fallback = fallback;\n this.name = `${primary.name} (with Encrypted Vault fallback)`;\n }\n\n async isAvailable(): Promise<boolean> {\n return true;\n }\n\n async set(service: string, account: string, secret: string): Promise<void> {\n try {\n await this.primary.set(service, account, secret);\n } catch {\n await this.fallback.set(service, account, secret);\n }\n }\n\n async get(service: string, account: string): Promise<string | null> {\n try {\n const val = await this.primary.get(service, account);\n if (val !== null && val.length > 0) {\n return val;\n }\n } catch {\n // ignore and try fallback\n }\n return this.fallback.get(service, account);\n }\n\n async delete(service: string, account: string): Promise<void> {\n try {\n await this.primary.delete(service, account);\n } catch {\n // ignore\n }\n await this.fallback.delete(service, account);\n }\n}\n\nexport class StoreFactory {\n static async getStore(paths: PathResolver = defaultPathResolver, forceEncrypted = false): Promise<CredentialStore> {\n const vault = new EncryptedVaultCredentialStore(paths);\n\n if (forceEncrypted || process.env.GITBRIDGE_USE_VAULT === \"1\" || process.env.NODE_ENV === \"test\") {\n return vault;\n }\n\n if (process.platform === \"darwin\") {\n const macStore = new MacOSKeychainCredentialStore();\n if (await macStore.isAvailable()) {\n return new CompositeCredentialStore(macStore, vault);\n }\n } else if (process.platform === \"win32\") {\n const winStore = new WindowsCredentialStore();\n if (await winStore.isAvailable()) {\n return new CompositeCredentialStore(winStore, vault);\n }\n } else if (process.platform === \"linux\") {\n const linuxStore = new LinuxKeyringCredentialStore();\n if (await linuxStore.isAvailable()) {\n return new CompositeCredentialStore(linuxStore, vault);\n }\n }\n\n // Universal fallback\n return vault;\n }\n}\n", "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { GitCli } from \"../git/git-cli\";\nimport { IdentityResolver, type ResolvedContext } from \"../identity/identity-resolver\";\nimport { ConfigStore } from \"../config/config-store\";\n\nexport interface GuardCheckResult {\n allowed: boolean;\n expectedEmail: string | null;\n currentEmail: string | null;\n message?: string;\n}\n\nexport class IdentityGuard {\n private store: ConfigStore;\n private resolver: IdentityResolver;\n\n constructor(store: ConfigStore) {\n this.store = store;\n this.resolver = new IdentityResolver(store);\n }\n\n async check(cwd: string = process.cwd()): Promise<GuardCheckResult> {\n const ctx: ResolvedContext = await this.resolver.resolve(cwd);\n\n if (!ctx.isGitRepo) {\n return { allowed: true, expectedEmail: null, currentEmail: null };\n }\n\n const expectedEmail = ctx.identity?.email || null;\n const currentEmail = ctx.localGitEmail || null;\n\n if (expectedEmail && currentEmail && expectedEmail !== currentEmail) {\n return {\n allowed: false,\n expectedEmail,\n currentEmail,\n message: `Mismatched Git commit identity! Current: '${currentEmail}', Expected: '${expectedEmail}' (${ctx.identity?.name}).`,\n };\n }\n\n return {\n allowed: true,\n expectedEmail,\n currentEmail,\n };\n }\n\n isInstalled(repoPath: string): boolean {\n const hookFile = path.join(repoPath, \".git\", \"hooks\", \"pre-commit\");\n if (!fs.existsSync(hookFile)) return false;\n const content = fs.readFileSync(hookFile, \"utf-8\");\n return content.includes(\"gitbridge hook pre-commit\") || content.includes(\"gb hook pre-commit\");\n }\n\n async install(repoPath: string): Promise<boolean> {\n return this.installPreCommitHook(repoPath);\n }\n\n async uninstall(repoPath: string): Promise<boolean> {\n return this.uninstallPreCommitHook(repoPath);\n }\n\n async installPreCommitHook(repoPath: string): Promise<boolean> {\n const git = new GitCli(repoPath);\n const root = await git.getRepoRoot();\n if (!root) return false;\n\n const hooksDir = path.join(root, \".git\", \"hooks\");\n if (!fs.existsSync(hooksDir)) {\n fs.mkdirSync(hooksDir, { recursive: true });\n }\n\n const hookFile = path.join(hooksDir, \"pre-commit\");\n\n const hookScript = `#!/usr/bin/env bash\n# GitBridge Pre-Commit Identity Guard\nif command -v gitbridge >/dev/null 2>&1; then\n gitbridge hook pre-commit\nelif command -v gb >/dev/null 2>&1; then\n gb hook pre-commit\nfi\n`;\n\n if (fs.existsSync(hookFile)) {\n const existing = fs.readFileSync(hookFile, \"utf-8\");\n if (!existing.includes(\"gitbridge hook pre-commit\")) {\n fs.appendFileSync(hookFile, `\\n${hookScript}\\n`, { mode: 0o755 });\n }\n } else {\n fs.writeFileSync(hookFile, hookScript, { encoding: \"utf-8\", mode: 0o755 });\n }\n\n return true;\n }\n\n async uninstallPreCommitHook(repoPath: string): Promise<boolean> {\n const git = new GitCli(repoPath);\n const root = await git.getRepoRoot();\n if (!root) return false;\n\n const hookFile = path.join(root, \".git\", \"hooks\", \"pre-commit\");\n if (!fs.existsSync(hookFile)) return true;\n\n const content = fs.readFileSync(hookFile, \"utf-8\");\n if (content.includes(\"GitBridge Pre-Commit Identity Guard\") || content.includes(\"gitbridge hook pre-commit\")) {\n const nonCommentLines = content\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => l.length > 0 && !l.startsWith(\"#\"));\n\n const isOnlyGitBridge = nonCommentLines.every(\n (l) =>\n l.startsWith(\"if \") ||\n l.startsWith(\"elif \") ||\n l === \"fi\" ||\n l.includes(\"gitbridge\") ||\n l.includes(\"gb hook\")\n );\n\n if (isOnlyGitBridge) {\n fs.unlinkSync(hookFile);\n } else {\n const filtered = content\n .split(\"\\n\")\n .filter(\n (l) =>\n !l.includes(\"GitBridge\") &&\n !l.includes(\"gitbridge hook\") &&\n !l.includes(\"gb hook\") &&\n !l.includes(\"command -v gitbridge\") &&\n !l.includes(\"command -v gb\")\n )\n .join(\"\\n\")\n .trim();\n fs.writeFileSync(hookFile, `${filtered}\\n`, { encoding: \"utf-8\", mode: 0o755 });\n }\n }\n\n return true;\n }\n}\n", "import { Command } from \"commander\";\nimport { handleStatusCommand } from \"./commands/status\";\nimport { handleEnableCommand, handleDisableCommand } from \"./commands/enable\";\nimport { handleIdentityList, handleIdentityAdd, handleIdentityUse, handleIdentityRemove } from \"./commands/identity\";\nimport { handleAccountList, handleAccountRemove } from \"./commands/account\";\nimport { handleAuthLogin, handleAuthLogout } from \"./commands/auth\";\nimport { handleProviderList } from \"./commands/provider\";\nimport { handleRuleList, handleRuleAdd, handleRuleRemove } from \"./commands/rule\";\nimport { handleRepoInit } from \"./commands/repo\";\nimport { handleContextCommand } from \"./commands/context\";\nimport { handleRemoteList, handleRemoteAdd } from \"./commands/remote\";\nimport { handlePushCommand } from \"./commands/push\";\nimport { handleSwitchCommand } from \"./commands/switch\";\nimport { handleDoctorCommand } from \"./commands/doctor\";\nimport { handleSetupCommand } from \"./commands/setup\";\nimport { handleCredentialCommand } from \"./commands/credential\";\nimport { handleHookCommand } from \"./commands/hook\";\n\nexport function createProgram(name = \"gitbridge\"): Command {\n const program = new Command();\n\n program\n .name(name)\n .description(\"Universal Git Identity & Multi-Account Management Layer\")\n .version(\"0.1.0\");\n\n // Onboarding Wizard\n program\n .command(\"setup\")\n .description(\"Interactive onboarding wizard to configure identities, providers, and rules\")\n .action(() => handleSetupCommand());\n\n // Status & Context\n program\n .command(\"status\")\n .alias(\"st\")\n .description(\"Show overall GitBridge status, active identities, accounts, and rules\")\n .action(() => handleStatusCommand());\n\n program\n .command(\"context\")\n .alias(\"ctx\")\n .description(\"Display GitBridge and Git identity context for current directory or repo\")\n .action(() => handleContextCommand());\n\n // Enable / Disable\n program\n .command(\"enable\")\n .description(\"Enable GitBridge integration in ~/.gitconfig and ~/.ssh/config\")\n .action(() => handleEnableCommand());\n\n program\n .command(\"disable\")\n .description(\"Disable GitBridge integration and safely restore original Git config\")\n .action(() => handleDisableCommand());\n\n // Switch Shortcut\n program\n .command(\"switch [identityId]\")\n .alias(\"sw\")\n .description(\"Quickly switch active Git identity (globally or for current repository)\")\n .option(\"-g, --global\", \"Switch global default identity instead of local repo\")\n .action((identityId, opts) => handleSwitchCommand(identityId, opts));\n\n // Init Repository Profile\n program\n .command(\"init\")\n .description(\"Initialize GitBridge profile and identity for the current Git repository\")\n .action(() => handleRepoInit());\n\n // Identity Subcommands\n const identityCmd = program\n .command(\"identity\")\n .alias(\"id\")\n .description(\"Manage Git commit identities (name, email, signing key)\");\n \n identityCmd.command(\"list\").alias(\"ls\").description(\"List all configured identities\").action(() => handleIdentityList());\n identityCmd\n .command(\"add\")\n .description(\"Create a new Git identity\")\n .option(\"--id <id>\", \"Identity ID (e.g. personal, work)\")\n .option(\"--name <name>\", \"Full name for Git commits\")\n .option(\"--email <email>\", \"Email address for Git commits\")\n .option(\"--signing-key <key>\", \"SSH/GPG commit signing key\")\n .option(\"--default\", \"Set as global default identity\")\n .action((opts) => handleIdentityAdd(opts));\n identityCmd.command(\"use <id>\").description(\"Set global default Git identity\").action((id) => handleIdentityUse(id));\n identityCmd.command(\"remove <id>\").alias(\"rm\").description(\"Remove an identity\").action((id) => handleIdentityRemove(id));\n\n // Account Subcommands\n const accountCmd = program\n .command(\"account\")\n .alias(\"acc\")\n .description(\"Manage authenticated provider accounts\");\n \n accountCmd.command(\"list\").alias(\"ls\").description(\"List logged-in provider accounts\").action(() => handleAccountList());\n accountCmd.command(\"remove <id>\").alias(\"rm\").description(\"Remove an account and erase credentials\").action((id) => handleAccountRemove(id));\n\n // Auth Subcommands\n const authCmd = program.command(\"auth\").description(\"Authenticate with Git providers\");\n authCmd\n .command(\"login [provider]\")\n .description(\"Log in to a Git provider (GitHub, GitLab, Bitbucket)\")\n .option(\"-t, --token <token>\", \"Personal access token\")\n .option(\"--host <host>\", \"Custom host for enterprise/self-hosted instances\")\n .option(\"--ssh-key <path>\", \"Path to SSH private key to associate\")\n .action((prov, opts) => handleAuthLogin(prov, opts));\n authCmd\n .command(\"logout <provider> [username]\")\n .description(\"Log out of a provider and remove stored tokens\")\n .action((prov, user) => handleAuthLogout(prov, user));\n\n // Provider Subcommands\n const providerCmd = program\n .command(\"provider\")\n .alias(\"prov\")\n .description(\"Inspect supported Git providers\");\n \n providerCmd.command(\"list\").alias(\"ls\").description(\"List supported Git providers\").action(() => handleProviderList());\n\n // Rule Subcommands\n const ruleCmd = program\n .command(\"rule\")\n .alias(\"rules\")\n .description(\"Manage directory routing rules\");\n \n ruleCmd.command(\"list\").alias(\"ls\").description(\"List directory routing rules\").action(() => handleRuleList());\n ruleCmd\n .command(\"add [path] [identityId]\")\n .description(\"Add a directory routing rule (maps a folder to an identity)\")\n .option(\"--id <id>\", \"Custom rule ID\")\n .option(\"--provider <provider>\", \"Default provider for this directory\")\n .option(\"--account <accountId>\", \"Default account for this directory\")\n .action((p, id, opts) => handleRuleAdd(p, id, opts));\n ruleCmd.command(\"remove <idOrPath>\").alias(\"rm\").description(\"Remove a directory routing rule\").action((target) => handleRuleRemove(target));\n\n // Remote Subcommands\n const remoteCmd = program\n .command(\"remote\")\n .alias(\"rem\")\n .description(\"Manage repository remotes across providers\");\n \n remoteCmd.command(\"list\").alias(\"ls\").description(\"List remotes for current repository\").action(() => handleRemoteList());\n remoteCmd\n .command(\"add <name> <url>\")\n .description(\"Add a remote with optional provider account routing\")\n .option(\"-a, --account <accountId>\", \"Account ID to route SSH alias to\")\n .action((name, url, opts) => handleRemoteAdd(name, url, opts));\n\n // Push Multi-Remote Runner\n program\n .command(\"push [remoteOrProvider]\")\n .description(\"Push current branch to configured remotes or multiple providers\")\n .option(\"--all\", \"Push to all configured remotes simultaneously\")\n .option(\"--tags\", \"Push tags as well\")\n .option(\"-f, --force\", \"Force push\")\n .action((target, opts) => handlePushCommand(target, opts));\n\n // Doctor Diagnostics\n program\n .command(\"doctor\")\n .alias(\"doc\")\n .description(\"Run comprehensive health and diagnostic checks\")\n .action(() => handleDoctorCommand());\n\n // Credential Helper (Invoked by Git CLI)\n const credCmd = program.command(\"credential\").description(\"Git credential helper bridge (invoked by git)\");\n credCmd.command(\"get\").description(\"Retrieve credentials for git\").action(() => handleCredentialCommand(\"get\"));\n credCmd.command(\"store\").description(\"Store credentials for git\").action(() => handleCredentialCommand(\"store\"));\n credCmd.command(\"erase\").description(\"Erase credentials for git\").action(() => handleCredentialCommand(\"erase\"));\n\n // Hook Subcommand (Invoked by Git hooks)\n const hookCmd = program.command(\"hook\").description(\"Internal Git hook runner\");\n hookCmd.command(\"pre-commit\").description(\"Pre-commit identity validation\").action(() => handleHookCommand(\"pre-commit\"));\n\n return program;\n}\n", "import pc from \"picocolors\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitConfigInjector } from \"@/core/git/gitconfig-injector\";\nimport { SshInjector } from \"@/core/ssh/ssh-injector\";\nimport { formatBadge, showBanner } from \"../ui/banners\";\nimport { renderIdentitiesTable, renderAccountsTable, renderRulesTable } from \"../ui/tables\";\n\nexport async function handleStatusCommand(store: ConfigStore = defaultConfigStore) {\n showBanner();\n\n const config = store.loadConfig();\n const identities = store.loadIdentities();\n const accounts = store.loadAccounts();\n const rules = store.loadRules();\n\n const gitInjector = new GitConfigInjector(store);\n const sshInjector = new SshInjector(store);\n\n const gitInstalled = gitInjector.isInstalled();\n const sshInstalled = sshInjector.isInstalled();\n\n console.log(pc.bold(\" STATUS OVERVIEW\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(` GitBridge Mode: ${config.enabled ? formatBadge(\"ENABLED\", \"green\") : formatBadge(\"DISABLED\", \"red\")}`);\n console.log(` Git Extension Block: ${gitInstalled ? pc.green(\"\u2714 Active in ~/.gitconfig\") : pc.yellow(\"\u26A0 Not installed (run 'gitbridge enable')\")}`);\n console.log(` SSH Extension Block: ${sshInstalled ? pc.green(\"\u2714 Active in ~/.ssh/config\") : pc.gray(\"\u25CB Not installed\")}`);\n console.log(` Default Identity: ${config.defaultIdentityId ? pc.cyan(config.defaultIdentityId) : pc.gray(\"none\")}`);\n console.log(\"\");\n\n console.log(pc.bold(\" IDENTITIES\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderIdentitiesTable(identities, config.defaultIdentityId));\n console.log(\"\");\n\n console.log(pc.bold(\" AUTHENTICATED PROVIDER ACCOUNTS\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderAccountsTable(accounts));\n console.log(\"\");\n\n console.log(pc.bold(\" DIRECTORY RULES\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderRulesTable(rules));\n console.log(\"\");\n}\n", "import pc from \"picocolors\";\n\nexport function showBanner(): void {\n console.log(\n pc.cyan(`\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 ${pc.bold(\"GitBridge\")} \u2502\n \u2502 Universal Git Identity & Multi-Account Layer \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n `)\n );\n}\n\nexport function formatBadge(text: string, color: \"green\" | \"blue\" | \"yellow\" | \"red\" | \"magenta\" | \"cyan\" = \"blue\"): string {\n switch (color) {\n case \"green\":\n return pc.bgGreen(pc.black(` ${text} `));\n case \"blue\":\n return pc.bgBlue(pc.white(` ${text} `));\n case \"yellow\":\n return pc.bgYellow(pc.black(` ${text} `));\n case \"red\":\n return pc.bgRed(pc.white(` ${text} `));\n case \"magenta\":\n return pc.bgMagenta(pc.white(` ${text} `));\n case \"cyan\":\n return pc.bgCyan(pc.black(` ${text} `));\n }\n}\n", "import Table from \"cli-table3\";\nimport pc from \"picocolors\";\nimport type { GitIdentity, ProviderAccount, DirectoryRule } from \"@/core/config/schema\";\nimport type { GitRemoteInfo } from \"@/core/git/git-cli\";\n\nexport function renderIdentitiesTable(identities: GitIdentity[], defaultId: string | null): string {\n if (identities.length === 0) {\n return pc.gray(\" No identities configured yet. Run 'gitbridge identity add' to create one.\\n\");\n }\n\n const table = new Table({\n head: [pc.bold(\"ID\"), pc.bold(\"Name\"), pc.bold(\"Email\"), pc.bold(\"Default\"), pc.bold(\"Signing Key\")],\n style: { head: [\"cyan\"] },\n });\n\n for (const id of identities) {\n const isDef = id.id === defaultId || id.isDefault;\n table.push([\n pc.cyan(id.id),\n id.name,\n id.email,\n isDef ? pc.green(\"\u2714 yes\") : pc.gray(\"no\"),\n id.signingKey ? pc.yellow(id.signingKey.slice(0, 20) + \"...\") : pc.gray(\"none\"),\n ]);\n }\n\n return table.toString();\n}\n\nexport function renderAccountsTable(accounts: ProviderAccount[]): string {\n if (accounts.length === 0) {\n return pc.gray(\" No accounts logged in yet. Run 'gitbridge auth login <provider>' to add one.\\n\");\n }\n\n const table = new Table({\n head: [pc.bold(\"ID\"), pc.bold(\"Provider\"), pc.bold(\"Username\"), pc.bold(\"Host\"), pc.bold(\"Auth Type\"), pc.bold(\"SSH Key\")],\n style: { head: [\"cyan\"] },\n });\n\n for (const acc of accounts) {\n table.push([\n pc.cyan(acc.id),\n pc.magenta(acc.providerId.toUpperCase()),\n acc.username,\n acc.host,\n acc.authType,\n acc.sshKeyPath ? pc.yellow(acc.sshKeyPath) : pc.gray(\"none\"),\n ]);\n }\n\n return table.toString();\n}\n\nexport function renderRulesTable(rules: DirectoryRule[]): string {\n if (rules.length === 0) {\n return pc.gray(\" No directory rules configured. Run 'gitbridge rule add' to map directories.\\n\");\n }\n\n const table = new Table({\n head: [pc.bold(\"Rule ID\"), pc.bold(\"Directory Path\"), pc.bold(\"Identity\"), pc.bold(\"Provider\"), pc.bold(\"Account\")],\n style: { head: [\"cyan\"] },\n });\n\n for (const rule of rules) {\n table.push([\n pc.cyan(rule.id),\n pc.blue(rule.path),\n pc.green(rule.identityId),\n rule.defaultProvider ? pc.magenta(rule.defaultProvider) : pc.gray(\"any\"),\n rule.defaultAccountId ? pc.yellow(rule.defaultAccountId) : pc.gray(\"any\"),\n ]);\n }\n\n return table.toString();\n}\n\nexport function renderRemotesTable(remotes: GitRemoteInfo[]): string {\n if (remotes.length === 0) {\n return pc.gray(\" No Git remotes found.\\n\");\n }\n\n const table = new Table({\n head: [pc.bold(\"Remote\"), pc.bold(\"Provider\"), pc.bold(\"Host\"), pc.bold(\"Repo / Org\"), pc.bold(\"Account Alias\")],\n style: { head: [\"cyan\"] },\n });\n\n for (const r of remotes) {\n const parsed = r.parsedPush || r.parsedFetch;\n table.push([\n pc.cyan(r.name),\n parsed ? pc.magenta(parsed.providerId.toUpperCase()) : pc.gray(\"unknown\"),\n parsed ? parsed.host : pc.gray(\"unknown\"),\n parsed ? parsed.fullName : pc.gray(\"unknown\"),\n parsed?.accountAlias ? pc.yellow(parsed.accountAlias) : pc.gray(\"default\"),\n ]);\n }\n\n return table.toString();\n}\n", "import pc from \"picocolors\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nclass Logger {\n private isDebug = process.env.DEBUG === \"true\" || process.env.GITBRIDGE_DEBUG === \"1\";\n\n setDebug(val: boolean) {\n this.isDebug = val;\n }\n\n debug(msg: string, ...args: unknown[]) {\n if (this.isDebug) {\n console.log(pc.gray(`[DEBUG] ${msg}`), ...args);\n }\n }\n\n info(msg: string) {\n console.log(pc.blue(\"\u2139 \") + msg);\n }\n\n success(msg: string) {\n console.log(pc.green(\"\u2714 \") + pc.bold(msg));\n }\n\n warn(msg: string) {\n console.log(pc.yellow(\"\u26A0 \") + pc.yellow(msg));\n }\n\n error(msg: string, err?: unknown) {\n console.error(pc.red(\"\u2716 \") + pc.red(msg));\n if (err && this.isDebug) {\n console.error(err);\n }\n }\n\n highlight(text: string): string {\n return pc.cyan(text);\n }\n\n dim(text: string): string {\n return pc.gray(text);\n }\n\n bold(text: string): string {\n return pc.bold(text);\n }\n}\n\nexport const logger = new Logger();\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitConfigInjector } from \"@/core/git/gitconfig-injector\";\nimport { SshInjector } from \"@/core/ssh/ssh-injector\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\n\nexport async function handleEnableCommand(store: ConfigStore = defaultConfigStore) {\n store.setEnabled(true);\n\n const gitInjector = new GitConfigInjector(store);\n const sshInjector = new SshInjector(store);\n\n const gitRes = gitInjector.inject();\n const sshRes = sshInjector.inject();\n\n logger.success(\"GitBridge enabled successfully!\");\n if (gitRes.backupPath) {\n logger.debug(`Created backup of .gitconfig at ${gitRes.backupPath}`);\n }\n if (sshRes.backupPath) {\n logger.debug(`Created backup of .ssh/config at ${sshRes.backupPath}`);\n }\n\n console.log(pc.green(\"\\n\u2714 GitBridge integration is now active.\"));\n console.log(pc.gray(\" \u2022 Native Git commands (commit, push, pull) will now inherit GitBridge context.\"));\n console.log(pc.gray(\" \u2022 Run 'gitbridge status' or 'gitbridge context' to inspect current setup.\\n\"));\n}\n\nexport async function handleDisableCommand(store: ConfigStore = defaultConfigStore) {\n store.setEnabled(false);\n\n const gitInjector = new GitConfigInjector(store);\n const sshInjector = new SshInjector(store);\n\n gitInjector.remove();\n sshInjector.remove();\n\n logger.success(\"GitBridge disabled successfully!\");\n console.log(pc.yellow(\"\\n\u26A0 GitBridge integration has been safely removed.\"));\n console.log(pc.gray(\" \u2022 ~/.gitconfig and ~/.ssh/config have been restored to native settings.\"));\n console.log(pc.gray(\" \u2022 Run 'gitbridge enable' to reactivate whenever you want.\\n\"));\n}\n", "import * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\n\nexport function handleCancel(): never {\n p.cancel(pc.yellow(\"Operation cancelled.\"));\n process.exit(0);\n}\n\nexport function isCancel(value: unknown): boolean {\n return p.isCancel(value);\n}\n\nexport interface PromptOption<T> {\n value: T;\n label?: string;\n hint?: string;\n}\n\nexport async function promptText(options: {\n message: string;\n placeholder?: string;\n defaultValue?: string;\n validate?: (value: string) => string | Error | undefined;\n}): Promise<string> {\n const res = await p.text({\n message: options.message,\n placeholder: options.placeholder,\n defaultValue: options.defaultValue,\n validate: options.validate,\n });\n if (p.isCancel(res)) handleCancel();\n return String(res);\n}\n\nexport async function promptSelect<T extends string>(options: {\n message: string;\n options: Array<PromptOption<T>>;\n initialValue?: T;\n}): Promise<T> {\n const res = await p.select({\n message: options.message,\n options: options.options as any,\n initialValue: options.initialValue,\n });\n if (p.isCancel(res)) handleCancel();\n return res as T;\n}\n\nexport async function promptMultiSelect<T extends string>(options: {\n message: string;\n options: Array<PromptOption<T>>;\n required?: boolean;\n}): Promise<T[]> {\n const res = await p.multiselect({\n message: options.message,\n options: options.options as any,\n required: options.required,\n });\n if (p.isCancel(res)) handleCancel();\n return res as T[];\n}\n\nexport async function promptConfirm(options: {\n message: string;\n active?: string;\n inactive?: string;\n initialValue?: boolean;\n}): Promise<boolean> {\n const res = await p.confirm({\n message: options.message,\n active: options.active,\n inactive: options.inactive,\n initialValue: options.initialValue,\n });\n if (p.isCancel(res)) handleCancel();\n return Boolean(res);\n}\n\nexport { p };\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitConfigGenerator } from \"@/core/git/config-generator\";\nimport { renderIdentitiesTable } from \"../ui/tables\";\nimport { promptText, promptConfirm } from \"../ui/prompts\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\n\nexport async function handleIdentityList(store: ConfigStore = defaultConfigStore) {\n const identities = store.loadIdentities();\n const config = store.loadConfig();\n\n console.log(pc.bold(\"\\n GIT IDENTITIES\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderIdentitiesTable(identities, config.defaultIdentityId));\n}\n\nexport async function handleIdentityAdd(\n options: { id?: string; name?: string; email?: string; signingKey?: string; default?: boolean } = {},\n store: ConfigStore = defaultConfigStore\n) {\n const isInteractive = !options.id && !options.name && !options.email;\n\n let id = options.id;\n let name = options.name;\n let email = options.email;\n let signingKey = options.signingKey || null;\n let isDefault = options.default;\n\n if (!id) {\n id = await promptText({\n message: \"Enter an identity ID (e.g. personal, work, client-acme):\",\n validate: (val) => {\n if (!val || !val.trim()) return \"Identity ID is required.\";\n if (store.getIdentity(val.trim())) return \"An identity with this ID already exists.\";\n return undefined;\n },\n });\n }\n\n if (!name) {\n name = await promptText({\n message: \"Enter full name for Git commits (e.g. Fuad Tesfaye):\",\n validate: (val) => (!val || !val.trim() ? \"Name is required.\" : undefined),\n });\n }\n\n if (!email) {\n email = await promptText({\n message: \"Enter email address for Git commits:\",\n validate: (val) => (!val || !val.includes(\"@\") ? \"Please enter a valid email address.\" : undefined),\n });\n }\n\n if (isInteractive && signingKey === null) {\n const addKey = await promptConfirm({\n message: \"Do you want to configure an SSH or GPG commit signing key for this identity?\",\n initialValue: false,\n });\n if (addKey) {\n signingKey = await promptText({\n message: \"Enter signing key (SSH public key or GPG Key ID):\",\n });\n }\n }\n\n if (isDefault === undefined) {\n const existing = store.loadIdentities();\n if (existing.length === 0) {\n isDefault = true;\n } else if (isInteractive) {\n isDefault = await promptConfirm({\n message: \"Set this identity as your global default identity?\",\n initialValue: false,\n });\n } else {\n isDefault = false;\n }\n }\n\n const created = store.addIdentity({\n id: id.trim(),\n name: name.trim(),\n email: email.trim(),\n signingKey: signingKey ? signingKey.trim() : null,\n isDefault,\n });\n\n // Regenerate config\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Identity '${created.id}' created successfully!`);\n console.log(pc.gray(` Name: ${created.name}`));\n console.log(pc.gray(` Email: ${created.email}`));\n if (created.isDefault) {\n console.log(pc.green(\" Set as global default identity.\"));\n }\n console.log(\"\");\n}\n\nexport async function handleIdentityUse(id: string, store: ConfigStore = defaultConfigStore) {\n const target = store.getIdentity(id);\n if (!target) {\n logger.error(`Identity with ID '${id}' does not exist.`);\n return;\n }\n\n store.setDefaultIdentity(id);\n\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Switched global default Git identity to '${target.id}' (${target.email})`);\n}\n\nexport async function handleIdentityRemove(id: string, store: ConfigStore = defaultConfigStore) {\n const removed = store.removeIdentity(id);\n if (!removed) {\n logger.error(`Identity with ID '${id}' not found.`);\n return;\n }\n\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Removed identity '${id}'.`);\n}\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { StoreFactory } from \"@/core/storage/store-factory\";\nimport { SshConfigGenerator } from \"@/core/ssh/ssh-config-generator\";\nimport { renderAccountsTable } from \"../ui/tables\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\n\nexport async function handleAccountList(store: ConfigStore = defaultConfigStore) {\n const accounts = store.loadAccounts();\n\n console.log(pc.bold(\"\\n AUTHENTICATED PROVIDER ACCOUNTS\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderAccountsTable(accounts));\n}\n\nexport async function handleAccountRemove(id: string, store: ConfigStore = defaultConfigStore) {\n const account = store.getAccount(id);\n if (!account) {\n logger.error(`Account with ID '${id}' not found.`);\n return;\n }\n\n // Delete credential from secure store\n const credStore = await StoreFactory.getStore(store.getPathResolver());\n await credStore.delete(account.host, account.id);\n\n store.removeAccount(id);\n\n const sshGen = new SshConfigGenerator(store);\n sshGen.generate();\n\n logger.success(`Removed account '${id}' and erased credentials.`);\n}\n", "import ora from \"ora\";\nimport pc from \"picocolors\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { defaultProviderRegistry } from \"@/core/providers/provider-registry\";\nimport { StoreFactory } from \"@/core/storage/store-factory\";\nimport { SshConfigGenerator } from \"@/core/ssh/ssh-config-generator\";\nimport { SshKeyDetector } from \"@/core/ssh/ssh-key-detector\";\nimport { promptSelect, promptText, promptConfirm } from \"../ui/prompts\";\nimport { logger } from \"@/utils/logger\";\nimport type { GitProviderType } from \"@/core/config/schema\";\n\nexport async function handleAuthLogin(\n providerName?: string,\n options: { token?: string; host?: string; sshKey?: string } = {},\n store: ConfigStore = defaultConfigStore\n) {\n let targetProvider = providerName?.toLowerCase() as GitProviderType | undefined;\n\n if (!targetProvider) {\n targetProvider = await promptSelect<GitProviderType>({\n message: \"Select Git Provider to authenticate with:\",\n options: [\n { value: \"github\", label: \"GitHub (github.com / Enterprise)\" },\n { value: \"gitlab\", label: \"GitLab (gitlab.com / Self-Hosted)\" },\n { value: \"bitbucket\", label: \"Bitbucket (bitbucket.org / Server)\" },\n ],\n });\n }\n\n const provider = defaultProviderRegistry.get(targetProvider);\n if (!provider) {\n logger.error(`Unknown provider: '${targetProvider}'`);\n return;\n }\n\n const host = options.host || provider.defaultHost;\n let token = options.token;\n let username = \"\";\n\n if (!token) {\n if (targetProvider === \"github\" && provider.startDeviceFlow && provider.pollDeviceFlow) {\n const method = await promptSelect({\n message: \"Choose authentication method for GitHub:\",\n options: [\n { value: \"device\", label: \"Web Browser (Device Code Authorization)\" },\n { value: \"pat\", label: \"Personal Access Token (PAT)\" },\n ],\n });\n\n if (method === \"device\") {\n const spinner = ora(\"Initiating GitHub Device Authorization...\").start();\n try {\n const deviceFlow = await provider.startDeviceFlow();\n spinner.stop();\n\n console.log(\"\\n \" + pc.bold(pc.cyan(\"GitHub Device Authorization\")));\n console.log(` 1. Open your browser: ${pc.underline(pc.cyan(deviceFlow.verificationUri))}`);\n console.log(` 2. Enter the one-time code: ${pc.bold(pc.green(deviceFlow.userCode))}\\n`);\n\n const pollSpinner = ora(\"Waiting for browser authorization...\").start();\n const authResult = await provider.pollDeviceFlow(deviceFlow.deviceCode, deviceFlow.interval);\n token = authResult.token;\n pollSpinner.succeed(\"Authorization granted!\");\n } catch (err: unknown) {\n spinner.fail(\"Device flow failed.\");\n logger.error(err instanceof Error ? err.message : String(err));\n return;\n }\n }\n }\n\n if (!token) {\n token = await promptText({\n message: `Enter your Personal Access Token (PAT) for ${provider.name} (${host}):`,\n validate: (val) => (!val || !val.trim() ? \"Token cannot be empty.\" : undefined),\n });\n }\n }\n\n const spinner = ora(`Validating credentials with ${provider.name}...`).start();\n\n try {\n const user = await provider.getUser(token, host);\n username = user.username;\n spinner.succeed(`Authenticated as ${pc.green(user.displayName || user.username)} (@${user.username})`);\n\n // Ask for SSH key association\n let sshKeyPath = options.sshKey;\n if (!sshKeyPath) {\n const availableKeys = SshKeyDetector.listAvailableKeys();\n if (availableKeys.length > 0) {\n const linkKey = await promptConfirm({\n message: `Do you want to link an SSH key for this ${provider.name} account?`,\n initialValue: true,\n });\n\n if (linkKey) {\n sshKeyPath = await promptSelect({\n message: \"Select SSH key to link:\",\n options: availableKeys.map((k) => ({\n value: k.privateKeyPath,\n label: `${k.name} (${k.type})`,\n hint: k.comment,\n })),\n });\n }\n }\n }\n\n const accountId = `${targetProvider}_${username.replace(/[^a-zA-Z0-9_-]/g, \"_\")}`;\n\n // Save account\n store.addAccount({\n id: accountId,\n providerId: targetProvider,\n host,\n username,\n displayName: user.displayName,\n authType: \"oauth\",\n sshKeyPath,\n });\n\n // Save token in secure store\n const credStore = await StoreFactory.getStore(store.getPathResolver());\n await credStore.set(host, accountId, token);\n\n // Update SSH config\n const sshGen = new SshConfigGenerator(store);\n sshGen.generate();\n\n logger.success(`Account '${accountId}' registered and token secured in OS Keychain/Keyring!`);\n console.log(pc.gray(` Host: ${host}`));\n console.log(pc.gray(` Username: ${username}`));\n if (sshKeyPath) {\n console.log(pc.gray(` SSH Alias: ${host}-${accountId}`));\n }\n console.log(\"\");\n } catch (err: unknown) {\n spinner.fail(`Authentication failed.`);\n logger.error(err instanceof Error ? err.message : String(err));\n }\n}\n\nexport async function handleAuthLogout(providerName: string, username?: string, store: ConfigStore = defaultConfigStore) {\n const accounts = store.loadAccounts().filter((a) => a.providerId === providerName);\n\n if (accounts.length === 0) {\n logger.warn(`No accounts found for provider '${providerName}'.`);\n return;\n }\n\n let targetAccount = accounts[0];\n if (username) {\n const found = accounts.find((a) => a.username === username);\n if (!found) {\n logger.error(`Account '${username}' not found for provider '${providerName}'.`);\n return;\n }\n targetAccount = found;\n }\n\n const credStore = await StoreFactory.getStore(store.getPathResolver());\n await credStore.delete(targetAccount.host, targetAccount.id);\n\n store.removeAccount(targetAccount.id);\n\n const sshGen = new SshConfigGenerator(store);\n sshGen.generate();\n\n logger.success(`Logged out of ${targetAccount.providerId} (${targetAccount.username}). Credentials removed.`);\n}\n", "import Table from \"cli-table3\";\nimport pc from \"picocolors\";\nimport { defaultProviderRegistry } from \"@/core/providers/provider-registry\";\nimport { logger } from \"@/utils/logger\";\n\nexport async function handleProviderList() {\n const providers = defaultProviderRegistry.list();\n\n console.log(pc.bold(\"\\n GIT PROVIDERS\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n\n const table = new Table({\n head: [pc.bold(\"ID\"), pc.bold(\"Name\"), pc.bold(\"Default Host\"), pc.bold(\"Status\")],\n style: { head: [\"cyan\"] },\n });\n\n for (const p of providers) {\n table.push([pc.cyan(p.id), p.name, p.defaultHost, pc.green(\"\u2714 supported\")]);\n }\n\n console.log(table.toString());\n console.log(\"\");\n}\n", "import path from \"node:path\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitConfigGenerator } from \"@/core/git/config-generator\";\nimport { renderRulesTable } from \"../ui/tables\";\nimport { promptSelect, promptText } from \"../ui/prompts\";\nimport { collapseTilde, expandTilde } from \"@/utils/platform\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\nimport type { GitProviderType } from \"@/core/config/schema\";\n\nexport async function handleRuleList(store: ConfigStore = defaultConfigStore) {\n const rules = store.loadRules();\n\n console.log(pc.bold(\"\\n DIRECTORY ROUTING RULES\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderRulesTable(rules));\n}\n\nexport async function handleRuleAdd(\n dirPath?: string,\n identityId?: string,\n options: { id?: string; provider?: string; account?: string } = {},\n store: ConfigStore = defaultConfigStore\n) {\n const identities = store.loadIdentities();\n const accounts = store.loadAccounts();\n\n if (identities.length === 0) {\n logger.warn(\"No identities found. Please create an identity first with 'gitbridge identity add'.\");\n return;\n }\n\n let targetPath = dirPath;\n if (!targetPath) {\n targetPath = await promptText({\n message: \"Enter the directory path to map (e.g. ~/Projects/company or /path/to/work):\",\n validate: (val) => (!val || !val.trim() ? \"Directory path is required.\" : undefined),\n });\n }\n\n targetPath = collapseTilde(path.resolve(expandTilde(targetPath.trim())));\n\n let targetIdentity = identityId;\n if (!targetIdentity) {\n targetIdentity = await promptSelect({\n message: `Select identity to assign to '${targetPath}':`,\n options: identities.map((i) => ({\n value: i.id,\n label: `${i.id} (${i.name} <${i.email}>)`,\n })),\n });\n }\n\n const ruleId = options.id || `rule_${path.basename(targetPath).replace(/[^a-zA-Z0-9_-]/g, \"_\")}`;\n\n let defaultProvider: GitProviderType | undefined = options.provider as GitProviderType | undefined;\n let defaultAccountId = options.account;\n\n if (accounts.length > 0 && !defaultAccountId) {\n const matchingAccounts = accounts.filter((a) => a.username.includes(targetIdentity!) || a.id.includes(targetIdentity!));\n if (matchingAccounts.length > 0) {\n defaultAccountId = matchingAccounts[0].id;\n defaultProvider = matchingAccounts[0].providerId;\n }\n }\n\n store.addRule({\n id: ruleId,\n path: targetPath,\n identityId: targetIdentity,\n defaultProvider,\n defaultAccountId,\n });\n\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Directory rule '${ruleId}' added successfully!`);\n console.log(pc.gray(` Path: ${targetPath}`));\n console.log(pc.gray(` Identity: ${targetIdentity}`));\n if (defaultAccountId) {\n console.log(pc.gray(` Account: ${defaultAccountId}`));\n }\n console.log(pc.green(\" Git includeIf rules regenerated.\"));\n console.log(\"\");\n}\n\nexport async function handleRuleRemove(idOrPath: string, store: ConfigStore = defaultConfigStore) {\n const removed = store.removeRule(idOrPath);\n if (!removed) {\n logger.error(`Rule '${idOrPath}' not found.`);\n return;\n }\n\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Directory rule '${idOrPath}' removed.`);\n}\n", "import path from \"node:path\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitCli } from \"@/core/git/git-cli\";\nimport { IdentityGuard } from \"@/core/safety/identity-guard\";\nimport { promptSelect, promptConfirm } from \"../ui/prompts\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\nimport type { RepositoryRemote } from \"@/core/config/schema\";\n\nexport async function handleRepoInit(store: ConfigStore = defaultConfigStore) {\n const cwd = process.cwd();\n const git = new GitCli(cwd);\n\n let isGitRepo = await git.isGitRepo();\n if (!isGitRepo) {\n const initialize = await promptConfirm({\n message: `Current directory is not a Git repository. Run 'git init'?`,\n initialValue: true,\n });\n if (initialize) {\n await git.exec([\"init\"]);\n isGitRepo = true;\n } else {\n logger.warn(\"Initialization aborted.\");\n return;\n }\n }\n\n const repoRoot = (await git.getRepoRoot()) || cwd;\n const repoName = path.basename(repoRoot);\n\n console.log(pc.bold(`\\n CONFIGURING REPOSITORY: ${pc.cyan(repoName)}`));\n console.log(pc.gray(` Path: ${repoRoot}\\n`));\n\n const identities = store.loadIdentities();\n const accounts = store.loadAccounts();\n\n if (identities.length === 0) {\n logger.warn(\"No GitBridge identities configured yet. Run 'gitbridge identity add' first.\");\n return;\n }\n\n // 1. Select Identity\n const selectedIdentityId = await promptSelect({\n message: \"Select Git identity for this repository:\",\n options: identities.map((i) => ({\n value: i.id,\n label: `${i.id} (${i.name} <${i.email}>)`,\n })),\n });\n\n const identity = store.getIdentity(selectedIdentityId)!;\n\n // Set local git config user.name and user.email\n await git.setConfig(\"user.name\", identity.name, \"local\");\n await git.setConfig(\"user.email\", identity.email, \"local\");\n if (identity.signingKey) {\n await git.setConfig(\"user.signingkey\", identity.signingKey, \"local\");\n }\n\n // 2. Configure Remotes\n const existingRemotes = await git.getRemotes();\n const repositoryRemotes: RepositoryRemote[] = [];\n\n if (existingRemotes.length > 0) {\n console.log(pc.bold(\"\\n Detected Remotes:\"));\n for (const r of existingRemotes) {\n const parsed = r.parsedPush || r.parsedFetch;\n console.log(` \u2022 ${pc.cyan(r.name)}: ${r.fetchUrl}`);\n\n if (parsed) {\n let accountId = parsed.accountAlias;\n if (!accountId && accounts.length > 0) {\n const matching = accounts.find((a) => a.host === parsed.host);\n if (matching) {\n accountId = matching.id;\n }\n }\n\n repositoryRemotes.push({\n name: r.name,\n providerId: parsed.providerId,\n host: parsed.host,\n accountId,\n url: r.fetchUrl,\n rawUrl: r.fetchUrl,\n });\n }\n }\n }\n\n // 3. Optional Pre-Commit Identity Guard\n const installHook = await promptConfirm({\n message: \"Install GitBridge pre-commit identity guard hook in this repo?\",\n initialValue: true,\n });\n\n if (installHook) {\n const guard = new IdentityGuard(store);\n await guard.installPreCommitHook(repoRoot);\n }\n\n // 4. Save Repository Profile\n store.saveRepositoryProfile({\n path: repoRoot,\n identityId: selectedIdentityId,\n remotes: repositoryRemotes,\n safetyHookInstalled: installHook,\n });\n\n logger.success(`Repository '${repoName}' initialized with GitBridge!`);\n console.log(pc.gray(` Identity: ${identity.name} <${identity.email}>`));\n console.log(pc.gray(` Pre-commit guard: ${installHook ? pc.green(\"installed\") : pc.gray(\"skipped\")}`));\n console.log(pc.green(\"\\nYou can now make commits and push normally with native Git!\\n\"));\n}\n", "import path from \"node:path\";\nimport { IdentityResolver } from \"@/core/identity/identity-resolver\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { renderRemotesTable } from \"../ui/tables\";\nimport { formatBadge } from \"../ui/banners\";\nimport pc from \"picocolors\";\n\nexport async function handleContextCommand(store: ConfigStore = defaultConfigStore) {\n const resolver = new IdentityResolver(store);\n const ctx = await resolver.resolve();\n\n console.log(pc.bold(\"\\n GITBRIDGE CONTEXT\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n\n if (ctx.isGitRepo) {\n const repoName = ctx.repoRoot ? path.basename(ctx.repoRoot) : \"unknown\";\n console.log(` Repository: ${pc.cyan(repoName)} (${ctx.repoRoot})`);\n } else {\n console.log(` Directory: ${pc.blue(ctx.cwd)} ${pc.gray(\"(not a git repo)\")}`);\n }\n\n console.log(` Resolution Source: ${formatBadge(ctx.source.toUpperCase(), \"cyan\")}`);\n\n if (ctx.identity) {\n console.log(` Resolved Identity: ${pc.green(ctx.identity.name)} <${pc.green(ctx.identity.email)}>`);\n if (ctx.identity.signingKey) {\n console.log(` Signing Key: ${pc.yellow(ctx.identity.signingKey)}`);\n }\n } else {\n console.log(` Resolved Identity: ${pc.yellow(\"None configured\")}`);\n }\n\n if (ctx.isGitRepo) {\n console.log(` Local Git Email: ${ctx.localGitEmail ? pc.cyan(ctx.localGitEmail) : pc.gray(\"not set in .git/config\")}`);\n if (ctx.isMismatched) {\n console.log(\n pc.red(` \u26A0 WARNING: Local git email '${ctx.localGitEmail}' does not match resolved identity '${ctx.identity?.email}'!`)\n );\n }\n }\n\n if (ctx.account) {\n console.log(` Target Account: ${pc.magenta(ctx.account.providerId.toUpperCase())} (${ctx.account.username})`);\n if (ctx.account.sshKeyPath) {\n console.log(` SSH Key: ${pc.yellow(ctx.account.sshKeyPath)}`);\n }\n }\n\n if (ctx.matchedRule) {\n console.log(` Matched Rule: ${pc.blue(ctx.matchedRule.id)} (${ctx.matchedRule.path})`);\n }\n\n if (ctx.isGitRepo && ctx.remotes.length > 0) {\n console.log(\"\\n \" + pc.bold(\"Configured Remotes:\"));\n console.log(renderRemotesTable(ctx.remotes));\n } else {\n console.log(\"\");\n }\n}\n", "import { GitCli } from \"@/core/git/git-cli\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { parseRemoteUrl, buildSshUrl } from \"@/core/git/url-parser\";\nimport { renderRemotesTable } from \"../ui/tables\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\nimport type { RepositoryRemote, RepositoryProfile } from \"@/core/config/schema\";\n\nexport async function handleRemoteList() {\n const git = new GitCli();\n if (!(await git.isGitRepo())) {\n logger.error(\"Current directory is not a Git repository.\");\n return;\n }\n\n const remotes = await git.getRemotes();\n console.log(pc.bold(\"\\n GIT REMOTES\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n console.log(renderRemotesTable(remotes));\n}\n\nexport async function handleRemoteAdd(\n name: string,\n url: string,\n options: { account?: string } = {},\n store: ConfigStore = defaultConfigStore\n) {\n const git = new GitCli();\n if (!(await git.isGitRepo())) {\n logger.error(\"Current directory is not a Git repository.\");\n return;\n }\n\n const parsed = parseRemoteUrl(url);\n if (!parsed) {\n logger.error(\"Invalid remote URL format.\");\n return;\n }\n\n let finalUrl = url;\n if (options.account && parsed.protocol === \"ssh\") {\n finalUrl = buildSshUrl(parsed.host, parsed.owner, parsed.repo, options.account);\n }\n\n await git.setRemoteUrl(name, finalUrl);\n\n // Update repository profile in repos.json\n const repoRoot = await git.getRepoRoot();\n if (repoRoot) {\n const existing = store.getRepository(repoRoot);\n const remotes: RepositoryRemote[] = existing ? [...existing.remotes] : [];\n const existingIdx = remotes.findIndex((r) => r.name === name);\n const remoteData: RepositoryRemote = {\n name,\n providerId: parsed.providerId,\n host: parsed.host,\n accountId: options.account,\n url: finalUrl,\n rawUrl: url,\n };\n\n if (existingIdx >= 0) {\n remotes[existingIdx] = remoteData;\n } else {\n remotes.push(remoteData);\n }\n\n const profile: RepositoryProfile = {\n path: repoRoot,\n identityId: existing?.identityId,\n remotes,\n safetyHookInstalled: existing?.safetyHookInstalled || false,\n updatedAt: new Date().toISOString(),\n };\n\n store.saveRepositoryProfile(profile);\n }\n\n logger.success(`Remote '${name}' added: ${finalUrl}`);\n}\n", "import ora from \"ora\";\nimport pc from \"picocolors\";\nimport { GitCli } from \"@/core/git/git-cli\";\nimport { logger } from \"@/utils/logger\";\n\nexport async function handlePushCommand(\n targetRemoteOrProvider?: string,\n options: { all?: boolean; tags?: boolean; force?: boolean } = {}\n) {\n const git = new GitCli();\n if (!(await git.isGitRepo())) {\n logger.error(\"Current directory is not a Git repository.\");\n return;\n }\n\n const currentBranch = await git.getCurrentBranch();\n if (!currentBranch) {\n logger.error(\"Unable to determine current Git branch (HEAD might be detached).\");\n return;\n }\n\n const remotes = await git.getRemotes();\n if (remotes.length === 0) {\n logger.error(\"No remotes configured for this repository.\");\n return;\n }\n\n let targets = remotes;\n if (targetRemoteOrProvider && !options.all) {\n targets = remotes.filter(\n (r) =>\n r.name === targetRemoteOrProvider ||\n r.parsedPush?.providerId === targetRemoteOrProvider ||\n r.parsedFetch?.providerId === targetRemoteOrProvider\n );\n\n if (targets.length === 0) {\n logger.error(`No remote matching '${targetRemoteOrProvider}' found.`);\n return;\n }\n }\n\n console.log(pc.bold(`\\n Pushing branch '${pc.cyan(currentBranch)}' to ${targets.length} remote(s)...\\n`));\n\n const results = await Promise.allSettled(\n targets.map(async (remote) => {\n const spinner = ora(`Pushing to ${pc.cyan(remote.name)} (${remote.pushUrl})...`).start();\n try {\n const pushArgs = [\"push\", remote.name, currentBranch];\n if (options.tags) pushArgs.push(\"--tags\");\n if (options.force) pushArgs.push(\"--force\");\n\n await git.exec(pushArgs);\n spinner.succeed(`Pushed to ${pc.green(remote.name)} [${remote.parsedPush?.providerId.toUpperCase() || \"GIT\"}]`);\n return { remote: remote.name, success: true };\n } catch (err: unknown) {\n spinner.fail(`Failed push to ${pc.red(remote.name)}: ${err instanceof Error ? err.message : String(err)}`);\n return { remote: remote.name, success: false, error: String(err) };\n }\n })\n );\n\n const successful = results.filter((r) => r.status === \"fulfilled\" && r.value.success).length;\n console.log(\"\");\n if (successful === targets.length) {\n logger.success(`All ${successful} remote(s) updated successfully!`);\n } else {\n logger.warn(`Push finished with ${successful}/${targets.length} remotes succeeded.`);\n }\n}\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitCli } from \"@/core/git/git-cli\";\nimport { GitConfigGenerator } from \"@/core/git/config-generator\";\nimport { promptSelect } from \"../ui/prompts\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\nimport type { RepositoryProfile } from \"@/core/config/schema\";\n\nexport async function handleSwitchCommand(\n targetIdentityId?: string,\n options: { global?: boolean } = {},\n store: ConfigStore = defaultConfigStore\n) {\n const identities = store.loadIdentities();\n if (identities.length === 0) {\n logger.warn(\"No identities configured. Create one with 'gitbridge identity add'.\");\n return;\n }\n\n let selectedId = targetIdentityId;\n if (!selectedId) {\n selectedId = await promptSelect({\n message: \"Switch to identity:\",\n options: identities.map((i) => ({\n value: i.id,\n label: `${i.id} (${i.name} <${i.email}>)`,\n hint: i.isDefault ? \"current global default\" : undefined,\n })),\n });\n }\n\n const identity = store.getIdentity(selectedId);\n if (!identity) {\n logger.error(`Identity '${selectedId}' not found.`);\n return;\n }\n\n const git = new GitCli();\n const isGitRepo = await git.isGitRepo();\n\n if (isGitRepo && !options.global) {\n await git.setConfig(\"user.name\", identity.name, \"local\");\n await git.setConfig(\"user.email\", identity.email, \"local\");\n if (identity.signingKey) {\n await git.setConfig(\"user.signingkey\", identity.signingKey, \"local\");\n }\n\n const repoRoot = await git.getRepoRoot();\n if (repoRoot) {\n const existing = store.getRepository(repoRoot);\n const profile: RepositoryProfile = {\n path: repoRoot,\n identityId: identity.id,\n remotes: existing?.remotes || [],\n safetyHookInstalled: existing?.safetyHookInstalled || false,\n updatedAt: new Date().toISOString(),\n };\n store.saveRepositoryProfile(profile);\n }\n\n logger.success(`Switched repository identity to '${identity.id}'!`);\n console.log(pc.gray(` Name: ${identity.name}`));\n console.log(pc.gray(` Email: ${identity.email}`));\n console.log(pc.gray(\" Applied locally to current repository (.git/config).\"));\n } else {\n store.setDefaultIdentity(identity.id);\n const generator = new GitConfigGenerator(store);\n generator.generate();\n\n logger.success(`Switched global default Git identity to '${identity.id}'!`);\n console.log(pc.gray(` Name: ${identity.name}`));\n console.log(pc.gray(` Email: ${identity.email}`));\n console.log(pc.green(\" Applied globally across GitBridge configuration.\"));\n }\n}\n", "import ora from \"ora\";\nimport pc from \"picocolors\";\nimport { GitCli } from \"@/core/git/git-cli\";\nimport { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { GitConfigInjector } from \"@/core/git/gitconfig-injector\";\nimport { SshInjector } from \"@/core/ssh/ssh-injector\";\nimport { SshKeyDetector } from \"@/core/ssh/ssh-key-detector\";\nimport { StoreFactory } from \"@/core/storage/store-factory\";\nimport { defaultProviderRegistry } from \"@/core/providers/provider-registry\";\nimport { getPlatform } from \"@/utils/platform\";\n\nexport async function handleDoctorCommand(store: ConfigStore = defaultConfigStore) {\n console.log(pc.bold(\"\\n GITBRIDGE DOCTOR - SYSTEM DIAGNOSTICS\"));\n console.log(\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\");\n\n const git = new GitCli();\n const gitInjector = new GitConfigInjector(store);\n const sshInjector = new SshInjector(store);\n\n // 1. Core Tooling\n const gitVersion = await git.getGitVersion();\n const bunVersion = typeof Bun !== \"undefined\" ? Bun.version : \"N/A\";\n const platform = getPlatform();\n\n console.log(pc.bold(\" 1. Toolchain & Environment\"));\n if (gitVersion) {\n console.log(` ${pc.green(\"\u2714\")} Git CLI: ${pc.cyan(gitVersion)}`);\n } else {\n console.log(` ${pc.red(\"\u2716\")} Git CLI: ${pc.red(\"Not found on PATH\")}`);\n }\n\n console.log(` ${pc.green(\"\u2714\")} Bun Runtime: ${pc.cyan(bunVersion)}`);\n console.log(` ${pc.green(\"\u2714\")} Platform: ${pc.cyan(platform)} (${process.arch})`);\n\n // 2. Integration Blocks\n console.log(pc.bold(\"\\n 2. Git & SSH Integrations\"));\n const gitInstalled = gitInjector.isInstalled();\n const sshInstalled = sshInjector.isInstalled();\n\n if (gitInstalled) {\n console.log(` ${pc.green(\"\u2714\")} ~/.gitconfig: ${pc.green(\"Managed block active\")}`);\n } else {\n console.log(` ${pc.yellow(\"\u26A0\")} ~/.gitconfig: ${pc.yellow(\"Not enabled (run 'gitbridge enable')\")}`);\n }\n\n if (sshInstalled) {\n console.log(` ${pc.green(\"\u2714\")} ~/.ssh/config: ${pc.green(\"Include directive active\")}`);\n } else {\n console.log(` ${pc.gray(\"\u25CB\")} ~/.ssh/config: ${pc.gray(\"Not enabled\")}`);\n }\n\n // 3. Credential Store Backend\n console.log(pc.bold(\"\\n 3. Secure Credential Storage\"));\n const credStore = await StoreFactory.getStore(store.getPathResolver());\n const storeAvailable = await credStore.isAvailable();\n if (storeAvailable) {\n console.log(` ${pc.green(\"\u2714\")} Active Backend: ${pc.cyan(credStore.name)}`);\n } else {\n console.log(` ${pc.red(\"\u2716\")} Active Backend: ${pc.red(\"Unavailable\")}`);\n }\n\n // 4. SSH Keys\n const sshKeys = SshKeyDetector.listAvailableKeys();\n console.log(pc.bold(\"\\n 4. Discovered SSH Keys\"));\n if (sshKeys.length > 0) {\n for (const key of sshKeys) {\n console.log(` ${pc.green(\"\u2714\")} ${key.name}: ${pc.gray(key.publicKeyPath)} (${key.type})`);\n }\n } else {\n console.log(` ${pc.gray(\"\u25CB\")} No .pub keys found in ~/.ssh`);\n }\n\n // 5. Provider API Health\n console.log(pc.bold(\"\\n 5. Provider Connectivity\"));\n const providers = defaultProviderRegistry.list();\n\n for (const provider of providers) {\n const spinner = ora(` Checking ${provider.name} (${provider.defaultHost})...`).start();\n const health = await provider.checkHealth();\n if (health.apiOk) {\n spinner.succeed(` ${pc.green(\"\u2714\")} ${provider.name}: API reachable (${health.pingMs}ms)`);\n } else {\n spinner.warn(` ${pc.yellow(\"\u26A0\")} ${provider.name}: ${health.error || \"Unreachable\"}`);\n }\n }\n\n console.log(pc.green(\"\\n\u2714 Diagnostics complete.\\n\"));\n}\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { handleIdentityAdd } from \"./identity\";\nimport { handleAuthLogin } from \"./auth\";\nimport { handleRuleAdd } from \"./rule\";\nimport { handleEnableCommand } from \"./enable\";\nimport { promptConfirm, promptMultiSelect } from \"../ui/prompts\";\nimport { showBanner } from \"../ui/banners\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\nimport type { GitProviderType } from \"@/core/config/schema\";\n\nexport async function handleSetupCommand(store: ConfigStore = defaultConfigStore) {\n showBanner();\n console.log(pc.bold(\" Welcome to GitBridge Interactive Onboarding!\\n\"));\n console.log(pc.gray(\" Let's set up your Git identities, provider connections, and workspace rules.\\n\"));\n\n // 1. Create Primary Identity\n console.log(pc.cyan(\"\u2500\u2500 Step 1: Create your Primary Git Identity \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"));\n await handleIdentityAdd({ id: \"personal\", default: true }, store);\n\n // Option for Second Identity (e.g. Work)\n const addWork = await promptConfirm({\n message: \"Do you also want to create a Work or secondary identity now?\",\n initialValue: true,\n });\n\n if (addWork) {\n console.log(pc.cyan(\"\\n\u2500\u2500 Step 1b: Create Work Git Identity \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"));\n await handleIdentityAdd({ id: \"work\", default: false }, store);\n }\n\n // 2. Provider Connections\n console.log(pc.cyan(\"\\n\u2500\u2500 Step 2: Connect Git Providers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"));\n const selectedProviders = await promptMultiSelect<GitProviderType>({\n message: \"Which Git providers do you use? (Select with spacebar):\",\n options: [\n { value: \"github\", label: \"GitHub\" },\n { value: \"gitlab\", label: \"GitLab\" },\n { value: \"bitbucket\", label: \"Bitbucket\" },\n ],\n });\n\n for (const prov of selectedProviders) {\n const loginNow = await promptConfirm({\n message: `Do you want to log in to ${prov.toUpperCase()} right now?`,\n initialValue: true,\n });\n if (loginNow) {\n await handleAuthLogin(prov, {}, store);\n }\n }\n\n // 3. Directory Rules\n console.log(pc.cyan(\"\\n\u2500\u2500 Step 3: Workspace Directory Routing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"));\n const addDirRule = await promptConfirm({\n message: \"Do you want to map a directory (e.g. ~/Projects/work) to an identity?\",\n initialValue: true,\n });\n\n if (addDirRule) {\n await handleRuleAdd(undefined, undefined, {}, store);\n }\n\n // 4. Enable Integration\n console.log(pc.cyan(\"\\n\u2500\u2500 Step 4: Activate Git Integration \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"));\n await handleEnableCommand(store);\n\n logger.success(\"GitBridge setup completed successfully!\");\n console.log(pc.bold(\"\\n You're all set! Try running:\"));\n console.log(pc.cyan(\" gitbridge status\") + pc.gray(\" # view configured status\"));\n console.log(pc.cyan(\" gitbridge context\") + pc.gray(\" # inspect current directory\"));\n console.log(pc.cyan(\" gitbridge doctor\") + pc.gray(\" # run system diagnostics\\n\"));\n}\n", "import { ConfigStore, defaultConfigStore } from \"@/core/config/config-store\";\nimport { StoreFactory } from \"@/core/storage/store-factory\";\nimport { IdentityResolver } from \"@/core/identity/identity-resolver\";\n\nexport interface GitCredentialPayload {\n protocol?: string;\n host?: string;\n path?: string;\n username?: string;\n password?: string;\n}\n\nexport function parseGitCredentialInput(raw: string): GitCredentialPayload {\n const lines = raw.split(\"\\n\");\n const payload: GitCredentialPayload = {};\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx !== -1) {\n const key = trimmed.slice(0, eqIdx);\n const val = trimmed.slice(eqIdx + 1);\n if (key === \"protocol\") payload.protocol = val;\n if (key === \"host\") payload.host = val;\n if (key === \"path\") payload.path = val;\n if (key === \"username\") payload.username = val;\n if (key === \"password\") payload.password = val;\n }\n }\n\n return payload;\n}\n\nexport class GitCredentialHelperHandler {\n private store: ConfigStore;\n private resolver: IdentityResolver;\n\n constructor(store: ConfigStore = defaultConfigStore) {\n this.store = store;\n this.resolver = new IdentityResolver(store);\n }\n\n async handleGet(input: string, cwd: string = process.cwd()): Promise<string> {\n const payload = parseGitCredentialInput(input);\n if (!payload.host) return \"\";\n\n const accounts = this.store.loadAccounts();\n const config = this.store.loadConfig();\n\n if (!config.enabled) return \"\";\n\n // 1. Resolve context for cwd\n const ctx = await this.resolver.resolve(cwd);\n\n let targetAccount = ctx.account;\n\n // 2. If no account in resolved context, find account by host and matching username or first for host\n if (!targetAccount) {\n if (payload.username) {\n targetAccount = accounts.find((a) => a.host === payload.host && a.username === payload.username) || null;\n }\n if (!targetAccount) {\n targetAccount = accounts.find((a) => a.host === payload.host) || null;\n }\n }\n\n if (!targetAccount) return \"\";\n\n const credStore = await StoreFactory.getStore(this.store.getPathResolver());\n const token = await credStore.get(targetAccount.host, targetAccount.id);\n\n if (!token) return \"\";\n\n const lines = [\n `username=${targetAccount.username}`,\n `password=${token}`,\n \"\", // trailing newline required by Git protocol\n ];\n\n return lines.join(\"\\n\");\n }\n\n async handleStore(input: string): Promise<void> {\n const payload = parseGitCredentialInput(input);\n if (!payload.host || !payload.username || !payload.password) return;\n\n const credStore = await StoreFactory.getStore(this.store.getPathResolver());\n const accountId = `${payload.host.replace(/[^a-zA-Z0-9]/g, \"_\")}_${payload.username}`;\n\n await credStore.set(payload.host, accountId, payload.password);\n }\n\n async handleErase(input: string): Promise<void> {\n const payload = parseGitCredentialInput(input);\n if (!payload.host || !payload.username) return;\n\n const credStore = await StoreFactory.getStore(this.store.getPathResolver());\n const accountId = `${payload.host.replace(/[^a-zA-Z0-9]/g, \"_\")}_${payload.username}`;\n\n await credStore.delete(payload.host, accountId);\n }\n}\n\nexport async function handleCredentialCommand(action: \"get\" | \"store\" | \"erase\", stdinData?: string) {\n const handler = new GitCredentialHelperHandler();\n\n let input = stdinData;\n if (input === undefined) {\n input = await new Response(Bun.stdin.stream()).text();\n }\n\n if (action === \"get\") {\n const output = await handler.handleGet(input);\n if (output) {\n process.stdout.write(output);\n }\n } else if (action === \"store\") {\n await handler.handleStore(input);\n } else if (action === \"erase\") {\n await handler.handleErase(input);\n }\n}\n", "import { IdentityGuard } from \"@/core/safety/identity-guard\";\nimport { defaultConfigStore } from \"@/core/config/config-store\";\nimport { logger } from \"@/utils/logger\";\nimport pc from \"picocolors\";\n\nexport async function handleHookCommand(hookType: string) {\n if (hookType !== \"pre-commit\") {\n return;\n }\n\n const guard = new IdentityGuard(defaultConfigStore);\n const result = await guard.check();\n\n if (!result.allowed) {\n console.error(pc.red(\"\\n\u2716 [GitBridge Identity Guard] Commit Blocked!\"));\n console.error(pc.yellow(` ${result.message}`));\n console.error(\n pc.gray(\" To fix this commit identity, run: \") +\n pc.cyan(`git config user.email \"${result.expectedEmail}\"`)\n );\n console.error(\n pc.gray(\" Or update your GitBridge profile with: \") + pc.cyan(\"gitbridge repo init\\n\")\n );\n process.exit(1);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAGX,IAAM,wBAAwB,aAAE,KAAK,CAAC,UAAU,UAAU,aAAa,SAAS,QAAQ,CAAC;AAIzF,IAAM,iBAAiB,aAAE,KAAK,CAAC,SAAS,OAAO,OAAO,UAAU,CAAC;AAIjE,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,IAAI,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,MAAM,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,OAAO,aAAE,OAAO,EAAE,MAAM;AAAA,EACxB,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA,EACzD,WAAW,aAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAC/C,WAAW,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,OAAM,oBAAI,KAAK,GAAE,YAAY,CAAC;AACpF,CAAC;AAGM,IAAM,uBAAuB,aAAE,OAAO;AAAA,EAC3C,YAAY,aAAE,MAAM,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC;AAIM,IAAM,wBAAwB,aAAE,OAAO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B,EAAE,OAAO,MAAM,wBAAwB,OAAO,CAAC;AAC/G,UAAQ,QAAQ,OAAO,EAAE,YAAY,2BAA2B,EAAE,OAAO,MAAM,wBAAwB,OAAO,CAAC;AAG/G,QAAM,UAAU,QAAQ,QAAQ,MAAM,EAAE,YAAY,0BAA0B;AAC9E,UAAQ,QAAQ,YAAY,EAAE,YAAY,gCAAgC,EAAE,OAAO,MAAM,kBAAkB,YAAY,CAAC;AAExH,SAAO;AACT;",
6
+ "names": ["import_node_path", "import_node_path", "p", "os", "path", "path", "fs", "path", "import_node_fs", "fs", "import_node_fs", "import_node_path", "fs", "path", "import_node_fs", "fs", "import_node_fs", "import_node_path", "fs", "path", "import_node_fs", "import_node_path", "path", "fs", "import_node_path", "path", "text", "import_node_fs", "import_node_path", "import_node_os", "os", "crypto", "fs", "path", "import_node_fs", "import_node_path", "path", "fs", "import_picocolors", "pc", "text", "import_picocolors", "pc", "Table", "pc", "import_picocolors", "pc", "text", "import_picocolors", "pc", "import_picocolors", "pc", "import_picocolors", "pc", "import_picocolors", "pc", "import_picocolors", "spinner", "ora", "pc", "import_cli_table3", "import_picocolors", "pc", "Table", "p", "import_node_path", "import_picocolors", "pc", "path", "import_node_path", "import_picocolors", "path", "pc", "import_node_path", "import_picocolors", "pc", "path", "import_picocolors", "pc", "import_ora", "import_picocolors", "pc", "ora", "import_picocolors", "pc", "import_ora", "import_picocolors", "pc", "ora", "import_picocolors", "pc", "import_picocolors", "pc", "p", "name"]
7
+ }