@ikarmic/forge-core 5.1.1 → 5.2.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/dist/agent/agent.js +14 -3
- package/dist/agent/goal.d.ts +5 -8
- package/dist/agent/race-abort.d.ts +8 -0
- package/dist/agent/race-abort.js +24 -0
- package/dist/agent/stack-facts.d.ts +23 -0
- package/dist/agent/stack-facts.js +150 -0
- package/dist/code-index/parser.js +48 -3
- package/dist/github/github-tools.d.ts +2 -18
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/journey/answers-block.js +14 -1
- package/dist/journey/offer.js +2 -1
- package/dist/mcp/json-schema-to-zod.js +12 -1
- package/dist/orchestrator/index.d.ts +1 -1
- package/dist/orchestrator/index.js +1 -1
- package/dist/orchestrator/orchestrator.d.ts +45 -6
- package/dist/orchestrator/orchestrator.js +62 -12
- package/dist/orchestrator/router.d.ts +1 -1
- package/dist/orchestrator/router.js +4 -1
- package/dist/orchestrator/specialists.d.ts +6 -1
- package/dist/orchestrator/specialists.js +165 -68
- package/dist/orchestrator/types.d.ts +1 -1
- package/dist/policy/policy.d.ts +6 -59
- package/dist/pricing.d.ts +2 -0
- package/dist/pricing.js +35 -16
- package/dist/structured/schema.js +9 -12
- package/dist/tools/apply-patch.d.ts +1 -5
- package/dist/tools/ask-user.d.ts +2 -10
- package/dist/tools/ask-user.js +12 -4
- package/dist/tools/browser-tools.d.ts +15 -31
- package/dist/tools/codebase-search.d.ts +1 -7
- package/dist/tools/dependency-audit.d.ts +30 -0
- package/dist/tools/dependency-audit.js +197 -0
- package/dist/tools/edit-file.d.ts +1 -15
- package/dist/tools/fetch-url.d.ts +1 -18
- package/dist/tools/find-references.d.ts +1 -5
- package/dist/tools/find-symbol.d.ts +10 -8
- package/dist/tools/git-diff.d.ts +13 -0
- package/dist/tools/git-diff.js +85 -0
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +5 -1
- package/dist/tools/list-files.d.ts +1 -19
- package/dist/tools/list-symbols.d.ts +1 -5
- package/dist/tools/memory.d.ts +23 -43
- package/dist/tools/notebook.d.ts +11 -17
- package/dist/tools/read-file.d.ts +1 -11
- package/dist/tools/read-image.d.ts +1 -12
- package/dist/tools/read-only.d.ts +1 -1
- package/dist/tools/read-only.js +2 -0
- package/dist/tools/run-command.d.ts +1 -17
- package/dist/tools/search-files.d.ts +1 -17
- package/dist/tools/sub-agent-wait.d.ts +2 -8
- package/dist/tools/sub-agent.d.ts +1 -69
- package/dist/tools/todo.d.ts +8 -20
- package/dist/tools/web-search.d.ts +1 -7
- package/dist/tools/write-file.d.ts +1 -7
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `git_diff`: the current changes, read-only, so Review and Security can see what changed without a
|
|
3
|
+
* `run_command` approval card. It runs one fixed program with fixed flags; the model chooses only a base
|
|
4
|
+
* ref, staged or not, and paths. A base that looks like an option is refused: `git diff --output=<file>`
|
|
5
|
+
* writes a file, and an option passed where a ref belongs is how a model (or a prompt it read) gets there.
|
|
6
|
+
*/
|
|
7
|
+
import { execFile } from 'node:child_process';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { promisify } from 'node:util';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { resolveOnPath } from '../lsp/client.js';
|
|
12
|
+
import { resolveAndCheckPath } from './shared.js';
|
|
13
|
+
import { shellEnv } from './shell-env.js';
|
|
14
|
+
const run = promisify(execFile);
|
|
15
|
+
/** The most diff text handed to the model; the rest is cut with a note. */
|
|
16
|
+
export const MAX_DIFF_CHARS = 60_000;
|
|
17
|
+
const params = z.object({
|
|
18
|
+
base: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Compare against this ref (a branch, tag, commit or range such as main...HEAD). Default: HEAD, i.e. your uncommitted changes.'),
|
|
22
|
+
staged: z.boolean().optional().describe('Only the staged changes (git diff --cached).'),
|
|
23
|
+
paths: z.array(z.string()).optional().describe('Limit the diff to these files or folders inside the project.'),
|
|
24
|
+
});
|
|
25
|
+
/** A ref git will read as a ref, never as an option: no leading dash, only the characters refs and ranges use. */
|
|
26
|
+
export function isSafeGitRef(ref) {
|
|
27
|
+
return ref.length > 0 && !ref.startsWith('-') && /^[A-Za-z0-9._/~^@{}:-]+$/.test(ref);
|
|
28
|
+
}
|
|
29
|
+
async function git(args, cwd) {
|
|
30
|
+
const env = shellEnv(process.env);
|
|
31
|
+
const program = resolveOnPath('git', env, process.platform) ?? 'git';
|
|
32
|
+
try {
|
|
33
|
+
// No repository code and no lock on the person's index: core.fsmonitor names a program git would run for
|
|
34
|
+
// status, and an optional index refresh can collide with the person's own commit (RB-41).
|
|
35
|
+
const safe = ['-c', 'core.fsmonitor=false', '--no-optional-locks', ...args];
|
|
36
|
+
const { stdout, stderr } = await run(program, safe, { cwd, env, maxBuffer: 64 * 1024 * 1024, windowsHide: true });
|
|
37
|
+
return { ok: true, stdout, stderr };
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
const e = err;
|
|
41
|
+
return { ok: false, stdout: e.stdout ?? '', stderr: e.stderr ?? e.message };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function cut(text) {
|
|
45
|
+
if (text.length <= MAX_DIFF_CHARS)
|
|
46
|
+
return text;
|
|
47
|
+
const left = text.length - MAX_DIFF_CHARS;
|
|
48
|
+
return `${text.slice(0, MAX_DIFF_CHARS)}\n[diff cut: ${left} characters left out. Pass paths to see one file at a time.]`;
|
|
49
|
+
}
|
|
50
|
+
export const gitDiffTool = {
|
|
51
|
+
name: 'git_diff',
|
|
52
|
+
description: 'Show the current changes as a unified diff, plus new untracked files. Read-only: it never changes files or the repository. ' +
|
|
53
|
+
'By default it compares your working tree and staged changes with HEAD; pass base to compare with a branch or commit, staged for staged changes only, paths to narrow it.',
|
|
54
|
+
parameters: params,
|
|
55
|
+
execute: async (args, ctx) => {
|
|
56
|
+
if (args.base !== undefined && !isSafeGitRef(args.base)) {
|
|
57
|
+
return `git_diff refused the base "${args.base}": a base must be a branch, tag, commit or range, and must not start with "-".`;
|
|
58
|
+
}
|
|
59
|
+
const rels = (args.paths ?? []).map((p) => path.relative(ctx.cwd, resolveAndCheckPath(p, ctx)) || '.');
|
|
60
|
+
const inside = await git(['rev-parse', '--is-inside-work-tree'], ctx.cwd);
|
|
61
|
+
if (!inside.ok || inside.stdout.trim() !== 'true')
|
|
62
|
+
return 'This folder is not a git repository, so there is no diff to show.';
|
|
63
|
+
const diffArgs = ['diff', '--no-ext-diff', '--no-textconv', '--no-color'];
|
|
64
|
+
// A repository with no commit has no HEAD: its staged files are the change.
|
|
65
|
+
const hasHead = (await git(['rev-parse', '--verify', '--quiet', 'HEAD'], ctx.cwd)).ok;
|
|
66
|
+
if (args.staged || (!args.base && !hasHead))
|
|
67
|
+
diffArgs.push('--cached');
|
|
68
|
+
else if (!args.base)
|
|
69
|
+
diffArgs.push('HEAD');
|
|
70
|
+
if (args.base)
|
|
71
|
+
diffArgs.push(args.base);
|
|
72
|
+
diffArgs.push('--', ...rels);
|
|
73
|
+
const diff = await git(diffArgs, ctx.cwd);
|
|
74
|
+
if (!diff.ok)
|
|
75
|
+
return `git diff failed: ${diff.stderr.trim()}`;
|
|
76
|
+
const status = await git(['status', '--porcelain=v1', '--', ...rels], ctx.cwd);
|
|
77
|
+
const parts = [diff.stdout.trim() ? diff.stdout : '(no changes in tracked files)'];
|
|
78
|
+
if (status.ok && status.stdout.trim())
|
|
79
|
+
parts.push(`git status:\n${status.stdout}`);
|
|
80
|
+
if (status.ok && /^\?\? /m.test(status.stdout)) {
|
|
81
|
+
parts.push('Untracked files (marked ??) are new and not shown in the diff above: read them with read_file.');
|
|
82
|
+
}
|
|
83
|
+
return cut(parts.join('\n'));
|
|
84
|
+
},
|
|
85
|
+
};
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { editFileTool } from './edit-file.js';
|
|
|
3
3
|
import { fetchUrlTool } from './fetch-url.js';
|
|
4
4
|
import { findReferencesTool } from './find-references.js';
|
|
5
5
|
import { findSymbolTool } from './find-symbol.js';
|
|
6
|
+
import { dependencyAuditTool } from './dependency-audit.js';
|
|
7
|
+
import { gitDiffTool } from './git-diff.js';
|
|
6
8
|
import { listFilesTool } from './list-files.js';
|
|
7
9
|
import { listSymbolsTool } from './list-symbols.js';
|
|
8
10
|
import { memoryForgetTool, memoryReadTool, memoryWriteTool } from './memory.js';
|
|
@@ -30,7 +32,7 @@ type AnyToolDefinition = ToolDefinition<any, any>;
|
|
|
30
32
|
* intentional: the model sees this order in its tool list.
|
|
31
33
|
*/
|
|
32
34
|
export declare const BUILTIN_TOOLS: readonly AnyToolDefinition[];
|
|
33
|
-
export { applyPatchTool, askUserTool, editFileTool, editNotebookTool, fetchUrlTool, findReferencesTool, findSymbolTool, listFilesTool, listSymbolsTool, memoryForgetTool, memoryReadTool, memoryWriteTool, readFileTool, readImageTool, runCommandTool, searchFilesTool, subAgentTool, subAgentWaitTool, todoReadTool, todoWriteTool, writeFileTool, };
|
|
35
|
+
export { applyPatchTool, askUserTool, dependencyAuditTool, editFileTool, editNotebookTool, fetchUrlTool, findReferencesTool, findSymbolTool, gitDiffTool, listFilesTool, listSymbolsTool, memoryForgetTool, memoryReadTool, memoryWriteTool, readFileTool, readImageTool, runCommandTool, searchFilesTool, subAgentTool, subAgentWaitTool, todoReadTool, todoWriteTool, writeFileTool, };
|
|
34
36
|
export type { ToolContext, ToolDefinition, ToolPolicy, ToolSandbox } from '../types.js';
|
|
35
37
|
export { checkPolicyViolation, globToRegex, mergeToolSandbox, normalizePathPattern, pathMatchesAny } from './policy.js';
|
|
36
38
|
export { redact, countRedactions, buildRules } from './redact.js';
|
package/dist/tools/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { editFileTool } from './edit-file.js';
|
|
|
3
3
|
import { fetchUrlTool } from './fetch-url.js';
|
|
4
4
|
import { findReferencesTool } from './find-references.js';
|
|
5
5
|
import { findSymbolTool } from './find-symbol.js';
|
|
6
|
+
import { dependencyAuditTool } from './dependency-audit.js';
|
|
7
|
+
import { gitDiffTool } from './git-diff.js';
|
|
6
8
|
import { listFilesTool } from './list-files.js';
|
|
7
9
|
import { listSymbolsTool } from './list-symbols.js';
|
|
8
10
|
import { memoryForgetTool, memoryReadTool, memoryWriteTool } from './memory.js';
|
|
@@ -30,6 +32,8 @@ export const BUILTIN_TOOLS = [
|
|
|
30
32
|
findSymbolTool,
|
|
31
33
|
listSymbolsTool,
|
|
32
34
|
findReferencesTool,
|
|
35
|
+
gitDiffTool,
|
|
36
|
+
dependencyAuditTool,
|
|
33
37
|
writeFileTool,
|
|
34
38
|
editFileTool,
|
|
35
39
|
applyPatchTool,
|
|
@@ -45,7 +49,7 @@ export const BUILTIN_TOOLS = [
|
|
|
45
49
|
todoReadTool,
|
|
46
50
|
askUserTool,
|
|
47
51
|
];
|
|
48
|
-
export { applyPatchTool, askUserTool, editFileTool, editNotebookTool, fetchUrlTool, findReferencesTool, findSymbolTool, listFilesTool, listSymbolsTool, memoryForgetTool, memoryReadTool, memoryWriteTool, readFileTool, readImageTool, runCommandTool, searchFilesTool, subAgentTool, subAgentWaitTool, todoReadTool, todoWriteTool, writeFileTool, };
|
|
52
|
+
export { applyPatchTool, askUserTool, dependencyAuditTool, editFileTool, editNotebookTool, fetchUrlTool, findReferencesTool, findSymbolTool, gitDiffTool, listFilesTool, listSymbolsTool, memoryForgetTool, memoryReadTool, memoryWriteTool, readFileTool, readImageTool, runCommandTool, searchFilesTool, subAgentTool, subAgentWaitTool, todoReadTool, todoWriteTool, writeFileTool, };
|
|
49
53
|
export { checkPolicyViolation, globToRegex, mergeToolSandbox, normalizePathPattern, pathMatchesAny } from './policy.js';
|
|
50
54
|
export { redact, countRedactions, buildRules } from './redact.js';
|
|
51
55
|
export { ToolResultCache, buildCacheKey, cachedExecute } from './result-cache.js';
|
|
@@ -2,30 +2,12 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { ToolDefinition } from '../types.js';
|
|
3
3
|
declare const params: z.ZodObject<{
|
|
4
4
|
path: z.ZodOptional<z.ZodString>;
|
|
5
|
-
/** Maximum entries to return. Defaults to 500. */
|
|
6
5
|
max_entries: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
/** Include dotfiles. Default false. */
|
|
8
6
|
include_hidden: z.ZodOptional<z.ZodBoolean>;
|
|
9
7
|
include_ignored: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
/** Recurse into subdirectories. Default false. */
|
|
11
8
|
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
-
/** Max recursion depth when recursive=true. Default 4. */
|
|
13
9
|
max_depth: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
},
|
|
15
|
-
path?: string | undefined;
|
|
16
|
-
recursive?: boolean | undefined;
|
|
17
|
-
max_entries?: number | undefined;
|
|
18
|
-
include_hidden?: boolean | undefined;
|
|
19
|
-
include_ignored?: boolean | undefined;
|
|
20
|
-
max_depth?: number | undefined;
|
|
21
|
-
}, {
|
|
22
|
-
path?: string | undefined;
|
|
23
|
-
recursive?: boolean | undefined;
|
|
24
|
-
max_entries?: number | undefined;
|
|
25
|
-
include_hidden?: boolean | undefined;
|
|
26
|
-
include_ignored?: boolean | undefined;
|
|
27
|
-
max_depth?: number | undefined;
|
|
28
|
-
}>;
|
|
10
|
+
}, z.core.$strip>;
|
|
29
11
|
export interface ListEntry {
|
|
30
12
|
path: string;
|
|
31
13
|
type: 'file' | 'directory' | 'other';
|
|
@@ -3,11 +3,7 @@ import type { SymbolKind } from '../code-index/types.js';
|
|
|
3
3
|
import type { ToolDefinition } from '../types.js';
|
|
4
4
|
declare const params: z.ZodObject<{
|
|
5
5
|
path: z.ZodString;
|
|
6
|
-
},
|
|
7
|
-
path: string;
|
|
8
|
-
}, {
|
|
9
|
-
path: string;
|
|
10
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
11
7
|
export interface SymbolOutlineEntry {
|
|
12
8
|
name: string;
|
|
13
9
|
kind: SymbolKind;
|
package/dist/tools/memory.d.ts
CHANGED
|
@@ -2,21 +2,13 @@ import { z } from 'zod';
|
|
|
2
2
|
import { type MemoryType } from '../memory/memory-store.js';
|
|
3
3
|
import type { ToolDefinition } from '../types.js';
|
|
4
4
|
declare const readParams: z.ZodObject<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
scope: z.ZodOptional<z.ZodEnum<["project", "global", "both"]>>;
|
|
11
|
-
/** Optional heading to filter by. Returns just that section's body. */
|
|
5
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
project: "project";
|
|
7
|
+
global: "global";
|
|
8
|
+
both: "both";
|
|
9
|
+
}>>;
|
|
12
10
|
section: z.ZodOptional<z.ZodString>;
|
|
13
|
-
},
|
|
14
|
-
section?: string | undefined;
|
|
15
|
-
scope?: "project" | "global" | "both" | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
section?: string | undefined;
|
|
18
|
-
scope?: "project" | "global" | "both" | undefined;
|
|
19
|
-
}>;
|
|
11
|
+
}, z.core.$strip>;
|
|
20
12
|
export interface MemoryReadResult {
|
|
21
13
|
scope: 'project' | 'global' | 'both';
|
|
22
14
|
content: string;
|
|
@@ -31,30 +23,21 @@ export declare const memoryReadTool: ToolDefinition<z.infer<typeof readParams>,
|
|
|
31
23
|
/** Longest body `memory_write` accepts. Memory holds short facts, not documents. */
|
|
32
24
|
export declare const MAX_BODY_CHARS = 1200;
|
|
33
25
|
declare const writeParams: z.ZodObject<{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
project: "project";
|
|
28
|
+
global: "global";
|
|
29
|
+
}>>;
|
|
37
30
|
heading: z.ZodString;
|
|
38
|
-
/** Section body. Markdown allowed. */
|
|
39
31
|
body: z.ZodString;
|
|
40
|
-
type: z.ZodOptional<z.ZodEnum<
|
|
41
|
-
|
|
32
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
33
|
+
convention: "convention";
|
|
34
|
+
decision: "decision";
|
|
35
|
+
correction: "correction";
|
|
36
|
+
reference: "reference";
|
|
37
|
+
}>>;
|
|
38
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
39
|
pin: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
-
},
|
|
44
|
-
body: string;
|
|
45
|
-
heading: string;
|
|
46
|
-
type?: "convention" | "decision" | "correction" | "reference" | undefined;
|
|
47
|
-
refs?: string[] | undefined;
|
|
48
|
-
pin?: boolean | undefined;
|
|
49
|
-
scope?: "project" | "global" | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
body: string;
|
|
52
|
-
heading: string;
|
|
53
|
-
type?: "convention" | "decision" | "correction" | "reference" | undefined;
|
|
54
|
-
refs?: string[] | undefined;
|
|
55
|
-
pin?: boolean | undefined;
|
|
56
|
-
scope?: "project" | "global" | undefined;
|
|
57
|
-
}>;
|
|
40
|
+
}, z.core.$strip>;
|
|
58
41
|
export interface MemoryWriteResult {
|
|
59
42
|
scope: 'project' | 'global';
|
|
60
43
|
path: string;
|
|
@@ -69,15 +52,12 @@ export interface MemoryWriteResult {
|
|
|
69
52
|
}
|
|
70
53
|
export declare const memoryWriteTool: ToolDefinition<z.infer<typeof writeParams>, MemoryWriteResult>;
|
|
71
54
|
declare const forgetParams: z.ZodObject<{
|
|
72
|
-
scope: z.ZodOptional<z.ZodEnum<
|
|
55
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
project: "project";
|
|
57
|
+
global: "global";
|
|
58
|
+
}>>;
|
|
73
59
|
heading: z.ZodString;
|
|
74
|
-
},
|
|
75
|
-
heading: string;
|
|
76
|
-
scope?: "project" | "global" | undefined;
|
|
77
|
-
}, {
|
|
78
|
-
heading: string;
|
|
79
|
-
scope?: "project" | "global" | undefined;
|
|
80
|
-
}>;
|
|
60
|
+
}, z.core.$strip>;
|
|
81
61
|
export interface MemoryForgetResult {
|
|
82
62
|
scope: 'project' | 'global';
|
|
83
63
|
heading: string;
|
package/dist/tools/notebook.d.ts
CHANGED
|
@@ -39,26 +39,20 @@ export declare function outputText(output: unknown): string;
|
|
|
39
39
|
export declare function renderNotebook(nb: Notebook): string;
|
|
40
40
|
declare const params: z.ZodObject<{
|
|
41
41
|
path: z.ZodString;
|
|
42
|
-
mode: z.ZodOptional<z.ZodEnum<
|
|
42
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
replace: "replace";
|
|
44
|
+
delete: "delete";
|
|
45
|
+
insert: "insert";
|
|
46
|
+
}>>;
|
|
43
47
|
cell_index: z.ZodOptional<z.ZodNumber>;
|
|
44
48
|
cell_id: z.ZodOptional<z.ZodString>;
|
|
45
49
|
source: z.ZodOptional<z.ZodString>;
|
|
46
|
-
cell_type: z.ZodOptional<z.ZodEnum<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
cell_index?: number | undefined;
|
|
53
|
-
cell_id?: string | undefined;
|
|
54
|
-
}, {
|
|
55
|
-
path: string;
|
|
56
|
-
mode?: "replace" | "delete" | "insert" | undefined;
|
|
57
|
-
source?: string | undefined;
|
|
58
|
-
cell_type?: "code" | "raw" | "markdown" | undefined;
|
|
59
|
-
cell_index?: number | undefined;
|
|
60
|
-
cell_id?: string | undefined;
|
|
61
|
-
}>;
|
|
50
|
+
cell_type: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
code: "code";
|
|
52
|
+
raw: "raw";
|
|
53
|
+
markdown: "markdown";
|
|
54
|
+
}>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
62
56
|
export interface EditNotebookResult {
|
|
63
57
|
path: string;
|
|
64
58
|
mode: 'replace' | 'insert' | 'delete';
|
|
@@ -2,19 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { ToolDefinition } from '../types.js';
|
|
3
3
|
declare const params: z.ZodObject<{
|
|
4
4
|
path: z.ZodString;
|
|
5
|
-
/** 1-based line number to start reading from. Omit to start at the beginning. */
|
|
6
5
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
/** Maximum number of lines to return. Defaults to 2000. */
|
|
8
6
|
max_lines: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
},
|
|
10
|
-
path: string;
|
|
11
|
-
offset?: number | undefined;
|
|
12
|
-
max_lines?: number | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
path: string;
|
|
15
|
-
offset?: number | undefined;
|
|
16
|
-
max_lines?: number | undefined;
|
|
17
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
18
8
|
export interface ReadFileResult {
|
|
19
9
|
path: string;
|
|
20
10
|
totalLines: number;
|
|
@@ -26,19 +26,8 @@ import { z } from 'zod';
|
|
|
26
26
|
import type { ToolDefinition } from '../types.js';
|
|
27
27
|
declare const params: z.ZodObject<{
|
|
28
28
|
path: z.ZodString;
|
|
29
|
-
/**
|
|
30
|
-
* Maximum bytes to read. The tool errors if the file exceeds this
|
|
31
|
-
* limit; the default is 5 MB which covers most screenshots and
|
|
32
|
-
* diagrams without flooding the model context.
|
|
33
|
-
*/
|
|
34
29
|
max_bytes: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
},
|
|
36
|
-
path: string;
|
|
37
|
-
max_bytes?: number | undefined;
|
|
38
|
-
}, {
|
|
39
|
-
path: string;
|
|
40
|
-
max_bytes?: number | undefined;
|
|
41
|
-
}>;
|
|
30
|
+
}, z.core.$strip>;
|
|
42
31
|
export interface ReadImageResult {
|
|
43
32
|
path: string;
|
|
44
33
|
mime: string;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* anything. Asking before each of them is noise, so they are approved without a prompt by default;
|
|
4
4
|
* edits, commands, web access and sub-agents still ask.
|
|
5
5
|
*/
|
|
6
|
-
export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_files", "search_files", "find_symbol", "list_symbols", "find_references", "codebase_search", "memory_read", "sub_agent_wait"];
|
|
6
|
+
export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_files", "search_files", "find_symbol", "list_symbols", "find_references", "git_diff", "codebase_search", "memory_read", "sub_agent_wait"];
|
|
7
7
|
/** The tools that run without a prompt: the user's list, or the read-only tools when none is set. */
|
|
8
8
|
export declare function resolveAutoApprove(configured?: readonly string[]): string[];
|
package/dist/tools/read-only.js
CHANGED
|
@@ -10,6 +10,8 @@ export const READ_ONLY_TOOLS = [
|
|
|
10
10
|
'find_symbol',
|
|
11
11
|
'list_symbols',
|
|
12
12
|
'find_references',
|
|
13
|
+
// Runs one fixed git command; refuses option-shaped refs.
|
|
14
|
+
'git_diff',
|
|
13
15
|
'codebase_search',
|
|
14
16
|
'memory_read',
|
|
15
17
|
// Only observes the sub-agents the person already let start.
|
|
@@ -2,25 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { ToolDefinition } from '../types.js';
|
|
3
3
|
declare const params: z.ZodObject<{
|
|
4
4
|
command: z.ZodString;
|
|
5
|
-
/**
|
|
6
|
-
* Optional explicit timeout in ms. Default 60_000 (1 minute). Set to 0 to
|
|
7
|
-
* disable (not recommended).
|
|
8
|
-
*/
|
|
9
5
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
/**
|
|
11
|
-
* Optional working directory override. Must be inside the project root
|
|
12
|
-
* unless the configured ToolContext permits otherwise.
|
|
13
|
-
*/
|
|
14
6
|
cwd: z.ZodOptional<z.ZodString>;
|
|
15
|
-
},
|
|
16
|
-
command: string;
|
|
17
|
-
timeout_ms?: number | undefined;
|
|
18
|
-
cwd?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
command: string;
|
|
21
|
-
timeout_ms?: number | undefined;
|
|
22
|
-
cwd?: string | undefined;
|
|
23
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
24
8
|
export interface RunCommandResult {
|
|
25
9
|
command: string;
|
|
26
10
|
exitCode: number | null;
|
|
@@ -4,26 +4,10 @@ declare const params: z.ZodObject<{
|
|
|
4
4
|
pattern: z.ZodString;
|
|
5
5
|
path: z.ZodOptional<z.ZodString>;
|
|
6
6
|
include: z.ZodOptional<z.ZodString>;
|
|
7
|
-
/** Maximum matches to return. Default 200. */
|
|
8
7
|
max_results: z.ZodOptional<z.ZodNumber>;
|
|
9
8
|
include_ignored: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
/** Show a few lines of context around each match. */
|
|
11
9
|
context_lines: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
},
|
|
13
|
-
pattern: string;
|
|
14
|
-
path?: string | undefined;
|
|
15
|
-
include?: string | undefined;
|
|
16
|
-
max_results?: number | undefined;
|
|
17
|
-
include_ignored?: boolean | undefined;
|
|
18
|
-
context_lines?: number | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
pattern: string;
|
|
21
|
-
path?: string | undefined;
|
|
22
|
-
include?: string | undefined;
|
|
23
|
-
max_results?: number | undefined;
|
|
24
|
-
include_ignored?: boolean | undefined;
|
|
25
|
-
context_lines?: number | undefined;
|
|
26
|
-
}>;
|
|
10
|
+
}, z.core.$strip>;
|
|
27
11
|
export interface SearchMatch {
|
|
28
12
|
path: string;
|
|
29
13
|
line: number;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ToolDefinition } from '../types.js';
|
|
3
3
|
declare const params: z.ZodObject<{
|
|
4
|
-
ids: z.ZodOptional<z.ZodArray<z.ZodString
|
|
4
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
5
|
timeout_seconds: z.ZodOptional<z.ZodNumber>;
|
|
6
|
-
},
|
|
7
|
-
ids?: string[] | undefined;
|
|
8
|
-
timeout_seconds?: number | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
ids?: string[] | undefined;
|
|
11
|
-
timeout_seconds?: number | undefined;
|
|
12
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
13
7
|
export interface SubAgentWaitResult {
|
|
14
8
|
agents: Array<{
|
|
15
9
|
id: string;
|
|
@@ -2,84 +2,16 @@ import { z } from 'zod';
|
|
|
2
2
|
import { type AgentDef } from '../agents/agent-files.js';
|
|
3
3
|
import type { AgentConfig, ModelConfig, ToolContext, ToolDefinition } from '../types.js';
|
|
4
4
|
declare const params: z.ZodObject<{
|
|
5
|
-
/** The task for the sub-agent to perform. Free-form text. */
|
|
6
5
|
task: z.ZodString;
|
|
7
|
-
/** Name of an agent file (`.forge/agents/<name>.md`) to run as: its prompt, tools, model and step cap. */
|
|
8
6
|
agent: z.ZodOptional<z.ZodString>;
|
|
9
|
-
/** Hard cap on iterations for the sub-agent. Default 10. */
|
|
10
7
|
max_iterations: z.ZodOptional<z.ZodNumber>;
|
|
11
|
-
/**
|
|
12
|
-
* Run the sub-agent without approval prompts (autonomous). Defaults to
|
|
13
|
-
* `false` even when the parent is in `--auto` mode: the sub-agent is
|
|
14
|
-
* expected to be focused and short-lived, so the explicit opt-in is
|
|
15
|
-
* deliberate to avoid runaway destructive work.
|
|
16
|
-
*/
|
|
17
8
|
auto: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Working directory for the sub-agent. Defaults to the parent's cwd.
|
|
20
|
-
* Useful when the sub-task should operate on a subdirectory without
|
|
21
|
-
* dragging the parent through the navigation.
|
|
22
|
-
*/
|
|
23
9
|
cwd: z.ZodOptional<z.ZodString>;
|
|
24
|
-
/**
|
|
25
|
-
* Run the sub-agent in an isolated git worktree. The worktree is
|
|
26
|
-
* created at `<repoRoot>/.forge/worktrees/<label>/`, the child runs
|
|
27
|
-
* there, and the worktree is removed on completion (success or
|
|
28
|
-
* error). Falls back to plain `cwd` mode (with a stderr warning)
|
|
29
|
-
* when the parent's cwd is not inside a git repo.
|
|
30
|
-
*
|
|
31
|
-
* Pair this with `orchestrator run` parallel dispatch (v2.3) to
|
|
32
|
-
* safely run multiple specialists concurrently without them
|
|
33
|
-
* clobbering each other's files.
|
|
34
|
-
*/
|
|
35
10
|
use_worktree: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
-
/**
|
|
37
|
-
* Human-readable label for the worktree (used in the branch name and
|
|
38
|
-
* directory). Defaults to a random short hash. Ignored when
|
|
39
|
-
* `use_worktree` is false.
|
|
40
|
-
*/
|
|
41
11
|
worktree_label: z.ZodOptional<z.ZodString>;
|
|
42
|
-
/**
|
|
43
|
-
* v2.14: when `use_worktree: true`, also delete the auto-created
|
|
44
|
-
* `forge/<label>-<short-sha>` branch once the worktree's working
|
|
45
|
-
* tree is gone. Default `true` because sub-agents are short-lived
|
|
46
|
-
* and orphan branches are pure clutter.
|
|
47
|
-
*
|
|
48
|
-
* Set to `false` when you want to inspect the diff afterwards (e.g.
|
|
49
|
-
* `git diff main..forge/<label>-<sha>`) or hand the branch to a
|
|
50
|
-
* human reviewer.
|
|
51
|
-
*
|
|
52
|
-
* The branch is only deleted when no other worktree currently
|
|
53
|
-
* references it, so two Forge sessions working on the same branch
|
|
54
|
-
* won't collide.
|
|
55
|
-
*/
|
|
56
12
|
cleanup_branch: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
-
/**
|
|
58
|
-
* Start the child and return at once. The child keeps working while the parent continues; collect its answer with
|
|
59
|
-
* `sub_agent_wait`. Only where the surface can show background runs; elsewhere the child runs to completion as usual.
|
|
60
|
-
*/
|
|
61
13
|
background: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
-
},
|
|
63
|
-
task: string;
|
|
64
|
-
agent?: string | undefined;
|
|
65
|
-
cwd?: string | undefined;
|
|
66
|
-
auto?: boolean | undefined;
|
|
67
|
-
background?: boolean | undefined;
|
|
68
|
-
max_iterations?: number | undefined;
|
|
69
|
-
use_worktree?: boolean | undefined;
|
|
70
|
-
worktree_label?: string | undefined;
|
|
71
|
-
cleanup_branch?: boolean | undefined;
|
|
72
|
-
}, {
|
|
73
|
-
task: string;
|
|
74
|
-
agent?: string | undefined;
|
|
75
|
-
cwd?: string | undefined;
|
|
76
|
-
auto?: boolean | undefined;
|
|
77
|
-
background?: boolean | undefined;
|
|
78
|
-
max_iterations?: number | undefined;
|
|
79
|
-
use_worktree?: boolean | undefined;
|
|
80
|
-
worktree_label?: string | undefined;
|
|
81
|
-
cleanup_branch?: boolean | undefined;
|
|
82
|
-
}>;
|
|
14
|
+
}, z.core.$strip>;
|
|
83
15
|
/** What `sub_agent { background: true }` returns instead of a result. */
|
|
84
16
|
export interface SubAgentStarted {
|
|
85
17
|
started: true;
|
package/dist/tools/todo.d.ts
CHANGED
|
@@ -7,26 +7,14 @@ import type { TodoItem, ToolDefinition } from '../types.js';
|
|
|
7
7
|
declare const writeParams: z.ZodObject<{
|
|
8
8
|
todos: z.ZodArray<z.ZodObject<{
|
|
9
9
|
content: z.ZodString;
|
|
10
|
-
status: z.ZodEnum<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
todos: {
|
|
20
|
-
status: "pending" | "in_progress" | "completed";
|
|
21
|
-
content: string;
|
|
22
|
-
}[];
|
|
23
|
-
}, {
|
|
24
|
-
todos: {
|
|
25
|
-
status: "pending" | "in_progress" | "completed";
|
|
26
|
-
content: string;
|
|
27
|
-
}[];
|
|
28
|
-
}>;
|
|
29
|
-
declare const readParams: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
10
|
+
status: z.ZodEnum<{
|
|
11
|
+
pending: "pending";
|
|
12
|
+
in_progress: "in_progress";
|
|
13
|
+
completed: "completed";
|
|
14
|
+
}>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const readParams: z.ZodObject<{}, z.core.$strip>;
|
|
30
18
|
export declare const todoWriteTool: ToolDefinition<z.infer<typeof writeParams>, {
|
|
31
19
|
todos: TodoItem[];
|
|
32
20
|
}>;
|
|
@@ -39,13 +39,7 @@ export declare function searchWeb(cfg: WebSearchConfig, query: string, count: nu
|
|
|
39
39
|
declare const params: z.ZodObject<{
|
|
40
40
|
query: z.ZodString;
|
|
41
41
|
max_results: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
},
|
|
43
|
-
query: string;
|
|
44
|
-
max_results?: number | undefined;
|
|
45
|
-
}, {
|
|
46
|
-
query: string;
|
|
47
|
-
max_results?: number | undefined;
|
|
48
|
-
}>;
|
|
42
|
+
}, z.core.$strip>;
|
|
49
43
|
export interface WebSearchToolResult {
|
|
50
44
|
provider: WebSearchProvider;
|
|
51
45
|
query: string;
|
|
@@ -3,13 +3,7 @@ import type { ToolDefinition } from '../types.js';
|
|
|
3
3
|
declare const params: z.ZodObject<{
|
|
4
4
|
path: z.ZodString;
|
|
5
5
|
content: z.ZodString;
|
|
6
|
-
},
|
|
7
|
-
path: string;
|
|
8
|
-
content: string;
|
|
9
|
-
}, {
|
|
10
|
-
path: string;
|
|
11
|
-
content: string;
|
|
12
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
13
7
|
export interface WriteFileResult {
|
|
14
8
|
path: string;
|
|
15
9
|
bytes: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -564,6 +564,8 @@ export interface AgentConfig {
|
|
|
564
564
|
* be surprising.
|
|
565
565
|
*/
|
|
566
566
|
disableMemory?: boolean;
|
|
567
|
+
/** Leave out the `<stack>` block (the versions the workspace's files state). Default: included. */
|
|
568
|
+
disableStackFacts?: boolean;
|
|
567
569
|
/**
|
|
568
570
|
* Skip injecting `AGENTS.md` / `CLAUDE.md` / `CONVENTIONS.md` from the
|
|
569
571
|
* working directory into the system prompt.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikarmic/forge-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Agent engine for IKarmic AI Forge. Model loop, tools, MCP, sandbox, memory, compaction, plan mode, skills, hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"tree-sitter-wasms": "^0.1.13",
|
|
57
57
|
"undici": "^7.30.0",
|
|
58
58
|
"web-tree-sitter": "0.20.8",
|
|
59
|
-
"zod": "^
|
|
59
|
+
"zod": "^4.6.7"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@ai-sdk/provider": "^4.0.0",
|
|
63
63
|
"@types/node": "^22.7.0",
|
|
64
64
|
"typescript": "^5.6.3",
|
|
65
|
-
"vitest": "^5.0.
|
|
65
|
+
"vitest": "^5.0.5"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsc -p tsconfig.json",
|