erosolar-cli 2.1.238 → 2.1.239
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/README.md +9 -0
- package/dist/contracts/tools.schema.json +3 -1
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +5 -1
- package/dist/core/agent.js.map +1 -1
- package/dist/core/agentOrchestrator.d.ts +4 -0
- package/dist/core/agentOrchestrator.d.ts.map +1 -1
- package/dist/core/agentOrchestrator.js +58 -6
- package/dist/core/agentOrchestrator.js.map +1 -1
- package/dist/core/autoExecutionOrchestrator.d.ts +172 -0
- package/dist/core/autoExecutionOrchestrator.d.ts.map +1 -0
- package/dist/core/autoExecutionOrchestrator.js +591 -0
- package/dist/core/autoExecutionOrchestrator.js.map +1 -0
- package/dist/core/contextManager.d.ts.map +1 -1
- package/dist/core/contextManager.js.map +1 -1
- package/dist/core/dualAgentOrchestrator.d.ts +34 -0
- package/dist/core/dualAgentOrchestrator.d.ts.map +1 -0
- package/dist/core/dualAgentOrchestrator.js +94 -0
- package/dist/core/dualAgentOrchestrator.js.map +1 -0
- package/dist/core/errors/safetyValidator.d.ts +25 -12
- package/dist/core/errors/safetyValidator.d.ts.map +1 -1
- package/dist/core/errors/safetyValidator.js +165 -17
- package/dist/core/errors/safetyValidator.js.map +1 -1
- package/dist/core/governmentProcedures.d.ts +118 -0
- package/dist/core/governmentProcedures.d.ts.map +1 -0
- package/dist/core/governmentProcedures.js +912 -0
- package/dist/core/governmentProcedures.js.map +1 -0
- package/dist/core/infrastructureTemplates.d.ts +123 -0
- package/dist/core/infrastructureTemplates.d.ts.map +1 -0
- package/dist/core/infrastructureTemplates.js +1326 -0
- package/dist/core/infrastructureTemplates.js.map +1 -0
- package/dist/core/orchestration.d.ts +534 -0
- package/dist/core/orchestration.d.ts.map +1 -0
- package/dist/core/orchestration.js +2009 -0
- package/dist/core/orchestration.js.map +1 -0
- package/dist/core/persistentObjectiveStore.d.ts +292 -0
- package/dist/core/persistentObjectiveStore.d.ts.map +1 -0
- package/dist/core/persistentObjectiveStore.js +613 -0
- package/dist/core/persistentObjectiveStore.js.map +1 -0
- package/dist/core/preferences.js +1 -1
- package/dist/core/preferences.js.map +1 -1
- package/dist/core/reliabilityPrompt.d.ts.map +1 -1
- package/dist/core/reliabilityPrompt.js +3 -0
- package/dist/core/reliabilityPrompt.js.map +1 -1
- package/dist/core/securityDeliverableGenerator.d.ts +292 -0
- package/dist/core/securityDeliverableGenerator.d.ts.map +1 -0
- package/dist/core/securityDeliverableGenerator.js +1590 -0
- package/dist/core/securityDeliverableGenerator.js.map +1 -0
- package/dist/core/taskCompletionDetector.d.ts.map +1 -1
- package/dist/core/taskCompletionDetector.js +4 -1
- package/dist/core/taskCompletionDetector.js.map +1 -1
- package/dist/shell/autoExecutor.d.ts.map +1 -1
- package/dist/shell/autoExecutor.js +32 -3
- package/dist/shell/autoExecutor.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +9 -0
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +282 -190
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/tools/bashTools.d.ts +3 -5
- package/dist/tools/bashTools.d.ts.map +1 -1
- package/dist/tools/bashTools.js +259 -161
- package/dist/tools/bashTools.js.map +1 -1
- package/dist/tools/tao/index.d.ts +4 -4
- package/dist/tools/tao/index.d.ts.map +1 -1
- package/dist/tools/tao/index.js +15 -5
- package/dist/tools/tao/index.js.map +1 -1
- package/dist/tools/tao/rl.d.ts +164 -0
- package/dist/tools/tao/rl.d.ts.map +1 -0
- package/dist/tools/tao/rl.js +2998 -0
- package/dist/tools/tao/rl.js.map +1 -0
- package/dist/tools/taoTools.d.ts +2 -2
- package/dist/tools/taoTools.d.ts.map +1 -1
- package/dist/tools/taoTools.js +103 -20
- package/dist/tools/taoTools.js.map +1 -1
- package/dist/ui/PromptController.d.ts +3 -0
- package/dist/ui/PromptController.d.ts.map +1 -1
- package/dist/ui/PromptController.js +3 -0
- package/dist/ui/PromptController.js.map +1 -1
- package/dist/ui/UnifiedUIRenderer.d.ts +4 -0
- package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
- package/dist/ui/UnifiedUIRenderer.js +37 -6
- package/dist/ui/UnifiedUIRenderer.js.map +1 -1
- package/dist/ui/display.d.ts +9 -1
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +66 -9
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/shortcutsHelp.d.ts.map +1 -1
- package/dist/ui/shortcutsHelp.js +1 -0
- package/dist/ui/shortcutsHelp.js.map +1 -1
- package/package.json +3 -2
- package/dist/capabilities/askUserCapability.d.ts +0 -14
- package/dist/capabilities/askUserCapability.d.ts.map +0 -1
- package/dist/capabilities/askUserCapability.js +0 -134
- package/dist/capabilities/askUserCapability.js.map +0 -1
- package/dist/capabilities/codeGenerationCapability.d.ts +0 -13
- package/dist/capabilities/codeGenerationCapability.d.ts.map +0 -1
- package/dist/capabilities/codeGenerationCapability.js +0 -25
- package/dist/capabilities/codeGenerationCapability.js.map +0 -1
- package/dist/capabilities/performanceMonitoringCapability.d.ts +0 -108
- package/dist/capabilities/performanceMonitoringCapability.d.ts.map +0 -1
- package/dist/capabilities/performanceMonitoringCapability.js +0 -176
- package/dist/capabilities/performanceMonitoringCapability.js.map +0 -1
- package/dist/capabilities/todoCapability.d.ts +0 -19
- package/dist/capabilities/todoCapability.d.ts.map +0 -1
- package/dist/capabilities/todoCapability.js +0 -170
- package/dist/capabilities/todoCapability.js.map +0 -1
- package/dist/core/baseToolFactory.d.ts +0 -187
- package/dist/core/baseToolFactory.d.ts.map +0 -1
- package/dist/core/baseToolFactory.js +0 -352
- package/dist/core/baseToolFactory.js.map +0 -1
- package/dist/core/intelligentSummarizer.d.ts +0 -79
- package/dist/core/intelligentSummarizer.d.ts.map +0 -1
- package/dist/core/intelligentSummarizer.js +0 -273
- package/dist/core/intelligentSummarizer.js.map +0 -1
- package/dist/core/memorySystem.d.ts +0 -67
- package/dist/core/memorySystem.d.ts.map +0 -1
- package/dist/core/memorySystem.js +0 -334
- package/dist/core/memorySystem.js.map +0 -1
- package/dist/core/outputStyles.d.ts +0 -48
- package/dist/core/outputStyles.d.ts.map +0 -1
- package/dist/core/outputStyles.js +0 -270
- package/dist/core/outputStyles.js.map +0 -1
- package/dist/core/toolPatternAnalyzer.d.ts +0 -87
- package/dist/core/toolPatternAnalyzer.d.ts.map +0 -1
- package/dist/core/toolPatternAnalyzer.js +0 -272
- package/dist/core/toolPatternAnalyzer.js.map +0 -1
- package/dist/tools/backgroundBashTools.d.ts +0 -21
- package/dist/tools/backgroundBashTools.d.ts.map +0 -1
- package/dist/tools/backgroundBashTools.js +0 -215
- package/dist/tools/backgroundBashTools.js.map +0 -1
- package/dist/tools/code-quality-dashboard.d.ts +0 -57
- package/dist/tools/code-quality-dashboard.d.ts.map +0 -1
- package/dist/tools/code-quality-dashboard.js +0 -218
- package/dist/tools/code-quality-dashboard.js.map +0 -1
- package/dist/tools/tao/rlEngine.d.ts +0 -40
- package/dist/tools/tao/rlEngine.d.ts.map +0 -1
- package/dist/tools/tao/rlEngine.js +0 -237
- package/dist/tools/tao/rlEngine.js.map +0 -1
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory System - Erosolar-CLI Style (EROSOLAR.md)
|
|
3
|
-
*
|
|
4
|
-
* Hierarchical memory files for persistent context and project-specific instructions.
|
|
5
|
-
* Similar to Erosolar-CLI's CLAUDE.md system.
|
|
6
|
-
*
|
|
7
|
-
* Memory Hierarchy (highest to lowest priority):
|
|
8
|
-
* 1. Enterprise policy (~/.erosolar/EROSOLAR.md at OS level)
|
|
9
|
-
* 2. User memory (~/.erosolar/EROSOLAR.md)
|
|
10
|
-
* 3. Project memory (./EROSOLAR.md or ./.erosolar/EROSOLAR.md)
|
|
11
|
-
* 4. Directory memory (./subdirectory/EROSOLAR.md - recursive discovery)
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Automatic loading on session start
|
|
15
|
-
* - Recursive discovery in file tree
|
|
16
|
-
* - Import syntax (@path/to/import) for referencing other files
|
|
17
|
-
* - Maximum 5-level import depth
|
|
18
|
-
* - Quick addition via # prefix input
|
|
19
|
-
* - Direct editing with /memory command
|
|
20
|
-
*/
|
|
21
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
22
|
-
import { homedir } from 'node:os';
|
|
23
|
-
import { join, dirname, resolve, isAbsolute } from 'node:path';
|
|
24
|
-
const MEMORY_FILENAME = 'EROSOLAR.md';
|
|
25
|
-
const MAX_IMPORT_DEPTH = 5;
|
|
26
|
-
const MAX_MEMORY_SIZE = 100 * 1024; // 100KB max per file
|
|
27
|
-
/**
|
|
28
|
-
* Get user memory directory
|
|
29
|
-
*/
|
|
30
|
-
function getUserMemoryDir() {
|
|
31
|
-
return join(homedir(), '.erosolar');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get user memory file path
|
|
35
|
-
*/
|
|
36
|
-
function getUserMemoryPath() {
|
|
37
|
-
return join(getUserMemoryDir(), MEMORY_FILENAME);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get project memory file path (tries both locations)
|
|
41
|
-
*/
|
|
42
|
-
function getProjectMemoryPath(workingDir) {
|
|
43
|
-
// Try root level first
|
|
44
|
-
const rootPath = join(workingDir, MEMORY_FILENAME);
|
|
45
|
-
if (existsSync(rootPath)) {
|
|
46
|
-
return rootPath;
|
|
47
|
-
}
|
|
48
|
-
// Try .erosolar directory
|
|
49
|
-
const dotPath = join(workingDir, '.erosolar', MEMORY_FILENAME);
|
|
50
|
-
if (existsSync(dotPath)) {
|
|
51
|
-
return dotPath;
|
|
52
|
-
}
|
|
53
|
-
// Return default path for creation
|
|
54
|
-
return rootPath;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Find all memory files in directory tree (recursive upward and downward)
|
|
58
|
-
*/
|
|
59
|
-
function findMemoryFiles(workingDir, searchDownward = true) {
|
|
60
|
-
const files = [];
|
|
61
|
-
// Search upward to find project root memory files
|
|
62
|
-
let currentDir = workingDir;
|
|
63
|
-
const visited = new Set();
|
|
64
|
-
while (currentDir && !visited.has(currentDir)) {
|
|
65
|
-
visited.add(currentDir);
|
|
66
|
-
const memoryPath = join(currentDir, MEMORY_FILENAME);
|
|
67
|
-
if (existsSync(memoryPath)) {
|
|
68
|
-
files.push(memoryPath);
|
|
69
|
-
}
|
|
70
|
-
const dotMemoryPath = join(currentDir, '.erosolar', MEMORY_FILENAME);
|
|
71
|
-
if (existsSync(dotMemoryPath)) {
|
|
72
|
-
files.push(dotMemoryPath);
|
|
73
|
-
}
|
|
74
|
-
const parentDir = dirname(currentDir);
|
|
75
|
-
if (parentDir === currentDir)
|
|
76
|
-
break;
|
|
77
|
-
currentDir = parentDir;
|
|
78
|
-
}
|
|
79
|
-
// Optionally search downward (only one level to avoid performance issues)
|
|
80
|
-
if (searchDownward) {
|
|
81
|
-
try {
|
|
82
|
-
const entries = readdirSync(workingDir, { withFileTypes: true });
|
|
83
|
-
for (const entry of entries) {
|
|
84
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
85
|
-
const subMemoryPath = join(workingDir, entry.name, MEMORY_FILENAME);
|
|
86
|
-
if (existsSync(subMemoryPath)) {
|
|
87
|
-
files.push(subMemoryPath);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
// Ignore directory read errors
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return [...new Set(files)]; // Deduplicate
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Read file content safely with size limit
|
|
100
|
-
*/
|
|
101
|
-
function readFileSafe(path, maxSize = MAX_MEMORY_SIZE) {
|
|
102
|
-
try {
|
|
103
|
-
if (!existsSync(path)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const stats = statSync(path);
|
|
107
|
-
if (stats.size > maxSize) {
|
|
108
|
-
// Return truncated content with warning
|
|
109
|
-
const content = readFileSync(path, 'utf8').slice(0, maxSize);
|
|
110
|
-
return `${content}\n\n[Content truncated - file exceeds maximum size]`;
|
|
111
|
-
}
|
|
112
|
-
return readFileSync(path, 'utf8');
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Resolve @import syntax in memory files
|
|
120
|
-
*/
|
|
121
|
-
function resolveImportsRecursive(content, basePath, depth, visited) {
|
|
122
|
-
if (depth > MAX_IMPORT_DEPTH) {
|
|
123
|
-
return `${content}\n\n[Import depth limit reached]`;
|
|
124
|
-
}
|
|
125
|
-
// Match @path/to/file or @./relative/path patterns
|
|
126
|
-
const importPattern = /@([^\s\n]+)/g;
|
|
127
|
-
let result = content;
|
|
128
|
-
let match;
|
|
129
|
-
while ((match = importPattern.exec(content)) !== null) {
|
|
130
|
-
const importPath = match[1];
|
|
131
|
-
const fullPath = isAbsolute(importPath)
|
|
132
|
-
? importPath
|
|
133
|
-
: resolve(dirname(basePath), importPath);
|
|
134
|
-
if (visited.has(fullPath)) {
|
|
135
|
-
continue; // Prevent circular imports
|
|
136
|
-
}
|
|
137
|
-
const importedContent = readFileSafe(fullPath);
|
|
138
|
-
if (importedContent !== null) {
|
|
139
|
-
visited.add(fullPath);
|
|
140
|
-
const resolvedContent = resolveImportsRecursive(importedContent, fullPath, depth + 1, visited);
|
|
141
|
-
result = result.replace(match[0], resolvedContent);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Determine memory source type from path
|
|
148
|
-
*/
|
|
149
|
-
function getMemorySource(path, workingDir) {
|
|
150
|
-
const userDir = getUserMemoryDir();
|
|
151
|
-
if (path.startsWith(userDir)) {
|
|
152
|
-
return 'user';
|
|
153
|
-
}
|
|
154
|
-
if (path === join(workingDir, MEMORY_FILENAME) ||
|
|
155
|
-
path === join(workingDir, '.erosolar', MEMORY_FILENAME)) {
|
|
156
|
-
return 'project';
|
|
157
|
-
}
|
|
158
|
-
return 'directory';
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Create the memory system
|
|
162
|
-
*/
|
|
163
|
-
export function createMemorySystem() {
|
|
164
|
-
return {
|
|
165
|
-
loadAllMemory(workingDir) {
|
|
166
|
-
const memoryFiles = [];
|
|
167
|
-
let priority = 0;
|
|
168
|
-
// Load user memory (highest priority)
|
|
169
|
-
const userMemoryPath = getUserMemoryPath();
|
|
170
|
-
const userContent = readFileSafe(userMemoryPath);
|
|
171
|
-
if (userContent) {
|
|
172
|
-
memoryFiles.push({
|
|
173
|
-
path: userMemoryPath,
|
|
174
|
-
content: userContent,
|
|
175
|
-
source: 'user',
|
|
176
|
-
priority: priority++,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
// Load project and directory memory files
|
|
180
|
-
const projectFiles = findMemoryFiles(workingDir);
|
|
181
|
-
for (const filePath of projectFiles) {
|
|
182
|
-
const content = readFileSafe(filePath);
|
|
183
|
-
if (content) {
|
|
184
|
-
memoryFiles.push({
|
|
185
|
-
path: filePath,
|
|
186
|
-
content,
|
|
187
|
-
source: getMemorySource(filePath, workingDir),
|
|
188
|
-
priority: priority++,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return memoryFiles;
|
|
193
|
-
},
|
|
194
|
-
loadMemoryFile(path) {
|
|
195
|
-
const content = readFileSafe(path);
|
|
196
|
-
if (!content) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
path,
|
|
201
|
-
content,
|
|
202
|
-
source: 'directory', // Will be overridden by caller if needed
|
|
203
|
-
priority: 0,
|
|
204
|
-
};
|
|
205
|
-
},
|
|
206
|
-
saveToProjectMemory(workingDir, content) {
|
|
207
|
-
const memoryPath = getProjectMemoryPath(workingDir) ?? join(workingDir, MEMORY_FILENAME);
|
|
208
|
-
try {
|
|
209
|
-
const dir = dirname(memoryPath);
|
|
210
|
-
mkdirSync(dir, { recursive: true });
|
|
211
|
-
writeFileSync(memoryPath, content, 'utf8');
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
saveToUserMemory(content) {
|
|
219
|
-
const memoryPath = getUserMemoryPath();
|
|
220
|
-
try {
|
|
221
|
-
mkdirSync(getUserMemoryDir(), { recursive: true });
|
|
222
|
-
writeFileSync(memoryPath, content, 'utf8');
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
appendToProjectMemory(workingDir, content) {
|
|
230
|
-
const memoryPath = getProjectMemoryPath(workingDir) ?? join(workingDir, MEMORY_FILENAME);
|
|
231
|
-
const existingContent = readFileSafe(memoryPath) ?? '';
|
|
232
|
-
const timestamp = new Date().toISOString().split('T')[0];
|
|
233
|
-
const newEntry = `\n\n## Added ${timestamp}\n\n${content}`;
|
|
234
|
-
return this.saveToProjectMemory(workingDir, existingContent + newEntry);
|
|
235
|
-
},
|
|
236
|
-
appendToUserMemory(content) {
|
|
237
|
-
const existingContent = readFileSafe(getUserMemoryPath()) ?? '';
|
|
238
|
-
const timestamp = new Date().toISOString().split('T')[0];
|
|
239
|
-
const newEntry = `\n\n## Added ${timestamp}\n\n${content}`;
|
|
240
|
-
return this.saveToUserMemory(existingContent + newEntry);
|
|
241
|
-
},
|
|
242
|
-
getMemoryPaths(workingDir) {
|
|
243
|
-
const paths = [];
|
|
244
|
-
const userPath = getUserMemoryPath();
|
|
245
|
-
if (existsSync(userPath)) {
|
|
246
|
-
paths.push(userPath);
|
|
247
|
-
}
|
|
248
|
-
paths.push(...findMemoryFiles(workingDir));
|
|
249
|
-
return [...new Set(paths)];
|
|
250
|
-
},
|
|
251
|
-
resolveImports(content, basePath, depth = 0) {
|
|
252
|
-
return resolveImportsRecursive(content, basePath, depth, new Set());
|
|
253
|
-
},
|
|
254
|
-
parseAtReferences(input, workingDir) {
|
|
255
|
-
const references = [];
|
|
256
|
-
// Match @path/to/file or @path/to/file:10-20 (with line range)
|
|
257
|
-
const refPattern = /@([^\s]+?)(?::(\d+)(?:-(\d+))?)?(?=\s|$)/g;
|
|
258
|
-
let cleanInput = input;
|
|
259
|
-
let match;
|
|
260
|
-
while ((match = refPattern.exec(input)) !== null) {
|
|
261
|
-
const refPath = match[1];
|
|
262
|
-
const startLine = match[2] ? parseInt(match[2], 10) : undefined;
|
|
263
|
-
const endLine = match[3] ? parseInt(match[3], 10) : startLine;
|
|
264
|
-
const fullPath = isAbsolute(refPath)
|
|
265
|
-
? refPath
|
|
266
|
-
: resolve(workingDir, refPath);
|
|
267
|
-
const content = readFileSafe(fullPath, MAX_MEMORY_SIZE * 2);
|
|
268
|
-
if (content !== null) {
|
|
269
|
-
let fileContent = content;
|
|
270
|
-
// Extract line range if specified
|
|
271
|
-
if (startLine !== undefined) {
|
|
272
|
-
const lines = content.split('\n');
|
|
273
|
-
const start = Math.max(0, startLine - 1);
|
|
274
|
-
const end = endLine ? Math.min(lines.length, endLine) : start + 1;
|
|
275
|
-
fileContent = lines.slice(start, end).join('\n');
|
|
276
|
-
}
|
|
277
|
-
references.push({
|
|
278
|
-
path: refPath,
|
|
279
|
-
content: fileContent,
|
|
280
|
-
lineRange: startLine ? { start: startLine, end: endLine ?? startLine } : undefined,
|
|
281
|
-
});
|
|
282
|
-
cleanInput = cleanInput.replace(match[0], '');
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return { cleanInput: cleanInput.trim(), references };
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Format memory content for display in system prompt
|
|
291
|
-
*/
|
|
292
|
-
export function formatMemoryForPrompt(memoryFiles) {
|
|
293
|
-
if (memoryFiles.length === 0) {
|
|
294
|
-
return '';
|
|
295
|
-
}
|
|
296
|
-
const sections = [];
|
|
297
|
-
for (const memory of memoryFiles) {
|
|
298
|
-
const sourceLabel = {
|
|
299
|
-
'enterprise': 'Enterprise Policy',
|
|
300
|
-
'user': 'User Preferences',
|
|
301
|
-
'project': 'Project Memory',
|
|
302
|
-
'directory': 'Directory Context',
|
|
303
|
-
}[memory.source];
|
|
304
|
-
sections.push(`<memory source="${sourceLabel}" path="${memory.path}">\n${memory.content}\n</memory>`);
|
|
305
|
-
}
|
|
306
|
-
return `\n<project-memory>\n${sections.join('\n\n')}\n</project-memory>\n`;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Format referenced files for prompt context
|
|
310
|
-
*/
|
|
311
|
-
export function formatReferencesForPrompt(references) {
|
|
312
|
-
if (references.length === 0) {
|
|
313
|
-
return '';
|
|
314
|
-
}
|
|
315
|
-
const sections = [];
|
|
316
|
-
for (const ref of references) {
|
|
317
|
-
const rangeStr = ref.lineRange
|
|
318
|
-
? ` lines ${ref.lineRange.start}-${ref.lineRange.end}`
|
|
319
|
-
: '';
|
|
320
|
-
sections.push(`<file path="${ref.path}"${rangeStr}>\n${ref.content}\n</file>`);
|
|
321
|
-
}
|
|
322
|
-
return `\n<referenced-files>\n${sections.join('\n\n')}\n</referenced-files>\n`;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Global memory system instance
|
|
326
|
-
*/
|
|
327
|
-
let globalMemorySystem = null;
|
|
328
|
-
export function getMemorySystem() {
|
|
329
|
-
if (!globalMemorySystem) {
|
|
330
|
-
globalMemorySystem = createMemorySystem();
|
|
331
|
-
}
|
|
332
|
-
return globalMemorySystem;
|
|
333
|
-
}
|
|
334
|
-
//# sourceMappingURL=memorySystem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":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,CAAC,OAAO,WAAW,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,yBAAyB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,IAAI,kBAAkB,GAAwB,IAAI,CAAC;AAEnD,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output Styles System - Erosolar-CLI Style
|
|
3
|
-
*
|
|
4
|
-
* Configurable output styles that modify how the agent responds.
|
|
5
|
-
* Similar to Erosolar-CLI's output-styles feature.
|
|
6
|
-
*
|
|
7
|
-
* Built-in Styles:
|
|
8
|
-
* - Default: Standard system prompt for efficient software engineering
|
|
9
|
-
* - Explanatory: Educational insights between coding tasks
|
|
10
|
-
* - Learning: Collaborative learn-by-doing mode with TODO(human) markers
|
|
11
|
-
* - Concise: Minimal output, focuses on code changes only
|
|
12
|
-
*
|
|
13
|
-
* Custom styles can be created in:
|
|
14
|
-
* - ~/.erosolar/output-styles/ (user-level)
|
|
15
|
-
* - .erosolar/output-styles/ (project-level)
|
|
16
|
-
*/
|
|
17
|
-
export type BuiltInStyleId = 'default' | 'explanatory' | 'learning' | 'concise';
|
|
18
|
-
export interface OutputStyle {
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
instructions: string;
|
|
23
|
-
isBuiltIn: boolean;
|
|
24
|
-
source: 'built-in' | 'user' | 'project';
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get all available output styles
|
|
28
|
-
*/
|
|
29
|
-
export declare function getAvailableStyles(workingDir: string): OutputStyle[];
|
|
30
|
-
/**
|
|
31
|
-
* Get a specific output style by ID
|
|
32
|
-
*/
|
|
33
|
-
export declare function getOutputStyle(id: string, workingDir: string): OutputStyle | null;
|
|
34
|
-
/**
|
|
35
|
-
* Create a custom output style
|
|
36
|
-
*/
|
|
37
|
-
export declare function createCustomStyle(style: Omit<OutputStyle, 'isBuiltIn' | 'source'>, location: 'user' | 'project', workingDir?: string): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Format style for system prompt injection
|
|
40
|
-
*/
|
|
41
|
-
export declare function formatStyleForPrompt(style: OutputStyle): string;
|
|
42
|
-
export declare function getCurrentStyleId(): string;
|
|
43
|
-
export declare function setCurrentStyleId(id: string): void;
|
|
44
|
-
/**
|
|
45
|
-
* Format styles list for display
|
|
46
|
-
*/
|
|
47
|
-
export declare function formatStylesListForDisplay(styles: OutputStyle[], currentId: string): string;
|
|
48
|
-
//# sourceMappingURL=outputStyles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outputStyles.d.ts","sourceRoot":"","sources":["../../src/core/outputStyles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;CACzC;AA6ID;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,EAAE,CAoBpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAuBjF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,QAAQ,CAAC,EAChD,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAsBT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAI/D;AAOD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAiC3F"}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output Styles System - Erosolar-CLI Style
|
|
3
|
-
*
|
|
4
|
-
* Configurable output styles that modify how the agent responds.
|
|
5
|
-
* Similar to Erosolar-CLI's output-styles feature.
|
|
6
|
-
*
|
|
7
|
-
* Built-in Styles:
|
|
8
|
-
* - Default: Standard system prompt for efficient software engineering
|
|
9
|
-
* - Explanatory: Educational insights between coding tasks
|
|
10
|
-
* - Learning: Collaborative learn-by-doing mode with TODO(human) markers
|
|
11
|
-
* - Concise: Minimal output, focuses on code changes only
|
|
12
|
-
*
|
|
13
|
-
* Custom styles can be created in:
|
|
14
|
-
* - ~/.erosolar/output-styles/ (user-level)
|
|
15
|
-
* - .erosolar/output-styles/ (project-level)
|
|
16
|
-
*/
|
|
17
|
-
import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
18
|
-
import { homedir } from 'node:os';
|
|
19
|
-
import { join } from 'node:path';
|
|
20
|
-
const USER_STYLES_DIR = join(homedir(), '.erosolar', 'output-styles');
|
|
21
|
-
const PROJECT_STYLES_SUBDIR = '.erosolar/output-styles';
|
|
22
|
-
/**
|
|
23
|
-
* Built-in output styles
|
|
24
|
-
*/
|
|
25
|
-
const BUILT_IN_STYLES = {
|
|
26
|
-
default: {
|
|
27
|
-
id: 'default',
|
|
28
|
-
name: 'Default',
|
|
29
|
-
description: 'Standard efficient software engineering mode',
|
|
30
|
-
instructions: `You are an expert software engineer. Focus on:
|
|
31
|
-
- Writing clean, maintainable code
|
|
32
|
-
- Providing direct, actionable solutions
|
|
33
|
-
- Following best practices and conventions
|
|
34
|
-
- Being concise while remaining helpful
|
|
35
|
-
- Explaining only when necessary for understanding`,
|
|
36
|
-
},
|
|
37
|
-
explanatory: {
|
|
38
|
-
id: 'explanatory',
|
|
39
|
-
name: 'Explanatory',
|
|
40
|
-
description: 'Educational mode with detailed explanations',
|
|
41
|
-
instructions: `You are an expert software engineer and educator. Focus on:
|
|
42
|
-
- Explaining the "why" behind code decisions
|
|
43
|
-
- Teaching concepts as you implement solutions
|
|
44
|
-
- Providing context about patterns and best practices
|
|
45
|
-
- Breaking down complex problems step by step
|
|
46
|
-
- Offering alternative approaches when relevant
|
|
47
|
-
- Including comments that explain non-obvious code
|
|
48
|
-
|
|
49
|
-
When making changes:
|
|
50
|
-
1. Briefly explain what you're about to do and why
|
|
51
|
-
2. Implement the solution with inline comments
|
|
52
|
-
3. Summarize key learnings after completion`,
|
|
53
|
-
},
|
|
54
|
-
learning: {
|
|
55
|
-
id: 'learning',
|
|
56
|
-
name: 'Learning',
|
|
57
|
-
description: 'Collaborative learn-by-doing mode',
|
|
58
|
-
instructions: `You are a collaborative coding mentor helping the user learn by doing. Focus on:
|
|
59
|
-
- Guiding rather than solving directly
|
|
60
|
-
- Asking questions to prompt thinking
|
|
61
|
-
- Leaving room for the user to complete parts of the solution
|
|
62
|
-
- Using TODO(human) markers for tasks the user should complete
|
|
63
|
-
- Explaining concepts as they become relevant
|
|
64
|
-
- Celebrating progress and building confidence
|
|
65
|
-
|
|
66
|
-
When implementing solutions:
|
|
67
|
-
1. Start with a high-level plan
|
|
68
|
-
2. Implement core structure, leaving some parts as TODO(human)
|
|
69
|
-
3. Explain what each TODO requires
|
|
70
|
-
4. Encourage the user to try implementing those parts
|
|
71
|
-
|
|
72
|
-
Example TODO format:
|
|
73
|
-
\`\`\`
|
|
74
|
-
// TODO(human): Implement the validation logic here
|
|
75
|
-
// Hint: Check if the input is a valid email format
|
|
76
|
-
// Consider using a regex pattern like /^[^@]+@[^@]+\\.[^@]+$/
|
|
77
|
-
\`\`\``,
|
|
78
|
-
},
|
|
79
|
-
concise: {
|
|
80
|
-
id: 'concise',
|
|
81
|
-
name: 'Concise',
|
|
82
|
-
description: 'Minimal output, code-focused',
|
|
83
|
-
instructions: `Be extremely concise. Focus exclusively on code changes.
|
|
84
|
-
- No explanations unless critical for understanding
|
|
85
|
-
- No summaries or recaps
|
|
86
|
-
- Direct code modifications only
|
|
87
|
-
- Single-line responses when possible
|
|
88
|
-
- Skip pleasantries and transitions`,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Parse a custom style file (Markdown with YAML frontmatter)
|
|
93
|
-
*/
|
|
94
|
-
function parseStyleFile(content, source) {
|
|
95
|
-
try {
|
|
96
|
-
// Extract YAML frontmatter
|
|
97
|
-
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
98
|
-
if (!frontmatterMatch) {
|
|
99
|
-
// No frontmatter, use entire content as instructions
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
const [, frontmatter, body] = frontmatterMatch;
|
|
103
|
-
if (!frontmatter || !body)
|
|
104
|
-
return null;
|
|
105
|
-
// Parse simple YAML (id, name, description)
|
|
106
|
-
const parseYamlField = (yaml, field) => {
|
|
107
|
-
const match = yaml.match(new RegExp(`^${field}:\\s*(.+)$`, 'm'));
|
|
108
|
-
return match ? match[1].trim().replace(/^["']|["']$/g, '') : null;
|
|
109
|
-
};
|
|
110
|
-
const id = parseYamlField(frontmatter, 'id');
|
|
111
|
-
const name = parseYamlField(frontmatter, 'name') ?? id;
|
|
112
|
-
const description = parseYamlField(frontmatter, 'description') ?? '';
|
|
113
|
-
if (!id)
|
|
114
|
-
return null;
|
|
115
|
-
return {
|
|
116
|
-
id,
|
|
117
|
-
name: name ?? id,
|
|
118
|
-
description,
|
|
119
|
-
instructions: body.trim(),
|
|
120
|
-
isBuiltIn: false,
|
|
121
|
-
source,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Load custom styles from a directory
|
|
130
|
-
*/
|
|
131
|
-
function loadStylesFromDir(dir, source) {
|
|
132
|
-
if (!existsSync(dir)) {
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
const styles = [];
|
|
136
|
-
try {
|
|
137
|
-
const files = readdirSync(dir).filter(f => f.endsWith('.md'));
|
|
138
|
-
for (const file of files) {
|
|
139
|
-
const content = readFileSync(join(dir, file), 'utf8');
|
|
140
|
-
const style = parseStyleFile(content, source);
|
|
141
|
-
if (style) {
|
|
142
|
-
styles.push(style);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
// Ignore directory read errors
|
|
148
|
-
}
|
|
149
|
-
return styles;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Get all available output styles
|
|
153
|
-
*/
|
|
154
|
-
export function getAvailableStyles(workingDir) {
|
|
155
|
-
const styles = [];
|
|
156
|
-
// Add built-in styles
|
|
157
|
-
for (const style of Object.values(BUILT_IN_STYLES)) {
|
|
158
|
-
styles.push({
|
|
159
|
-
...style,
|
|
160
|
-
isBuiltIn: true,
|
|
161
|
-
source: 'built-in',
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
// Add user styles
|
|
165
|
-
styles.push(...loadStylesFromDir(USER_STYLES_DIR, 'user'));
|
|
166
|
-
// Add project styles
|
|
167
|
-
const projectStylesDir = join(workingDir, PROJECT_STYLES_SUBDIR);
|
|
168
|
-
styles.push(...loadStylesFromDir(projectStylesDir, 'project'));
|
|
169
|
-
return styles;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get a specific output style by ID
|
|
173
|
-
*/
|
|
174
|
-
export function getOutputStyle(id, workingDir) {
|
|
175
|
-
// Check built-in styles first
|
|
176
|
-
if (id in BUILT_IN_STYLES) {
|
|
177
|
-
const style = BUILT_IN_STYLES[id];
|
|
178
|
-
return {
|
|
179
|
-
...style,
|
|
180
|
-
isBuiltIn: true,
|
|
181
|
-
source: 'built-in',
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
// Check user styles
|
|
185
|
-
const userStyles = loadStylesFromDir(USER_STYLES_DIR, 'user');
|
|
186
|
-
const userStyle = userStyles.find(s => s.id === id);
|
|
187
|
-
if (userStyle)
|
|
188
|
-
return userStyle;
|
|
189
|
-
// Check project styles
|
|
190
|
-
const projectStylesDir = join(workingDir, PROJECT_STYLES_SUBDIR);
|
|
191
|
-
const projectStyles = loadStylesFromDir(projectStylesDir, 'project');
|
|
192
|
-
const projectStyle = projectStyles.find(s => s.id === id);
|
|
193
|
-
if (projectStyle)
|
|
194
|
-
return projectStyle;
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Create a custom output style
|
|
199
|
-
*/
|
|
200
|
-
export function createCustomStyle(style, location, workingDir) {
|
|
201
|
-
const dir = location === 'user'
|
|
202
|
-
? USER_STYLES_DIR
|
|
203
|
-
: join(workingDir ?? process.cwd(), PROJECT_STYLES_SUBDIR);
|
|
204
|
-
try {
|
|
205
|
-
mkdirSync(dir, { recursive: true });
|
|
206
|
-
const content = `---
|
|
207
|
-
id: ${style.id}
|
|
208
|
-
name: ${style.name}
|
|
209
|
-
description: ${style.description}
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
${style.instructions}
|
|
213
|
-
`;
|
|
214
|
-
writeFileSync(join(dir, `${style.id}.md`), content, 'utf8');
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Format style for system prompt injection
|
|
223
|
-
*/
|
|
224
|
-
export function formatStyleForPrompt(style) {
|
|
225
|
-
return `<output-style name="${style.name}">
|
|
226
|
-
${style.instructions}
|
|
227
|
-
</output-style>`;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Style preference storage
|
|
231
|
-
*/
|
|
232
|
-
let currentStyleId = 'default';
|
|
233
|
-
export function getCurrentStyleId() {
|
|
234
|
-
return currentStyleId;
|
|
235
|
-
}
|
|
236
|
-
export function setCurrentStyleId(id) {
|
|
237
|
-
currentStyleId = id;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Format styles list for display
|
|
241
|
-
*/
|
|
242
|
-
export function formatStylesListForDisplay(styles, currentId) {
|
|
243
|
-
const lines = ['Available Output Styles:', ''];
|
|
244
|
-
const bySource = {
|
|
245
|
-
'built-in': styles.filter(s => s.source === 'built-in'),
|
|
246
|
-
'user': styles.filter(s => s.source === 'user'),
|
|
247
|
-
'project': styles.filter(s => s.source === 'project'),
|
|
248
|
-
};
|
|
249
|
-
const formatStyle = (s) => {
|
|
250
|
-
const marker = s.id === currentId ? '●' : '○';
|
|
251
|
-
return ` ${marker} ${s.name} (${s.id}) - ${s.description}`;
|
|
252
|
-
};
|
|
253
|
-
if (bySource['built-in'].length > 0) {
|
|
254
|
-
lines.push('Built-in:');
|
|
255
|
-
lines.push(...bySource['built-in'].map(formatStyle));
|
|
256
|
-
lines.push('');
|
|
257
|
-
}
|
|
258
|
-
if (bySource['user'].length > 0) {
|
|
259
|
-
lines.push('User (~/.erosolar/output-styles/):');
|
|
260
|
-
lines.push(...bySource['user'].map(formatStyle));
|
|
261
|
-
lines.push('');
|
|
262
|
-
}
|
|
263
|
-
if (bySource['project'].length > 0) {
|
|
264
|
-
lines.push('Project (.erosolar/output-styles/):');
|
|
265
|
-
lines.push(...bySource['project'].map(formatStyle));
|
|
266
|
-
lines.push('');
|
|
267
|
-
}
|
|
268
|
-
return lines.join('\n');
|
|
269
|
-
}
|
|
270
|
-
//# sourceMappingURL=outputStyles.js.map
|