@nahisaho/musubix-codegraph 2.3.2 → 2.3.4

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 (41) hide show
  1. package/dist/cli.d.ts +13 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +318 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +8 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/pr/errors.d.ts +63 -0
  10. package/dist/pr/errors.d.ts.map +1 -0
  11. package/dist/pr/errors.js +116 -0
  12. package/dist/pr/errors.js.map +1 -0
  13. package/dist/pr/git-operations.d.ts +186 -0
  14. package/dist/pr/git-operations.d.ts.map +1 -0
  15. package/dist/pr/git-operations.js +441 -0
  16. package/dist/pr/git-operations.js.map +1 -0
  17. package/dist/pr/github-adapter.d.ts +163 -0
  18. package/dist/pr/github-adapter.d.ts.map +1 -0
  19. package/dist/pr/github-adapter.js +467 -0
  20. package/dist/pr/github-adapter.js.map +1 -0
  21. package/dist/pr/index.d.ts +20 -0
  22. package/dist/pr/index.d.ts.map +1 -0
  23. package/dist/pr/index.js +26 -0
  24. package/dist/pr/index.js.map +1 -0
  25. package/dist/pr/pr-creator.d.ts +173 -0
  26. package/dist/pr/pr-creator.d.ts.map +1 -0
  27. package/dist/pr/pr-creator.js +468 -0
  28. package/dist/pr/pr-creator.js.map +1 -0
  29. package/dist/pr/pr-template.d.ts +105 -0
  30. package/dist/pr/pr-template.d.ts.map +1 -0
  31. package/dist/pr/pr-template.js +273 -0
  32. package/dist/pr/pr-template.js.map +1 -0
  33. package/dist/pr/refactoring-applier.d.ts +143 -0
  34. package/dist/pr/refactoring-applier.d.ts.map +1 -0
  35. package/dist/pr/refactoring-applier.js +412 -0
  36. package/dist/pr/refactoring-applier.js.map +1 -0
  37. package/dist/pr/types.d.ts +362 -0
  38. package/dist/pr/types.d.ts.map +1 -0
  39. package/dist/pr/types.js +63 -0
  40. package/dist/pr/types.js.map +1 -0
  41. package/package.json +11 -2
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - GitHub Adapter
3
+ *
4
+ * GitHub API integration using Octokit or gh CLI fallback
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/musubix-codegraph/pr
8
+ *
9
+ * @see REQ-CG-PR-001 - GitHub Authentication
10
+ * @see REQ-CG-PR-005 - GitHub PR Creation
11
+ * @see DES-CG-PR-004 - Class Design
12
+ */
13
+ import type { GitHubConfig, GitHubAuthMethod, GitHubAuthResult, PRInfo } from './types.js';
14
+ /**
15
+ * Pull Request creation options for GitHub API
16
+ */
17
+ export interface CreatePROptions {
18
+ /** PR title */
19
+ title: string;
20
+ /** PR body (Markdown) */
21
+ body: string;
22
+ /** Head branch (the branch with changes) */
23
+ head: string;
24
+ /** Base branch (the branch to merge into) */
25
+ base: string;
26
+ /** Create as draft PR */
27
+ draft?: boolean;
28
+ /** Maintainer can modify */
29
+ maintainerCanModify?: boolean;
30
+ }
31
+ /**
32
+ * Options for updating a PR
33
+ */
34
+ export interface UpdatePROptions {
35
+ /** PR number */
36
+ number: number;
37
+ /** New title */
38
+ title?: string;
39
+ /** New body */
40
+ body?: string;
41
+ /** New state */
42
+ state?: 'open' | 'closed';
43
+ }
44
+ /**
45
+ * PR label
46
+ */
47
+ export interface PRLabel {
48
+ name: string;
49
+ color?: string;
50
+ description?: string;
51
+ }
52
+ /**
53
+ * GitHub Adapter
54
+ *
55
+ * Provides a unified interface for GitHub operations.
56
+ * Supports both direct API access (via GITHUB_TOKEN) and gh CLI fallback.
57
+ *
58
+ * @see DES-CG-PR-004
59
+ * @example
60
+ * ```typescript
61
+ * const github = new GitHubAdapter({ owner: 'user', repo: 'project' });
62
+ * await github.authenticate();
63
+ * const pr = await github.createPullRequest({
64
+ * title: 'refactor: extract interface',
65
+ * body: '...',
66
+ * head: 'refactor/extract-interface',
67
+ * base: 'main'
68
+ * });
69
+ * ```
70
+ */
71
+ export declare class GitHubAdapter {
72
+ private readonly config;
73
+ private authMethod;
74
+ private authenticated;
75
+ private username?;
76
+ /**
77
+ * Create a new GitHubAdapter
78
+ * @param config - GitHub configuration
79
+ */
80
+ constructor(config: GitHubConfig);
81
+ /**
82
+ * Authenticate with GitHub
83
+ * @see REQ-CG-PR-001
84
+ */
85
+ authenticate(): Promise<GitHubAuthResult>;
86
+ /**
87
+ * Check if authenticated
88
+ */
89
+ isAuthenticated(): boolean;
90
+ /**
91
+ * Get authentication method
92
+ */
93
+ getAuthMethod(): GitHubAuthMethod;
94
+ /**
95
+ * Get authenticated username
96
+ */
97
+ getUsername(): string | undefined;
98
+ /**
99
+ * Validate a GitHub token
100
+ */
101
+ private validateToken;
102
+ /**
103
+ * Check if gh CLI is available
104
+ */
105
+ private isGhCliAvailable;
106
+ /**
107
+ * Authenticate using gh CLI
108
+ */
109
+ private authenticateWithGhCli;
110
+ /**
111
+ * Create a pull request
112
+ * @see REQ-CG-PR-005
113
+ */
114
+ createPullRequest(options: CreatePROptions): Promise<PRInfo>;
115
+ /**
116
+ * Create PR using GitHub API
117
+ */
118
+ private createPRWithApi;
119
+ /**
120
+ * Create PR using gh CLI
121
+ */
122
+ private createPRWithGhCli;
123
+ /**
124
+ * Get PR information
125
+ */
126
+ getPullRequest(prNumber: number): Promise<PRInfo>;
127
+ /**
128
+ * Get PR using API
129
+ */
130
+ private getPRWithApi;
131
+ /**
132
+ * Get PR using gh CLI
133
+ */
134
+ private getPRWithGhCli;
135
+ /**
136
+ * Add labels to PR
137
+ */
138
+ addLabels(prNumber: number, labels: string[]): Promise<void>;
139
+ /**
140
+ * Add reviewers to PR
141
+ */
142
+ addReviewers(prNumber: number, reviewers: string[]): Promise<void>;
143
+ /**
144
+ * Add assignees to PR
145
+ */
146
+ addAssignees(prNumber: number, assignees: string[]): Promise<void>;
147
+ /**
148
+ * Get repository information
149
+ */
150
+ getRepository(): Promise<{
151
+ defaultBranch: string;
152
+ private: boolean;
153
+ }>;
154
+ /**
155
+ * Ensure authenticated before operations
156
+ */
157
+ private ensureAuthenticated;
158
+ }
159
+ /**
160
+ * Create a GitHubAdapter instance
161
+ */
162
+ export declare function createGitHubAdapter(owner: string, repo: string, token?: string): GitHubAdapter;
163
+ //# sourceMappingURL=github-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-adapter.d.ts","sourceRoot":"","sources":["../../src/pr/github-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACP,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe;IACf,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,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G;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAEf"}
@@ -0,0 +1,467 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - GitHub Adapter
3
+ *
4
+ * GitHub API integration using Octokit or gh CLI fallback
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/musubix-codegraph/pr
8
+ *
9
+ * @see REQ-CG-PR-001 - GitHub Authentication
10
+ * @see REQ-CG-PR-005 - GitHub PR Creation
11
+ * @see DES-CG-PR-004 - Class Design
12
+ */
13
+ import { execSync } from 'node:child_process';
14
+ /**
15
+ * GitHub Adapter
16
+ *
17
+ * Provides a unified interface for GitHub operations.
18
+ * Supports both direct API access (via GITHUB_TOKEN) and gh CLI fallback.
19
+ *
20
+ * @see DES-CG-PR-004
21
+ * @example
22
+ * ```typescript
23
+ * const github = new GitHubAdapter({ owner: 'user', repo: 'project' });
24
+ * await github.authenticate();
25
+ * const pr = await github.createPullRequest({
26
+ * title: 'refactor: extract interface',
27
+ * body: '...',
28
+ * head: 'refactor/extract-interface',
29
+ * base: 'main'
30
+ * });
31
+ * ```
32
+ */
33
+ export class GitHubAdapter {
34
+ config;
35
+ authMethod = 'none';
36
+ authenticated = false;
37
+ username;
38
+ /**
39
+ * Create a new GitHubAdapter
40
+ * @param config - GitHub configuration
41
+ */
42
+ constructor(config) {
43
+ this.config = {
44
+ ...config,
45
+ baseUrl: config.baseUrl ?? 'https://api.github.com',
46
+ };
47
+ }
48
+ // ============================================================================
49
+ // Authentication
50
+ // ============================================================================
51
+ /**
52
+ * Authenticate with GitHub
53
+ * @see REQ-CG-PR-001
54
+ */
55
+ async authenticate() {
56
+ // Try environment variable token first
57
+ const envToken = process.env.GITHUB_TOKEN;
58
+ if (envToken || this.config.token) {
59
+ const token = this.config.token ?? envToken;
60
+ try {
61
+ const result = await this.validateToken(token);
62
+ if (result.authenticated) {
63
+ this.authMethod = 'token';
64
+ this.authenticated = true;
65
+ this.username = result.username;
66
+ return result;
67
+ }
68
+ }
69
+ catch {
70
+ // Token validation failed, try gh CLI
71
+ }
72
+ }
73
+ // Try gh CLI
74
+ if (this.isGhCliAvailable()) {
75
+ try {
76
+ const result = await this.authenticateWithGhCli();
77
+ if (result.authenticated) {
78
+ this.authMethod = 'gh-cli';
79
+ this.authenticated = true;
80
+ this.username = result.username;
81
+ return result;
82
+ }
83
+ }
84
+ catch {
85
+ // gh CLI auth failed
86
+ }
87
+ }
88
+ return {
89
+ authenticated: false,
90
+ method: 'none',
91
+ error: 'No valid authentication method found. Set GITHUB_TOKEN or authenticate with gh CLI.',
92
+ };
93
+ }
94
+ /**
95
+ * Check if authenticated
96
+ */
97
+ isAuthenticated() {
98
+ return this.authenticated;
99
+ }
100
+ /**
101
+ * Get authentication method
102
+ */
103
+ getAuthMethod() {
104
+ return this.authMethod;
105
+ }
106
+ /**
107
+ * Get authenticated username
108
+ */
109
+ getUsername() {
110
+ return this.username;
111
+ }
112
+ /**
113
+ * Validate a GitHub token
114
+ */
115
+ async validateToken(token) {
116
+ try {
117
+ const response = await fetch(`${this.config.baseUrl}/user`, {
118
+ headers: {
119
+ Authorization: `Bearer ${token}`,
120
+ Accept: 'application/vnd.github+json',
121
+ 'X-GitHub-Api-Version': '2022-11-28',
122
+ },
123
+ });
124
+ if (!response.ok) {
125
+ return {
126
+ authenticated: false,
127
+ method: 'token',
128
+ error: `Token validation failed: ${response.status} ${response.statusText}`,
129
+ };
130
+ }
131
+ const user = await response.json();
132
+ return {
133
+ authenticated: true,
134
+ method: 'token',
135
+ username: user.login,
136
+ };
137
+ }
138
+ catch (error) {
139
+ return {
140
+ authenticated: false,
141
+ method: 'token',
142
+ error: `Token validation error: ${error instanceof Error ? error.message : String(error)}`,
143
+ };
144
+ }
145
+ }
146
+ /**
147
+ * Check if gh CLI is available
148
+ */
149
+ isGhCliAvailable() {
150
+ try {
151
+ execSync('gh --version', { stdio: 'pipe' });
152
+ return true;
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ }
158
+ /**
159
+ * Authenticate using gh CLI
160
+ */
161
+ async authenticateWithGhCli() {
162
+ try {
163
+ // Check auth status
164
+ execSync('gh auth status', {
165
+ encoding: 'utf-8',
166
+ stdio: ['pipe', 'pipe', 'pipe'],
167
+ });
168
+ // Get username
169
+ const username = execSync('gh api user --jq .login', {
170
+ encoding: 'utf-8',
171
+ stdio: ['pipe', 'pipe', 'pipe'],
172
+ }).trim();
173
+ return {
174
+ authenticated: true,
175
+ method: 'gh-cli',
176
+ username,
177
+ };
178
+ }
179
+ catch (error) {
180
+ return {
181
+ authenticated: false,
182
+ method: 'gh-cli',
183
+ error: `gh CLI authentication failed: ${error instanceof Error ? error.message : String(error)}`,
184
+ };
185
+ }
186
+ }
187
+ // ============================================================================
188
+ // Pull Request Operations
189
+ // ============================================================================
190
+ /**
191
+ * Create a pull request
192
+ * @see REQ-CG-PR-005
193
+ */
194
+ async createPullRequest(options) {
195
+ this.ensureAuthenticated();
196
+ if (this.authMethod === 'gh-cli') {
197
+ return this.createPRWithGhCli(options);
198
+ }
199
+ return this.createPRWithApi(options);
200
+ }
201
+ /**
202
+ * Create PR using GitHub API
203
+ */
204
+ async createPRWithApi(options) {
205
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
206
+ if (!token) {
207
+ throw new Error('No GitHub token available');
208
+ }
209
+ const response = await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}/pulls`, {
210
+ method: 'POST',
211
+ headers: {
212
+ Authorization: `Bearer ${token}`,
213
+ Accept: 'application/vnd.github+json',
214
+ 'X-GitHub-Api-Version': '2022-11-28',
215
+ 'Content-Type': 'application/json',
216
+ },
217
+ body: JSON.stringify({
218
+ title: options.title,
219
+ body: options.body,
220
+ head: options.head,
221
+ base: options.base,
222
+ draft: options.draft ?? false,
223
+ maintainer_can_modify: options.maintainerCanModify ?? true,
224
+ }),
225
+ });
226
+ if (!response.ok) {
227
+ const error = await response.json();
228
+ throw new Error(`Failed to create PR: ${response.status} ${error.message}`);
229
+ }
230
+ const pr = await response.json();
231
+ return {
232
+ number: pr.number,
233
+ url: pr.html_url,
234
+ title: pr.title,
235
+ state: pr.state,
236
+ head: pr.head.ref,
237
+ base: pr.base.ref,
238
+ createdAt: new Date(pr.created_at),
239
+ };
240
+ }
241
+ /**
242
+ * Create PR using gh CLI
243
+ */
244
+ createPRWithGhCli(options) {
245
+ const args = [
246
+ 'pr', 'create',
247
+ '--repo', `${this.config.owner}/${this.config.repo}`,
248
+ '--title', options.title,
249
+ '--body', options.body,
250
+ '--head', options.head,
251
+ '--base', options.base,
252
+ ];
253
+ if (options.draft) {
254
+ args.push('--draft');
255
+ }
256
+ try {
257
+ const output = execSync(`gh ${args.join(' ')}`, {
258
+ encoding: 'utf-8',
259
+ stdio: ['pipe', 'pipe', 'pipe'],
260
+ }).trim();
261
+ // Parse PR URL from output
262
+ const urlMatch = output.match(/https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)/);
263
+ if (!urlMatch) {
264
+ throw new Error(`Failed to parse PR URL from gh output: ${output}`);
265
+ }
266
+ const prNumber = parseInt(urlMatch[1], 10);
267
+ return {
268
+ number: prNumber,
269
+ url: output,
270
+ title: options.title,
271
+ state: 'open',
272
+ head: options.head,
273
+ base: options.base,
274
+ createdAt: new Date(),
275
+ };
276
+ }
277
+ catch (error) {
278
+ throw new Error(`gh CLI PR creation failed: ${error instanceof Error ? error.message : String(error)}`);
279
+ }
280
+ }
281
+ /**
282
+ * Get PR information
283
+ */
284
+ async getPullRequest(prNumber) {
285
+ this.ensureAuthenticated();
286
+ if (this.authMethod === 'gh-cli') {
287
+ return this.getPRWithGhCli(prNumber);
288
+ }
289
+ return this.getPRWithApi(prNumber);
290
+ }
291
+ /**
292
+ * Get PR using API
293
+ */
294
+ async getPRWithApi(prNumber) {
295
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
296
+ if (!token) {
297
+ throw new Error('No GitHub token available');
298
+ }
299
+ const response = await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}/pulls/${prNumber}`, {
300
+ headers: {
301
+ Authorization: `Bearer ${token}`,
302
+ Accept: 'application/vnd.github+json',
303
+ 'X-GitHub-Api-Version': '2022-11-28',
304
+ },
305
+ });
306
+ if (!response.ok) {
307
+ throw new Error(`Failed to get PR: ${response.status}`);
308
+ }
309
+ const pr = await response.json();
310
+ return {
311
+ number: pr.number,
312
+ url: pr.html_url,
313
+ title: pr.title,
314
+ state: pr.merged ? 'merged' : pr.state,
315
+ head: pr.head.ref,
316
+ base: pr.base.ref,
317
+ createdAt: new Date(pr.created_at),
318
+ };
319
+ }
320
+ /**
321
+ * Get PR using gh CLI
322
+ */
323
+ getPRWithGhCli(prNumber) {
324
+ try {
325
+ const output = execSync(`gh pr view ${prNumber} --repo ${this.config.owner}/${this.config.repo} --json number,url,title,state,headRefName,baseRefName,createdAt`, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
326
+ const pr = JSON.parse(output);
327
+ return {
328
+ number: pr.number,
329
+ url: pr.url,
330
+ title: pr.title,
331
+ state: pr.state.toLowerCase(),
332
+ head: pr.headRefName,
333
+ base: pr.baseRefName,
334
+ createdAt: new Date(pr.createdAt),
335
+ };
336
+ }
337
+ catch (error) {
338
+ throw new Error(`Failed to get PR: ${error instanceof Error ? error.message : String(error)}`);
339
+ }
340
+ }
341
+ /**
342
+ * Add labels to PR
343
+ */
344
+ async addLabels(prNumber, labels) {
345
+ this.ensureAuthenticated();
346
+ if (this.authMethod === 'gh-cli') {
347
+ execSync(`gh pr edit ${prNumber} --repo ${this.config.owner}/${this.config.repo} --add-label "${labels.join(',')}"`, { stdio: 'pipe' });
348
+ return;
349
+ }
350
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
351
+ if (!token) {
352
+ throw new Error('No GitHub token available');
353
+ }
354
+ await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}/issues/${prNumber}/labels`, {
355
+ method: 'POST',
356
+ headers: {
357
+ Authorization: `Bearer ${token}`,
358
+ Accept: 'application/vnd.github+json',
359
+ 'X-GitHub-Api-Version': '2022-11-28',
360
+ 'Content-Type': 'application/json',
361
+ },
362
+ body: JSON.stringify({ labels }),
363
+ });
364
+ }
365
+ /**
366
+ * Add reviewers to PR
367
+ */
368
+ async addReviewers(prNumber, reviewers) {
369
+ this.ensureAuthenticated();
370
+ if (this.authMethod === 'gh-cli') {
371
+ execSync(`gh pr edit ${prNumber} --repo ${this.config.owner}/${this.config.repo} --add-reviewer "${reviewers.join(',')}"`, { stdio: 'pipe' });
372
+ return;
373
+ }
374
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
375
+ if (!token) {
376
+ throw new Error('No GitHub token available');
377
+ }
378
+ await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}/pulls/${prNumber}/requested_reviewers`, {
379
+ method: 'POST',
380
+ headers: {
381
+ Authorization: `Bearer ${token}`,
382
+ Accept: 'application/vnd.github+json',
383
+ 'X-GitHub-Api-Version': '2022-11-28',
384
+ 'Content-Type': 'application/json',
385
+ },
386
+ body: JSON.stringify({ reviewers }),
387
+ });
388
+ }
389
+ /**
390
+ * Add assignees to PR
391
+ */
392
+ async addAssignees(prNumber, assignees) {
393
+ this.ensureAuthenticated();
394
+ if (this.authMethod === 'gh-cli') {
395
+ execSync(`gh pr edit ${prNumber} --repo ${this.config.owner}/${this.config.repo} --add-assignee "${assignees.join(',')}"`, { stdio: 'pipe' });
396
+ return;
397
+ }
398
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
399
+ if (!token) {
400
+ throw new Error('No GitHub token available');
401
+ }
402
+ await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}/issues/${prNumber}/assignees`, {
403
+ method: 'POST',
404
+ headers: {
405
+ Authorization: `Bearer ${token}`,
406
+ Accept: 'application/vnd.github+json',
407
+ 'X-GitHub-Api-Version': '2022-11-28',
408
+ 'Content-Type': 'application/json',
409
+ },
410
+ body: JSON.stringify({ assignees }),
411
+ });
412
+ }
413
+ // ============================================================================
414
+ // Repository Information
415
+ // ============================================================================
416
+ /**
417
+ * Get repository information
418
+ */
419
+ async getRepository() {
420
+ this.ensureAuthenticated();
421
+ if (this.authMethod === 'gh-cli') {
422
+ const output = execSync(`gh repo view ${this.config.owner}/${this.config.repo} --json defaultBranchRef,isPrivate`, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
423
+ const repo = JSON.parse(output);
424
+ return {
425
+ defaultBranch: repo.defaultBranchRef.name,
426
+ private: repo.isPrivate,
427
+ };
428
+ }
429
+ const token = this.config.token ?? process.env.GITHUB_TOKEN;
430
+ if (!token) {
431
+ throw new Error('No GitHub token available');
432
+ }
433
+ const response = await fetch(`${this.config.baseUrl}/repos/${this.config.owner}/${this.config.repo}`, {
434
+ headers: {
435
+ Authorization: `Bearer ${token}`,
436
+ Accept: 'application/vnd.github+json',
437
+ 'X-GitHub-Api-Version': '2022-11-28',
438
+ },
439
+ });
440
+ if (!response.ok) {
441
+ throw new Error(`Failed to get repository: ${response.status}`);
442
+ }
443
+ const repo = await response.json();
444
+ return {
445
+ defaultBranch: repo.default_branch,
446
+ private: repo.private,
447
+ };
448
+ }
449
+ // ============================================================================
450
+ // Private Helpers
451
+ // ============================================================================
452
+ /**
453
+ * Ensure authenticated before operations
454
+ */
455
+ ensureAuthenticated() {
456
+ if (!this.authenticated) {
457
+ throw new Error('Not authenticated. Call authenticate() first.');
458
+ }
459
+ }
460
+ }
461
+ /**
462
+ * Create a GitHubAdapter instance
463
+ */
464
+ export function createGitHubAdapter(owner, repo, token) {
465
+ return new GitHubAdapter({ owner, repo, token });
466
+ }
467
+ //# sourceMappingURL=github-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-adapter.js","sourceRoot":"","sources":["../../src/pr/github-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,E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EAG/B,CAAC;QAEF,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,cAAc;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,+EAA+E;IAC/E,kBAAkB;IAClB,+EAA+E;IAE/E;;OAEG;IACK,mBAAmB;QACzB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,IAAY,EACZ,KAAc;IAEd,OAAO,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph/pr - PR Creation Module
3
+ *
4
+ * Automatic PR generation from refactoring suggestions
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/musubix-codegraph/pr
8
+ *
9
+ * @see REQ-CG-PR-001 - REQ-CG-PR-009
10
+ * @see DES-CG-PR-001 - DES-CG-PR-006
11
+ */
12
+ export { PRCreator, createPRCreator, createRefactoringPR, type PRCreatorConfig, type PRCreatorState, } from './pr-creator.js';
13
+ export { PRCreatorError, PRErrorMessages, type PRErrorCode, } from './errors.js';
14
+ export { GitOperations, createGitOperations, } from './git-operations.js';
15
+ export { GitHubAdapter, createGitHubAdapter, type CreatePROptions, type UpdatePROptions, type PRLabel, } from './github-adapter.js';
16
+ export { RefactoringApplier, createRefactoringApplier, type ApplyChangeResult, type ApplyResult, type ApplyOptions, } from './refactoring-applier.js';
17
+ export { PRTemplateGenerator, createPRTemplateGenerator, generateSimplePRBody, generatePRTitle, type PRTemplateOptions, } from './pr-template.js';
18
+ export type { RefactoringType, RefactoringSeverity, CodeChange, RefactoringSuggestion, BranchInfo, CommitInfo, GitOperationOptions, GitHubConfig, GitHubAuthMethod, GitHubAuthResult, PRInfo, PRCreateOptions, PRCreateResult, PRPreview, FileDiff, BatchRefactoringOptions, BatchRefactoringResult, PRCreatorEvents, ConventionalCommitType, } from './types.js';
19
+ export { REFACTORING_TO_COMMIT_TYPE, generateBranchName, generateCommitMessage, } from './types.js';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,cAAc,EACd,eAAe,EACf,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAEV,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,qBAAqB,EAGrB,UAAU,EACV,UAAU,EACV,mBAAmB,EAGnB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EAGN,eAAe,EACf,cAAc,EACd,SAAS,EACT,QAAQ,EAGR,uBAAuB,EACvB,sBAAsB,EAGtB,eAAe,EAGf,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}