@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.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @nahisaho/musubix-codegraph CLI
4
+ *
5
+ * Command-line interface for CodeGraph operations
6
+ *
7
+ * @packageDocumentation
8
+ * @module @nahisaho/musubix-codegraph/cli
9
+ *
10
+ * @see REQ-CG-PR-009 - CLI Integration
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
package/dist/cli.js ADDED
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @nahisaho/musubix-codegraph CLI
4
+ *
5
+ * Command-line interface for CodeGraph operations
6
+ *
7
+ * @packageDocumentation
8
+ * @module @nahisaho/musubix-codegraph/cli
9
+ *
10
+ * @see REQ-CG-PR-009 - CLI Integration
11
+ */
12
+ import { program } from 'commander';
13
+ import { readFileSync, existsSync } from 'node:fs';
14
+ import { resolve } from 'node:path';
15
+ // Read package.json for version
16
+ const packageJsonPath = new URL('../package.json', import.meta.url);
17
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
18
+ program
19
+ .name('cg')
20
+ .description('MUSUBIX CodeGraph - Code Graph Analysis CLI')
21
+ .version(packageJson.version);
22
+ // ============================================================================
23
+ // PR Commands
24
+ // ============================================================================
25
+ const prCommand = program
26
+ .command('pr')
27
+ .description('PR creation from refactoring suggestions');
28
+ /**
29
+ * cg pr create
30
+ */
31
+ prCommand
32
+ .command('create <suggestionFile>')
33
+ .description('Create a PR from a refactoring suggestion JSON file')
34
+ .option('-b, --branch <name>', 'Custom branch name')
35
+ .option('-t, --title <title>', 'Custom PR title')
36
+ .option('--base <branch>', 'Base branch (default: main/master)')
37
+ .option('-l, --labels <labels>', 'Comma-separated labels')
38
+ .option('-r, --reviewers <reviewers>', 'Comma-separated reviewers')
39
+ .option('-a, --assignees <assignees>', 'Comma-separated assignees')
40
+ .option('--draft', 'Create as draft PR')
41
+ .option('--dry-run', 'Preview changes without creating PR')
42
+ .option('--repo <path>', 'Repository path (default: current directory)')
43
+ .action(async (suggestionFile, options) => {
44
+ try {
45
+ const { createPRCreator } = await import('./pr/index.js');
46
+ // Read suggestion file
47
+ const filePath = resolve(suggestionFile);
48
+ if (!existsSync(filePath)) {
49
+ console.error(`❌ Suggestion file not found: ${filePath}`);
50
+ process.exit(1);
51
+ }
52
+ const suggestion = JSON.parse(readFileSync(filePath, 'utf-8'));
53
+ const repoPath = options.repo ?? process.cwd();
54
+ console.log('🚀 Initializing PR Creator...');
55
+ const creator = createPRCreator(repoPath);
56
+ // Event listeners for progress
57
+ creator.on('pr:start', () => console.log('📋 Starting PR creation...'));
58
+ creator.on('pr:branch', ({ name }) => console.log(`🌿 Creating branch: ${name}`));
59
+ creator.on('pr:applying', ({ file }) => console.log(`📝 Applying changes to: ${file}`));
60
+ creator.on('pr:commit', ({ message }) => console.log(`💾 Committing: ${message.split('\n')[0]}`));
61
+ creator.on('pr:push', ({ branch }) => console.log(`⬆️ Pushing branch: ${branch}`));
62
+ creator.on('pr:created', ({ pr }) => console.log(`✅ PR created: ${pr.url}`));
63
+ const initResult = await creator.initialize();
64
+ if (!initResult.success) {
65
+ console.error(`❌ Initialization failed: ${initResult.error}`);
66
+ process.exit(1);
67
+ }
68
+ const result = await creator.create({
69
+ suggestion,
70
+ branchName: options.branch,
71
+ title: options.title,
72
+ baseBranch: options.base,
73
+ labels: options.labels?.split(',').map((s) => s.trim()),
74
+ reviewers: options.reviewers?.split(',').map((s) => s.trim()),
75
+ assignees: options.assignees?.split(',').map((s) => s.trim()),
76
+ draft: options.draft,
77
+ dryRun: options.dryRun,
78
+ });
79
+ if (result.success) {
80
+ if (options.dryRun) {
81
+ console.log('\n📋 Dry Run Preview:');
82
+ console.log(` Branch: ${result.branchName}`);
83
+ console.log(` Files: ${result.filesChanged.length}`);
84
+ console.log(` +${result.linesAdded} / -${result.linesDeleted} lines`);
85
+ if (result.preview) {
86
+ console.log(`\n📝 PR Title: ${result.preview.title}`);
87
+ console.log(`\n📄 Commit Message:\n${result.preview.commitMessage}`);
88
+ }
89
+ }
90
+ else {
91
+ console.log('\n🎉 PR created successfully!');
92
+ console.log(` URL: ${result.pr?.url}`);
93
+ console.log(` Branch: ${result.branchName}`);
94
+ console.log(` Commit: ${result.commitHash}`);
95
+ }
96
+ }
97
+ else {
98
+ console.error(`\n❌ PR creation failed: ${result.error}`);
99
+ process.exit(1);
100
+ }
101
+ if (result.warnings && result.warnings.length > 0) {
102
+ console.log('\n⚠️ Warnings:');
103
+ result.warnings.forEach(w => console.log(` - ${w}`));
104
+ }
105
+ }
106
+ catch (error) {
107
+ console.error('❌ Error:', error instanceof Error ? error.message : error);
108
+ process.exit(1);
109
+ }
110
+ });
111
+ /**
112
+ * cg pr preview
113
+ */
114
+ prCommand
115
+ .command('preview <suggestionFile>')
116
+ .description('Preview PR changes without creating')
117
+ .option('--repo <path>', 'Repository path (default: current directory)')
118
+ .option('--json', 'Output as JSON')
119
+ .action(async (suggestionFile, options) => {
120
+ try {
121
+ const { createPRCreator } = await import('./pr/index.js');
122
+ // Read suggestion file
123
+ const filePath = resolve(suggestionFile);
124
+ if (!existsSync(filePath)) {
125
+ console.error(`❌ Suggestion file not found: ${filePath}`);
126
+ process.exit(1);
127
+ }
128
+ const suggestion = JSON.parse(readFileSync(filePath, 'utf-8'));
129
+ const repoPath = options.repo ?? process.cwd();
130
+ const creator = createPRCreator(repoPath);
131
+ const initResult = await creator.initialize();
132
+ if (!initResult.success) {
133
+ console.error(`❌ Initialization failed: ${initResult.error}`);
134
+ process.exit(1);
135
+ }
136
+ const preview = await creator.preview({ suggestion });
137
+ if (options.json) {
138
+ console.log(JSON.stringify(preview, null, 2));
139
+ }
140
+ else {
141
+ console.log('📋 PR Preview\n');
142
+ console.log(`Branch: ${preview.branchName}`);
143
+ console.log(`Title: ${preview.title}`);
144
+ console.log(`\n📝 Commit Message:\n${preview.commitMessage}`);
145
+ console.log(`\n📄 Files Changed (${preview.diffs.length}):`);
146
+ for (const diff of preview.diffs) {
147
+ console.log(` ${diff.changeType === 'added' ? '➕' : '📝'} ${diff.filePath} (+${diff.additions}/-${diff.deletions})`);
148
+ }
149
+ console.log('\n📋 PR Body Preview:\n');
150
+ console.log(preview.body.slice(0, 500) + (preview.body.length > 500 ? '...' : ''));
151
+ }
152
+ }
153
+ catch (error) {
154
+ console.error('❌ Error:', error instanceof Error ? error.message : error);
155
+ process.exit(1);
156
+ }
157
+ });
158
+ /**
159
+ * cg pr validate
160
+ */
161
+ prCommand
162
+ .command('validate <suggestionFile>')
163
+ .description('Validate that a suggestion can be applied')
164
+ .option('--repo <path>', 'Repository path (default: current directory)')
165
+ .action(async (suggestionFile, options) => {
166
+ try {
167
+ const { createPRCreator } = await import('./pr/index.js');
168
+ // Read suggestion file
169
+ const filePath = resolve(suggestionFile);
170
+ if (!existsSync(filePath)) {
171
+ console.error(`❌ Suggestion file not found: ${filePath}`);
172
+ process.exit(1);
173
+ }
174
+ const suggestion = JSON.parse(readFileSync(filePath, 'utf-8'));
175
+ const repoPath = options.repo ?? process.cwd();
176
+ const creator = createPRCreator(repoPath);
177
+ const initResult = await creator.initialize();
178
+ if (!initResult.success) {
179
+ console.error(`❌ Initialization failed: ${initResult.error}`);
180
+ process.exit(1);
181
+ }
182
+ const result = creator.validate(suggestion);
183
+ if (result.valid) {
184
+ console.log('✅ Suggestion is valid and can be applied');
185
+ }
186
+ else {
187
+ console.error(`❌ Suggestion validation failed: ${result.reason}`);
188
+ process.exit(1);
189
+ }
190
+ }
191
+ catch (error) {
192
+ console.error('❌ Error:', error instanceof Error ? error.message : error);
193
+ process.exit(1);
194
+ }
195
+ });
196
+ // ============================================================================
197
+ // Parse and Execute
198
+ // ============================================================================
199
+ program.parse();
200
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,gCAAgC;AAChC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvE,OAAO;KACJ,IAAI,CAAC,IAAI,CAAC;KACV,WAAW,CAAC,6CAA6C,CAAC;KAC1D,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEhC,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E,MAAM,SAAS,GAAG,OAAO;KACtB,OAAO,CAAC,IAAI,CAAC;KACb,WAAW,CAAC,0CAA0C,CAAC,CAAC;AAE3D;;GAEG;AACH,SAAS;KACN,OAAO,CAAC,yBAAyB,CAAC;KAClC,WAAW,CAAC,qDAAqD,CAAC;KAClE,MAAM,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;KACnD,MAAM,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;KAChD,MAAM,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;KAC/D,MAAM,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;KACzD,MAAM,CAAC,6BAA6B,EAAE,2BAA2B,CAAC;KAClE,MAAM,CAAC,6BAA6B,EAAE,2BAA2B,CAAC;KAClE,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC;KACvC,M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AC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAE/C,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAC9C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,4BAA4B,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAE5C,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,mCAAmC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -15,4 +15,5 @@ export { CodeGraph, createCodeGraph } from './codegraph.js';
15
15
  export { TypedEventEmitter, CodeGraphEventEmitter, } from './events/index.js';
