@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,362 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - PR Creation Type Definitions
3
+ *
4
+ * Types for automatic refactoring PR generation
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 DES-CG-PR-003 - Type Definitions
12
+ */
13
+ /**
14
+ * Types of refactoring operations
15
+ * @see REQ-CG-PR-002
16
+ */
17
+ export type RefactoringType = 'extract_interface' | 'extract_method' | 'extract_class' | 'inline' | 'rename' | 'move' | 'security_fix' | 'performance' | 'simplify';
18
+ /**
19
+ * Severity levels for refactoring suggestions
20
+ */
21
+ export type RefactoringSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
22
+ /**
23
+ * A single code change within a file
24
+ * @see DES-CG-PR-003
25
+ */
26
+ export interface CodeChange {
27
+ /** File path relative to repository root */
28
+ filePath: string;
29
+ /** Starting line number (1-based) */
30
+ startLine: number;
31
+ /** Ending line number (1-based, inclusive) */
32
+ endLine: number;
33
+ /** Starting column (0-based) */
34
+ startColumn?: number;
35
+ /** Ending column (0-based) */
36
+ endColumn?: number;
37
+ /** Original code to be replaced */
38
+ originalCode: string;
39
+ /** New code after refactoring */
40
+ newCode: string;
41
+ /** Description of the change */
42
+ description: string;
43
+ }
44
+ /**
45
+ * Refactoring suggestion from CodeGraph analysis
46
+ * @see REQ-CG-PR-002
47
+ * @see DES-CG-PR-003
48
+ */
49
+ export interface RefactoringSuggestion {
50
+ /** Unique identifier for the suggestion */
51
+ id: string;
52
+ /** Entity ID that this suggestion targets */
53
+ entityId: string;
54
+ /** Type of refactoring */
55
+ type: RefactoringType;
56
+ /** Human-readable title */
57
+ title: string;
58
+ /** Detailed description of the refactoring */
59
+ description: string;
60
+ /** Reason why this refactoring is suggested */
61
+ reason: string;
62
+ /** Severity/priority of the suggestion */
63
+ severity: RefactoringSeverity;
64
+ /** List of code changes to apply */
65
+ changes: CodeChange[];
66
+ /** Estimated impact (files affected) */
67
+ impact: {
68
+ filesAffected: number;
69
+ linesChanged: number;
70
+ dependencies: string[];
71
+ };
72
+ /** Related CWE if security-related */
73
+ cwe?: string;
74
+ /** Confidence score (0-1) */
75
+ confidence: number;
76
+ /** Timestamp when suggestion was generated */
77
+ createdAt: Date;
78
+ }
79
+ /**
80
+ * Git branch information
81
+ */
82
+ export interface BranchInfo {
83
+ /** Branch name */
84
+ name: string;
85
+ /** Whether this is the current branch */
86
+ current: boolean;
87
+ /** Remote tracking branch if any */
88
+ tracking?: string;
89
+ /** Latest commit hash */
90
+ commit: string;
91
+ }
92
+ /**
93
+ * Git commit information
94
+ */
95
+ export interface CommitInfo {
96
+ /** Commit hash */
97
+ hash: string;
98
+ /** Commit message */
99
+ message: string;
100
+ /** Author name */
101
+ author: string;
102
+ /** Author email */
103
+ email: string;
104
+ /** Commit date */
105
+ date: Date;
106
+ }
107
+ /**
108
+ * Options for Git operations
109
+ * @see REQ-CG-PR-003
110
+ */
111
+ export interface GitOperationOptions {
112
+ /** Repository root path */
113
+ repoPath: string;
114
+ /** Base branch to create from (default: current branch) */
115
+ baseBranch?: string;
116
+ /** Remote name (default: 'origin') */
117
+ remote?: string;
118
+ /** Whether to force push */
119
+ force?: boolean;
120
+ }
121
+ /**
122
+ * GitHub authentication configuration
123
+ * @see REQ-CG-PR-001
124
+ * @see DES-CG-PR-003
125
+ */
126
+ export interface GitHubConfig {
127
+ /** GitHub Personal Access Token */
128
+ token?: string;
129
+ /** Repository owner (user or organization) */
130
+ owner: string;
131
+ /** Repository name */
132
+ repo: string;
133
+ /** GitHub API base URL (for GitHub Enterprise) */
134
+ baseUrl?: string;
135
+ }
136
+ /**
137
+ * GitHub authentication method
138
+ */
139
+ export type GitHubAuthMethod = 'token' | 'gh-cli' | 'none';
140
+ /**
141
+ * GitHub authentication result
142
+ */
143
+ export interface GitHubAuthResult {
144
+ /** Whether authentication succeeded */
145
+ authenticated: boolean;
146
+ /** Authentication method used */
147
+ method: GitHubAuthMethod;
148
+ /** Authenticated username */
149
+ username?: string;
150
+ /** Error message if authentication failed */
151
+ error?: string;
152
+ }
153
+ /**
154
+ * Pull Request creation result
155
+ * @see REQ-CG-PR-005
156
+ */
157
+ export interface PRInfo {
158
+ /** PR number */
159
+ number: number;
160
+ /** PR URL */
161
+ url: string;
162
+ /** PR title */
163
+ title: string;
164
+ /** PR state */
165
+ state: 'open' | 'closed' | 'merged';
166
+ /** Head branch */
167
+ head: string;
168
+ /** Base branch */
169
+ base: string;
170
+ /** Created timestamp */
171
+ createdAt: Date;
172
+ }
173
+ /**
174
+ * Options for PR creation
175
+ * @see REQ-CG-PR-005
176
+ * @see REQ-CG-PR-007
177
+ * @see DES-CG-PR-003
178
+ */
179
+ export interface PRCreateOptions {
180
+ /** Refactoring suggestion to apply */
181
+ suggestion: RefactoringSuggestion;
182
+ /** Custom branch name (default: auto-generated) */
183
+ branchName?: string;
184
+ /** Custom PR title (default: from suggestion) */
185
+ title?: string;
186
+ /** Custom PR body (default: auto-generated) */
187
+ body?: string;
188
+ /** Base branch for PR (default: main/master) */
189
+ baseBranch?: string;
190
+ /** Labels to add to PR */
191
+ labels?: string[];
192
+ /** Assignees for PR */
193
+ assignees?: string[];
194
+ /** Reviewers for PR */
195
+ reviewers?: string[];
196
+ /** Whether to create as draft PR */
197
+ draft?: boolean;
198
+ /** Dry run mode - preview without creating */
199
+ dryRun?: boolean;
200
+ /** Auto-merge settings */
201
+ autoMerge?: {
202
+ enabled: boolean;
203
+ method: 'merge' | 'squash' | 'rebase';
204
+ };
205
+ }
206
+ /**
207
+ * Result of PR creation operation
208
+ * @see DES-CG-PR-003
209
+ */
210
+ export interface PRCreateResult {
211
+ /** Whether operation succeeded */
212
+ success: boolean;
213
+ /** Created PR info (if not dry run) */
214
+ pr?: PRInfo;
215
+ /** Branch name created */
216
+ branchName: string;
217
+ /** Commit hash */
218
+ commitHash?: string;
219
+ /** Files changed */
220
+ filesChanged: string[];
221
+ /** Lines added */
222
+ linesAdded: number;
223
+ /** Lines deleted */
224
+ linesDeleted: number;
225
+ /** Preview of changes (for dry run) */
226
+ preview?: PRPreview;
227
+ /** Error message if failed */
228
+ error?: string;
229
+ /** Warnings during operation */
230
+ warnings?: string[];
231
+ }
232
+ /**
233
+ * Preview of PR changes (for dry run mode)
234
+ * @see REQ-CG-PR-007
235
+ */
236
+ export interface PRPreview {
237
+ /** Branch that would be created */
238
+ branchName: string;
239
+ /** Base branch for the PR */
240
+ baseBranch: string;
241
+ /** PR title */
242
+ title: string;
243
+ /** PR body (Markdown) */
244
+ body: string;
245
+ /** File diffs */
246
+ diffs: FileDiff[];
247
+ /** Commit message */
248
+ commitMessage: string;
249
+ }
250
+ /**
251
+ * Diff for a single file
252
+ */
253
+ export interface FileDiff {
254
+ /** File path */
255
+ filePath: string;
256
+ /** Type of change */
257
+ changeType: 'added' | 'modified' | 'deleted';
258
+ /** Unified diff content */
259
+ diff: string;
260
+ /** Lines added */
261
+ additions: number;
262
+ /** Lines deleted */
263
+ deletions: number;
264
+ }
265
+ /**
266
+ * Options for batch refactoring
267
+ * @see REQ-CG-PR-008
268
+ */
269
+ export interface BatchRefactoringOptions {
270
+ /** Multiple suggestions to apply */
271
+ suggestions: RefactoringSuggestion[];
272
+ /** Strategy for handling multiple suggestions */
273
+ strategy: 'single-pr' | 'multiple-prs' | 'grouped';
274
+ /** Grouping criteria (for 'grouped' strategy) */
275
+ groupBy?: 'type' | 'file' | 'severity';
276
+ /** Base branch */
277
+ baseBranch?: string;
278
+ /** Common labels for all PRs */
279
+ labels?: string[];
280
+ /** Dry run mode */
281
+ dryRun?: boolean;
282
+ }
283
+ /**
284
+ * Result of batch refactoring operation
285
+ */
286
+ export interface BatchRefactoringResult {
287
+ /** Overall success status */
288
+ success: boolean;
289
+ /** Total suggestions processed */
290
+ totalSuggestions: number;
291
+ /** Successfully applied suggestions */
292
+ appliedSuggestions: number;
293
+ /** Failed suggestions */
294
+ failedSuggestions: number;
295
+ /** PRs created */
296
+ prs: PRCreateResult[];
297
+ /** Errors encountered */
298
+ errors: Array<{
299
+ suggestionId: string;
300
+ error: string;
301
+ }>;
302
+ }
303
+ /**
304
+ * Events emitted during PR creation
305
+ */
306
+ export interface PRCreatorEvents {
307
+ /** Emitted when starting PR creation */
308
+ 'pr:start': {
309
+ suggestion: RefactoringSuggestion;
310
+ };
311
+ /** Emitted when applying changes */
312
+ 'pr:applying': {
313
+ file: string;
314
+ changes: number;
315
+ };
316
+ /** Emitted when creating branch */
317
+ 'pr:branch': {
318
+ name: string;
319
+ };
320
+ /** Emitted when committing */
321
+ 'pr:commit': {
322
+ hash: string;
323
+ message: string;
324
+ };
325
+ /** Emitted when pushing */
326
+ 'pr:push': {
327
+ branch: string;
328
+ remote: string;
329
+ };
330
+ /** Emitted when PR is created */
331
+ 'pr:created': {
332
+ pr: PRInfo;
333
+ };
334
+ /** Emitted on completion */
335
+ 'pr:complete': {
336
+ result: PRCreateResult;
337
+ };
338
+ /** Emitted on error */
339
+ 'pr:error': {
340
+ error: Error;
341
+ stage: string;
342
+ };
343
+ }
344
+ /**
345
+ * Conventional commit type
346
+ * @see REQ-CG-PR-004
347
+ */
348
+ export type ConventionalCommitType = 'feat' | 'fix' | 'refactor' | 'perf' | 'security' | 'style' | 'docs' | 'test' | 'chore';
349
+ /**
350
+ * Mapping from refactoring type to commit type
351
+ */
352
+ export declare const REFACTORING_TO_COMMIT_TYPE: Record<RefactoringType, ConventionalCommitType>;
353
+ /**
354
+ * Generate branch name from suggestion
355
+ */
356
+ export declare function generateBranchName(suggestion: RefactoringSuggestion): string;
357
+ /**
358
+ * Generate conventional commit message
359
+ * @see REQ-CG-PR-004
360
+ */
361
+ export declare function generateCommitMessage(suggestion: RefactoringSuggestion): string;
362
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pr/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,cAAc,GACd,aAAa,GACb,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAElF;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,oCAAoC;IACpC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,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,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,2BAA2B;IAC3B,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,iCAAiC;IACjC,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,4BAA4B;IAC5B,aAAa,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC;IAC1C,uBAAuB;IACvB,UAAU,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAMD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,KAAK,GACL,UAAU,GACV,MAAM,GACN,UAAU,GACV,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,CAAC;AAEZ;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAUtF,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAQ5E;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAwB/E"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - PR Creation Type Definitions
3
+ *
4
+ * Types for automatic refactoring PR generation
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 DES-CG-PR-003 - Type Definitions
12
+ */
13
+ /**
14
+ * Mapping from refactoring type to commit type
15
+ */
16
+ export const REFACTORING_TO_COMMIT_TYPE = {
17
+ extract_interface: 'refactor',
18
+ extract_method: 'refactor',
19
+ extract_class: 'refactor',
20
+ inline: 'refactor',
21
+ rename: 'refactor',
22
+ move: 'refactor',
23
+ security_fix: 'security',
24
+ performance: 'perf',
25
+ simplify: 'refactor',
26
+ };
27
+ /**
28
+ * Generate branch name from suggestion
29
+ */
30
+ export function generateBranchName(suggestion) {
31
+ const type = suggestion.type.replace(/_/g, '-');
32
+ const entity = suggestion.entityId
33
+ .replace(/[^a-zA-Z0-9]/g, '-')
34
+ .toLowerCase()
35
+ .slice(0, 30);
36
+ const timestamp = Date.now().toString(36);
37
+ return `refactor/${type}/${entity}-${timestamp}`;
38
+ }
39
+ /**
40
+ * Generate conventional commit message
41
+ * @see REQ-CG-PR-004
42
+ */
43
+ export function generateCommitMessage(suggestion) {
44
+ const commitType = REFACTORING_TO_COMMIT_TYPE[suggestion.type];
45
+ const scope = suggestion.entityId.split('.')[0] || 'core';
46
+ const subject = suggestion.title.toLowerCase().replace(/\.$/, '');
47
+ let message = `${commitType}(${scope}): ${subject}`;
48
+ // Add body with details
49
+ if (suggestion.reason) {
50
+ message += `\n\n${suggestion.reason}`;
51
+ }
52
+ // Add footer with metadata
53
+ const footers = [];
54
+ if (suggestion.cwe) {
55
+ footers.push(`Fixes: ${suggestion.cwe}`);
56
+ }
57
+ footers.push(`Suggestion-ID: ${suggestion.id}`);
58
+ if (footers.length > 0) {
59
+ message += '\n\n' + footers.join('\n');
60
+ }
61
+ return message;
62
+ }
63
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/pr/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+XH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAoD;IACzF,iBAAiB,EAAE,UAAU;IAC7B,cAAc,EAAE,UAAU;IAC1B,aAAa,EAAE,UAAU;IACzB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,UAAU;IACxB,WAAW,EAA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IAAI,CAAC,kBAAkB,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@nahisaho/musubix-codegraph",
3
- "version": "2.3.2",
4
- "description": "MUSUBIX CodeGraph - Multi-language Code Graph Analysis Engine supporting 16 programming languages",
3
+ "version": "2.3.3",
4
+ "description": "MUSUBIX CodeGraph - Multi-language Code Graph Analysis Engine supporting 16 programming languages with PR generation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "cg": "./dist/cli.js",
10
+ "musubix-codegraph": "./dist/cli.js"
11
+ },
8
12
  "exports": {
9
13
  ".": {
10
14
  "types": "./dist/index.d.ts",
@@ -25,6 +29,10 @@
25
29
  "./graphrag": {
26
30
  "types": "./dist/graphrag/index.d.ts",
27
31
  "import": "./dist/graphrag/index.js"
32
+ },
33
+ "./pr": {
34
+ "types": "./dist/pr/index.d.ts",
35
+ "import": "./dist/pr/index.js"
28
36
  }
29
37
  },
30
38
  "files": [
@@ -63,6 +71,7 @@
63
71
  "node": ">=20.0.0"
64
72
  },
65
73
  "dependencies": {
74
+ "commander": "^12.0.0",
66
75
  "tree-sitter": "^0.21.1",
67
76
  "tree-sitter-typescript": "^0.21.2",
68
77
  "tree-sitter-javascript": "^0.21.4",