@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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network error for remote connection failures
|
|
3
|
+
*/
|
|
4
|
+
import { GitError } from './git-error.js';
|
|
5
|
+
export class NetworkError extends GitError {
|
|
6
|
+
type = 'network';
|
|
7
|
+
/** Remote that failed */
|
|
8
|
+
remote;
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = 'NetworkError';
|
|
12
|
+
this.remote = options.remote;
|
|
13
|
+
}
|
|
14
|
+
toSafeMessage() {
|
|
15
|
+
if (this.remote) {
|
|
16
|
+
return `Network error connecting to remote '${this.remote}'`;
|
|
17
|
+
}
|
|
18
|
+
return 'Network error. Please check your connection.';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Patterns that indicate a network error
|
|
23
|
+
*/
|
|
24
|
+
export const NETWORK_ERROR_PATTERNS = [
|
|
25
|
+
/could not resolve host/i,
|
|
26
|
+
/connection refused/i,
|
|
27
|
+
/connection timed out/i,
|
|
28
|
+
/network is unreachable/i,
|
|
29
|
+
/unable to access/i,
|
|
30
|
+
/couldn't connect to server/i,
|
|
31
|
+
/failed to connect/i,
|
|
32
|
+
/no route to host/i,
|
|
33
|
+
/connection reset/i,
|
|
34
|
+
/ssl.*error/i,
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Check if an error message indicates a network error
|
|
38
|
+
*/
|
|
39
|
+
export function isNetworkError(stderr) {
|
|
40
|
+
return NETWORK_ERROR_PATTERNS.some((pattern) => pattern.test(stderr));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extract remote name from error message if present
|
|
44
|
+
*/
|
|
45
|
+
export function extractRemote(stderr) {
|
|
46
|
+
// Try to extract remote from common git error formats
|
|
47
|
+
const patterns = [
|
|
48
|
+
/fatal: unable to access '([^']+)'/,
|
|
49
|
+
/fatal: repository '([^']+)' not found/,
|
|
50
|
+
/remote: ([^\s]+)/,
|
|
51
|
+
];
|
|
52
|
+
for (const pattern of patterns) {
|
|
53
|
+
const match = stderr.match(pattern);
|
|
54
|
+
if (match?.[1]) {
|
|
55
|
+
// Try to extract host from URL
|
|
56
|
+
try {
|
|
57
|
+
const url = new URL(match[1]);
|
|
58
|
+
return url.hostname;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return match[1];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=network-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-error.js","sourceRoot":"","sources":["../../src/errors/network-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAA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,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generacy-ai/agency-plugin-git
|
|
3
|
+
*
|
|
4
|
+
* Git operations plugin providing source control tools for agents.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - source_control.status - Get working tree status
|
|
8
|
+
* - source_control.diff - Show changes
|
|
9
|
+
* - source_control.log - View commit history
|
|
10
|
+
* - source_control.commit - Create a commit
|
|
11
|
+
* - source_control.push - Push to remote
|
|
12
|
+
* - source_control.pull - Pull from remote
|
|
13
|
+
* - source_control.checkout - Switch branches or restore files
|
|
14
|
+
* - source_control.branch - Create, list, or delete branches
|
|
15
|
+
* - source_control.stash - Stash/unstash changes
|
|
16
|
+
* - source_control.blame - Show line-by-line authorship
|
|
17
|
+
* - source_control.merge - Merge branches
|
|
18
|
+
* - source_control.rebase - Rebase current branch
|
|
19
|
+
*/
|
|
20
|
+
export { GitPlugin, createGitPlugin } from './plugin.js';
|
|
21
|
+
export { type GitPluginConfig, DEFAULT_CONFIG, resolveConfig } from './config.js';
|
|
22
|
+
export type { BaseToolParams, ExecGitOptions, ExecGitResult, StatusParams, StatusResult, FileChange, DiffParams, DiffResult, DiffFileStat, LogParams, LogResult, CommitInfo, CommitParams, CommitResult, PushParams, PullParams, CheckoutParams, BranchParams, BranchInfo, BranchListResult, StashParams, StashEntry, StashListResult, BlameParams, BlameResult, BlameLine, MergeParams, RebaseParams, ConflictInfo, ForcePushEscalation, EscalationResponse, } from './types.js';
|
|
23
|
+
export { GitError, AuthError, NetworkError, ConflictError, DetachedHeadError, } from './errors/index.js';
|
|
24
|
+
import { GitPlugin } from './plugin.js';
|
|
25
|
+
export default GitPlugin;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,KAAK,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGlF,YAAY,EAEV,cAAc,EACd,cAAc,EACd,aAAa,EAEb,YAAY,EACZ,YAAY,EACZ,UAAU,EAEV,UAAU,EACV,UAAU,EACV,YAAY,EAEZ,SAAS,EACT,SAAS,EACT,UAAU,EAEV,YAAY,EACZ,YAAY,EAEZ,UAAU,EAEV,UAAU,EAEV,cAAc,EAEd,YAAY,EACZ,UAAU,EACV,gBAAgB,EAEhB,WAAW,EACX,UAAU,EACV,eAAe,EAEf,WAAW,EACX,WAAW,EACX,SAAS,EAET,WAAW,EAEX,YAAY,EAEZ,YAAY,EAEZ,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generacy-ai/agency-plugin-git
|
|
3
|
+
*
|
|
4
|
+
* Git operations plugin providing source control tools for agents.
|
|
5
|
+
*
|
|
6
|
+
* Tools:
|
|
7
|
+
* - source_control.status - Get working tree status
|
|
8
|
+
* - source_control.diff - Show changes
|
|
9
|
+
* - source_control.log - View commit history
|
|
10
|
+
* - source_control.commit - Create a commit
|
|
11
|
+
* - source_control.push - Push to remote
|
|
12
|
+
* - source_control.pull - Pull from remote
|
|
13
|
+
* - source_control.checkout - Switch branches or restore files
|
|
14
|
+
* - source_control.branch - Create, list, or delete branches
|
|
15
|
+
* - source_control.stash - Stash/unstash changes
|
|
16
|
+
* - source_control.blame - Show line-by-line authorship
|
|
17
|
+
* - source_control.merge - Merge branches
|
|
18
|
+
* - source_control.rebase - Rebase current branch
|
|
19
|
+
*/
|
|
20
|
+
// Plugin
|
|
21
|
+
export { GitPlugin, createGitPlugin } from './plugin.js';
|
|
22
|
+
// Configuration
|
|
23
|
+
export { DEFAULT_CONFIG, resolveConfig } from './config.js';
|
|
24
|
+
// Errors
|
|
25
|
+
export { GitError, AuthError, NetworkError, ConflictError, DetachedHeadError, } from './errors/index.js';
|
|
26
|
+
// Default export for plugin
|
|
27
|
+
import { GitPlugin } from './plugin.js';
|
|
28
|
+
export default GitPlugin;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzD,gBAAgB;AAChB,OAAO,EAAwB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoDlF,SAAS;AACT,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,eAAe,SAAS,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitPlugin class implementing AgencyPlugin interface
|
|
3
|
+
*
|
|
4
|
+
* Provides 12 source control tools for git operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgencyPlugin, PluginManifest, AgencyCoreAPI } from '@generacy-ai/agency';
|
|
7
|
+
/**
|
|
8
|
+
* Git plugin for Agency
|
|
9
|
+
*
|
|
10
|
+
* Provides source control operations with:
|
|
11
|
+
* - Structured output (not raw git output)
|
|
12
|
+
* - Categorized error handling
|
|
13
|
+
* - Mode affiliations (research, coding, review)
|
|
14
|
+
* - Humancy escalation for destructive operations
|
|
15
|
+
*/
|
|
16
|
+
export declare class GitPlugin implements AgencyPlugin {
|
|
17
|
+
readonly manifest: PluginManifest;
|
|
18
|
+
private config;
|
|
19
|
+
private core;
|
|
20
|
+
initialize(core: AgencyCoreAPI): Promise<void>;
|
|
21
|
+
shutdown(): Promise<void>;
|
|
22
|
+
onModeChange?(_mode: string): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a new GitPlugin instance
|
|
26
|
+
*/
|
|
27
|
+
export declare function createGitPlugin(): GitPlugin;
|
|
28
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACd,MAAM,qBAAqB,CAAC;AAI7B;;;;;;;;GAQG;AACH,qBAAa,SAAU,YAAW,YAAY;IAC5C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CA2B/B;IAEF,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,IAAI,CAA8B;IAEpC,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAU/B,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAInC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitPlugin class implementing AgencyPlugin interface
|
|
3
|
+
*
|
|
4
|
+
* Provides 12 source control tools for git operations.
|
|
5
|
+
*/
|
|
6
|
+
import { DEFAULT_CONFIG, resolveConfig } from './config.js';
|
|
7
|
+
import { createTools } from './tools/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Git plugin for Agency
|
|
10
|
+
*
|
|
11
|
+
* Provides source control operations with:
|
|
12
|
+
* - Structured output (not raw git output)
|
|
13
|
+
* - Categorized error handling
|
|
14
|
+
* - Mode affiliations (research, coding, review)
|
|
15
|
+
* - Humancy escalation for destructive operations
|
|
16
|
+
*/
|
|
17
|
+
export class GitPlugin {
|
|
18
|
+
manifest = {
|
|
19
|
+
id: '@generacy-ai/agency-plugin-git',
|
|
20
|
+
name: 'Git Plugin',
|
|
21
|
+
version: '0.0.0',
|
|
22
|
+
description: 'Source control operations for agents',
|
|
23
|
+
main: './dist/index.js',
|
|
24
|
+
types: './dist/index.d.ts',
|
|
25
|
+
dependencies: [],
|
|
26
|
+
tools: [
|
|
27
|
+
'source_control.status',
|
|
28
|
+
'source_control.diff',
|
|
29
|
+
'source_control.log',
|
|
30
|
+
'source_control.commit',
|
|
31
|
+
'source_control.push',
|
|
32
|
+
'source_control.pull',
|
|
33
|
+
'source_control.checkout',
|
|
34
|
+
'source_control.branch',
|
|
35
|
+
'source_control.stash',
|
|
36
|
+
'source_control.blame',
|
|
37
|
+
'source_control.merge',
|
|
38
|
+
'source_control.rebase',
|
|
39
|
+
],
|
|
40
|
+
modes: ['research', 'coding', 'review'],
|
|
41
|
+
critical: false,
|
|
42
|
+
provides: [{ facet: 'SourceControl', qualifier: 'git', priority: 10 }],
|
|
43
|
+
requires: [],
|
|
44
|
+
uses: [],
|
|
45
|
+
};
|
|
46
|
+
config = DEFAULT_CONFIG;
|
|
47
|
+
core = null;
|
|
48
|
+
async initialize(core) {
|
|
49
|
+
this.core = core;
|
|
50
|
+
// Load plugin configuration
|
|
51
|
+
const userConfig = core.getConfig('plugins.git');
|
|
52
|
+
this.config = resolveConfig(userConfig);
|
|
53
|
+
// Create and register all tools
|
|
54
|
+
const tools = createTools(this.config, core);
|
|
55
|
+
for (const tool of tools) {
|
|
56
|
+
core.registerTool(tool);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async shutdown() {
|
|
60
|
+
// Unregister all tools
|
|
61
|
+
if (this.core) {
|
|
62
|
+
for (const toolName of this.manifest.tools ?? []) {
|
|
63
|
+
this.core.unregisterTool(toolName);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.core = null;
|
|
67
|
+
}
|
|
68
|
+
onModeChange(_mode) {
|
|
69
|
+
// Tools automatically filter based on mode affiliations
|
|
70
|
+
// No additional action needed
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a new GitPlugin instance
|
|
75
|
+
*/
|
|
76
|
+
export function createGitPlugin() {
|
|
77
|
+
return new GitPlugin();
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EAAwB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,OAAO,SAAS;IACX,QAAQ,GAAmB;QAClC,EAAE,EAAE,gCAAgC;QACpC,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,sCAAsC;QACnD,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,mBAAmB;QAC1B,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE;YACL,uBAAuB;YACv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AY,CAAE,KAAa;QACzB,wDAAwD;QACxD,8BAA8B;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.blame tool
|
|
3
|
+
*
|
|
4
|
+
* Show line-by-line authorship.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgencyTool } from '@generacy-ai/agency';
|
|
7
|
+
import type { GitPluginConfig } from '../config.js';
|
|
8
|
+
export declare function createBlameTool(config: GitPluginConfig): AgencyTool;
|
|
9
|
+
//# sourceMappingURL=blame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blame.d.ts","sourceRoot":"","sources":["../../src/tools/blame.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,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAyEnE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.blame tool
|
|
3
|
+
*
|
|
4
|
+
* Show line-by-line authorship.
|
|
5
|
+
*/
|
|
6
|
+
import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
|
|
7
|
+
import { execGitOrThrow } from '../utils/exec-git.js';
|
|
8
|
+
import { parseBlame, formatBlame } from '../utils/parse-blame.js';
|
|
9
|
+
export function createBlameTool(config) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'source_control.blame',
|
|
12
|
+
description: 'Show line-by-line authorship',
|
|
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',
|
|
22
|
+
},
|
|
23
|
+
file: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'File to blame (required)',
|
|
26
|
+
},
|
|
27
|
+
lines: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
items: { type: 'number' },
|
|
30
|
+
description: 'Line range [start, end]',
|
|
31
|
+
},
|
|
32
|
+
rev: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Revision to blame from (default: HEAD)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ['file'],
|
|
38
|
+
},
|
|
39
|
+
async execute(params) {
|
|
40
|
+
const { cwd, file, lines, rev } = params || {};
|
|
41
|
+
if (!file) {
|
|
42
|
+
return terseToMcpToolResult(TerseOutput.failure('file parameter is required'));
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const args = ['blame', '--porcelain'];
|
|
46
|
+
if (lines && lines.length === 2) {
|
|
47
|
+
args.push(`-L${lines[0]},${lines[1]}`);
|
|
48
|
+
}
|
|
49
|
+
if (rev) {
|
|
50
|
+
args.push(rev);
|
|
51
|
+
}
|
|
52
|
+
args.push('--', file);
|
|
53
|
+
const result = await execGitOrThrow(args, { cwd, timeout: config.timeout });
|
|
54
|
+
const blameResult = parseBlame(result.stdout);
|
|
55
|
+
const summary = formatBlame(blameResult, false);
|
|
56
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
57
|
+
...blameResult,
|
|
58
|
+
summary,
|
|
59
|
+
})));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=blame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bl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I,GAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;gBAEhD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAChC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACzC,CAAC;gBAED,IAAI,GAAG,EAAE,CAAC;oBACR,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACjB,CAAC;gBAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEtB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;gBAE5E,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC9C,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBAEhD,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;oBACb,GAAG,WAAW;oBACd,OAAO;iBACR,CAAC,CACH,CACF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,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.branch tool
|
|
3
|
+
*
|
|
4
|
+
* Create, list, or delete branches.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgencyTool } from '@generacy-ai/agency';
|
|
7
|
+
import type { GitPluginConfig } from '../config.js';
|
|
8
|
+
export declare function createBranchTool(config: GitPluginConfig): AgencyTool;
|
|
9
|
+
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/tools/branch.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,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAgGpE"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.branch tool
|
|
3
|
+
*
|
|
4
|
+
* Create, list, or delete branches.
|
|
5
|
+
*/
|
|
6
|
+
import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
|
|
7
|
+
import { execGitOrThrow } from '../utils/exec-git.js';
|
|
8
|
+
export function createBranchTool(config) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'source_control.branch',
|
|
11
|
+
description: 'Create, list, or delete branches',
|
|
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: ['list', 'create', 'delete', 'rename'],
|
|
25
|
+
description: 'Action to perform (required)',
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Branch name (required for create/delete/rename)',
|
|
30
|
+
},
|
|
31
|
+
newName: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'New name (for rename)',
|
|
34
|
+
},
|
|
35
|
+
force: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
description: 'Force delete unmerged branch',
|
|
38
|
+
},
|
|
39
|
+
all: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
description: 'Include remote branches in list',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['action'],
|
|
45
|
+
},
|
|
46
|
+
async execute(params) {
|
|
47
|
+
const { cwd, action, name, newName, force = false, all = false, } = params || {};
|
|
48
|
+
if (!action) {
|
|
49
|
+
return terseToMcpToolResult(TerseOutput.failure('action parameter is required'));
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
switch (action) {
|
|
53
|
+
case 'list':
|
|
54
|
+
return await listBranches(cwd, all, config);
|
|
55
|
+
case 'create':
|
|
56
|
+
if (!name) {
|
|
57
|
+
return terseToMcpToolResult(TerseOutput.failure('name parameter is required for create'));
|
|
58
|
+
}
|
|
59
|
+
return await createBranch(cwd, name, config);
|
|
60
|
+
case 'delete':
|
|
61
|
+
if (!name) {
|
|
62
|
+
return terseToMcpToolResult(TerseOutput.failure('name parameter is required for delete'));
|
|
63
|
+
}
|
|
64
|
+
return await deleteBranch(cwd, name, force, config);
|
|
65
|
+
case 'rename':
|
|
66
|
+
if (!name || !newName) {
|
|
67
|
+
return terseToMcpToolResult(TerseOutput.failure('name and newName parameters are required for rename'));
|
|
68
|
+
}
|
|
69
|
+
return await renameBranch(cwd, name, newName, config);
|
|
70
|
+
default:
|
|
71
|
+
return terseToMcpToolResult(TerseOutput.failure(`Unknown action: ${action}`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function listBranches(cwd, all, config) {
|
|
81
|
+
const args = ['branch', '--format=%(refname:short)|%(objectname:short)|%(upstream:short)|%(HEAD)'];
|
|
82
|
+
if (all) {
|
|
83
|
+
args.push('-a');
|
|
84
|
+
}
|
|
85
|
+
const result = await execGitOrThrow(args, { cwd, timeout: config.timeout });
|
|
86
|
+
const branches = [];
|
|
87
|
+
let current = '';
|
|
88
|
+
for (const line of result.stdout.split('\n').filter(Boolean)) {
|
|
89
|
+
const [name, commit, upstream, head] = line.split('|');
|
|
90
|
+
if (!name || !commit)
|
|
91
|
+
continue;
|
|
92
|
+
const isCurrent = head === '*';
|
|
93
|
+
const isRemote = name.startsWith('remotes/') || name.includes('/');
|
|
94
|
+
if (isCurrent) {
|
|
95
|
+
current = name;
|
|
96
|
+
}
|
|
97
|
+
branches.push({
|
|
98
|
+
name,
|
|
99
|
+
current: isCurrent,
|
|
100
|
+
remote: isRemote,
|
|
101
|
+
upstream: upstream || undefined,
|
|
102
|
+
commit,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const listResult = { branches, current };
|
|
106
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
107
|
+
...listResult,
|
|
108
|
+
summary: `${branches.length} branch(es), current: ${current}`,
|
|
109
|
+
})));
|
|
110
|
+
}
|
|
111
|
+
async function createBranch(cwd, name, config) {
|
|
112
|
+
await execGitOrThrow(['branch', name], { cwd, timeout: config.timeout });
|
|
113
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
114
|
+
success: true,
|
|
115
|
+
action: 'create',
|
|
116
|
+
name,
|
|
117
|
+
summary: `Created branch '${name}'`,
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
async function deleteBranch(cwd, name, force, config) {
|
|
121
|
+
const args = ['branch', force ? '-D' : '-d', name];
|
|
122
|
+
await execGitOrThrow(args, { cwd, timeout: config.timeout });
|
|
123
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
124
|
+
success: true,
|
|
125
|
+
action: 'delete',
|
|
126
|
+
name,
|
|
127
|
+
force,
|
|
128
|
+
summary: `Deleted branch '${name}'`,
|
|
129
|
+
})));
|
|
130
|
+
}
|
|
131
|
+
async function renameBranch(cwd, oldName, newName, config) {
|
|
132
|
+
await execGitOrThrow(['branch', '-m', oldName, newName], { cwd, timeout: config.timeout });
|
|
133
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
134
|
+
success: true,
|
|
135
|
+
action: 'rename',
|
|
136
|
+
oldName,
|
|
137
|
+
newName,
|
|
138
|
+
summary: `Renamed branch '${oldName}' to '${newName}'`,
|
|
139
|
+
})));
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/tools/branch.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,gBAAgB,CAAC,MAAuB;IACtD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,kCAAkC;QAC/C,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,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;oBAC5C,WAAW,EAAE,8BAA8B;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iDAAiD;iBAC/D;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uBAAuB;iBACrC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EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAE7D,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,QAAQ;QAChB,IAAI;QACJ,KAAK;QACL,OAAO,EAAE,mBAAmB,IAAI,GAAG;KACpC,CAAC,CACH,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,GAAuB,EACvB,OAAe,EACf,OAAe,EACf,MAAuB;IAEvB,MAAM,cAAc,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAE3F,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,QAAQ;QAChB,OAAO;QACP,OAAO;QACP,OAAO,EAAE,mBAAmB,OAAO,SAAS,OAAO,GAAG;KACvD,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.checkout tool
|
|
3
|
+
*
|
|
4
|
+
* Switch branches or restore files.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgencyTool } from '@generacy-ai/agency';
|
|
7
|
+
import type { GitPluginConfig } from '../config.js';
|
|
8
|
+
export declare function createCheckoutTool(config: GitPluginConfig): AgencyTool;
|
|
9
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/tools/checkout.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,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAiHtE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* source_control.checkout tool
|
|
3
|
+
*
|
|
4
|
+
* Switch branches or restore files.
|
|
5
|
+
*/
|
|
6
|
+
import { TerseOutput, terseToMcpToolResult } from '@generacy-ai/agency';
|
|
7
|
+
import { execGitOrThrow, execGit } from '../utils/exec-git.js';
|
|
8
|
+
export function createCheckoutTool(config) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'source_control.checkout',
|
|
11
|
+
description: 'Switch branches or restore files',
|
|
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
|
+
ref: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'Branch, commit, or file path to checkout (required)',
|
|
25
|
+
},
|
|
26
|
+
create: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description: 'Create new branch',
|
|
29
|
+
},
|
|
30
|
+
force: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
description: 'Force checkout (discard local changes)',
|
|
33
|
+
},
|
|
34
|
+
files: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
items: { type: 'string' },
|
|
37
|
+
description: 'Checkout specific files only',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ['ref'],
|
|
41
|
+
},
|
|
42
|
+
async execute(params) {
|
|
43
|
+
const { cwd, ref, create = false, force = false, files, } = params || {};
|
|
44
|
+
if (!ref) {
|
|
45
|
+
return terseToMcpToolResult(TerseOutput.failure('ref parameter is required'));
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const args = ['checkout'];
|
|
49
|
+
if (create) {
|
|
50
|
+
args.push('-b');
|
|
51
|
+
}
|
|
52
|
+
if (force) {
|
|
53
|
+
args.push('-f');
|
|
54
|
+
}
|
|
55
|
+
args.push(ref);
|
|
56
|
+
if (files && files.length > 0) {
|
|
57
|
+
args.push('--', ...files);
|
|
58
|
+
}
|
|
59
|
+
await execGitOrThrow(args, { cwd, timeout: config.timeout });
|
|
60
|
+
// Get current state
|
|
61
|
+
const branchResult = await execGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd, timeout: config.timeout });
|
|
62
|
+
const currentBranch = branchResult.stdout.trim();
|
|
63
|
+
const isDetached = currentBranch === 'HEAD';
|
|
64
|
+
let summary;
|
|
65
|
+
if (files && files.length > 0) {
|
|
66
|
+
summary = `Restored ${files.length} file(s) from ${ref}`;
|
|
67
|
+
}
|
|
68
|
+
else if (create) {
|
|
69
|
+
summary = `Created and switched to branch '${ref}'`;
|
|
70
|
+
}
|
|
71
|
+
else if (isDetached) {
|
|
72
|
+
const hashResult = await execGit(['rev-parse', '--short', 'HEAD'], { cwd, timeout: config.timeout });
|
|
73
|
+
summary = `HEAD detached at ${hashResult.stdout.trim()}`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
summary = `Switched to branch '${currentBranch}'`;
|
|
77
|
+
}
|
|
78
|
+
return terseToMcpToolResult(TerseOutput.success(JSON.stringify({
|
|
79
|
+
success: true,
|
|
80
|
+
ref,
|
|
81
|
+
branch: isDetached ? null : currentBranch,
|
|
82
|
+
detached: isDetached,
|
|
83
|
+
created: create,
|
|
84
|
+
files: files ?? [],
|
|
85
|
+
summary,
|
|
86
|
+
})));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return terseToMcpToolResult(TerseOutput.failure(error instanceof Error ? error : String(error)));
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/tools/checkout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,UAAU,kBAAkB,CAAC,MAAuB;IACxD,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,kCAAkC;QAC/C,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,GAAG,EAAE;oBACH,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qDAAqD;iBACnE;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,mBAAmB;iBACjC;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,wCAAwC;iBACtD;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,8BAA8B;iBAC5C;aACF;YACD,QAAQ,EAAE,CAAC,KAAK,CAAC;SAClB;QAED,KAAK,CAAC,OAAO,CAAC,MAAe;YAC3B,MAAM,EACJ,GAAG,EACH,GAAG,EACH,MAAM,GAAG,KAAK,EACd,KAAK,GAAG,KAAK,EACb,KAAK,GACN,GAAI,MAAyB,IAAI,EAAE,CAAC;YAErC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,OAAO,oBAAoB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GAAG,MAAM,OAAO,CAC9B,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,EAChC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CACjC,CAAC;oBACF,OAAO,GAAG,oBAAoB,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC3D,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,uBAAuB,aAAa,GAAG,CAAC;gBACpD,CAAC;gBAED,OAAO,oBAAoB,CACzB,WAAW,CAAC,OAAO,CACjB,IAAI,CAAC,SAAS,CAAC;oBACb,OAAO,EAAE,IAAI;oBACb,GAAG;oBACH,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa;oBACzC,QAAQ,EAAE,UAAU;oBACpB,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,KAAK,IAAI,EAAE;oBAClB,OAAO;iBACR,CAAC,CACH,CACF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,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.commit tool
|
|
3
|
+
*
|
|
4
|
+
* Create a commit with structured output.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgencyTool } from '@generacy-ai/agency';
|
|
7
|
+
import type { GitPluginConfig } from '../config.js';
|
|
8
|
+
export declare function createCommitTool(config: GitPluginConfig): AgencyTool;
|
|
9
|
+
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/tools/commit.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,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAkHpE"}
|