16
16
  export type { Language, EntityType, Entity, EntityInput, RelationType, Relation, RelationInput, CodeGraphOptions, ParserOptions, GraphOptions, IndexerOptions, GraphRAGOptions, StorageAdapter, StorageStats, CodeGraphEvents, IndexProgress, QueryResult, IndexResult, CallPath, ModuleAnalysis, CodeSnippet, FileStructure, SearchResult, Community, GraphStatistics, ParseResult, GraphQuery, DependencyOptions, LocalSearchOptions, GlobalSearchOptions, } from './types.js';
17
17
  export { LANGUAGE_EXTENSIONS, DEFAULT_CODEGRAPH_OPTIONS, generateEntityId, generateRelationId, isSupportedLanguage, getLanguageFromExtension, } from './types.js';
18
+ export { createPRCreator, PRCreator, GitOperations, GitHubAdapter, RefactoringApplier, PRTemplateGenerator, type RefactoringSuggestion, type CodeChange, type PRCreateOptions, type PRCreateResult, type PRPreview, type GitHubConfig, type PRInfo, type FileDiff, type PRCreatorEvents, generateBranchName, generateCommitMessage, } from './pr/index.js';
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAEV,QAAQ,EAGR,UAAU,EACV,MAAM,EACN,WAAW,EAGX,YAAY,EACZ,QAAQ,EACR,aAAa,EAGb,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EAGf,cAAc,EACd,YAAY,EAGZ,eAAe,EACf,aAAa,EAGb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,EACf,WAAW,EAGX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAEV,QAAQ,EAGR,UAAU,EACV,MAAM,EACN,WAAW,EAGX,YAAY,EACZ,QAAQ,EACR,aAAa,EAGb,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EAGf,cAAc,EACd,YAAY,EAGZ,eAAe,EACf,aAAa,EAGb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,EACf,WAAW,EAGX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAEL,eAAe,EAGf,SAAS,EACT,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EAGnB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,eAAe,EAGpB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -17,4 +17,12 @@ export { CodeGraph, createCodeGraph } from './codegraph.js';
17
17
  export { TypedEventEmitter, CodeGraphEventEmitter, } from './events/index.js';
