@codebolt/agent 6.1.11 → 6.1.13
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/processor-pieces/messageModifiers/atFileProcessorModifier.js +6 -1
- package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.js +14 -0
- package/dist/processor-pieces/messageModifiers/directoryContextModifier.js +8 -3
- package/dist/processor-pieces/messageModifiers/environmentContextModifier.d.ts +1 -0
- package/dist/processor-pieces/messageModifiers/environmentContextModifier.js +43 -3
- package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.js +1 -1
- package/package.json +1 -1
|
@@ -126,7 +126,8 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
126
126
|
let workspaceDirectories = [];
|
|
127
127
|
try {
|
|
128
128
|
const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
|
|
129
|
-
|
|
129
|
+
const effectiveProjectPath = process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'] || projectPath;
|
|
130
|
+
workspaceDirectories = effectiveProjectPath ? [effectiveProjectPath] : [await this.getProjectPath()];
|
|
130
131
|
}
|
|
131
132
|
catch (error) {
|
|
132
133
|
workspaceDirectories = [await this.getProjectPath()];
|
|
@@ -357,6 +358,10 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
357
358
|
return -1;
|
|
358
359
|
}
|
|
359
360
|
async getProjectPath() {
|
|
361
|
+
const effectiveProjectPath = process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'];
|
|
362
|
+
if (effectiveProjectPath) {
|
|
363
|
+
return effectiveProjectPath;
|
|
364
|
+
}
|
|
360
365
|
try {
|
|
361
366
|
const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
|
|
362
367
|
return projectPath || process.cwd();
|
|
@@ -32,8 +32,22 @@ class CoreSystemPromptModifier extends base_1.BaseMessageModifier {
|
|
|
32
32
|
return `${basePrompt}${memorySuffix}`;
|
|
33
33
|
}
|
|
34
34
|
getDefaultSystemPrompt() {
|
|
35
|
+
const effectiveProjectPath = process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'];
|
|
36
|
+
const baseProjectPath = process.env['CODEBOLT_BASE_PROJECT_PATH'];
|
|
37
|
+
const workspaceContext = effectiveProjectPath
|
|
38
|
+
? `
|
|
39
|
+
|
|
40
|
+
# Workspace Context
|
|
41
|
+
|
|
42
|
+
- Effective project path for this task: ${effectiveProjectPath}
|
|
43
|
+
${baseProjectPath ? `- CodeBolt base project path: ${baseProjectPath}
|
|
44
|
+
- CodeBolt app-level configuration, providers, plugins, and .codebolt data are loaded from the base project path.
|
|
45
|
+
- File edits, shell commands, and code changes for the user's task must target the effective project path unless the user explicitly asks you to inspect or change base project configuration.` : '- No separate CodeBolt base project path was provided; treat the effective project path as the active project root.'}
|
|
46
|
+
`
|
|
47
|
+
: '';
|
|
35
48
|
return `
|
|
36
49
|
You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
|
|
50
|
+
${workspaceContext}
|
|
37
51
|
|
|
38
52
|
# Core Mandates
|
|
39
53
|
|
|
@@ -76,7 +76,8 @@ class DirectoryContextModifier extends base_1.BaseMessageModifier {
|
|
|
76
76
|
let workspaceDirectories = this.options.workspaceDirectories;
|
|
77
77
|
if (!workspaceDirectories || workspaceDirectories.length === 0) {
|
|
78
78
|
const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
|
|
79
|
-
|
|
79
|
+
const effectiveProjectPath = process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'] || projectPath;
|
|
80
|
+
workspaceDirectories = effectiveProjectPath ? [effectiveProjectPath] : [];
|
|
80
81
|
}
|
|
81
82
|
if (workspaceDirectories.length === 0) {
|
|
82
83
|
return createdMessage;
|
|
@@ -86,12 +87,16 @@ class DirectoryContextModifier extends base_1.BaseMessageModifier {
|
|
|
86
87
|
const folderStructures = await Promise.all(workspaceDirectories.map((dir) => this.getFolderStructure(dir)));
|
|
87
88
|
const folderStructure = folderStructures.join('\n');
|
|
88
89
|
let workingDirPreamble;
|
|
90
|
+
const baseProjectPath = process.env['CODEBOLT_BASE_PROJECT_PATH'];
|
|
89
91
|
if (workspaceDirectories.length === 1) {
|
|
90
|
-
workingDirPreamble = `I'm currently working in the directory: ${workspaceDirectories[0]}`;
|
|
92
|
+
workingDirPreamble = `I'm currently working in the effective project directory: ${workspaceDirectories[0]}`;
|
|
91
93
|
}
|
|
92
94
|
else {
|
|
93
95
|
const dirList = workspaceDirectories.map((dir) => ` - ${dir}`).join('\n');
|
|
94
|
-
workingDirPreamble = `I'm currently working in the following directories:\n${dirList}`;
|
|
96
|
+
workingDirPreamble = `I'm currently working in the following effective project directories:\n${dirList}`;
|
|
97
|
+
}
|
|
98
|
+
if (baseProjectPath) {
|
|
99
|
+
workingDirPreamble += `\nCodeBolt base project directory for app-level configuration/plugins: ${baseProjectPath}`;
|
|
95
100
|
}
|
|
96
101
|
const directoryContext = `${workingDirPreamble}
|
|
97
102
|
Here is the folder structure of the current working directories:
|
|
@@ -13,6 +13,7 @@ export declare class EnvironmentContextModifier extends BaseMessageModifier {
|
|
|
13
13
|
private readonly defaultExcludePatterns;
|
|
14
14
|
constructor(options?: EnvironmentContextOptions);
|
|
15
15
|
modify(_originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
|
|
16
|
+
private readProjectAgentMd;
|
|
16
17
|
private generateFullContext;
|
|
17
18
|
private findRelevantFiles;
|
|
18
19
|
private walkDirectory;
|
|
@@ -81,7 +81,8 @@ class EnvironmentContextModifier extends base_1.BaseMessageModifier {
|
|
|
81
81
|
if (!projectPath) {
|
|
82
82
|
return createdMessage;
|
|
83
83
|
}
|
|
84
|
-
const currentDir = projectPath;
|
|
84
|
+
const currentDir = process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'] || projectPath;
|
|
85
|
+
const baseProjectPath = process.env['CODEBOLT_BASE_PROJECT_PATH'];
|
|
85
86
|
// Get basic directory listing
|
|
86
87
|
let directoryListing = '';
|
|
87
88
|
try {
|
|
@@ -97,11 +98,23 @@ class EnvironmentContextModifier extends base_1.BaseMessageModifier {
|
|
|
97
98
|
This is the CodeBolt AI Agent. Setting up context for our chat.
|
|
98
99
|
Today's date is ${today} (formatted according to the user's locale).
|
|
99
100
|
Operating system: ${platform}
|
|
100
|
-
|
|
101
|
+
Effective project directory for this task: ${currentDir}
|
|
102
|
+
${baseProjectPath ? `CodeBolt base project directory: ${baseProjectPath}
|
|
103
|
+
CodeBolt app-level configuration, providers, plugins, and .codebolt data are loaded from the base project directory. Code changes for the task should still target the effective project directory unless the user explicitly says otherwise.` : ''}
|
|
101
104
|
${directoryListing}
|
|
102
105
|
`.trim();
|
|
103
106
|
// Prepare context parts (same as gemini-cli)
|
|
104
107
|
const contextParts = [environmentContext];
|
|
108
|
+
const agentMdContext = await this.readProjectAgentMd(currentDir);
|
|
109
|
+
if (agentMdContext) {
|
|
110
|
+
contextParts.push(agentMdContext);
|
|
111
|
+
}
|
|
112
|
+
if (baseProjectPath && path.resolve(baseProjectPath) !== path.resolve(currentDir)) {
|
|
113
|
+
const baseAgentMdContext = await this.readProjectAgentMd(baseProjectPath, 'Base Project Agent Instructions');
|
|
114
|
+
if (baseAgentMdContext) {
|
|
115
|
+
contextParts.push(baseAgentMdContext);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
105
118
|
// Add full file context if enabled (just like gemini-cli does)
|
|
106
119
|
if (this.options.enableFullContext) {
|
|
107
120
|
try {
|
|
@@ -125,12 +138,14 @@ ${directoryListing}
|
|
|
125
138
|
metadata: {
|
|
126
139
|
...createdMessage.metadata,
|
|
127
140
|
environmentContextAdded: true,
|
|
141
|
+
projectAgentMdContextAdded: Boolean(agentMdContext),
|
|
128
142
|
fullContextAdded: this.options.enableFullContext,
|
|
129
143
|
contextFilesCount: this.options.enableFullContext ? await this.countContextFiles(currentDir) : 0,
|
|
130
144
|
environmentInfo: {
|
|
131
145
|
date: today,
|
|
132
146
|
platform,
|
|
133
|
-
currentDir
|
|
147
|
+
currentDir,
|
|
148
|
+
baseProjectPath
|
|
134
149
|
}
|
|
135
150
|
}
|
|
136
151
|
});
|
|
@@ -140,6 +155,31 @@ ${directoryListing}
|
|
|
140
155
|
return createdMessage;
|
|
141
156
|
}
|
|
142
157
|
}
|
|
158
|
+
async readProjectAgentMd(basePath, title = 'Project Agent Instructions') {
|
|
159
|
+
const agentMdPath = path.join(basePath, '.codebolt', 'agent.md');
|
|
160
|
+
const relativePath = path.relative(basePath, agentMdPath);
|
|
161
|
+
try {
|
|
162
|
+
const stats = await fs.promises.stat(agentMdPath);
|
|
163
|
+
if (!stats.isFile()) {
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
if (stats.size > this.options.maxFileSize) {
|
|
167
|
+
return `--- ${title} (${relativePath}) ---\n[File too large: ${stats.size} bytes]`;
|
|
168
|
+
}
|
|
169
|
+
const content = await fs.promises.readFile(agentMdPath, 'utf-8');
|
|
170
|
+
if (!content.trim()) {
|
|
171
|
+
return '';
|
|
172
|
+
}
|
|
173
|
+
return `--- ${title} (${relativePath}) ---\n${content}`;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const nodeError = error;
|
|
177
|
+
if (nodeError.code !== 'ENOENT') {
|
|
178
|
+
console.error(`Error reading ${relativePath}:`, error);
|
|
179
|
+
}
|
|
180
|
+
return '';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
143
183
|
// Full context methods (integrated like gemini-cli)
|
|
144
184
|
async generateFullContext(basePath) {
|
|
145
185
|
try {
|
|
@@ -16,7 +16,7 @@ class ShellProcessorModifier extends base_1.BasePostToolCallProcessor {
|
|
|
16
16
|
maxExecutionTime: options.maxExecutionTime || 10000, // 10 seconds
|
|
17
17
|
allowedCommands: options.allowedCommands || ['ls', 'pwd', 'echo', 'cat', 'head', 'tail', 'grep', 'find', 'wc'],
|
|
18
18
|
blockedCommands: options.blockedCommands || ['rm', 'del', 'format', 'sudo', 'su', 'chmod', 'chown', 'kill', 'killall'],
|
|
19
|
-
workingDirectory: options.workingDirectory || process.cwd()
|
|
19
|
+
workingDirectory: options.workingDirectory || process.env['CODEBOLT_EFFECTIVE_PROJECT_PATH'] || process.env['CODEBOLT_PROJECT_PATH'] || process.cwd()
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
async modify(input) {
|