@generacy-ai/agency-plugin-git 0.0.0-preview-20260302182740
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/LICENSE +191 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -0
- package/dist/errors/auth-error.d.ts +23 -0
- package/dist/errors/auth-error.d.ts.map +1 -0
- package/dist/errors/auth-error.js +33 -0
- package/dist/errors/auth-error.js.map +1 -0
- package/dist/errors/conflict-error.d.ts +31 -0
- package/dist/errors/conflict-error.d.ts.map +1 -0
- package/dist/errors/conflict-error.js +49 -0
- package/dist/errors/conflict-error.js.map +1 -0
- package/dist/errors/detached-head-error.d.ts +26 -0
- package/dist/errors/detached-head-error.d.ts.map +1 -0
- package/dist/errors/detached-head-error.js +32 -0
- package/dist/errors/detached-head-error.js.map +1 -0
- package/dist/errors/git-error.d.ts +25 -0
- package/dist/errors/git-error.d.ts.map +1 -0
- package/dist/errors/git-error.js +33 -0
- package/dist/errors/git-error.js.map +1 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +9 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/network-error.d.ts +30 -0
- package/dist/errors/network-error.d.ts.map +1 -0
- package/dist/errors/network-error.js +67 -0
- package/dist/errors/network-error.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +28 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +79 -0
- package/dist/plugin.js.map +1 -0
- package/dist/tools/blame.d.ts +9 -0
- package/dist/tools/blame.d.ts.map +1 -0
- package/dist/tools/blame.js +67 -0
- package/dist/tools/blame.js.map +1 -0
- package/dist/tools/branch.d.ts +9 -0
- package/dist/tools/branch.d.ts.map +1 -0
- package/dist/tools/branch.js +141 -0
- package/dist/tools/branch.js.map +1 -0
- package/dist/tools/checkout.d.ts +9 -0
- package/dist/tools/checkout.d.ts.map +1 -0
- package/dist/tools/checkout.js +94 -0
- package/dist/tools/checkout.js.map +1 -0
- package/dist/tools/commit.d.ts +9 -0
- package/dist/tools/commit.d.ts.map +1 -0
- package/dist/tools/commit.js +90 -0
- package/dist/tools/commit.js.map +1 -0
- package/dist/tools/diff.d.ts +9 -0
- package/dist/tools/diff.d.ts.map +1 -0
- package/dist/tools/diff.js +97 -0
- package/dist/tools/diff.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/log.d.ts +9 -0
- package/dist/tools/log.d.ts.map +1 -0
- package/dist/tools/log.js +91 -0
- package/dist/tools/log.js.map +1 -0
- package/dist/tools/merge.d.ts +9 -0
- package/dist/tools/merge.d.ts.map +1 -0
- package/dist/tools/merge.js +119 -0
- package/dist/tools/merge.js.map +1 -0
- package/dist/tools/pull.d.ts +9 -0
- package/dist/tools/pull.d.ts.map +1 -0
- package/dist/tools/pull.js +113 -0
- package/dist/tools/pull.js.map +1 -0
- package/dist/tools/push.d.ts +9 -0
- package/dist/tools/push.d.ts.map +1 -0
- package/dist/tools/push.js +116 -0
- package/dist/tools/push.js.map +1 -0
- package/dist/tools/rebase.d.ts +9 -0
- package/dist/tools/rebase.d.ts.map +1 -0
- package/dist/tools/rebase.js +147 -0
- package/dist/tools/rebase.js.map +1 -0
- package/dist/tools/stash.d.ts +9 -0
- package/dist/tools/stash.d.ts.map +1 -0
- package/dist/tools/stash.js +151 -0
- package/dist/tools/stash.js.map +1 -0
- package/dist/tools/status.d.ts +9 -0
- package/dist/tools/status.d.ts.map +1 -0
- package/dist/tools/status.js +76 -0
- package/dist/tools/status.js.map +1 -0
- package/dist/types.d.ts +297 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/conflict-parser.d.ts +38 -0
- package/dist/utils/conflict-parser.d.ts.map +1 -0
- package/dist/utils/conflict-parser.js +158 -0
- package/dist/utils/conflict-parser.js.map +1 -0
- package/dist/utils/exec-git.d.ts +45 -0
- package/dist/utils/exec-git.d.ts.map +1 -0
- package/dist/utils/exec-git.js +180 -0
- package/dist/utils/exec-git.js.map +1 -0
- package/dist/utils/parse-blame.d.ts +29 -0
- package/dist/utils/parse-blame.d.ts.map +1 -0
- package/dist/utils/parse-blame.js +97 -0
- package/dist/utils/parse-blame.js.map +1 -0
- package/dist/utils/parse-diff.d.ts +25 -0
- package/dist/utils/parse-diff.d.ts.map +1 -0
- package/dist/utils/parse-diff.js +105 -0
- package/dist/utils/parse-diff.js.map +1 -0
- package/dist/utils/parse-log.d.ts +33 -0
- package/dist/utils/parse-log.d.ts.map +1 -0
- package/dist/utils/parse-log.js +90 -0
- package/dist/utils/parse-log.js.map +1 -0
- package/dist/utils/parse-status.d.ts +22 -0
- package/dist/utils/parse-status.d.ts.map +1 -0
- package/dist/utils/parse-status.js +173 -0
- package/dist/utils/parse-status.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.status tool
|
|
3
|
+
*
|
|
4
|
+
* Get working tree status with structured output.
|
|
5
|
+
*/
|
|
6
|
+
import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
|
|
7
|
+
import { execGitOrThrow } from '../utils/exec-git.js';
|
|
8
|
+
import { parseStatus } from '../utils/parse-status.js';
|
|
9
|
+
export function createStatusTool(config) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'source_control.status',
|
|
12
|
+
description: 'Get working tree status',
|
|
13
|
+
namespace: 'source_control',
|
|
14
|
+
outputPattern: 'terse',
|
|
15
|
+
modes: ['default', 'research', 'coding', 'review'],
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
cwd: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Working directory. Defaults to current directory.',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async execute(params) {
|
|
26
|
+
const { cwd } = params || {};
|
|
27
|
+
try {
|
|
28
|
+
const result = await execGitOrThrow(['status', '--porcelain=v2', '--branch'], { cwd, timeout: config.timeout });
|
|
29
|
+
const status = parseStatus(result.stdout);
|
|
30
|
+
const summary = formatStatusSummary(status);
|
|
31
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({ ...status, summary })));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function formatStatusSummary(status) {
|
|
40
|
+
const parts = [];
|
|
41
|
+
if (status.branch) {
|
|
42
|
+
parts.push(`On branch ${status.branch}`);
|
|
43
|
+
}
|
|
44
|
+
if (status.upstream) {
|
|
45
|
+
if (status.ahead > 0 && status.behind > 0) {
|
|
46
|
+
parts.push(`diverged from ${status.upstream} (+${status.ahead}/-${status.behind})`);
|
|
47
|
+
}
|
|
48
|
+
else if (status.ahead > 0) {
|
|
49
|
+
parts.push(`ahead of ${status.upstream} by ${status.ahead}`);
|
|
50
|
+
}
|
|
51
|
+
else if (status.behind > 0) {
|
|
52
|
+
parts.push(`behind ${status.upstream} by ${status.behind}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const changes = [];
|
|
56
|
+
if (status.staged.length > 0) {
|
|
57
|
+
changes.push(`${status.staged.length} staged`);
|
|
58
|
+
}
|
|
59
|
+
if (status.unstaged.length > 0) {
|
|
60
|
+
changes.push(`${status.unstaged.length} modified`);
|
|
61
|
+
}
|
|
62
|
+
if (status.untracked.length > 0) {
|
|
63
|
+
changes.push(`${status.untracked.length} untracked`);
|
|
64
|
+
}
|
|
65
|
+
if (status.conflicts.length > 0) {
|
|
66
|
+
changes.push(`${status.conflicts.length} conflicts`);
|
|
67
|
+
}
|
|
68
|
+
if (changes.length > 0) {
|
|
69
|
+
parts.push(changes.join(', '));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
parts.push('working tree clean');
|
|
73
|
+
}
|
|
74
|
+
return parts.join('. ');
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,yBAAyB;QACtC,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC;QAClD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,GAAG,EAAE;oBACH,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,mDAAmD;iBACjE;aACF;SACF;QAED,KAAK,CAAC,OAAO,CAAC,MAAe;YAC3B,MAAM,EAAE,GAAG,EAAE,GAAI,MAAuB,IAAI,EAAE,CAAC;YAE/C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,UAAU,CAAC,EACxC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CACjC,CAAC;gBA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,CAAC,QAAQ,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,WAAW,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @generacy-ai/agency-plugin-git
|
|
3
|
+
*
|
|
4
|
+
* Defines tool parameters, results, and error types for all git operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base parameters shared by all tools
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseToolParams {
|
|
10
|
+
/** Working directory. Defaults to process.cwd() */
|
|
11
|
+
cwd?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StatusParams extends BaseToolParams {
|
|
14
|
+
}
|
|
15
|
+
export interface FileChange {
|
|
16
|
+
/** File path relative to repo root */
|
|
17
|
+
path: string;
|
|
18
|
+
/** Change type */
|
|
19
|
+
status: 'added' | 'modified' | 'deleted' | 'renamed' | 'copied';
|
|
20
|
+
/** Original path for renames/copies */
|
|
21
|
+
oldPath?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface StatusResult {
|
|
24
|
+
/** Current branch name */
|
|
25
|
+
branch: string;
|
|
26
|
+
/** Upstream branch if tracking */
|
|
27
|
+
upstream?: string;
|
|
28
|
+
/** Commits ahead of upstream */
|
|
29
|
+
ahead: number;
|
|
30
|
+
/** Commits behind upstream */
|
|
31
|
+
behind: number;
|
|
32
|
+
/** Files in staging area */
|
|
33
|
+
staged: FileChange[];
|
|
34
|
+
/** Modified but not staged files */
|
|
35
|
+
unstaged: FileChange[];
|
|
36
|
+
/** Untracked files */
|
|
37
|
+
untracked: string[];
|
|
38
|
+
/** Files with merge conflicts */
|
|
39
|
+
conflicts: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface DiffParams extends BaseToolParams {
|
|
42
|
+
/** Show staged changes only */
|
|
43
|
+
staged?: boolean;
|
|
44
|
+
/** First ref for comparison (default: working tree) */
|
|
45
|
+
ref1?: string;
|
|
46
|
+
/** Second ref for comparison */
|
|
47
|
+
ref2?: string;
|
|
48
|
+
/** Specific files to diff */
|
|
49
|
+
files?: string[];
|
|
50
|
+
/** Output format */
|
|
51
|
+
format?: 'summary' | 'stat' | 'full';
|
|
52
|
+
}
|
|
53
|
+
export interface DiffFileStat {
|
|
54
|
+
path: string;
|
|
55
|
+
insertions: number;
|
|
56
|
+
deletions: number;
|
|
57
|
+
binary?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface DiffResult {
|
|
60
|
+
/** Number of files changed */
|
|
61
|
+
filesChanged: number;
|
|
62
|
+
/** Total insertions */
|
|
63
|
+
insertions: number;
|
|
64
|
+
/** Total deletions */
|
|
65
|
+
deletions: number;
|
|
66
|
+
/** Per-file stats (when format is 'stat' or 'full') */
|
|
67
|
+
files?: DiffFileStat[];
|
|
68
|
+
/** Full diff text (when format is 'full') */
|
|
69
|
+
patch?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface LogParams extends BaseToolParams {
|
|
72
|
+
/** Maximum commits to return. Default: 10 */
|
|
73
|
+
limit?: number;
|
|
74
|
+
/** Starting ref. Default: HEAD */
|
|
75
|
+
ref?: string;
|
|
76
|
+
/** Show commits for specific file */
|
|
77
|
+
file?: string;
|
|
78
|
+
/** Only show commits by author (email or name pattern) */
|
|
79
|
+
author?: string;
|
|
80
|
+
/** Only show commits since date (ISO format) */
|
|
81
|
+
since?: string;
|
|
82
|
+
/** Only show commits until date (ISO format) */
|
|
83
|
+
until?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface CommitInfo {
|
|
86
|
+
/** Full commit hash */
|
|
87
|
+
hash: string;
|
|
88
|
+
/** Short hash (7 chars) */
|
|
89
|
+
shortHash: string;
|
|
90
|
+
/** Commit message (first line) */
|
|
91
|
+
subject: string;
|
|
92
|
+
/** Full commit message */
|
|
93
|
+
body?: string;
|
|
94
|
+
/** Author name */
|
|
95
|
+
authorName: string;
|
|
96
|
+
/** Author email */
|
|
97
|
+
authorEmail: string;
|
|
98
|
+
/** Commit timestamp (ISO 8601) */
|
|
99
|
+
date: string;
|
|
100
|
+
/** Parent commit hashes */
|
|
101
|
+
parents: string[];
|
|
102
|
+
}
|
|
103
|
+
export interface LogResult {
|
|
104
|
+
/** List of commits */
|
|
105
|
+
commits: CommitInfo[];
|
|
106
|
+
/** Whether there are more commits beyond limit */
|
|
107
|
+
hasMore: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface CommitParams extends BaseToolParams {
|
|
110
|
+
/** Commit message (required) */
|
|
111
|
+
message: string;
|
|
112
|
+
/** Specific files to commit. If omitted, commits all staged */
|
|
113
|
+
files?: string[];
|
|
114
|
+
/** Amend the previous commit */
|
|
115
|
+
amend?: boolean;
|
|
116
|
+
/** Allow empty commit */
|
|
117
|
+
allowEmpty?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface CommitResult {
|
|
120
|
+
/** Created commit hash */
|
|
121
|
+
hash: string;
|
|
122
|
+
/** Short hash */
|
|
123
|
+
shortHash: string;
|
|
124
|
+
/** Branch name */
|
|
125
|
+
branch: string;
|
|
126
|
+
/** Files committed */
|
|
127
|
+
filesChanged: number;
|
|
128
|
+
}
|
|
129
|
+
export interface PushParams extends BaseToolParams {
|
|
130
|
+
/** Remote name. Default: configured defaultRemote */
|
|
131
|
+
remote?: string;
|
|
132
|
+
/** Branch to push. Default: current branch */
|
|
133
|
+
branch?: string;
|
|
134
|
+
/** Force push. Requires allowForcePush or escalation */
|
|
135
|
+
force?: boolean;
|
|
136
|
+
/** Set upstream tracking */
|
|
137
|
+
setUpstream?: boolean;
|
|
138
|
+
/** Push tags */
|
|
139
|
+
tags?: boolean;
|
|
140
|
+
}
|
|
141
|
+
export interface PullParams extends BaseToolParams {
|
|
142
|
+
/** Remote name. Default: configured defaultRemote */
|
|
143
|
+
remote?: string;
|
|
144
|
+
/** Branch to pull. Default: current branch's upstream */
|
|
145
|
+
branch?: string;
|
|
146
|
+
/** Rebase instead of merge */
|
|
147
|
+
rebase?: boolean;
|
|
148
|
+
/** Auto-stash before pull */
|
|
149
|
+
autostash?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface CheckoutParams extends BaseToolParams {
|
|
152
|
+
/** Branch, commit, or file path to checkout */
|
|
153
|
+
ref: string;
|
|
154
|
+
/** Create new branch */
|
|
155
|
+
create?: boolean;
|
|
156
|
+
/** Force checkout (discard local changes) */
|
|
157
|
+
force?: boolean;
|
|
158
|
+
/** Checkout specific files only */
|
|
159
|
+
files?: string[];
|
|
160
|
+
}
|
|
161
|
+
export interface BranchParams extends BaseToolParams {
|
|
162
|
+
/** Action to perform */
|
|
163
|
+
action: 'list' | 'create' | 'delete' | 'rename';
|
|
164
|
+
/** Branch name (required for create/delete/rename) */
|
|
165
|
+
name?: string;
|
|
166
|
+
/** New name (for rename) */
|
|
167
|
+
newName?: string;
|
|
168
|
+
/** Force delete unmerged branch */
|
|
169
|
+
force?: boolean;
|
|
170
|
+
/** Include remote branches in list */
|
|
171
|
+
all?: boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface BranchInfo {
|
|
174
|
+
/** Branch name */
|
|
175
|
+
name: string;
|
|
176
|
+
/** Whether this is the current branch */
|
|
177
|
+
current: boolean;
|
|
178
|
+
/** Whether this is a remote branch */
|
|
179
|
+
remote: boolean;
|
|
180
|
+
/** Upstream branch if tracking */
|
|
181
|
+
upstream?: string;
|
|
182
|
+
/** Latest commit hash */
|
|
183
|
+
commit: string;
|
|
184
|
+
}
|
|
185
|
+
export interface BranchListResult {
|
|
186
|
+
/** List of branches */
|
|
187
|
+
branches: BranchInfo[];
|
|
188
|
+
/** Current branch name */
|
|
189
|
+
current: string;
|
|
190
|
+
}
|
|
191
|
+
export interface StashParams extends BaseToolParams {
|
|
192
|
+
/** Action to perform */
|
|
193
|
+
action: 'push' | 'pop' | 'apply' | 'drop' | 'list' | 'show';
|
|
194
|
+
/** Stash message (for push) */
|
|
195
|
+
message?: string;
|
|
196
|
+
/** Stash index (for pop/apply/drop/show). Default: 0 */
|
|
197
|
+
index?: number;
|
|
198
|
+
/** Include untracked files (for push) */
|
|
199
|
+
includeUntracked?: boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface StashEntry {
|
|
202
|
+
/** Stash index */
|
|
203
|
+
index: number;
|
|
204
|
+
/** Stash message */
|
|
205
|
+
message: string;
|
|
206
|
+
/** Branch where stash was created */
|
|
207
|
+
branch: string;
|
|
208
|
+
}
|
|
209
|
+
export interface StashListResult {
|
|
210
|
+
/** List of stash entries */
|
|
211
|
+
entries: StashEntry[];
|
|
212
|
+
}
|
|
213
|
+
export interface BlameParams extends BaseToolParams {
|
|
214
|
+
/** File to blame (required) */
|
|
215
|
+
file: string;
|
|
216
|
+
/** Line range: [start, end] */
|
|
217
|
+
lines?: [number, number];
|
|
218
|
+
/** Rev to blame from. Default: HEAD */
|
|
219
|
+
rev?: string;
|
|
220
|
+
}
|
|
221
|
+
export interface BlameLine {
|
|
222
|
+
/** Line number (1-indexed) */
|
|
223
|
+
lineNumber: number;
|
|
224
|
+
/** Commit hash that last modified this line */
|
|
225
|
+
hash: string;
|
|
226
|
+
/** Author name */
|
|
227
|
+
author: string;
|
|
228
|
+
/** Commit timestamp (ISO 8601) */
|
|
229
|
+
date: string;
|
|
230
|
+
/** Line content */
|
|
231
|
+
content: string;
|
|
232
|
+
}
|
|
233
|
+
export interface BlameResult {
|
|
234
|
+
/** Blame information per line */
|
|
235
|
+
lines: BlameLine[];
|
|
236
|
+
}
|
|
237
|
+
export interface MergeParams extends BaseToolParams {
|
|
238
|
+
/** Branch to merge in (required) */
|
|
239
|
+
branch: string;
|
|
240
|
+
/** Don't auto-commit the merge */
|
|
241
|
+
noCommit?: boolean;
|
|
242
|
+
/** Merge strategy */
|
|
243
|
+
strategy?: 'ours' | 'theirs' | 'recursive';
|
|
244
|
+
/** Squash commits */
|
|
245
|
+
squash?: boolean;
|
|
246
|
+
}
|
|
247
|
+
export interface RebaseParams extends BaseToolParams {
|
|
248
|
+
/** Branch or commit to rebase onto (required for start) */
|
|
249
|
+
onto?: string;
|
|
250
|
+
/** Abort current rebase */
|
|
251
|
+
abort?: boolean;
|
|
252
|
+
/** Continue after resolving conflicts */
|
|
253
|
+
continue?: boolean;
|
|
254
|
+
/** Skip current commit */
|
|
255
|
+
skip?: boolean;
|
|
256
|
+
}
|
|
257
|
+
export interface ConflictInfo {
|
|
258
|
+
/** Conflicted file path */
|
|
259
|
+
file: string;
|
|
260
|
+
/** Type of conflict */
|
|
261
|
+
type: 'content' | 'add-add' | 'delete-modify' | 'rename';
|
|
262
|
+
/** Our version (between <<<< and ====) */
|
|
263
|
+
ours?: string;
|
|
264
|
+
/** Their version (between ==== and >>>>) */
|
|
265
|
+
theirs?: string;
|
|
266
|
+
/** Base version (for diff3 conflicts) */
|
|
267
|
+
ancestor?: string;
|
|
268
|
+
}
|
|
269
|
+
export interface ForcePushEscalation {
|
|
270
|
+
type: 'approval_request';
|
|
271
|
+
urgency: 'blocking_now';
|
|
272
|
+
title: string;
|
|
273
|
+
description: string;
|
|
274
|
+
context: {
|
|
275
|
+
remote: string;
|
|
276
|
+
branch: string;
|
|
277
|
+
commitsToLose: string[];
|
|
278
|
+
reason?: string;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
export interface EscalationResponse {
|
|
282
|
+
approved: boolean;
|
|
283
|
+
approver?: string;
|
|
284
|
+
reason?: string;
|
|
285
|
+
}
|
|
286
|
+
export interface ExecGitOptions {
|
|
287
|
+
cwd?: string;
|
|
288
|
+
timeout?: number;
|
|
289
|
+
env?: Record<string, string>;
|
|
290
|
+
}
|
|
291
|
+
export interface ExecGitResult {
|
|
292
|
+
exitCode: number;
|
|
293
|
+
stdout: string;
|
|
294
|
+
stderr: string;
|
|
295
|
+
command: string;
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAOD,MAAM,WAAW,YAAa,SAAQ,cAAc;CAAG;AAEvD,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,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C;IACpB,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse conflict markers from files
|
|
3
|
+
*/
|
|
4
|
+
import type { ConflictInfo } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parse conflict markers from file content
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseConflictMarkers(content: string): {
|
|
9
|
+
ours: string;
|
|
10
|
+
theirs: string;
|
|
11
|
+
ancestor?: string;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* Check if file contains conflict markers
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasConflictMarkers(content: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Determine conflict type from git status output
|
|
19
|
+
*
|
|
20
|
+
* Status codes for unmerged entries:
|
|
21
|
+
* DD - both deleted
|
|
22
|
+
* AU - added by us
|
|
23
|
+
* UD - deleted by them
|
|
24
|
+
* UA - added by them
|
|
25
|
+
* DU - deleted by us
|
|
26
|
+
* AA - both added
|
|
27
|
+
* UU - both modified
|
|
28
|
+
*/
|
|
29
|
+
export declare function getConflictType(statusCode: string): ConflictInfo['type'];
|
|
30
|
+
/**
|
|
31
|
+
* Parse conflicts from a list of files
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseConflictsFromFiles(files: string[], cwd?: string): Promise<ConflictInfo[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Get all conflicted files from git status
|
|
36
|
+
*/
|
|
37
|
+
export declare function getConflictedFilesFromStatus(statusOutput: string): string[];
|
|
38
|
+
//# sourceMappingURL=conflict-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-parser.d.ts","sourceRoot":"","sources":["../../src/utils/conflict-parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,IAAI,CAuDP;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,MAAM,CAAC,CAatB;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC,CAmCzB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAsB3E"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse conflict markers from files
|
|
3
|
+
*/
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
/**
|
|
7
|
+
* Conflict marker patterns
|
|
8
|
+
*/
|
|
9
|
+
const CONFLICT_START = /^<{7} /;
|
|
10
|
+
const CONFLICT_MIDDLE = /^={7}$/;
|
|
11
|
+
const CONFLICT_ANCESTOR = /^\|{7} /;
|
|
12
|
+
const CONFLICT_END = /^>{7} /;
|
|
13
|
+
/**
|
|
14
|
+
* Parse conflict markers from file content
|
|
15
|
+
*/
|
|
16
|
+
export function parseConflictMarkers(content) {
|
|
17
|
+
const lines = content.split('\n');
|
|
18
|
+
let inConflict = false;
|
|
19
|
+
let section = 'ours';
|
|
20
|
+
let ours = [];
|
|
21
|
+
let theirs = [];
|
|
22
|
+
let ancestor;
|
|
23
|
+
for (const line of lines) {
|
|
24
|
+
if (CONFLICT_START.test(line)) {
|
|
25
|
+
inConflict = true;
|
|
26
|
+
section = 'ours';
|
|
27
|
+
ours = [];
|
|
28
|
+
theirs = [];
|
|
29
|
+
ancestor = undefined;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!inConflict)
|
|
33
|
+
continue;
|
|
34
|
+
if (CONFLICT_ANCESTOR.test(line)) {
|
|
35
|
+
section = 'ancestor';
|
|
36
|
+
ancestor = [];
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (CONFLICT_MIDDLE.test(line)) {
|
|
40
|
+
section = 'theirs';
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (CONFLICT_END.test(line)) {
|
|
44
|
+
return {
|
|
45
|
+
ours: ours.join('\n'),
|
|
46
|
+
theirs: theirs.join('\n'),
|
|
47
|
+
ancestor: ancestor?.join('\n'),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Add line to current section
|
|
51
|
+
switch (section) {
|
|
52
|
+
case 'ours':
|
|
53
|
+
ours.push(line);
|
|
54
|
+
break;
|
|
55
|
+
case 'ancestor':
|
|
56
|
+
ancestor?.push(line);
|
|
57
|
+
break;
|
|
58
|
+
case 'theirs':
|
|
59
|
+
theirs.push(line);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if file contains conflict markers
|
|
67
|
+
*/
|
|
68
|
+
export function hasConflictMarkers(content) {
|
|
69
|
+
return CONFLICT_START.test(content);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Determine conflict type from git status output
|
|
73
|
+
*
|
|
74
|
+
* Status codes for unmerged entries:
|
|
75
|
+
* DD - both deleted
|
|
76
|
+
* AU - added by us
|
|
77
|
+
* UD - deleted by them
|
|
78
|
+
* UA - added by them
|
|
79
|
+
* DU - deleted by us
|
|
80
|
+
* AA - both added
|
|
81
|
+
* UU - both modified
|
|
82
|
+
*/
|
|
83
|
+
export function getConflictType(statusCode) {
|
|
84
|
+
switch (statusCode) {
|
|
85
|
+
case 'AA':
|
|
86
|
+
return 'add-add';
|
|
87
|
+
case 'DD':
|
|
88
|
+
case 'AU':
|
|
89
|
+
case 'UD':
|
|
90
|
+
case 'UA':
|
|
91
|
+
case 'DU':
|
|
92
|
+
return 'delete-modify';
|
|
93
|
+
default:
|
|
94
|
+
return 'content';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Parse conflicts from a list of files
|
|
99
|
+
*/
|
|
100
|
+
export async function parseConflictsFromFiles(files, cwd = process.cwd()) {
|
|
101
|
+
const conflicts = [];
|
|
102
|
+
for (const file of files) {
|
|
103
|
+
try {
|
|
104
|
+
const filePath = join(cwd, file);
|
|
105
|
+
const content = await readFile(filePath, 'utf-8');
|
|
106
|
+
const markers = parseConflictMarkers(content);
|
|
107
|
+
if (markers) {
|
|
108
|
+
conflicts.push({
|
|
109
|
+
file,
|
|
110
|
+
type: 'content',
|
|
111
|
+
ours: markers.ours,
|
|
112
|
+
theirs: markers.theirs,
|
|
113
|
+
ancestor: markers.ancestor,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// File is in conflict list but no markers found
|
|
118
|
+
// This could be a delete-modify or rename conflict
|
|
119
|
+
conflicts.push({
|
|
120
|
+
file,
|
|
121
|
+
type: 'content',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// File may have been deleted in conflict
|
|
127
|
+
conflicts.push({
|
|
128
|
+
file,
|
|
129
|
+
type: 'delete-modify',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return conflicts;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get all conflicted files from git status
|
|
137
|
+
*/
|
|
138
|
+
export function getConflictedFilesFromStatus(statusOutput) {
|
|
139
|
+
const lines = statusOutput.split('\n');
|
|
140
|
+
const conflicted = [];
|
|
141
|
+
for (const line of lines) {
|
|
142
|
+
// Look for unmerged entries in porcelain v2 format
|
|
143
|
+
if (line.startsWith('u ')) {
|
|
144
|
+
const parts = line.split('\t');
|
|
145
|
+
const path = parts[parts.length - 1];
|
|
146
|
+
if (path) {
|
|
147
|
+
conflicted.push(path);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Also check porcelain v1 format (UU, AA, DD, etc.)
|
|
151
|
+
const match = line.match(/^(UU|AA|DD|AU|UD|UA|DU) (.+)$/);
|
|
152
|
+
if (match?.[2]) {
|
|
153
|
+
conflicted.push(match[2]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return conflicted;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=conflict-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-parser.js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,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,oDAAoD;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC1D,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git command execution wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Spawn-based execution with timeout
|
|
6
|
+
* - Error classification
|
|
7
|
+
* - Raw output capture for parsing
|
|
8
|
+
*/
|
|
9
|
+
import type { ExecGitOptions, ExecGitResult } from '../types.js';
|
|
10
|
+
import { GitError } from '../errors/index.js';
|
|
11
|
+
import type { ConflictInfo } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Execute a git command and return the result
|
|
14
|
+
*
|
|
15
|
+
* @param args - Git command arguments (e.g., ['status', '--porcelain'])
|
|
16
|
+
* @param options - Execution options
|
|
17
|
+
* @returns ExecGitResult with exitCode, stdout, stderr
|
|
18
|
+
*/
|
|
19
|
+
export declare function execGit(args: string[], options?: ExecGitOptions): Promise<ExecGitResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Execute a git command and throw a classified error on failure
|
|
22
|
+
*
|
|
23
|
+
* @param args - Git command arguments
|
|
24
|
+
* @param options - Execution options
|
|
25
|
+
* @returns ExecGitResult on success
|
|
26
|
+
* @throws GitError (or subclass) on failure
|
|
27
|
+
*/
|
|
28
|
+
export declare function execGitOrThrow(args: string[], options?: ExecGitOptions): Promise<ExecGitResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Classify a git error based on exit code and stderr
|
|
31
|
+
*/
|
|
32
|
+
export declare function classifyError(result: ExecGitResult, cwd: string, conflicts?: ConflictInfo[]): GitError;
|
|
33
|
+
/**
|
|
34
|
+
* Check if git is available
|
|
35
|
+
*/
|
|
36
|
+
export declare function isGitAvailable(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the current git version
|
|
39
|
+
*/
|
|
40
|
+
export declare function getGitVersion(): Promise<string | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the current directory is a git repository
|
|
43
|
+
*/
|
|
44
|
+
export declare function isGitRepository(cwd?: string): Promise<boolean>;
|
|
45
|
+
//# sourceMappingURL=exec-git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-git.d.ts","sourceRoot":"","sources":["../../src/utils/exec-git.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,QAAQ,EAUT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CA6DxB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAQxB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,YAAY,EAAO,GAC7B,QAAQ,CAuDV;AAYD;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAOvD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW5D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUpE"}
|