18
18
  // Constants
19
19
  export { LANGUAGE_EXTENSIONS, DEFAULT_CODEGRAPH_OPTIONS, generateEntityId, generateRelationId, isSupportedLanguage, getLanguageFromExtension, } from './types.js';
20
+ // PR Creation Module (v2.3.3 NEW!)
21
+ export {
22
+ // Main factory
23
+ createPRCreator,
24
+ // Classes
25
+ PRCreator, GitOperations, GitHubAdapter, RefactoringApplier, PRTemplateGenerator,
26
+ // Utilities
27
+ generateBranchName, generateCommitMessage, } from './pr/index.js';
20
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAe;AACf,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAmD3B,YAAY;AACZ,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAe;AACf,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAmD3B,YAAY;AACZ,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAEpB,mCAAmC;AACnC,OAAO;AACL,eAAe;AACf,eAAe;AAEf,UAAU;AACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB;AAanB,YAAY;AACZ,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - Git Operations
3
+ *
4
+ * Git operations wrapper using simple-git
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/musubix-codegraph/pr
8
+ *
9
+ * @see REQ-CG-PR-003 - Git Branch Creation
10
+ * @see REQ-CG-PR-004 - Auto Commit
11
+ * @see DES-CG-PR-004 - Class Design
12
+ */
13
+ import type { BranchInfo, CommitInfo, GitOperationOptions, CodeChange } from './types.js';
14
+ /**
15
+ * Git operations wrapper
16
+ *
17
+ * Provides a safe interface for Git operations needed for PR creation.
18
+ * Uses child_process to interact with Git directly.
19
+ *
20
+ * @see DES-CG-PR-004
21
+ * @example
22
+ * ```typescript
23
+ * const git = new GitOperations('/path/to/repo');
24
+ * await git.createBranch('refactor/extract-interface');
25
+ * await git.commit('refactor(auth): extract IAuthService interface');
26
+ * await git.push();
27
+ * ```
28
+ */
29
+ export declare class GitOperations {
30
+ private readonly repoPath;
31
+ private readonly remote;
32
+ /**
33
+ * Create a new GitOperations instance
34
+ * @param options - Git operation options
35
+ */
36
+ constructor(options: GitOperationOptions);
37
+ /**
38
+ * Check if path is a Git repository
39
+ */
40
+ isGitRepository(): boolean;
41
+ /**
42
+ * Get repository root path
43
+ */
44
+ getRepoRoot(): string;
45
+ /**
46
+ * Get current branch name
47
+ * @see REQ-CG-PR-003
48
+ */
49
+ getCurrentBranch(): string;
50
+ /**
51
+ * Get default branch name (main or master)
52
+ */
53
+ getDefaultBranch(): string;
54
+ /**
55
+ * List all branches
56
+ */
57
+ listBranches(): BranchInfo[];
58
+ /**
59
+ * Check if branch exists
60
+ */
61
+ branchExists(branchName: string): boolean;
62
+ /**
63
+ * Create a new branch
64
+ * @see REQ-CG-PR-003
65
+ */
66
+ createBranch(branchName: string, baseBranch?: string): void;
67
+ /**
68
+ * Checkout an existing branch
69
+ */
70
+ checkout(branchName: string): void;
71
+ /**
72
+ * Delete a branch
73
+ */
74
+ deleteBranch(branchName: string, force?: boolean): void;
75
+ /**
76
+ * Check for uncommitted changes
77
+ */
78
+ hasUncommittedChanges(): boolean;
79
+ /**
80
+ * Get list of modified files
81
+ */
82
+ getModifiedFiles(): string[];
83
+ /**
84
+ * Stage files for commit
85
+ */
86
+ stageFiles(files: string[]): void;
87
+ /**
88
+ * Stage all changes
89
+ */
90
+ stageAll(): void;
91
+ /**
92
+ * Unstage files
93
+ */
94
+ unstageFiles(files: string[]): void;
95
+ /**
96
+ * Discard changes in working tree
97
+ */
98
+ discardChanges(files: string[]): void;
99
+ /**
100
+ * Stash changes
101
+ */
102
+ stash(message?: string): void;
103
+ /**
104
+ * Pop stash
105
+ */
106
+ stashPop(): void;
107
+ /**
108
+ * Create a commit
109
+ * @see REQ-CG-PR-004
110
+ */
111
+ commit(message: string, options?: {
112
+ allowEmpty?: boolean;
113
+ }): CommitInfo;
114
+ /**
115
+ * Get last commit info
116
+ */
117
+ getLastCommit(): CommitInfo;
118
+ /**
119
+ * Get commit history
120
+ */
121
+ getCommitHistory(count?: number): CommitInfo[];
122
+ /**
123
+ * Push branch to remote
124
+ */
125
+ push(options?: {
126
+ setUpstream?: boolean;
127
+ force?: boolean;
128
+ }): void;
129
+ /**
130
+ * Fetch from remote
131
+ */
132
+ fetch(prune?: boolean): void;
133
+ /**
134
+ * Pull from remote
135
+ */
136
+ pull(rebase?: boolean): void;
137
+ /**
138
+ * Get remote URL
139
+ */
140
+ getRemoteUrl(): string;
141
+ /**
142
+ * Parse GitHub owner/repo from remote URL
143
+ */
144
+ parseRemoteUrl(): {
145
+ owner: string;
146
+ repo: string;
147
+ } | null;
148
+ /**
149
+ * Get diff for staged changes
150
+ */
151
+ getStagedDiff(): string;
152
+ /**
153
+ * Get diff for unstaged changes
154
+ */
155
+ getUnstagedDiff(): string;
156
+ /**
157
+ * Get diff between branches
158
+ */
159
+ getDiffBetweenBranches(baseBranch: string, headBranch?: string): string;
160
+ /**
161
+ * Get diff stats
162
+ */
163
+ getDiffStats(baseBranch?: string): {
164
+ additions: number;
165
+ deletions: number;
166
+ files: number;
167
+ };
168
+ /**
169
+ * Apply code changes to files
170
+ * @see REQ-CG-PR-002
171
+ */
172
+ applyCodeChanges(changes: CodeChange[]): string[];
173
+ /**
174
+ * Revert changes to a file
175
+ */
176
+ revertFile(filePath: string): void;
177
+ /**
178
+ * Execute a git command synchronously
179
+ */
180
+ private git;
181
+ }
182
+ /**
183
+ * Create a GitOperations instance
184
+ */
185
+ export declare function createGitOperations(repoPath: string, remote?: string): GitOperations;
186
+ //# sourceMappingURL=git-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-operations.d.ts","sourceRoot":"","sources":["../../src/pr/git-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;OAGG;gBACS,OAAO,EAAE,mBAAmB;IAcxC;;OAEG;IACH,eAAe,IAAI,OAAO;IAS1B;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAgB1B;;OAEG;IACH,YAAY,IAAI,UAAU,EAAE;IAsB5B;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAazC;;;OAGG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAU3D;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQlC;;OAEG;IACH,YAAY,CAAC,UAAU,EA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