codebot-ai 1.7.0 → 1.8.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.d.ts +10 -0
- package/dist/agent.js +89 -3
- package/dist/audit.d.ts +1 -1
- package/dist/capabilities.d.ts +48 -0
- package/dist/capabilities.js +187 -0
- package/dist/cli.js +85 -1
- package/dist/history.d.ts +7 -3
- package/dist/history.js +55 -8
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -1
- package/dist/integrity.d.ts +35 -0
- package/dist/integrity.js +135 -0
- package/dist/policy.d.ts +9 -0
- package/dist/policy.js +32 -6
- package/dist/providers/anthropic.d.ts +1 -0
- package/dist/providers/anthropic.js +4 -0
- package/dist/providers/openai.d.ts +1 -0
- package/dist/providers/openai.js +4 -0
- package/dist/replay.d.ts +55 -0
- package/dist/replay.js +196 -0
- package/dist/tools/batch-edit.d.ts +3 -0
- package/dist/tools/batch-edit.js +12 -0
- package/dist/tools/edit.d.ts +3 -0
- package/dist/tools/edit.js +11 -0
- package/dist/tools/git.d.ts +5 -0
- package/dist/tools/git.js +31 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/write.d.ts +3 -0
- package/dist/tools/write.js +11 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/tools/edit.js
CHANGED
|
@@ -46,6 +46,10 @@ class EditFileTool {
|
|
|
46
46
|
name = 'edit_file';
|
|
47
47
|
description = 'Edit a file by replacing an exact string match with new content. The old_string must appear exactly once in the file. Shows a diff preview and creates an undo snapshot.';
|
|
48
48
|
permission = 'prompt';
|
|
49
|
+
policyEnforcer;
|
|
50
|
+
constructor(policyEnforcer) {
|
|
51
|
+
this.policyEnforcer = policyEnforcer;
|
|
52
|
+
}
|
|
49
53
|
parameters = {
|
|
50
54
|
type: 'object',
|
|
51
55
|
properties: {
|
|
@@ -74,6 +78,13 @@ class EditFileTool {
|
|
|
74
78
|
if (!safety.safe) {
|
|
75
79
|
return `Error: ${safety.reason}`;
|
|
76
80
|
}
|
|
81
|
+
// Policy: filesystem restrictions (denied paths, read-only, writable scope)
|
|
82
|
+
if (this.policyEnforcer) {
|
|
83
|
+
const policyCheck = this.policyEnforcer.isPathWritable(filePath);
|
|
84
|
+
if (!policyCheck.allowed) {
|
|
85
|
+
return `Error: Blocked by policy — ${policyCheck.reason}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
77
88
|
// Security: resolve symlinks before reading
|
|
78
89
|
let realPath;
|
|
79
90
|
try {
|
package/dist/tools/git.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Tool } from '../types';
|
|
2
|
+
import { PolicyEnforcer } from '../policy';
|
|
2
3
|
export declare class GitTool implements Tool {
|
|
3
4
|
name: string;
|
|
4
5
|
description: string;
|
|
5
6
|
permission: Tool['permission'];
|
|
7
|
+
private policyEnforcer?;
|
|
6
8
|
parameters: {
|
|
7
9
|
type: string;
|
|
8
10
|
properties: {
|
|
@@ -21,6 +23,9 @@ export declare class GitTool implements Tool {
|
|
|
21
23
|
};
|
|
22
24
|
required: string[];
|
|
23
25
|
};
|
|
26
|
+
constructor(policyEnforcer?: PolicyEnforcer);
|
|
24
27
|
execute(args: Record<string, unknown>): Promise<string>;
|
|
28
|
+
/** Get current git branch name. */
|
|
29
|
+
private getCurrentBranch;
|
|
25
30
|
}
|
|
26
31
|
//# sourceMappingURL=git.d.ts.map
|
package/dist/tools/git.js
CHANGED
|
@@ -10,6 +10,7 @@ class GitTool {
|
|
|
10
10
|
name = 'git';
|
|
11
11
|
description = 'Run git operations. Actions: status, diff, log, commit, branch, checkout, stash, push, pull, merge, blame, tag, add, reset.';
|
|
12
12
|
permission = 'prompt';
|
|
13
|
+
policyEnforcer;
|
|
13
14
|
parameters = {
|
|
14
15
|
type: 'object',
|
|
15
16
|
properties: {
|
|
@@ -19,6 +20,9 @@ class GitTool {
|
|
|
19
20
|
},
|
|
20
21
|
required: ['action'],
|
|
21
22
|
};
|
|
23
|
+
constructor(policyEnforcer) {
|
|
24
|
+
this.policyEnforcer = policyEnforcer;
|
|
25
|
+
}
|
|
22
26
|
async execute(args) {
|
|
23
27
|
const action = args.action;
|
|
24
28
|
if (!action)
|
|
@@ -36,6 +40,20 @@ class GitTool {
|
|
|
36
40
|
if (/clean\s+-[a-z]*f/i.test(fullCmd)) {
|
|
37
41
|
return 'Error: git clean -f is blocked for safety.';
|
|
38
42
|
}
|
|
43
|
+
// Policy: block push to main/master when never_push_main=true
|
|
44
|
+
if (action === 'push' && this.policyEnforcer?.isMainPushBlocked()) {
|
|
45
|
+
const currentBranch = this.getCurrentBranch(cwd);
|
|
46
|
+
if (currentBranch === 'main' || currentBranch === 'master') {
|
|
47
|
+
return 'Error: Pushing to main/master is blocked by policy (git.never_push_main=true). Create a feature branch first.';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Policy: block commit on main/master when always_branch=true
|
|
51
|
+
if (action === 'commit' && this.policyEnforcer?.shouldAlwaysBranch()) {
|
|
52
|
+
const currentBranch = this.getCurrentBranch(cwd);
|
|
53
|
+
if (currentBranch === 'main' || currentBranch === 'master') {
|
|
54
|
+
return 'Error: Committing to main/master is blocked by policy (git.always_branch=true). Create a feature branch first.';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
39
57
|
try {
|
|
40
58
|
const output = (0, child_process_1.execSync)(fullCmd, {
|
|
41
59
|
cwd,
|
|
@@ -53,6 +71,19 @@ class GitTool {
|
|
|
53
71
|
return `Exit ${e.status || 1}${stdout ? `\n${stdout}` : ''}${stderr ? `\nError: ${stderr}` : ''}`;
|
|
54
72
|
}
|
|
55
73
|
}
|
|
74
|
+
/** Get current git branch name. */
|
|
75
|
+
getCurrentBranch(cwd) {
|
|
76
|
+
try {
|
|
77
|
+
return (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD', {
|
|
78
|
+
cwd,
|
|
79
|
+
encoding: 'utf-8',
|
|
80
|
+
timeout: 5000,
|
|
81
|
+
}).trim();
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
56
87
|
}
|
|
57
88
|
exports.GitTool = GitTool;
|
|
58
89
|
//# sourceMappingURL=git.js.map
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Tool, ToolSchema } from '../types';
|
|
2
|
+
import { PolicyEnforcer } from '../policy';
|
|
2
3
|
export { EditFileTool } from './edit';
|
|
3
4
|
export declare class ToolRegistry {
|
|
4
5
|
private tools;
|
|
5
|
-
constructor(projectRoot?: string);
|
|
6
|
+
constructor(projectRoot?: string, policyEnforcer?: PolicyEnforcer);
|
|
6
7
|
register(tool: Tool): void;
|
|
7
8
|
get(name: string): Tool | undefined;
|
|
8
9
|
getSchemas(): ToolSchema[];
|
package/dist/tools/index.js
CHANGED
|
@@ -34,12 +34,12 @@ var edit_2 = require("./edit");
|
|
|
34
34
|
Object.defineProperty(exports, "EditFileTool", { enumerable: true, get: function () { return edit_2.EditFileTool; } });
|
|
35
35
|
class ToolRegistry {
|
|
36
36
|
tools = new Map();
|
|
37
|
-
constructor(projectRoot) {
|
|
38
|
-
// Core file tools
|
|
37
|
+
constructor(projectRoot, policyEnforcer) {
|
|
38
|
+
// Core file tools — policy-enforced tools receive the enforcer
|
|
39
39
|
this.register(new read_1.ReadFileTool());
|
|
40
|
-
this.register(new write_1.WriteFileTool());
|
|
41
|
-
this.register(new edit_1.EditFileTool());
|
|
42
|
-
this.register(new batch_edit_1.BatchEditTool());
|
|
40
|
+
this.register(new write_1.WriteFileTool(policyEnforcer));
|
|
41
|
+
this.register(new edit_1.EditFileTool(policyEnforcer));
|
|
42
|
+
this.register(new batch_edit_1.BatchEditTool(policyEnforcer));
|
|
43
43
|
this.register(new execute_1.ExecuteTool());
|
|
44
44
|
this.register(new glob_1.GlobTool());
|
|
45
45
|
this.register(new grep_1.GrepTool());
|
|
@@ -51,7 +51,7 @@ class ToolRegistry {
|
|
|
51
51
|
this.register(new browser_1.BrowserTool());
|
|
52
52
|
this.register(new routine_1.RoutineTool());
|
|
53
53
|
// v1.4.0 — intelligence & dev tools
|
|
54
|
-
this.register(new git_1.GitTool());
|
|
54
|
+
this.register(new git_1.GitTool(policyEnforcer));
|
|
55
55
|
this.register(new code_analysis_1.CodeAnalysisTool());
|
|
56
56
|
this.register(new multi_search_1.MultiSearchTool());
|
|
57
57
|
this.register(new task_planner_1.TaskPlannerTool());
|
package/dist/tools/write.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Tool } from '../types';
|
|
2
|
+
import { PolicyEnforcer } from '../policy';
|
|
2
3
|
export declare class WriteFileTool implements Tool {
|
|
3
4
|
name: string;
|
|
4
5
|
description: string;
|
|
5
6
|
permission: Tool['permission'];
|
|
7
|
+
private policyEnforcer?;
|
|
8
|
+
constructor(policyEnforcer?: PolicyEnforcer);
|
|
6
9
|
parameters: {
|
|
7
10
|
type: string;
|
|
8
11
|
properties: {
|
package/dist/tools/write.js
CHANGED
|
@@ -44,6 +44,10 @@ class WriteFileTool {
|
|
|
44
44
|
name = 'write_file';
|
|
45
45
|
description = 'Create a new file or overwrite an existing file with the given content. Automatically saves an undo snapshot for existing files.';
|
|
46
46
|
permission = 'prompt';
|
|
47
|
+
policyEnforcer;
|
|
48
|
+
constructor(policyEnforcer) {
|
|
49
|
+
this.policyEnforcer = policyEnforcer;
|
|
50
|
+
}
|
|
47
51
|
parameters = {
|
|
48
52
|
type: 'object',
|
|
49
53
|
properties: {
|
|
@@ -68,6 +72,13 @@ class WriteFileTool {
|
|
|
68
72
|
if (!safety.safe) {
|
|
69
73
|
return `Error: ${safety.reason}`;
|
|
70
74
|
}
|
|
75
|
+
// Policy: filesystem restrictions (denied paths, read-only, writable scope)
|
|
76
|
+
if (this.policyEnforcer) {
|
|
77
|
+
const policyCheck = this.policyEnforcer.isPathWritable(filePath);
|
|
78
|
+
if (!policyCheck.allowed) {
|
|
79
|
+
return `Error: Blocked by policy — ${policyCheck.reason}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
71
82
|
// Security: secret detection (warn but don't block)
|
|
72
83
|
const secrets = (0, secrets_1.scanForSecrets)(content);
|
|
73
84
|
let warning = '';
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebot-ai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Zero-dependency autonomous AI agent. Code, browse, search, automate. Works with any LLM — Ollama, Claude, GPT, Gemini, DeepSeek, Groq, Mistral, Grok.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|