@mcp-consultant-tools/github-enterprise 1.0.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.
@@ -0,0 +1,179 @@
1
+ /**
2
+ * GitHub Enterprise Repository Configuration
3
+ */
4
+ export interface GitHubRepoConfig {
5
+ id: string;
6
+ owner: string;
7
+ repo: string;
8
+ defaultBranch?: string;
9
+ active: boolean;
10
+ description?: string;
11
+ }
12
+ /**
13
+ * GitHub Enterprise Service Configuration
14
+ */
15
+ export interface GitHubEnterpriseConfig {
16
+ baseUrl: string;
17
+ apiVersion: string;
18
+ authMethod: 'pat' | 'github-app';
19
+ pat?: string;
20
+ appId?: string;
21
+ appPrivateKey?: string;
22
+ appInstallationId?: string;
23
+ repos: GitHubRepoConfig[];
24
+ enableWrite: boolean;
25
+ enableCreate: boolean;
26
+ enableCache: boolean;
27
+ cacheTtl: number;
28
+ maxFileSize: number;
29
+ maxSearchResults: number;
30
+ }
31
+ /**
32
+ * Branch Selection Result
33
+ */
34
+ export interface BranchSelection {
35
+ branch: string;
36
+ reason: string;
37
+ confidence: 'high' | 'medium' | 'low';
38
+ alternatives?: string[];
39
+ message?: string;
40
+ }
41
+ /**
42
+ * GitHub Enterprise Service
43
+ * Manages authentication, API requests, caching, and branch selection for GitHub Enterprise Cloud
44
+ */
45
+ export declare class GitHubEnterpriseService {
46
+ private config;
47
+ private readonly baseApiUrl;
48
+ private octokit;
49
+ private accessToken;
50
+ private tokenExpirationTime;
51
+ private cache;
52
+ constructor(config: GitHubEnterpriseConfig);
53
+ /**
54
+ * Initialize Octokit client based on authentication method
55
+ */
56
+ private initializeOctokit;
57
+ /**
58
+ * Get access token with caching (for GitHub App auth)
59
+ * Implements 5-minute buffer pattern before expiry
60
+ */
61
+ private getAccessToken;
62
+ /**
63
+ * Get cache key for a request
64
+ */
65
+ private getCacheKey;
66
+ /**
67
+ * Get cached response
68
+ */
69
+ private getCached;
70
+ /**
71
+ * Set cache entry
72
+ */
73
+ private setCache;
74
+ /**
75
+ * Clear cache entries
76
+ * @param pattern Optional pattern to match cache keys
77
+ * @param repoId Optional repo ID to clear cache for specific repo
78
+ * @returns Number of cache entries cleared
79
+ */
80
+ clearCache(pattern?: string, repoId?: string): number;
81
+ /**
82
+ * Make API request with error handling and caching
83
+ */
84
+ private makeRequest;
85
+ /**
86
+ * Get all configured repositories
87
+ */
88
+ getAllRepos(): GitHubRepoConfig[];
89
+ /**
90
+ * Get active repositories only
91
+ */
92
+ getActiveRepos(): GitHubRepoConfig[];
93
+ /**
94
+ * Get repository by ID with validation
95
+ */
96
+ getRepoById(repoId: string): GitHubRepoConfig;
97
+ /**
98
+ * List all branches for a repository
99
+ */
100
+ listBranches(repoId: string, protectedOnly?: boolean): Promise<any[]>;
101
+ /**
102
+ * Auto-detect default branch for a repository
103
+ * Handles typos gracefully and provides alternatives
104
+ */
105
+ getDefaultBranch(repoId: string, userSpecified?: string): Promise<BranchSelection>;
106
+ /**
107
+ * Get file content from a repository
108
+ */
109
+ getFile(repoId: string, path: string, branch?: string): Promise<any>;
110
+ /**
111
+ * Search code across repositories
112
+ */
113
+ searchCode(query: string, repoId?: string, path?: string, extension?: string): Promise<any>;
114
+ /**
115
+ * List files in a directory
116
+ */
117
+ listFiles(repoId: string, path?: string, branch?: string): Promise<any>;
118
+ /**
119
+ * Get commit history for a branch
120
+ */
121
+ getCommits(repoId: string, branch?: string, since?: string, until?: string, author?: string, path?: string, limit?: number): Promise<any[]>;
122
+ /**
123
+ * Get commit details
124
+ */
125
+ getCommitDetails(repoId: string, sha: string): Promise<any>;
126
+ /**
127
+ * Search commits by message
128
+ */
129
+ searchCommits(query: string, repoId?: string, author?: string, since?: string, until?: string): Promise<any>;
130
+ /**
131
+ * Compare two branches
132
+ */
133
+ compareBranches(repoId: string, base: string, head: string): Promise<any>;
134
+ /**
135
+ * Get branch details
136
+ */
137
+ getBranchDetails(repoId: string, branch: string): Promise<any>;
138
+ /**
139
+ * List pull requests
140
+ */
141
+ listPullRequests(repoId: string, state?: 'open' | 'closed' | 'all', base?: string, head?: string, sort?: 'created' | 'updated' | 'popularity', limit?: number): Promise<any[]>;
142
+ /**
143
+ * Get pull request details
144
+ */
145
+ getPullRequest(repoId: string, prNumber: number): Promise<any>;
146
+ /**
147
+ * Get pull request files
148
+ */
149
+ getPullRequestFiles(repoId: string, prNumber: number): Promise<any[]>;
150
+ /**
151
+ * Create a new branch (requires GHE_ENABLE_CREATE=true)
152
+ */
153
+ createBranch(repoId: string, branchName: string, fromBranch?: string): Promise<any>;
154
+ /**
155
+ * Update file content (requires GHE_ENABLE_WRITE=true)
156
+ */
157
+ updateFile(repoId: string, path: string, content: string, message: string, branch: string, sha: string): Promise<any>;
158
+ /**
159
+ * Create a new file (requires GHE_ENABLE_CREATE=true)
160
+ */
161
+ createFile(repoId: string, path: string, content: string, message: string, branch: string): Promise<any>;
162
+ /**
163
+ * Search repositories
164
+ */
165
+ searchRepositories(query: string, owner?: string): Promise<any>;
166
+ /**
167
+ * Get directory structure recursively
168
+ */
169
+ getDirectoryStructure(repoId: string, path?: string, branch?: string, depth?: number): Promise<any>;
170
+ /**
171
+ * Get file commit history
172
+ */
173
+ getFileHistory(repoId: string, path: string, branch?: string, limit?: number): Promise<any[]>;
174
+ /**
175
+ * Get commit diff
176
+ */
177
+ getCommitDiff(repoId: string, sha: string, format?: 'diff' | 'patch'): Promise<string>;
178
+ }
179
+ //# sourceMappingURL=GitHubEnterpriseService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubEnterpriseService.d.ts","sourceRoot":"","sources":["../src/GitHubEnterpriseService.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,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