@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.
Files changed (118) hide show
  1. package/LICENSE +191 -0
  2. package/dist/config.d.ts +25 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +22 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/errors/auth-error.d.ts +23 -0
  7. package/dist/errors/auth-error.d.ts.map +1 -0
  8. package/dist/errors/auth-error.js +33 -0
  9. package/dist/errors/auth-error.js.map +1 -0
  10. package/dist/errors/conflict-error.d.ts +31 -0
  11. package/dist/errors/conflict-error.d.ts.map +1 -0
  12. package/dist/errors/conflict-error.js +49 -0
  13. package/dist/errors/conflict-error.js.map +1 -0
  14. package/dist/errors/detached-head-error.d.ts +26 -0
  15. package/dist/errors/detached-head-error.d.ts.map +1 -0
  16. package/dist/errors/detached-head-error.js +32 -0
  17. package/dist/errors/detached-head-error.js.map +1 -0
  18. package/dist/errors/git-error.d.ts +25 -0
  19. package/dist/errors/git-error.d.ts.map +1 -0
  20. package/dist/errors/git-error.js +33 -0
  21. package/dist/errors/git-error.js.map +1 -0
  22. package/dist/errors/index.d.ts +9 -0
  23. package/dist/errors/index.d.ts.map +1 -0
  24. package/dist/errors/index.js +9 -0
  25. package/dist/errors/index.js.map +1 -0
  26. package/dist/errors/network-error.d.ts +30 -0
  27. package/dist/errors/network-error.d.ts.map +1 -0
  28. package/dist/errors/network-error.js +67 -0
  29. package/dist/errors/network-error.js.map +1 -0
  30. package/dist/index.d.ts +26 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +29 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/plugin.d.ts +28 -0
  35. package/dist/plugin.d.ts.map +1 -0
  36. package/dist/plugin.js +79 -0
  37. package/dist/plugin.js.map +1 -0
  38. package/dist/tools/blame.d.ts +9 -0
  39. package/dist/tools/blame.d.ts.map +1 -0
  40. package/dist/tools/blame.js +67 -0
  41. package/dist/tools/blame.js.map +1 -0
  42. package/dist/tools/branch.d.ts +9 -0
  43. package/dist/tools/branch.d.ts.map +1 -0
  44. package/dist/tools/branch.js +141 -0
  45. package/dist/tools/branch.js.map +1 -0
  46. package/dist/tools/checkout.d.ts +9 -0
  47. package/dist/tools/checkout.d.ts.map +1 -0
  48. package/dist/tools/checkout.js +94 -0
  49. package/dist/tools/checkout.js.map +1 -0
  50. package/dist/tools/commit.d.ts +9 -0
  51. package/dist/tools/commit.d.ts.map +1 -0
  52. package/dist/tools/commit.js +90 -0
  53. package/dist/tools/commit.js.map +1 -0
  54. package/dist/tools/diff.d.ts +9 -0
  55. package/dist/tools/diff.d.ts.map +1 -0
  56. package/dist/tools/diff.js +97 -0
  57. package/dist/tools/diff.js.map +1 -0
  58. package/dist/tools/index.d.ts +26 -0
  59. package/dist/tools/index.d.ts.map +1 -0
  60. package/dist/tools/index.js +55 -0
  61. package/dist/tools/index.js.map +1 -0
  62. package/dist/tools/log.d.ts +9 -0
  63. package/dist/tools/log.d.ts.map +1 -0
  64. package/dist/tools/log.js +91 -0
  65. package/dist/tools/log.js.map +1 -0
  66. package/dist/tools/merge.d.ts +9 -0
  67. package/dist/tools/merge.d.ts.map +1 -0
  68. package/dist/tools/merge.js +119 -0
  69. package/dist/tools/merge.js.map +1 -0
  70. package/dist/tools/pull.d.ts +9 -0
  71. package/dist/tools/pull.d.ts.map +1 -0
  72. package/dist/tools/pull.js +113 -0
  73. package/dist/tools/pull.js.map +1 -0
  74. package/dist/tools/push.d.ts +9 -0
  75. package/dist/tools/push.d.ts.map +1 -0
  76. package/dist/tools/push.js +116 -0
  77. package/dist/tools/push.js.map +1 -0
  78. package/dist/tools/rebase.d.ts +9 -0
  79. package/dist/tools/rebase.d.ts.map +1 -0
  80. package/dist/tools/rebase.js +147 -0
  81. package/dist/tools/rebase.js.map +1 -0
  82. package/dist/tools/stash.d.ts +9 -0
  83. package/dist/tools/stash.d.ts.map +1 -0
  84. package/dist/tools/stash.js +151 -0
  85. package/dist/tools/stash.js.map +1 -0
  86. package/dist/tools/status.d.ts +9 -0
  87. package/dist/tools/status.d.ts.map +1 -0
  88. package/dist/tools/status.js +76 -0
  89. package/dist/tools/status.js.map +1 -0
  90. package/dist/types.d.ts +297 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/types.js +7 -0
  93. package/dist/types.js.map +1 -0
  94. package/dist/utils/conflict-parser.d.ts +38 -0
  95. package/dist/utils/conflict-parser.d.ts.map +1 -0
  96. package/dist/utils/conflict-parser.js +158 -0
  97. package/dist/utils/conflict-parser.js.map +1 -0
  98. package/dist/utils/exec-git.d.ts +45 -0
  99. package/dist/utils/exec-git.d.ts.map +1 -0
  100. package/dist/utils/exec-git.js +180 -0
  101. package/dist/utils/exec-git.js.map +1 -0
  102. package/dist/utils/parse-blame.d.ts +29 -0
  103. package/dist/utils/parse-blame.d.ts.map +1 -0
  104. package/dist/utils/parse-blame.js +97 -0
  105. package/dist/utils/parse-blame.js.map +1 -0
  106. package/dist/utils/parse-diff.d.ts +25 -0
  107. package/dist/utils/parse-diff.d.ts.map +1 -0
  108. package/dist/utils/parse-diff.js +105 -0
  109. package/dist/utils/parse-diff.js.map +1 -0
  110. package/dist/utils/parse-log.d.ts +33 -0
  111. package/dist/utils/parse-log.d.ts.map +1 -0
  112. package/dist/utils/parse-log.js +90 -0
  113. package/dist/utils/parse-log.js.map +1 -0
  114. package/dist/utils/parse-status.d.ts +22 -0
  115. package/dist/utils/parse-status.d.ts.map +1 -0
  116. package/dist/utils/parse-status.js +173 -0
  117. package/dist/utils/parse-status.js.map +1 -0
  118. package/package.json +82 -0
