@rxpm/forge-cli 0.0.1
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/.dockerignore +6 -0
- package/.prettierrc +9 -0
- package/AGENT_RULES.md +42 -0
- package/Dockerfile +32 -0
- package/README.md +117 -0
- package/REQUIREMENTS.md +233 -0
- package/assets/preview_explain.webp +0 -0
- package/dist/agent/loop.d.ts +6 -0
- package/dist/agent/loop.js +62 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +40 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/config/env.d.ts +9 -0
- package/dist/config/env.js +16 -0
- package/dist/config/env.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/provider.d.ts +4 -0
- package/dist/llm/provider.js +12 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/tools/code.d.ts +15 -0
- package/dist/tools/code.js +53 -0
- package/dist/tools/code.js.map +1 -0
- package/dist/tools/fs.d.ts +18 -0
- package/dist/tools/fs.js +70 -0
- package/dist/tools/fs.js.map +1 -0
- package/dist/tools/git.d.ts +15 -0
- package/dist/tools/git.js +61 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.js +22 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/shell.d.ts +9 -0
- package/dist/tools/shell.js +31 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/ui/activity.d.ts +49 -0
- package/dist/ui/activity.js +421 -0
- package/dist/ui/activity.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +10 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/logger2.d.ts +16 -0
- package/dist/utils/logger2.js +55 -0
- package/dist/utils/logger2.js.map +1 -0
- package/dist/utils/test-tools.d.ts +1 -0
- package/dist/utils/test-tools.js +31 -0
- package/dist/utils/test-tools.js.map +1 -0
- package/package.json +43 -0
- package/src/agent/loop.ts +68 -0
- package/src/cli/commands.ts +44 -0
- package/src/config/env.ts +17 -0
- package/src/index.ts +22 -0
- package/src/llm/provider.ts +13 -0
- package/src/tools/code.ts +53 -0
- package/src/tools/fs.ts +71 -0
- package/src/tools/git.ts +60 -0
- package/src/tools/index.ts +23 -0
- package/src/tools/shell.ts +32 -0
- package/src/ui/activity.ts +504 -0
- package/src/utils/logger.ts +10 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: code.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Code tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { tool } from 'ai';
|
|
9
|
+
import { execa } from 'execa';
|
|
10
|
+
/** Searches for a string in the codebase using grep. */
|
|
11
|
+
export const searchCodeTool = tool({
|
|
12
|
+
title: 'SearchCode',
|
|
13
|
+
description: 'Search for a string in the codebase using grep.',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
query: z.string().describe('The search query string.'),
|
|
16
|
+
}),
|
|
17
|
+
async execute({ query }) {
|
|
18
|
+
try {
|
|
19
|
+
// Use grep to search for the query string.
|
|
20
|
+
// -r: recursive, -n: show line numbers, -l: show only filenames (optional),
|
|
21
|
+
// -i: ignore case (optional), -E: extended regex
|
|
22
|
+
const { stdout } = await execa('grep', ['-rnE', query, '.', '--exclude-dir={node_modules,dist,.git}'], {
|
|
23
|
+
reject: false, // Don't throw if grep finds nothing (it exits with code 1)
|
|
24
|
+
});
|
|
25
|
+
return stdout || 'No matches found.';
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return `Error searching code: ${error.message}`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
/** Opens a file and reads specific line range. */
|
|
33
|
+
export const openFileLinesTool = tool({
|
|
34
|
+
title: 'OpenFileLines',
|
|
35
|
+
description: 'Open a file and read specific line range.',
|
|
36
|
+
inputSchema: z.object({
|
|
37
|
+
path: z.string().describe('The path to the file.'),
|
|
38
|
+
start: z.coerce.number().describe('The start line number (1-based).'),
|
|
39
|
+
end: z.coerce.number().describe('The end line number (inclusive).'),
|
|
40
|
+
}),
|
|
41
|
+
async execute({ path, start, end }) {
|
|
42
|
+
try {
|
|
43
|
+
const content = await fs.readFile(path, 'utf-8');
|
|
44
|
+
const lines = content.split('\n');
|
|
45
|
+
const slicedLines = lines.slice(Math.max(0, start - 1), end);
|
|
46
|
+
return slicedLines.join('\n');
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return `Error reading file lines: ${error.message}`;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/tools/code.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,iDAAiD;IAC9D,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACzD,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE;QACnB,IAAI,CAAC;YACD,2CAA2C;YAC3C,4EAA4E;YAC5E,iDAAiD;YACjD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,EAAE,CAAC;YAClB,OAAO,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC;QACxD,CAAC;IACL,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: fs.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: File system tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
/** Reads the contents of a file. */
|
|
7
|
+
export declare const readFileTool: import("ai").Tool<{
|
|
8
|
+
path: string;
|
|
9
|
+
}, string>;
|
|
10
|
+
/** Writes content to a file. */
|
|
11
|
+
export declare const writeFileTool: import("ai").Tool<{
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}, string>;
|
|
15
|
+
/** Lists files in a directory recursively. */
|
|
16
|
+
export declare const listFilesTool: import("ai").Tool<{
|
|
17
|
+
path: string;
|
|
18
|
+
}, string>;
|
package/dist/tools/fs.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: fs.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: File system tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { tool } from 'ai';
|
|
9
|
+
import { glob } from 'glob';
|
|
10
|
+
/** Reads the contents of a file. */
|
|
11
|
+
export const readFileTool = tool({
|
|
12
|
+
title: 'ReadFile',
|
|
13
|
+
description: 'Read the contents of a file. LIMIT file size (max 5000 lines per read).',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
path: z.string().describe('The path to the file to read.'),
|
|
16
|
+
}),
|
|
17
|
+
async execute({ path }) {
|
|
18
|
+
try {
|
|
19
|
+
const content = await fs.readFile(path, 'utf-8');
|
|
20
|
+
const lines = content.split('\n');
|
|
21
|
+
if (lines.length > 5000) {
|
|
22
|
+
return `File too large: ${lines.length} lines. Max 5000 lines.`;
|
|
23
|
+
}
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return `Error reading file: ${error.message}`;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
/** Writes content to a file. */
|
|
32
|
+
export const writeFileTool = tool({
|
|
33
|
+
title: 'WriteFile',
|
|
34
|
+
description: 'Write content to a file. Justify large rewrites.',
|
|
35
|
+
inputSchema: z.object({
|
|
36
|
+
path: z.string().describe('The path to the file to write.'),
|
|
37
|
+
content: z.string().describe('The content to write to the file.'),
|
|
38
|
+
}),
|
|
39
|
+
async execute({ path, content }) {
|
|
40
|
+
try {
|
|
41
|
+
await fs.writeFile(path, content, 'utf-8');
|
|
42
|
+
return `Successfully wrote to ${path}`;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return `Error writing file: ${error.message}`;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
/** Lists files in a directory recursively. */
|
|
50
|
+
export const listFilesTool = tool({
|
|
51
|
+
title: 'ListFiles',
|
|
52
|
+
description: 'List files in a directory recursively.',
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
path: z.string().describe('The directory path to list files from. Defaults to ".".').default('.'),
|
|
55
|
+
}),
|
|
56
|
+
async execute({ path }) {
|
|
57
|
+
try {
|
|
58
|
+
const files = await glob('**/*', {
|
|
59
|
+
cwd: path,
|
|
60
|
+
nodir: true,
|
|
61
|
+
ignore: ['node_modules/**', 'dist/**', '.git/**', '.gitignore'],
|
|
62
|
+
});
|
|
63
|
+
return files.join('\n');
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return `Error listing files: ${error.message}`;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/tools/fs.ts"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+
*/
|
|
6
|
+
/** Checks the git status of the project. */
|
|
7
|
+
export declare const gitStatusTool: import("ai").Tool<Record<string, never>, string>;
|
|
8
|
+
/** Shows git diff for staged and unstaged changes. */
|
|
9
|
+
export declare const gitDiffTool: import("ai").Tool<{
|
|
10
|
+
staged: boolean;
|
|
11
|
+
}, string>;
|
|
12
|
+
/** Commits staged changes to git with a message. */
|
|
13
|
+
export declare const gitCommitTool: import("ai").Tool<{
|
|
14
|
+
message: string;
|
|
15
|
+
}, string>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: git.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Git tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { tool } from 'ai';
|
|
8
|
+
import { execa } from 'execa';
|
|
9
|
+
/** Checks the git status of the project. */
|
|
10
|
+
export const gitStatusTool = tool({
|
|
11
|
+
title: 'GitStatus',
|
|
12
|
+
description: 'Check the git status of the project.',
|
|
13
|
+
inputSchema: z.object({}),
|
|
14
|
+
async execute() {
|
|
15
|
+
try {
|
|
16
|
+
const { stdout } = await execa('git', ['status']);
|
|
17
|
+
return stdout || 'No output from git status.';
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return `Error checking git status: ${error.message}`;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
/** Shows git diff for staged and unstaged changes. */
|
|
25
|
+
export const gitDiffTool = tool({
|
|
26
|
+
title: 'GitDiff',
|
|
27
|
+
description: 'Show git diff for staged and unstaged changes.',
|
|
28
|
+
inputSchema: z.object({
|
|
29
|
+
staged: z.boolean().optional().describe('Show staged changes only.').default(false),
|
|
30
|
+
}),
|
|
31
|
+
async execute({ staged }) {
|
|
32
|
+
try {
|
|
33
|
+
const args = ['diff'];
|
|
34
|
+
if (staged)
|
|
35
|
+
args.push('--staged');
|
|
36
|
+
const { stdout } = await execa('git', args);
|
|
37
|
+
return stdout || 'No differences found.';
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return `Error showing git diff: ${error.message}`;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
/** Commits staged changes to git with a message. */
|
|
45
|
+
export const gitCommitTool = tool({
|
|
46
|
+
title: 'GitCommit',
|
|
47
|
+
description: 'Commit staged changes to git with a message.',
|
|
48
|
+
inputSchema: z.object({
|
|
49
|
+
message: z.string().describe('The commit message.'),
|
|
50
|
+
}),
|
|
51
|
+
async execute({ message }) {
|
|
52
|
+
try {
|
|
53
|
+
const { stdout } = await execa('git', ['commit', '-m', message]);
|
|
54
|
+
return stdout || 'Committed changes.';
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return `Error committing changes: ${error.message}`;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/tools/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,sCAAsC;IACnD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,KAAK,CAAC,OAAO;QACT,IAAI,CAAC;YACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClD,OAAO,MAAM,IAAI,4BAA4B,CAAC;QAClD,CAAC;QAAC,OAAO,K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AE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;YACjE,OAAO,MAAM,IAAI,oBAAoB,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC;QACxD,CAAC;IACL,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: index.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Index of all tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
export declare const tools: {
|
|
7
|
+
read_file: import("ai").Tool<{
|
|
8
|
+
path: string;
|
|
9
|
+
}, string>;
|
|
10
|
+
write_file: import("ai").Tool<{
|
|
11
|
+
path: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}, string>;
|
|
14
|
+
list_files: import("ai").Tool<{
|
|
15
|
+
path: string;
|
|
16
|
+
}, string>;
|
|
17
|
+
search_code: import("ai").Tool<{
|
|
18
|
+
query: string;
|
|
19
|
+
}, string>;
|
|
20
|
+
open_file_lines: import("ai").Tool<{
|
|
21
|
+
path: string;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
}, string>;
|
|
25
|
+
run_command: import("ai").Tool<{
|
|
26
|
+
command: string;
|
|
27
|
+
}, string>;
|
|
28
|
+
git_status: import("ai").Tool<Record<string, never>, string>;
|
|
29
|
+
git_diff: import("ai").Tool<{
|
|
30
|
+
staged: boolean;
|
|
31
|
+
}, string>;
|
|
32
|
+
git_commit: import("ai").Tool<{
|
|
33
|
+
message: string;
|
|
34
|
+
}, string>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: index.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Index of all tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileTool, writeFileTool, listFilesTool } from './fs.js';
|
|
7
|
+
import { searchCodeTool, openFileLinesTool } from './code.js';
|
|
8
|
+
import { runCommandTool } from './shell.js';
|
|
9
|
+
import { gitStatusTool, gitDiffTool, gitCommitTool } from './git.js';
|
|
10
|
+
// Export all tools
|
|
11
|
+
export const tools = {
|
|
12
|
+
read_file: readFileTool,
|
|
13
|
+
write_file: writeFileTool,
|
|
14
|
+
list_files: listFilesTool,
|
|
15
|
+
search_code: searchCodeTool,
|
|
16
|
+
open_file_lines: openFileLinesTool,
|
|
17
|
+
run_command: runCommandTool,
|
|
18
|
+
git_status: gitStatusTool,
|
|
19
|
+
git_diff: gitDiffTool,
|
|
20
|
+
git_commit: gitCommitTool,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAErE,mBAAmB;AACnB,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,cAAc;IAC3B,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,cAAc;IAC3B,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,WAAW;IACrB,UAAU,EAAE,aAAa;CAC5B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: shell.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Shell tools for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { tool } from 'ai';
|
|
8
|
+
import { execa } from 'execa';
|
|
9
|
+
/** Runs a shell command in the project root. */
|
|
10
|
+
export const runCommandTool = tool({
|
|
11
|
+
title: 'RunCommand',
|
|
12
|
+
description: 'Run a shell command in the project root. DO NOT run destructive commands without confirmation.',
|
|
13
|
+
inputSchema: z.object({
|
|
14
|
+
command: z.string().describe('The shell command to execute.'),
|
|
15
|
+
}),
|
|
16
|
+
async execute({ command }) {
|
|
17
|
+
// Simple safety check for common destructive commands
|
|
18
|
+
const destructive = ['rm -rf', 'sudo', 'chmod', 'chown', 'mkfs', 'dd'];
|
|
19
|
+
if (destructive.some((d) => command.includes(d))) {
|
|
20
|
+
return `Error: Command "${command}" is considered potentially destructive and requires manual execution or explicit user confirmation.`;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const { stdout, stderr } = await execa(command, { shell: true });
|
|
24
|
+
return stdout || stderr || 'Command executed successfully (no output).';
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return `Error executing command: ${error.message}\n${error.stderr || ''}`;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/tools/shell.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,gDAAgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,gGAAgG;IAC7G,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;KAChE,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE;QACrB,sDAAsD;QACtD,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACvE,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/C,OAAO,mBAAmB,OAAO,sGAAsG,CAAC;QAC5I,CAAC;QAED,IAAI,CAAC;YACD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACjE,OAAO,MAAM,IAAI,MAAM,IAAI,4CAA4C,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO,4BAA4B,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAC9E,CAAC;IACL,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File: activity.ts
|
|
3
|
+
* Author: Rajat Sharma
|
|
4
|
+
* Description: Gemini-inspired terminal activity display for the AI agent.
|
|
5
|
+
*/
|
|
6
|
+
interface StepToolCall {
|
|
7
|
+
toolName: string;
|
|
8
|
+
toolCallId: string;
|
|
9
|
+
args?: Record<string, any>;
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
interface StepToolResult {
|
|
13
|
+
toolName: string;
|
|
14
|
+
toolCallId: string;
|
|
15
|
+
output?: any;
|
|
16
|
+
result?: any;
|
|
17
|
+
title?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class ActivityDisplay {
|
|
20
|
+
private spinner;
|
|
21
|
+
private stepCount;
|
|
22
|
+
private toolCalls;
|
|
23
|
+
private startTime;
|
|
24
|
+
private readonly branch;
|
|
25
|
+
startThinking(): void;
|
|
26
|
+
stopThinking(): void;
|
|
27
|
+
onStepStart(): void;
|
|
28
|
+
onToolCall(call: {
|
|
29
|
+
toolName: string;
|
|
30
|
+
toolCallId: string;
|
|
31
|
+
args: Record<string, any>;
|
|
32
|
+
}): void;
|
|
33
|
+
onToolResult(result: {
|
|
34
|
+
toolName: string;
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
output?: any;
|
|
37
|
+
result?: any;
|
|
38
|
+
}): void;
|
|
39
|
+
onText(text: string): void;
|
|
40
|
+
onStepFinish(step: {
|
|
41
|
+
toolCalls: StepToolCall[];
|
|
42
|
+
toolResults: StepToolResult[];
|
|
43
|
+
text?: string;
|
|
44
|
+
}): void;
|
|
45
|
+
printSummary(status: 'success' | 'error', message?: string): void;
|
|
46
|
+
private renderFooter;
|
|
47
|
+
static printBanner(task: string): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|