@nehanahmed/forge 0.1.0
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 +21 -0
- package/README.MD +114 -0
- package/dist/cli/agent-cli.d.ts +29 -0
- package/dist/cli/agent-cli.d.ts.map +1 -0
- package/dist/cli/agent-cli.js +78 -0
- package/dist/cli/agent-cli.js.map +1 -0
- package/dist/cli/app.d.ts +6 -0
- package/dist/cli/app.d.ts.map +1 -0
- package/dist/cli/app.js +176 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/client.d.ts +4 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +37 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/compaction.d.ts +9 -0
- package/dist/core/compaction.d.ts.map +1 -0
- package/dist/core/compaction.js +170 -0
- package/dist/core/compaction.js.map +1 -0
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +35 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/converter.d.ts +8 -0
- package/dist/core/converter.d.ts.map +1 -0
- package/dist/core/converter.js +41 -0
- package/dist/core/converter.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/state.d.ts +22 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/state.js +153 -0
- package/dist/core/state.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/definitions.d.ts +81 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +89 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/helpers.d.ts +4 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/helpers.js +53 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/implementations.d.ts +8 -0
- package/dist/tools/implementations.d.ts.map +1 -0
- package/dist/tools/implementations.js +115 -0
- package/dist/tools/implementations.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// tools.ts — Agent SDK style
|
|
2
|
+
import { tool } from '@openrouter/agent';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { runBash, readFile, writeFile, editFile, spawnSubAgent, searchCodebase } from './implementations.js';
|
|
5
|
+
import { RISKY_TOOLS } from '../core/constants.js';
|
|
6
|
+
export function createTools(onConfirm) {
|
|
7
|
+
const runBashTool = tool({
|
|
8
|
+
name: 'run_bash',
|
|
9
|
+
description: 'Execute a shell command in the current working directory. Use this for listing files, searching code (grep/find), checking git status, running scripts, or any other shell operation. Returns combined stdout/stderr. Prefer read_file over `cat` for reading a single file, and prefer replace_string_in_file over shell text-manipulation (sed/awk) for editing.',
|
|
10
|
+
inputSchema: z.object({
|
|
11
|
+
command: z.string().describe('A single shell command to execute, e.g. "ls -la" or "grep -rn TODO src/"'),
|
|
12
|
+
}),
|
|
13
|
+
execute: async ({ command }) => {
|
|
14
|
+
const allowed = await onConfirm(`run_bash(${command})`);
|
|
15
|
+
if (!allowed)
|
|
16
|
+
return { error: 'User denied this action.' };
|
|
17
|
+
return { output: runBash(command) };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const readFileTool = tool({
|
|
21
|
+
name: 'read_file',
|
|
22
|
+
description: 'Read the full contents of a single file at the given path and return it as text. Use this before editing a file to see its exact current content.',
|
|
23
|
+
inputSchema: z.object({
|
|
24
|
+
path: z.string().describe('Relative or absolute path to the file to read.'),
|
|
25
|
+
}),
|
|
26
|
+
execute: async ({ path }) => ({ content: readFile(path) }),
|
|
27
|
+
});
|
|
28
|
+
const writeFileTool = tool({
|
|
29
|
+
name: 'write_file',
|
|
30
|
+
description: 'Create a new file or completely overwrite an existing file with the given content. Use this only for creating new files or when the entire file content should be replaced. For modifying part of an existing file, use replace_string_in_file instead — it is safer and preserves everything else in the file.',
|
|
31
|
+
inputSchema: z.object({
|
|
32
|
+
path: z.string().describe('Relative or absolute path to the file to write.'),
|
|
33
|
+
content: z.string().describe('The full content to write to the file, replacing anything already there.'),
|
|
34
|
+
}),
|
|
35
|
+
execute: async ({ path, content }) => {
|
|
36
|
+
const allowed = await onConfirm(`write_file(${path})`);
|
|
37
|
+
if (!allowed)
|
|
38
|
+
return { error: 'User denied this action.' };
|
|
39
|
+
return { result: writeFile(path, content) };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const replaceStringInFileTool = tool({
|
|
43
|
+
name: 'replace_string_in_file',
|
|
44
|
+
description: 'Make a precise, surgical edit to an existing file by replacing one exact occurrence of a string with a new string. This is the preferred way to modify part of a file — it leaves the rest of the file untouched. stringToReplace must match EXACTLY ONE location in the file, character-for-character (including whitespace/indentation). Keep stringToReplace as SHORT as possible: include only the specific text being changed plus the minimum surrounding context needed to make the match unique (e.g. a variable name plus one line of context, not an entire function). If the string appears zero times or multiple times, this tool will fail — read the file first with read_file if unsure of exact formatting, and widen the match only as much as needed to make it unique.',
|
|
45
|
+
inputSchema: z.object({
|
|
46
|
+
path: z.string().describe('Relative or absolute path to the file to edit.'),
|
|
47
|
+
stringToReplace: z.string().describe('The exact existing text to find and replace. Must match exactly one location in the file.'),
|
|
48
|
+
newString: z.string().describe('The text to replace it with.'),
|
|
49
|
+
}),
|
|
50
|
+
execute: async ({ path, stringToReplace, newString }) => {
|
|
51
|
+
const allowed = await onConfirm(`replace_string_in_file(${path})`);
|
|
52
|
+
if (!allowed)
|
|
53
|
+
return { error: 'User denied this action.' };
|
|
54
|
+
return { result: editFile(path, stringToReplace, newString) };
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const spawnSubAgentTool = tool({
|
|
58
|
+
name: 'spawn_sub_agent',
|
|
59
|
+
description: "Delegate a self-contained investigative task to a sub-agent with a fresh, isolated context. Use this for tasks that would pollute your context with a lot of intermediate noise — e.g. 'search the codebase for all usages of X', 'read through these 5 files and summarize the auth flow', 'find where Y is configured'. The sub-agent has read-only tools (read_file, run_bash) and returns a single summarized answer — you will NOT see its intermediate steps. Do not use this for tasks that require writing/editing files, or for simple single-file lookups you can do directly.",
|
|
60
|
+
inputSchema: z.object({
|
|
61
|
+
task: z.string().describe('A clear, self-contained description of what the sub-agent should find/do and report back. It has no knowledge of the current conversation, so include all necessary context.'),
|
|
62
|
+
}),
|
|
63
|
+
execute: async ({ task }) => ({ result: await spawnSubAgent(task) }),
|
|
64
|
+
});
|
|
65
|
+
const searchCodeTool = tool({
|
|
66
|
+
name: 'search_code',
|
|
67
|
+
description: 'Search the codebase for a text pattern using ripgrep (regex supported). Automatically excludes node_modules, dist, build output, and lockfiles — you do not need to add exclusions yourself. Use this instead of grep/rg via run_bash. Returns matching file paths and line numbers with surrounding context.',
|
|
68
|
+
inputSchema: z.object({
|
|
69
|
+
pattern: z.string().describe('Text or regex pattern to search for.'),
|
|
70
|
+
path: z.string().optional().describe('Directory to search in. Defaults to current directory.'),
|
|
71
|
+
maxResults: z
|
|
72
|
+
.number()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Maximum total matches to return (default 60, hard cap 150). Prefer narrowing your search pattern or path over raising this — only increase it if you've confirmed the results are truncated and a narrower search isn't feasible."),
|
|
75
|
+
}),
|
|
76
|
+
execute: async ({ pattern, path, maxResults }) => ({
|
|
77
|
+
result: searchCodebase(pattern, path ?? '.', maxResults ?? 60),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
return [
|
|
81
|
+
runBashTool,
|
|
82
|
+
readFileTool,
|
|
83
|
+
writeFileTool,
|
|
84
|
+
replaceStringInFileTool,
|
|
85
|
+
spawnSubAgentTool,
|
|
86
|
+
searchCodeTool,
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,MAAM,UAAU,WAAW,CAAC,SAAoB;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC;QACvB,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,oWAAoW;QACtW,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0EAA0E,CAAC;SACzG,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC7B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,OAAO,GAAG,CAAC,CAAC;YACxD,IAAI,CAAC,OAAO;gBAAE,OAAO,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC;YAC3D,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,EAAE,WA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KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;YACjD,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,IAAI,GAAG,EAAE,UAAU,IAAI,EAAE,CAAC;SAC/D,CAAC;KACH,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,YAAY;QACZ,aAAa;QACb,uBAAuB;QACvB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function deriveSessionTitle(firstMessage: string): string;
|
|
2
|
+
export declare function resolveSafePath(inputPath: string, cwd?: string): string;
|
|
3
|
+
export declare const formatRgOutput: (output: string, maxTotalMatches?: number) => string;
|
|
4
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/tools/helpers.ts"],"names":[],"mappings":"AAWA,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAMtF;AACD,eAAO,MAAM,cAAc,WAAY,MAAM,+BAAyB,MA4CrE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
export function deriveSessionTitle(firstMessage) {
|
|
3
|
+
const cleaned = firstMessage.trim().replace(/\s+/g, ' ');
|
|
4
|
+
return cleaned.length > 50 ? cleaned.slice(0, 50) + '…' : cleaned;
|
|
5
|
+
}
|
|
6
|
+
export function resolveSafePath(inputPath, cwd = process.cwd()) {
|
|
7
|
+
const resolved = path.resolve(cwd, inputPath);
|
|
8
|
+
if (!resolved.startsWith(path.resolve(cwd) + path.sep) && resolved !== path.resolve(cwd)) {
|
|
9
|
+
throw new Error(`Path "${inputPath}" resolves outside the working directory and is not allowed.`);
|
|
10
|
+
}
|
|
11
|
+
return resolved;
|
|
12
|
+
}
|
|
13
|
+
export const formatRgOutput = (output, maxTotalMatches = 60) => {
|
|
14
|
+
const lines = output.trim().split('\n').filter(Boolean);
|
|
15
|
+
const fileGroups = new Map();
|
|
16
|
+
let totalMatches = 0;
|
|
17
|
+
let truncated = false;
|
|
18
|
+
for (const line of lines) {
|
|
19
|
+
const event = JSON.parse(line);
|
|
20
|
+
if (event.type !== 'match' && event.type !== 'context')
|
|
21
|
+
continue;
|
|
22
|
+
if (event.type === 'match') {
|
|
23
|
+
if (totalMatches >= maxTotalMatches) {
|
|
24
|
+
truncated = true;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
totalMatches++;
|
|
28
|
+
}
|
|
29
|
+
const path = event.data.path.text;
|
|
30
|
+
const lineNumber = event.data?.line_number ?? 0;
|
|
31
|
+
const text = event.data?.lines?.text ?? '';
|
|
32
|
+
const isMatch = event.type === 'match';
|
|
33
|
+
if (!fileGroups.has(path))
|
|
34
|
+
fileGroups.set(path, []);
|
|
35
|
+
fileGroups.get(path).push({ lineNumber, text, isMatch });
|
|
36
|
+
}
|
|
37
|
+
if (fileGroups.size === 0)
|
|
38
|
+
return 'No matches found.';
|
|
39
|
+
const outputs = [];
|
|
40
|
+
for (const [filePath, entries] of fileGroups) {
|
|
41
|
+
entries.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
42
|
+
outputs.push(`\n📄 ${filePath}`);
|
|
43
|
+
for (const { lineNumber, text, isMatch } of entries) {
|
|
44
|
+
const marker = isMatch ? '→' : ' ';
|
|
45
|
+
outputs.push(` ${marker} ${lineNumber}: ${text}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (truncated) {
|
|
49
|
+
outputs.push(`\n[Results truncated at ${maxTotalMatches} matches — refine your search pattern (e.g. narrow the path or use a more specific pattern) for complete results.]`);
|
|
50
|
+
}
|
|
51
|
+
return outputs.join('\n').trim();
|
|
52
|
+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U,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC;QACjC,KAAK,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;YACpD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,2BAA2B,eAAe,oHAAoH,CAAC,CAAC;IAC/K,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function runBash(command: string): string;
|
|
2
|
+
export declare function readFile(path: string): string;
|
|
3
|
+
export declare function writeFile(path: string, content: string): string;
|
|
4
|
+
export declare function editFile(path: string, oldContent: string, newContent: string): string;
|
|
5
|
+
export declare function spawnSubAgent(task: string): Promise<string>;
|
|
6
|
+
export declare function searchCodebase(pattern: string, path?: string, maxResults?: number): string;
|
|
7
|
+
export declare const toolExecutors: Record<string, (args: any) => string | Promise<string>>;
|
|
8
|
+
//# sourceMappingURL=implementations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementations.d.ts","sourceRoot":"","sources":["../../src/tools/implementations.ts"],"names":[],"mappings":"AAQA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAW/C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ/D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAcrF;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBjE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,EAAE,UAAU,GAAE,MAAW,GAAG,MAAM,CA4BnG;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOjF,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { execFileSync, execSync } from 'child_process';
|
|
3
|
+
import { createTools } from './definitions.js';
|
|
4
|
+
import { MODEL, SUBAGENT_MAX_ITERATIONS, SUBAGENT_TOOLS, SYSTEM_PROMPT } from '../core/constants.js';
|
|
5
|
+
import { getClient } from '../core/client.js';
|
|
6
|
+
import { formatRgOutput, resolveSafePath } from './helpers.js';
|
|
7
|
+
import { stepCountIs } from '@openrouter/agent';
|
|
8
|
+
export function runBash(command) {
|
|
9
|
+
// NOTE: run_bash is NOT path-sandboxed — a shell command can `cd`, use
|
|
10
|
+
// absolute paths, or chain commands in ways resolveSafePath can't
|
|
11
|
+
// intercept. It stays a RISKY_TOOL requiring confirmation; true sandboxing
|
|
12
|
+
// would need a real subprocess jail (e.g. a restricted PATH/cwd + denylist
|
|
13
|
+
// of dangerous patterns), which is a separate, bigger piece of work.
|
|
14
|
+
try {
|
|
15
|
+
return execSync(command, { encoding: 'utf-8', timeout: 10_000, cwd: process.cwd() });
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
return `ERROR: ${err.stdout ?? ''}${err.stderr ?? err.message}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function readFile(path) {
|
|
22
|
+
try {
|
|
23
|
+
const safePath = resolveSafePath(path);
|
|
24
|
+
return fs.readFileSync(safePath, 'utf-8');
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return `ERROR: ${err.message}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function writeFile(path, content) {
|
|
31
|
+
try {
|
|
32
|
+
const safePath = resolveSafePath(path);
|
|
33
|
+
fs.writeFileSync(safePath, content, 'utf-8');
|
|
34
|
+
return `File written successfully to ${path}`;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
return `ERROR: ${err.message}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function editFile(path, oldContent, newContent) {
|
|
41
|
+
try {
|
|
42
|
+
const safePath = resolveSafePath(path);
|
|
43
|
+
const content = fs.readFileSync(safePath, 'utf-8');
|
|
44
|
+
const occurences = content.split(oldContent).length - 1;
|
|
45
|
+
if (occurences === 0) {
|
|
46
|
+
return `ERROR: The string "${oldContent}" was not found in the file.`;
|
|
47
|
+
}
|
|
48
|
+
const updatedContent = content.replace(oldContent, newContent);
|
|
49
|
+
fs.writeFileSync(safePath, updatedContent, 'utf-8');
|
|
50
|
+
return `Successfully replaced ${occurences} occurence(s) of "${oldContent}" with "${newContent}" in ${path}`;
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return `ERROR: ${err.message}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function spawnSubAgent(task) {
|
|
57
|
+
const readOnlyTools = createTools(async () => false)
|
|
58
|
+
.filter(t => SUBAGENT_TOOLS.includes(t.function.name));
|
|
59
|
+
let result;
|
|
60
|
+
try {
|
|
61
|
+
result = getClient().callModel({
|
|
62
|
+
model: MODEL,
|
|
63
|
+
instructions: SYSTEM_PROMPT,
|
|
64
|
+
input: task,
|
|
65
|
+
tools: readOnlyTools,
|
|
66
|
+
stopWhen: [stepCountIs(SUBAGENT_MAX_ITERATIONS)],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return `ERROR: sub-agent model call failed — ${err?.error?.message ?? err?.message ?? String(err)}`;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return await result.getText();
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return `ERROR: sub-agent stream failed — ${err?.error?.message ?? err?.message ?? String(err)}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function searchCodebase(pattern, path = '.', maxResults = 60) {
|
|
80
|
+
const inputPath = path && path.trim() ? path : '.';
|
|
81
|
+
const cappedMax = Math.min(maxResults, 150);
|
|
82
|
+
let resolvedPath;
|
|
83
|
+
try {
|
|
84
|
+
resolvedPath = resolveSafePath(inputPath);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return `ERROR: ${err.message}`;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const output = execFileSync('rg', [
|
|
91
|
+
'--json', '-n', '-C', '2', '--max-count', String(cappedMax),
|
|
92
|
+
'--glob', '!node_modules',
|
|
93
|
+
'--glob', '!dist',
|
|
94
|
+
'--glob', '!.git',
|
|
95
|
+
'--glob', '!*.lock',
|
|
96
|
+
'--glob', '!package-lock.json',
|
|
97
|
+
'--', pattern, resolvedPath,
|
|
98
|
+
], { encoding: 'utf-8', timeout: 10_000, maxBuffer: 10 * 1024 * 1024 });
|
|
99
|
+
return formatRgOutput(output, cappedMax);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err.status === 1)
|
|
103
|
+
return 'No matches found.';
|
|
104
|
+
return `ERROR: ${err.stderr ?? err.message}`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export const toolExecutors = {
|
|
108
|
+
run_bash: (args) => runBash(args.command),
|
|
109
|
+
read_file: (args) => readFile(args.path),
|
|
110
|
+
write_file: (args) => writeFile(args.path, args.content),
|
|
111
|
+
replace_string_in_file: (args) => editFile(args.path, args.stringToReplace, args.newString),
|
|
112
|
+
spawn_sub_agent: (args) => spawnSubAgent(args.task),
|
|
113
|
+
search_code: (args) => searchCodebase(args.pattern, args.path, args.maxResults),
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=implementations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementations.js","sourceRoot":"","sources":["../../src/tools/implementations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,uEAAuE;IACvE,kEAAkE;IAClE,2EAA2E;IAC3E,2EAA2E;IAC3E,qEAAqE;IACrE,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACvF,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,UAAU,GAAG,CAAC,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;IAClE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAA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,OAAO,CAAC;IACxD,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3F,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;IACnD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC;CAChF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type Message = {
|
|
2
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
3
|
+
content: string | null;
|
|
4
|
+
reasoning?: string;
|
|
5
|
+
toolCalls?: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
type: 'function';
|
|
8
|
+
function: {
|
|
9
|
+
name: string;
|
|
10
|
+
arguments: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
toolCallId?: string;
|
|
14
|
+
};
|
|
15
|
+
export type DisplayEntry = {
|
|
16
|
+
id: number;
|
|
17
|
+
kind: 'user' | 'reasoning' | 'tool_call' | 'tool_result' | 'assistant' | 'info';
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
export type LogEvent = {
|
|
21
|
+
type: 'reasoning_delta';
|
|
22
|
+
content: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'tool_call';
|
|
25
|
+
name: string;
|
|
26
|
+
args: any;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'tool_result';
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'assistant_delta';
|
|
32
|
+
content: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'info';
|
|
35
|
+
content: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'sub_agent';
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
40
|
+
export type Callbacks = {
|
|
41
|
+
onLog: (event: LogEvent) => void;
|
|
42
|
+
onConfirm: (description: string) => Promise<boolean>;
|
|
43
|
+
};
|
|
44
|
+
export type SessionSummary = {
|
|
45
|
+
id: string;
|
|
46
|
+
updatedAt: number;
|
|
47
|
+
createdAt: number;
|
|
48
|
+
status: string;
|
|
49
|
+
};
|
|
50
|
+
export type OnConfirm = (description: string) => Promise<boolean>;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;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AAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nehanahmed/forge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A Terminal-based AI agent that can perform tasks and interact with the user.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"build": "tsc && npm run postbuild",
|
|
10
|
+
"postbuild": "node ./scripts/add-shebang.js",
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"eval": "tsx evals/runner.ts"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"forge": "./dist/cli/app.js"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"ai",
|
|
22
|
+
"agent",
|
|
23
|
+
"cli",
|
|
24
|
+
"coding-agent",
|
|
25
|
+
"mutli-model"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/NehanAhmed/forge-agent.git"
|
|
30
|
+
},
|
|
31
|
+
"author": "Nehan Ahmed",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.MD",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"type": "module",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@openrouter/agent": "^0.11.0",
|
|
40
|
+
"dotenv": "^17.4.2",
|
|
41
|
+
"ink": "^7.1.1",
|
|
42
|
+
"ink-big-text": "^2.0.0",
|
|
43
|
+
"ink-gradient": "^4.0.1",
|
|
44
|
+
"ink-spinner": "^5.0.0",
|
|
45
|
+
"ink-text-input": "^6.0.0",
|
|
46
|
+
"react": "^19.2.8",
|
|
47
|
+
"tsx": "^4.23.12",
|
|
48
|
+
"typescript": "^7.0.2",
|
|
49
|
+
"zod": "^4.6.5"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^26.2.0",
|
|
53
|
+
"@types/react": "^19.2.18"
|
|
54
|
+
}
|
|
55
|
+
}
|