@@ -0,0 +1,113 @@
1
+ /**
2
+ * source_control.pull tool
3
+ *
4
+ * Pull from remote with conflict detection.
5
+ */
6
+ import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
7
+ import { execGit, classifyError } from '../utils/exec-git.js';
8
+ import { parseConflictsFromFiles, getConflictedFilesFromStatus } from '../utils/conflict-parser.js';
9
+ import { ConflictError } from '../errors/index.js';
10
+ export function createPullTool(config) {
11
+ return {
12
+ name: 'source_control.pull',
13
+ description: 'Pull from remote',
14
+ namespace: 'source_control',
15
+ outputPattern: 'terse',
16
+ modes: ['default', 'coding'],
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ cwd: {
21
+ type: 'string',
22
+ description: 'Working directory',
23
+ },
24
+ remote: {
25
+ type: 'string',
26
+ description: `Remote name (default: ${config.defaultRemote})`,
27
+ },
28
+ branch: {
29
+ type: 'string',
30
+ description: 'Branch to pull (default: current tracking branch)',
31
+ },
32
+ rebase: {
33
+ type: 'boolean',
34
+ description: 'Rebase instead of merge',
35
+ },
36
+ autostash: {
37
+ type: 'boolean',
38
+ description: 'Auto-stash before pull',
39
+ },
40
+ },
41
+ },
42
+ async execute(params) {
43
+ const { cwd, remote = config.defaultRemote, branch, rebase = false, autostash = false, } = params || {};
44
+ try {
45
+ const args = ['pull'];
46
+ if (rebase) {
47
+ args.push('--rebase');
48
+ }
49
+ if (autostash) {
50
+ args.push('--autostash');
51
+ }
52
+ args.push(remote);
53
+ if (branch) {
54
+ args.push(branch);
55
+ }
56
+ const result = await execGit(args, { cwd, timeout: config.timeout });
57
+ if (result.exitCode !== 0) {
58
+ // Check for conflicts
59
+ const statusResult = await execGit(['status', '--porcelain=v2'], { cwd, timeout: config.timeout });
60
+ const conflictedFiles = getConflictedFilesFromStatus(statusResult.stdout);
61
+ if (conflictedFiles.length > 0) {
62
+ const conflicts = await parseConflictsFromFiles(conflictedFiles, cwd);
63
+ throw new ConflictError('Pull resulted in conflicts', {
64
+ command: result.command,
65
+ exitCode: result.exitCode,
66
+ stderr: result.stderr,
67
+ cwd: cwd ?? process.cwd(),
68
+ conflicts,
69
+ });
70
+ }
71
+ // Other error
72
+ throw classifyError(result, cwd ?? process.cwd());
73
+ }
74
+ // Parse result
75
+ const isUpToDate = result.stdout.includes('Already up to date');
76
+ const isFastForward = result.stdout.includes('Fast-forward');
77
+ let summary;
78
+ if (isUpToDate) {
79
+ summary = 'Already up to date';
80
+ }
81
+ else if (isFastForward) {
82
+ summary = `Fast-forward merge from ${remote}${branch ? `/${branch}` : ''}`;
83
+ }
84
+ else if (rebase) {
85
+ summary = `Rebased onto ${remote}${branch ? `/${branch}` : ''}`;
86
+ }
87
+ else {
88
+ summary = `Merged from ${remote}${branch ? `/${branch}` : ''}`;
89
+ }
90
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
91
+ success: true,
92
+ remote,
93
+ branch: branch ?? 'tracking',
94
+ rebase,
95
+ upToDate: isUpToDate,
96
+ fastForward: isFastForward,
97
+ summary,
98
+ })));
99
+ }
100
+ catch (error) {
101
+ if (error instanceof ConflictError) {
102
+ return terseToMcpToolResult(TerseOutput.failure(JSON.stringify({
103
+ error: 'conflict',
104
+ message: error.message,
105
+ conflicts: error.conflicts,
106
+ })));
107
+ }
108
+ return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
109
+ }
110
+ },
111
+ };
112
+ }
113
+ //# sourceMappingURL=pull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/tools/pull.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,cAAc,CAAC,MAAuB;IACpD,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,kBAAkB;QAC/B,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE,CAAC,SAAS,EAAE,QAAQ,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B,OAAO,GAAG,gBAAgB,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,eAAe,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBACjE,CAAC;gBAED,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;oBACb,OAAO,EAAE,IAAI;oBACb,MAAM;oBACN,MAAM,EAAE,MAAM,IAAI,UAAU;oBAC5B,MAAM;oBACN,QAAQ,EAAE,UAAU;oBACpB,WAAW,EAAE,aAAa;oBAC1B,OAAO;iBACR,CAAC,CACH,CACF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;oBACnC,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;wBACb,KAAK,EAAE,UAAU;wBACjB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;qBAC3B,CAAC,CACH,CACF,CAAC;gBACJ,CAAC;gBAED,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * source_control.push tool
3
+ *
4
+ * Push to remote with force push escalation.
5
+ */
6
+ import type { AgencyTool, AgencyCoreAPI } from '@generacy-ai/agency';
7
+ import type { GitPluginConfig } from '../config.js';
8
+ export declare function createPushTool(config: GitPluginConfig, core: AgencyCoreAPI): AgencyTool;
9
+ //# sourceMappingURL=push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/tools/push.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,aAAa,GAClB,UAAU,CA2GZ"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * source_control.push tool
3
+ *
4
+ * Push to remote with force push escalation.
5
+ */
6
+ import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
7
+ import { execGitOrThrow, execGit } from '../utils/exec-git.js';
8
+ export function createPushTool(config, core) {
9
+ return {
10
+ name: 'source_control.push',
11
+ description: 'Push to remote',
12
+ namespace: 'source_control',
13
+ outputPattern: 'terse',
14
+ modes: ['default', 'coding'],
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ cwd: {
19
+ type: 'string',
20
+ description: 'Working directory',
21
+ },
22
+ remote: {
23
+ type: 'string',
24
+ description: `Remote name (default: ${config.defaultRemote})`,
25
+ },
26
+ branch: {
27
+ type: 'string',
28
+ description: 'Branch to push (default: current branch)',
29
+ },
30
+ force: {
31
+ type: 'boolean',
32
+ description: 'Force push (requires approval if allowForcePush is false)',
33
+ },
34
+ setUpstream: {
35
+ type: 'boolean',
36
+ description: 'Set upstream tracking',
37
+ },
38
+ tags: {
39
+ type: 'boolean',
40
+ description: 'Push tags',
41
+ },
42
+ },
43
+ },
44
+ async execute(params) {
45
+ const { cwd, remote = config.defaultRemote, branch, force = false, setUpstream = false, tags = false, } = params || {};
46
+ try {
47
+ // Handle force push
48
+ if (force && !config.allowForcePush) {
49
+ // Try to escalate via Humancy
50
+ const approved = await requestForcePushApproval(core, remote, branch ?? 'current branch', cwd);
51
+ if (!approved) {
52
+ return terseToMcpToolResult(TerseOutput.failure('Force push requires approval. Set allowForcePush: true in config or get Humancy approval.'));
53
+ }
54
+ }
55
+ const args = ['push'];
56
+ if (force) {
57
+ args.push('--force-with-lease');
58
+ }
59
+ if (setUpstream) {
60
+ args.push('-u');
61
+ }
62
+ if (tags) {
63
+ args.push('--tags');
64
+ }
65
+ args.push(remote);
66
+ if (branch) {
67
+ args.push(branch);
68
+ }
69
+ await execGitOrThrow(args, { cwd, timeout: config.timeout });
70
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
71
+ success: true,
72
+ remote,
73
+ branch: branch ?? 'current',
74
+ force,
75
+ summary: `Pushed to ${remote}${branch ? `/${branch}` : ''}`,
76
+ })));
77
+ }
78
+ catch (error) {
79
+ return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
80
+ }
81
+ },
82
+ };
83
+ }
84
+ async function requestForcePushApproval(core, remote, branch, cwd) {
85
+ try {
86
+ // Get commits that would be lost
87
+ const result = await execGit(['log', '--format=%H %s', `${remote}/${branch}..HEAD`, '-n', '10'], { cwd });
88
+ const commitsToLose = result.stdout.split('\n').filter(Boolean);
89
+ const escalation = {
90
+ type: 'approval_request',
91
+ urgency: 'blocking_now',
92
+ title: 'Force Push Approval Required',
93
+ description: `Agent requests force push to ${remote}/${branch}`,
94
+ context: {
95
+ remote,
96
+ branch,
97
+ commitsToLose,
98
+ },
99
+ };
100
+ // Try to send escalation via humancy channel
101
+ core.sendMessage('humancy.escalation', {
102
+ id: `force-push-${Date.now()}`,
103
+ channel: 'humancy.escalation',
104
+ sender: core.getPluginId(),
105
+ timestamp: new Date(),
106
+ payload: escalation,
107
+ });
108
+ // For now, we can't wait for response in this architecture
109
+ // Return false to indicate approval not yet received
110
+ return false;
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ }
116
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/tools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4
+ * Rebase current branch with conflict handling.
5
+ */
6
+ import type { AgencyTool } from '@generacy-ai/agency';
7
+ import type { GitPluginConfig } from '../config.js';
8
+ export declare function createRebaseTool(config: GitPluginConfig): AgencyTool;
9
+ //# sourceMappingURL=rebase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebase.d.ts","sourceRoot":"","sources":["../../src/tools/rebase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CA8HpE"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * source_control.rebase tool
3
+ *
4
+ * Rebase current branch with conflict handling.
5
+ */
6
+ import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
7
+ import { execGit, classifyError } from '../utils/exec-git.js';
8
+ import { parseConflictsFromFiles, getConflictedFilesFromStatus } from '../utils/conflict-parser.js';
9
+ import { ConflictError } from '../errors/index.js';
10
+ export function createRebaseTool(config) {
11
+ return {
12
+ name: 'source_control.rebase',
13
+ description: 'Rebase current branch',
14
+ namespace: 'source_control',
15
+ outputPattern: 'terse',
16
+ modes: ['default', 'coding'],
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ cwd: {
21
+ type: 'string',
22
+ description: 'Working directory',
23
+ },
24
+ onto: {
25
+ type: 'string',
26
+ description: 'Branch or commit to rebase onto',
27
+ },
28
+ abort: {
29
+ type: 'boolean',
30
+ description: 'Abort current rebase',
31
+ },
32
+ continue: {
33
+ type: 'boolean',
34
+ description: 'Continue after resolving conflicts',
35
+ },
36
+ skip: {
37
+ type: 'boolean',
38
+ description: 'Skip current commit',
39
+ },
40
+ },
41
+ },
42
+ async execute(params) {
43
+ const { cwd, onto, abort = false, continue: continueRebase = false, skip = false, } = params || {};
44
+ try {
45
+ // Handle control operations
46
+ if (abort) {
47
+ return await abortRebase(cwd, config);
48
+ }
49
+ if (continueRebase) {
50
+ return await continueRebaseOp(cwd, config);
51
+ }
52
+ if (skip) {
53
+ return await skipRebase(cwd, config);
54
+ }
55
+ // Start rebase
56
+ if (!onto) {
57
+ return terseToMcpToolResult(TerseOutput.failure('onto parameter is required to start rebase'));
58
+ }
59
+ const args = ['rebase', onto];
60
+ const result = await execGit(args, { cwd, timeout: config.timeout });
61
+ if (result.exitCode !== 0) {
62
+ // Check for conflicts
63
+ const statusResult = await execGit(['status', '--porcelain=v2'], { cwd, timeout: config.timeout });
64
+ const conflictedFiles = getConflictedFilesFromStatus(statusResult.stdout);
65
+ if (conflictedFiles.length > 0) {
66
+ const conflicts = await parseConflictsFromFiles(conflictedFiles, cwd);
67
+ throw new ConflictError(`Rebase conflict onto ${onto}`, {
68
+ command: result.command,
69
+ exitCode: result.exitCode,
70
+ stderr: result.stderr,
71
+ cwd: cwd ?? process.cwd(),
72
+ conflicts,
73
+ });
74
+ }
75
+ // Other error
76
+ throw classifyError(result, cwd ?? process.cwd());
77
+ }
78
+ const isUpToDate = result.stdout.includes('is up to date');
79
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
80
+ success: true,
81
+ onto,
82
+ upToDate: isUpToDate,
83
+ summary: isUpToDate
84
+ ? 'Already up to date'
85
+ : `Rebased onto '${onto}'`,
86
+ })));
87
+ }
88
+ catch (error) {
89
+ if (error instanceof ConflictError) {
90
+ return terseToMcpToolResult(TerseOutput.failure(JSON.stringify({
91
+ error: 'conflict',
92
+ message: error.message,
93
+ onto,
94
+ conflicts: error.conflicts,
95
+ hint: 'Resolve conflicts and run rebase with continue: true, or abort: true to cancel',
96
+ })));
97
+ }
98
+ return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
99
+ }
100
+ },
101
+ };
102
+ }
103
+ async function abortRebase(cwd, config) {
104
+ const result = await execGit(['rebase', '--abort'], { cwd, timeout: config.timeout });
105
+ if (result.exitCode !== 0 && !result.stderr.includes('No rebase in progress')) {
106
+ return terseToMcpToolResult(TerseOutput.failure(result.stderr || 'Failed to abort rebase'));
107
+ }
108
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
109
+ success: true,
110
+ action: 'abort',
111
+ summary: 'Rebase aborted',
112
+ })));
113
+ }
114
+ async function continueRebaseOp(cwd, config) {
115
+ const result = await execGit(['rebase', '--continue'], { cwd, timeout: config.timeout });
116
+ if (result.exitCode !== 0) {
117
+ // Check if still in conflict
118
+ const statusResult = await execGit(['status', '--porcelain=v2'], { cwd, timeout: config.timeout });
119
+ const conflictedFiles = getConflictedFilesFromStatus(statusResult.stdout);
120
+ if (conflictedFiles.length > 0) {
121
+ const conflicts = await parseConflictsFromFiles(conflictedFiles, cwd);
122
+ return terseToMcpToolResult(TerseOutput.failure(JSON.stringify({
123
+ error: 'conflict',
124
+ message: 'Conflicts remain after continue',
125
+ conflicts,
126
+ })));
127
+ }
128
+ return terseToMcpToolResult(TerseOutput.failure(result.stderr || 'Failed to continue rebase'));
129
+ }
130
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
131
+ success: true,
132
+ action: 'continue',
133
+ summary: 'Rebase continued',
134
+ })));
135
+ }
136
+ async function skipRebase(cwd, config) {
137
+ const result = await execGit(['rebase', '--skip'], { cwd, timeout: config.timeout });
138
+ if (result.exitCode !== 0) {
139
+ return terseToMcpToolResult(TerseOutput.failure(result.stderr || 'Failed to skip commit'));
140
+ }
141
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
142
+ success: true,
143
+ action: 'skip',
144
+ summary: 'Skipped current commit',
145
+ })));
146
+ }
147
+ //# sourceMappingURL=rebase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rebase.js","sourceRoot":"","sources":["../../src/tools/rebase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGxE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IAED,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CACH,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,GAAuB,EACvB,MAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAErF,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,uBAAuB,CAAC,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,wBAAwB;KAClC,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * source_control.stash tool
3
+ *
4
+ * Stash/unstash changes.
5
+ */
6
+ import type { AgencyTool } from '@generacy-ai/agency';
7
+ import type { GitPluginConfig } from '../config.js';
8
+ export declare function createStashTool(config: GitPluginConfig): AgencyTool;
9
+ //# sourceMappingURL=stash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash.d.ts","sourceRoot":"","sources":["../../src/tools/stash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAkFnE"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * source_control.stash tool
3
+ *
4
+ * Stash/unstash changes.
5
+ */
6
+ import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
7
+ import { execGitOrThrow } from '../utils/exec-git.js';
8
+ export function createStashTool(config) {
9
+ return {
10
+ name: 'source_control.stash',
11
+ description: 'Stash/unstash changes',
12
+ namespace: 'source_control',
13
+ outputPattern: 'terse',
14
+ modes: ['default', 'coding'],
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ cwd: {
19
+ type: 'string',
20
+ description: 'Working directory',
21
+ },
22
+ action: {
23
+ type: 'string',
24
+ enum: ['push', 'pop', 'apply', 'drop', 'list', 'show'],
25
+ description: 'Action to perform (required)',
26
+ },
27
+ message: {
28
+ type: 'string',
29
+ description: 'Stash message (for push)',
30
+ },
31
+ index: {
32
+ type: 'number',
33
+ description: 'Stash index (for pop/apply/drop/show, default: 0)',
34
+ },
35
+ includeUntracked: {
36
+ type: 'boolean',
37
+ description: 'Include untracked files (for push)',
38
+ },
39
+ },
40
+ required: ['action'],
41
+ },
42
+ async execute(params) {
43
+ const { cwd, action, message, index = 0, includeUntracked = false, } = params || {};
44
+ if (!action) {
45
+ return terseToMcpToolResult(TerseOutput.failure('action parameter is required'));
46
+ }
47
+ try {
48
+ switch (action) {
49
+ case 'push':
50
+ return await stashPush(cwd, message, includeUntracked, config);
51
+ case 'pop':
52
+ return await stashPop(cwd, index, config);
53
+ case 'apply':
54
+ return await stashApply(cwd, index, config);
55
+ case 'drop':
56
+ return await stashDrop(cwd, index, config);
57
+ case 'list':
58
+ return await stashList(cwd, config);
59
+ case 'show':
60
+ return await stashShow(cwd, index, config);
61
+ default:
62
+ return terseToMcpToolResult(TerseOutput.failure(`Unknown action: ${action}`));
63
+ }
64
+ }
65
+ catch (error) {
66
+ return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
67
+ }
68
+ },
69
+ };
70
+ }
71
+ async function stashPush(cwd, message, includeUntracked, config) {
72
+ const args = ['stash', 'push'];
73
+ if (message) {
74
+ args.push('-m', message);
75
+ }
76
+ if (includeUntracked) {
77
+ args.push('-u');
78
+ }
79
+ const result = await execGitOrThrow(args, { cwd, timeout: config.timeout });
80
+ const created = !result.stdout.includes('No local changes to save');
81
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
82
+ success: true,
83
+ action: 'push',
84
+ created,
85
+ message: message ?? '',
86
+ summary: created ? 'Stashed changes' : 'No changes to stash',
87
+ })));
88
+ }
89
+ async function stashPop(cwd, index, config) {
90
+ await execGitOrThrow(['stash', 'pop', `stash@{${index}}`], { cwd, timeout: config.timeout });
91
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
92
+ success: true,
93
+ action: 'pop',
94
+ index,
95
+ summary: `Popped stash@{${index}}`,
96
+ })));
97
+ }
98
+ async function stashApply(cwd, index, config) {
99
+ await execGitOrThrow(['stash', 'apply', `stash@{${index}}`], { cwd, timeout: config.timeout });
100
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
101
+ success: true,
102
+ action: 'apply',
103
+ index,
104
+ summary: `Applied stash@{${index}}`,
105
+ })));
106
+ }
107
+ async function stashDrop(cwd, index, config) {
108
+ await execGitOrThrow(['stash', 'drop', `stash@{${index}}`], { cwd, timeout: config.timeout });
109
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
110
+ success: true,
111
+ action: 'drop',
112
+ index,
113
+ summary: `Dropped stash@{${index}}`,
114
+ })));
115
+ }
116
+ async function stashList(cwd, config) {
117
+ const result = await execGitOrThrow(['stash', 'list', '--format=%gd|%gs'], { cwd, timeout: config.timeout });
118
+ const entries = [];
119
+ for (const line of result.stdout.split('\n').filter(Boolean)) {
120
+ const [ref, message] = line.split('|');
121
+ if (!ref)
122
+ continue;
123
+ // Parse stash@{N}
124
+ const match = ref.match(/stash@\{(\d+)\}/);
125
+ const index = match ? parseInt(match[1] ?? '0', 10) : entries.length;
126
+ // Extract branch from message like "WIP on main: abc123 commit message"
127
+ const branchMatch = message?.match(/^(?:WIP )?on ([^:]+):/);
128
+ const branch = branchMatch?.[1] ?? '';
129
+ entries.push({
130
+ index,
131
+ message: message ?? '',
132
+ branch,
133
+ });
134
+ }
135
+ const listResult = { entries };
136
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
137
+ ...listResult,
138
+ summary: entries.length > 0 ? `${entries.length} stash(es)` : 'No stashes',
139
+ })));
140
+ }
141
+ async function stashShow(cwd, index, config) {
142
+ const result = await execGitOrThrow(['stash', 'show', '--stat', `stash@{${index}}`], { cwd, timeout: config.timeout });
143
+ return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
144
+ success: true,
145
+ action: 'show',
146
+ index,
147
+ stat: result.stdout,
148
+ summary: `stash@{${index}}: ${result.stdout.split('\n')[0] ?? ''}`,
149
+ })));
150
+ }
151
+ //# sourceMappingURL=stash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash.js","sourceRoot":"","sources":["../../src/tools/stash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,uBAAuB;QACpC,SAAS,EAAE,gBAAgB;QAC3B,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;QAC5B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,GAAG,EAAE;oBACH,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,mBAAmB;iBACjC;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,E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,YAAY,CAAC,CAAC,CAAC,YAAY;KAC3E,CAAC,CACH,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CACtB,GAAuB,EACvB,KAAa,EACb,MAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,KAAK,GAAG,CAAC,EAC/C,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CACjC,CAAC;IAEF,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM;QACd,KAAK;QACL,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,OAAO,EAAE,UAAU,KAAK,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;KACnE,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * source_control.status tool
3
+ *
4
+ * Get working tree status with structured output.
5
+ */
6
+ import type { AgencyTool } from '@generacy-ai/agency';
7
+ import type { GitPluginConfig } from '../config.js';
8
+ export declare function createStatusTool(config: GitPluginConfig): AgencyTool;
9
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAuCpE"}