@nahisaho/musubix-codegraph 2.3.2 → 2.3.3

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,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,EA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AG/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,19 @@
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, } from './pr-creator.js';
13
+ export { GitOperations, createGitOperations, } from './git-operations.js';
14
+ export { GitHubAdapter, createGitHubAdapter, type CreatePROptions, type UpdatePROptions, type PRLabel, } from './github-adapter.js';
15
+ export { RefactoringApplier, createRefactoringApplier, type ApplyChangeResult, type ApplyResult, type ApplyOptions, } from './refactoring-applier.js';
16
+ export { PRTemplateGenerator, createPRTemplateGenerator, generateSimplePRBody, generatePRTitle, type PRTemplateOptions, } from './pr-template.js';
17
+ export type { RefactoringType, RefactoringSeverity, CodeChange, RefactoringSuggestion, BranchInfo, CommitInfo, GitOperationOptions, GitHubConfig, GitHubAuthMethod, GitHubAuthResult, PRInfo, PRCreateOptions, PRCreateResult, PRPreview, FileDiff, BatchRefactoringOptions, BatchRefactoringResult, PRCreatorEvents, ConventionalCommitType, } from './types.js';
18
+ export { REFACTORING_TO_COMMIT_TYPE, generateBranchName, generateCommitMessage, } from './types.js';
19
+ //# 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,GACrB,MAAM,iBAAiB,CAAC;AAGzB,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"}
@@ -0,0 +1,24 @@
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
+ // Main PR Creator
13
+ export { PRCreator, createPRCreator, createRefactoringPR, } from './pr-creator.js';
14
+ // Git Operations
15
+ export { GitOperations, createGitOperations, } from './git-operations.js';
16
+ // GitHub Adapter
17
+ export { GitHubAdapter, createGitHubAdapter, } from './github-adapter.js';
18
+ // Refactoring Applier
19
+ export { RefactoringApplier, createRefactoringApplier, } from './refactoring-applier.js';
20
+ // PR Template Generator
21
+ export { PRTemplateGenerator, createPRTemplateGenerator, generateSimplePRBody, generatePRTitle, } from './pr-template.js';
22
+ // Utility Functions
23
+ export { REFACTORING_TO_COMMIT_TYPE, generateBranchName, generateCommitMessage, } from './types.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,kBAAkB;AAClB,OAAO,EACL,SAAS,EACT,eAAe,EACf,mBAAmB,GAEpB,MAAM,iBAAiB,CAAC;AAEzB,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAE7B,sBAAsB;AACtB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAIzB,MAAM,0BAA0B,CAAC;AAElC,wBAAwB;AACxB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAEhB,MAAM,kBAAkB,CAAC;AAsC1B,oBAAoB;AACpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - PR Creator
3
+ *
4
+ * Main orchestrator for creating PRs from refactoring suggestions
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/musubix-codegraph/pr
8
+ *
9
+ * @see REQ-CG-PR-001 - GitHub Authentication
10
+ * @see REQ-CG-PR-002 - Auto Apply Refactoring
11
+ * @see REQ-CG-PR-003 - Git Branch Creation
12
+ * @see REQ-CG-PR-004 - Auto Commit
13
+ * @see REQ-CG-PR-005 - GitHub PR Creation
14
+ * @see DES-CG-PR-001 - Component Design
15
+ * @see DES-CG-PR-005 - Sequence Diagram
16
+ */
17
+ import { EventEmitter } from 'node:events';
18
+ import type { RefactoringSuggestion, PRCreateOptions, PRCreateResult, PRPreview, PRCreatorEvents } from './types.js';
19
+ /**
20
+ * PR Creator configuration
21
+ */
22
+ export interface PRCreatorConfig {
23
+ /** Repository root path */
24
+ repoPath: string;
25
+ /** GitHub token (optional, will try env or gh CLI) */
26
+ githubToken?: string;
27
+ /** Remote name (default: origin) */
28
+ remote?: string;
29
+ /** Create backups before modifications */
30
+ createBackups?: boolean;
31
+ }
32
+ /**
33
+ * PR Creator
34
+ *
35
+ * Orchestrates the entire PR creation workflow:
36
+ * 1. Authenticate with GitHub
37
+ * 2. Create a new branch
38
+ * 3. Apply refactoring changes
39
+ * 4. Commit changes
40
+ * 5. Push to remote
41
+ * 6. Create PR on GitHub
42
+ *
43
+ * @see DES-CG-PR-001
44
+ * @see DES-CG-PR-005
45
+ * @example
46
+ * ```typescript
47
+ * const creator = new PRCreator({ repoPath: '/path/to/repo' });
48
+ * await creator.initialize();
49
+ *
50
+ * const result = await creator.create({
51
+ * suggestion: refactoringSuggestion,
52
+ * baseBranch: 'main',
53
+ * labels: ['refactoring', 'auto-generated'],
54
+ * });
55
+ *
56
+ * console.log(`PR created: ${result.pr?.url}`);
57
+ * ```
58
+ */
59
+ export declare class PRCreator extends EventEmitter {
60
+ private readonly config;
61
+ private git;
62
+ private github;
63
+ private applier;
64
+ private templateGenerator;
65
+ private initialized;
66
+ private originalBranch;
67
+ /**
68
+ * Create a new PRCreator
69
+ * @param config - Configuration options
70
+ */
71
+ constructor(config: PRCreatorConfig);
72
+ /**
73
+ * Initialize the PR creator
74
+ * Sets up Git operations and authenticates with GitHub
75
+ */
76
+ initialize(): Promise<{
77
+ success: boolean;
78
+ error?: string;
79
+ }>;
80
+ /**
81
+ * Check if initialized
82
+ */
83
+ isInitialized(): boolean;
84
+ /**
85
+ * Create a PR from a refactoring suggestion
86
+ * @see REQ-CG-PR-002, REQ-CG-PR-003, REQ-CG-PR-004, REQ-CG-PR-005
87
+ */
88
+ create(options: PRCreateOptions): Promise<PRCreateResult>;
89
+ /**
90
+ * Preview PR creation without actually creating
91
+ * @see REQ-CG-PR-007
92
+ */
93
+ preview(options: PRCreateOptions): Promise<PRPreview>;
94
+ /**
95
+ * Validate a suggestion can be applied
96
+ */
97
+ validate(suggestion: RefactoringSuggestion): {
98
+ valid: boolean;
99
+ reason?: string;
100
+ };
101
+ /**
102
+ * Dry run implementation
103
+ */
104
+ private dryRun;
105
+ /**
106
+ * Ensure initialized before operations
107
+ */
108
+ private ensureInitialized;
109
+ /**
110
+ * Typed event emitter methods
111
+ */
112
+ emit<K extends keyof PRCreatorEvents>(event: K, data: PRCreatorEvents[K]): boolean;
113
+ on<K extends keyof PRCreatorEvents>(event: K, listener: (data: PRCreatorEvents[K]) => void): this;
114
+ once<K extends keyof PRCreatorEvents>(event: K, listener: (data: PRCreatorEvents[K]) => void): this;
115
+ }
116
+ /**
117
+ * Create a PRCreator instance
118
+ */
119
+ export declare function createPRCreator(repoPath: string, options?: Partial<PRCreatorConfig>): PRCreator;
120
+ /**
121
+ * Quick PR creation helper
122
+ *
123
+ * One-shot function to create a PR from a suggestion.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const result = await createRefactoringPR(
128
+ * '/path/to/repo',
129
+ * suggestion,
130
+ * { labels: ['refactoring'] }
131
+ * );
132
+ * ```
133
+ */
134
+ export declare function createRefactoringPR(repoPath: string, suggestion: RefactoringSuggestion, options?: Partial<PRCreateOptions>): Promise<PRCreateResult>;
135
+ //# sourceMappingURL=pr-creator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-creator.d.ts","sourceRoot":"","sources":["../../src/pr/pr-creator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,SAAS,EACT,eAAe,EAChB,MAAM,YAAY,CAAC;AAMpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,SAAU,SAAQ,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAuB;IAE7C;;;OAGG;gBACS,MAAM,EAAE,eAAe;IAcnC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAoDjE;;OAEG;IACH,aAAa,IAAI,OAAO;IAQxB;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IA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