@defai.digital/ax-cli 0.0.34
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/.automatosx/agents/aerospace-scientist.yaml +159 -0
- package/.automatosx/agents/architecture.yaml +244 -0
- package/.automatosx/agents/backend.yaml +172 -0
- package/.automatosx/agents/ceo.yaml +105 -0
- package/.automatosx/agents/creative-marketer.yaml +173 -0
- package/.automatosx/agents/cto.yaml +118 -0
- package/.automatosx/agents/data-scientist.yaml +200 -0
- package/.automatosx/agents/data.yaml +106 -0
- package/.automatosx/agents/design.yaml +115 -0
- package/.automatosx/agents/devops.yaml +124 -0
- package/.automatosx/agents/frontend.yaml +171 -0
- package/.automatosx/agents/fullstack.yaml +172 -0
- package/.automatosx/agents/mobile.yaml +185 -0
- package/.automatosx/agents/product.yaml +103 -0
- package/.automatosx/agents/quality.yaml +93 -0
- package/.automatosx/agents/quantum-engineer.yaml +167 -0
- package/.automatosx/agents/researcher.yaml +122 -0
- package/.automatosx/agents/security.yaml +115 -0
- package/.automatosx/agents/standard.yaml +214 -0
- package/.automatosx/agents/writer.yaml +122 -0
- package/.automatosx/feature-flags.json +13 -0
- package/.automatosx/memory/memory.db +0 -0
- package/.automatosx/providers/README.md +117 -0
- package/.automatosx/providers/grok-zai.yaml.template +61 -0
- package/.automatosx/providers/grok.yaml.template +71 -0
- package/.automatosx/status/backend-1763517593334-85037.json +9 -0
- package/.automatosx/status/quality-1763516867087-82043.json +9 -0
- package/.automatosx/status/quality-1763516976722-84817.json +9 -0
- package/.automatosx/status/security-1763517871950-87357.json +9 -0
- package/.automatosx/teams/business.yaml +56 -0
- package/.automatosx/teams/core.yaml +60 -0
- package/.automatosx/teams/design.yaml +58 -0
- package/.automatosx/teams/engineering.yaml +69 -0
- package/.automatosx/teams/research.yaml +56 -0
- package/.automatosx/templates/analyst.yaml +60 -0
- package/.automatosx/templates/assistant.yaml +48 -0
- package/.automatosx/templates/basic-agent.yaml +28 -0
- package/.automatosx/templates/code-reviewer.yaml +52 -0
- package/.automatosx/templates/debugger.yaml +63 -0
- package/.automatosx/templates/designer.yaml +69 -0
- package/.automatosx/templates/developer.yaml +60 -0
- package/.automatosx/templates/fullstack-developer.yaml +395 -0
- package/.automatosx/templates/qa-specialist.yaml +71 -0
- package/.claude/mcp/automatosx.json +244 -0
- package/.claude/settings.local.json +34 -0
- package/.grok/settings.json +37 -0
- package/LICENSE +26 -0
- package/README.md +518 -0
- package/automatosx/PRD/README.md +9 -0
- package/automatosx/tmp/README.md +10 -0
- package/automatosx.config.json +333 -0
- package/dist/agent/grok-agent.d.ts +52 -0
- package/dist/agent/grok-agent.js +627 -0
- package/dist/agent/grok-agent.js.map +1 -0
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.js +136 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +239 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/grok/client.d.ts +49 -0
- package/dist/grok/client.js +80 -0
- package/dist/grok/client.js.map +1 -0
- package/dist/grok/tools.d.ts +8 -0
- package/dist/grok/tools.js +349 -0
- package/dist/grok/tools.js.map +1 -0
- package/dist/hooks/use-enhanced-input.d.ts +37 -0
- package/dist/hooks/use-enhanced-input.js +214 -0
- package/dist/hooks/use-enhanced-input.js.map +1 -0
- package/dist/hooks/use-input-handler.d.ts +34 -0
- package/dist/hooks/use-input-handler.js +608 -0
- package/dist/hooks/use-input-handler.js.map +1 -0
- package/dist/hooks/use-input-history.d.ts +9 -0
- package/dist/hooks/use-input-history.js +69 -0
- package/dist/hooks/use-input-history.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +339 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +31 -0
- package/dist/mcp/client.js +152 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/config.d.ts +13 -0
- package/dist/mcp/config.js +43 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/transports.d.ts +48 -0
- package/dist/mcp/transports.js +217 -0
- package/dist/mcp/transports.js.map +1 -0
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.js +105 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/tools/bash.d.ts +10 -0
- package/dist/tools/bash.js +82 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/confirmation-tool.d.ts +16 -0
- package/dist/tools/confirmation-tool.js +72 -0
- package/dist/tools/confirmation-tool.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/morph-editor.d.ts +36 -0
- package/dist/tools/morph-editor.js +308 -0
- package/dist/tools/morph-editor.js.map +1 -0
- package/dist/tools/search.d.ts +68 -0
- package/dist/tools/search.js +300 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/text-editor.d.ts +16 -0
- package/dist/tools/text-editor.js +526 -0
- package/dist/tools/text-editor.js.map +1 -0
- package/dist/tools/todo-tool.d.ts +20 -0
- package/dist/tools/todo-tool.js +129 -0
- package/dist/tools/todo-tool.js.map +1 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/app.d.ts +7 -0
- package/dist/ui/app.js +99 -0
- package/dist/ui/app.js.map +1 -0
- package/dist/ui/components/api-key-input.d.ts +7 -0
- package/dist/ui/components/api-key-input.js +80 -0
- package/dist/ui/components/api-key-input.js.map +1 -0
- package/dist/ui/components/chat-history.d.ts +8 -0
- package/dist/ui/components/chat-history.js +157 -0
- package/dist/ui/components/chat-history.js.map +1 -0
- package/dist/ui/components/chat-input.d.ts +9 -0
- package/dist/ui/components/chat-input.js +67 -0
- package/dist/ui/components/chat-input.js.map +1 -0
- package/dist/ui/components/chat-interface.d.ts +8 -0
- package/dist/ui/components/chat-interface.js +272 -0
- package/dist/ui/components/chat-interface.js.map +1 -0
- package/dist/ui/components/command-suggestions.d.ts +17 -0
- package/dist/ui/components/command-suggestions.js +22 -0
- package/dist/ui/components/command-suggestions.js.map +1 -0
- package/dist/ui/components/confirmation-dialog.d.ts +11 -0
- package/dist/ui/components/confirmation-dialog.js +105 -0
- package/dist/ui/components/confirmation-dialog.js.map +1 -0
- package/dist/ui/components/diff-renderer.d.ts +13 -0
- package/dist/ui/components/diff-renderer.js +186 -0
- package/dist/ui/components/diff-renderer.js.map +1 -0
- package/dist/ui/components/loading-spinner.d.ts +8 -0
- package/dist/ui/components/loading-spinner.js +59 -0
- package/dist/ui/components/loading-spinner.js.map +1 -0
- package/dist/ui/components/mcp-status.d.ts +5 -0
- package/dist/ui/components/mcp-status.js +36 -0
- package/dist/ui/components/mcp-status.js.map +1 -0
- package/dist/ui/components/model-selection.d.ts +12 -0
- package/dist/ui/components/model-selection.js +17 -0
- package/dist/ui/components/model-selection.js.map +1 -0
- package/dist/ui/shared/max-sized-box.d.ts +8 -0
- package/dist/ui/shared/max-sized-box.js +6 -0
- package/dist/ui/shared/max-sized-box.js.map +1 -0
- package/dist/ui/utils/code-colorizer.d.ts +2 -0
- package/dist/ui/utils/code-colorizer.js +7 -0
- package/dist/ui/utils/code-colorizer.js.map +1 -0
- package/dist/ui/utils/colors.d.ts +14 -0
- package/dist/ui/utils/colors.js +15 -0
- package/dist/ui/utils/colors.js.map +1 -0
- package/dist/ui/utils/markdown-renderer.d.ts +4 -0
- package/dist/ui/utils/markdown-renderer.js +23 -0
- package/dist/ui/utils/markdown-renderer.js.map +1 -0
- package/dist/utils/confirmation-service.d.ts +32 -0
- package/dist/utils/confirmation-service.js +109 -0
- package/dist/utils/confirmation-service.js.map +1 -0
- package/dist/utils/custom-instructions.d.ts +1 -0
- package/dist/utils/custom-instructions.js +17 -0
- package/dist/utils/custom-instructions.js.map +1 -0
- package/dist/utils/model-config.d.ts +28 -0
- package/dist/utils/model-config.js +42 -0
- package/dist/utils/model-config.js.map +1 -0
- package/dist/utils/settings-manager.d.ts +94 -0
- package/dist/utils/settings-manager.js +240 -0
- package/dist/utils/settings-manager.js.map +1 -0
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.js +4 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/text-utils.d.ts +80 -0
- package/dist/utils/text-utils.js +182 -0
- package/dist/utils/text-utils.js.map +1 -0
- package/dist/utils/token-counter.d.ts +33 -0
- package/dist/utils/token-counter.js +78 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import * as fs from "fs-extra";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
export class SearchTool {
|
|
5
|
+
currentDirectory = process.cwd();
|
|
6
|
+
/**
|
|
7
|
+
* Unified search method that can search for text content or find files
|
|
8
|
+
*/
|
|
9
|
+
async search(query, options = {}) {
|
|
10
|
+
try {
|
|
11
|
+
const searchType = options.searchType || "both";
|
|
12
|
+
const results = [];
|
|
13
|
+
// Search for text content if requested
|
|
14
|
+
if (searchType === "text" || searchType === "both") {
|
|
15
|
+
const textResults = await this.executeRipgrep(query, options);
|
|
16
|
+
results.push(...textResults.map((r) => ({
|
|
17
|
+
type: "text",
|
|
18
|
+
file: r.file,
|
|
19
|
+
line: r.line,
|
|
20
|
+
column: r.column,
|
|
21
|
+
text: r.text,
|
|
22
|
+
match: r.match,
|
|
23
|
+
})));
|
|
24
|
+
}
|
|
25
|
+
// Search for files if requested
|
|
26
|
+
if (searchType === "files" || searchType === "both") {
|
|
27
|
+
const fileResults = await this.findFilesByPattern(query, options);
|
|
28
|
+
results.push(...fileResults.map((r) => ({
|
|
29
|
+
type: "file",
|
|
30
|
+
file: r.path,
|
|
31
|
+
score: r.score,
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
if (results.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
output: `No results found for "${query}"`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const formattedOutput = this.formatUnifiedResults(results, query, searchType);
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
output: formattedOutput,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Search error: ${error.message}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Execute ripgrep command with specified options
|
|
55
|
+
*/
|
|
56
|
+
async executeRipgrep(query, options) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const args = [
|
|
59
|
+
"--json",
|
|
60
|
+
"--with-filename",
|
|
61
|
+
"--line-number",
|
|
62
|
+
"--column",
|
|
63
|
+
"--no-heading",
|
|
64
|
+
"--color=never",
|
|
65
|
+
];
|
|
66
|
+
// Add case sensitivity
|
|
67
|
+
if (!options.caseSensitive) {
|
|
68
|
+
args.push("--ignore-case");
|
|
69
|
+
}
|
|
70
|
+
// Add whole word matching
|
|
71
|
+
if (options.wholeWord) {
|
|
72
|
+
args.push("--word-regexp");
|
|
73
|
+
}
|
|
74
|
+
// Add regex mode
|
|
75
|
+
if (!options.regex) {
|
|
76
|
+
args.push("--fixed-strings");
|
|
77
|
+
}
|
|
78
|
+
// Add max results limit
|
|
79
|
+
if (options.maxResults) {
|
|
80
|
+
args.push("--max-count", options.maxResults.toString());
|
|
81
|
+
}
|
|
82
|
+
// Add file type filters
|
|
83
|
+
if (options.fileTypes) {
|
|
84
|
+
options.fileTypes.forEach((type) => {
|
|
85
|
+
args.push("--type", type);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Add include pattern
|
|
89
|
+
if (options.includePattern) {
|
|
90
|
+
args.push("--glob", options.includePattern);
|
|
91
|
+
}
|
|
92
|
+
// Add exclude pattern
|
|
93
|
+
if (options.excludePattern) {
|
|
94
|
+
args.push("--glob", `!${options.excludePattern}`);
|
|
95
|
+
}
|
|
96
|
+
// Add exclude files
|
|
97
|
+
if (options.excludeFiles) {
|
|
98
|
+
options.excludeFiles.forEach((file) => {
|
|
99
|
+
args.push("--glob", `!${file}`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Respect gitignore and common ignore patterns
|
|
103
|
+
args.push("--no-require-git", "--follow", "--glob", "!.git/**", "--glob", "!node_modules/**", "--glob", "!.DS_Store", "--glob", "!*.log");
|
|
104
|
+
// Add query and search directory
|
|
105
|
+
args.push(query, this.currentDirectory);
|
|
106
|
+
const rg = spawn("rg", args);
|
|
107
|
+
let output = "";
|
|
108
|
+
let errorOutput = "";
|
|
109
|
+
rg.stdout.on("data", (data) => {
|
|
110
|
+
output += data.toString();
|
|
111
|
+
});
|
|
112
|
+
rg.stderr.on("data", (data) => {
|
|
113
|
+
errorOutput += data.toString();
|
|
114
|
+
});
|
|
115
|
+
rg.on("close", (code) => {
|
|
116
|
+
if (code === 0 || code === 1) {
|
|
117
|
+
// 0 = found, 1 = not found
|
|
118
|
+
const results = this.parseRipgrepOutput(output);
|
|
119
|
+
resolve(results);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
reject(new Error(`Ripgrep failed with code ${code}: ${errorOutput}`));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
rg.on("error", (error) => {
|
|
126
|
+
reject(error);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse ripgrep JSON output into SearchResult objects
|
|
132
|
+
*/
|
|
133
|
+
parseRipgrepOutput(output) {
|
|
134
|
+
const results = [];
|
|
135
|
+
const lines = output
|
|
136
|
+
.trim()
|
|
137
|
+
.split("\n")
|
|
138
|
+
.filter((line) => line.length > 0);
|
|
139
|
+
for (const line of lines) {
|
|
140
|
+
try {
|
|
141
|
+
const parsed = JSON.parse(line);
|
|
142
|
+
if (parsed.type === "match") {
|
|
143
|
+
const data = parsed.data;
|
|
144
|
+
results.push({
|
|
145
|
+
file: data.path.text,
|
|
146
|
+
line: data.line_number,
|
|
147
|
+
column: data.submatches[0]?.start || 0,
|
|
148
|
+
text: data.lines.text.trim(),
|
|
149
|
+
match: data.submatches[0]?.match?.text || "",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
// Skip invalid JSON lines
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return results;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Find files by pattern using a simple file walking approach
|
|
162
|
+
*/
|
|
163
|
+
async findFilesByPattern(pattern, options) {
|
|
164
|
+
const files = [];
|
|
165
|
+
const maxResults = options.maxResults || 50;
|
|
166
|
+
const searchPattern = pattern.toLowerCase();
|
|
167
|
+
const walkDir = async (dir, depth = 0) => {
|
|
168
|
+
if (depth > 10 || files.length >= maxResults)
|
|
169
|
+
return; // Prevent infinite recursion and limit results
|
|
170
|
+
try {
|
|
171
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (files.length >= maxResults)
|
|
174
|
+
break;
|
|
175
|
+
const fullPath = path.join(dir, entry.name);
|
|
176
|
+
const relativePath = path.relative(this.currentDirectory, fullPath);
|
|
177
|
+
// Skip hidden files unless explicitly included
|
|
178
|
+
if (!options.includeHidden && entry.name.startsWith(".")) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
// Skip common directories
|
|
182
|
+
if (entry.isDirectory() &&
|
|
183
|
+
[
|
|
184
|
+
"node_modules",
|
|
185
|
+
".git",
|
|
186
|
+
".svn",
|
|
187
|
+
".hg",
|
|
188
|
+
"dist",
|
|
189
|
+
"build",
|
|
190
|
+
".next",
|
|
191
|
+
".cache",
|
|
192
|
+
].includes(entry.name)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
// Apply exclude pattern
|
|
196
|
+
if (options.excludePattern &&
|
|
197
|
+
relativePath.includes(options.excludePattern)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (entry.isFile()) {
|
|
201
|
+
const score = this.calculateFileScore(entry.name, relativePath, searchPattern);
|
|
202
|
+
if (score > 0) {
|
|
203
|
+
files.push({
|
|
204
|
+
path: relativePath,
|
|
205
|
+
name: entry.name,
|
|
206
|
+
score,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else if (entry.isDirectory()) {
|
|
211
|
+
await walkDir(fullPath, depth + 1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
// Skip directories we can't read
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
await walkDir(this.currentDirectory);
|
|
220
|
+
// Sort by score (descending) and return top results
|
|
221
|
+
return files.sort((a, b) => b.score - a.score).slice(0, maxResults);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Calculate fuzzy match score for file names
|
|
225
|
+
*/
|
|
226
|
+
calculateFileScore(fileName, filePath, pattern) {
|
|
227
|
+
const lowerFileName = fileName.toLowerCase();
|
|
228
|
+
const lowerFilePath = filePath.toLowerCase();
|
|
229
|
+
// Exact matches get highest score
|
|
230
|
+
if (lowerFileName === pattern)
|
|
231
|
+
return 100;
|
|
232
|
+
if (lowerFileName.includes(pattern))
|
|
233
|
+
return 80;
|
|
234
|
+
// Path matches get medium score
|
|
235
|
+
if (lowerFilePath.includes(pattern))
|
|
236
|
+
return 60;
|
|
237
|
+
// Fuzzy matching - check if all characters of pattern exist in order
|
|
238
|
+
let patternIndex = 0;
|
|
239
|
+
for (let i = 0; i < lowerFileName.length && patternIndex < pattern.length; i++) {
|
|
240
|
+
if (lowerFileName[i] === pattern[patternIndex]) {
|
|
241
|
+
patternIndex++;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (patternIndex === pattern.length) {
|
|
245
|
+
// All characters found in order - score based on how close they are
|
|
246
|
+
return Math.max(10, 40 - (fileName.length - pattern.length));
|
|
247
|
+
}
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Format unified search results for display
|
|
252
|
+
*/
|
|
253
|
+
formatUnifiedResults(results, query, _searchType) {
|
|
254
|
+
if (results.length === 0) {
|
|
255
|
+
return `No results found for "${query}"`;
|
|
256
|
+
}
|
|
257
|
+
let output = `Search results for "${query}":\n`;
|
|
258
|
+
// Separate text and file results
|
|
259
|
+
const textResults = results.filter((r) => r.type === "text");
|
|
260
|
+
const fileResults = results.filter((r) => r.type === "file");
|
|
261
|
+
// Show all unique files (from both text matches and file matches)
|
|
262
|
+
const allFiles = new Set();
|
|
263
|
+
// Add files from text results
|
|
264
|
+
textResults.forEach((result) => {
|
|
265
|
+
allFiles.add(result.file);
|
|
266
|
+
});
|
|
267
|
+
// Add files from file search results
|
|
268
|
+
fileResults.forEach((result) => {
|
|
269
|
+
allFiles.add(result.file);
|
|
270
|
+
});
|
|
271
|
+
const fileList = Array.from(allFiles);
|
|
272
|
+
const displayLimit = 8;
|
|
273
|
+
// Show files in compact format
|
|
274
|
+
fileList.slice(0, displayLimit).forEach((file) => {
|
|
275
|
+
// Count matches in this file for text results
|
|
276
|
+
const matchCount = textResults.filter((r) => r.file === file).length;
|
|
277
|
+
const matchIndicator = matchCount > 0 ? ` (${matchCount} matches)` : "";
|
|
278
|
+
output += ` ${file}${matchIndicator}\n`;
|
|
279
|
+
});
|
|
280
|
+
// Show "+X more" if there are additional results
|
|
281
|
+
if (fileList.length > displayLimit) {
|
|
282
|
+
const remaining = fileList.length - displayLimit;
|
|
283
|
+
output += ` ... +${remaining} more\n`;
|
|
284
|
+
}
|
|
285
|
+
return output.trim();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Update current working directory
|
|
289
|
+
*/
|
|
290
|
+
setCurrentDirectory(directory) {
|
|
291
|
+
this.currentDirectory = directory;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get current working directory
|
|
295
|
+
*/
|
|
296
|
+
getCurrentDirectory() {
|
|
297
|
+
return this.currentDirectory;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA0B7B,MAAM,OAAO,UAAU;IACb,gBAAgB,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,KAAa,EACb,UAWI,EAAE;QAEN,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC;YAChD,MAAM,OAAO,GAA0B,EAAE,CAAC;YAE1C,uCAAuC;YACvC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBACnD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC9D,OAAO,CAAC,IAAI,CACV,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACzB,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,KAAK,EAAE,CAAC,CAAC,KAAK;iBACf,CAAC,CAAC,CACJ,CAAC;YACJ,CAAC;YAED,gCAAgC;YAChC,IAAI,UAAU,KAAK,OAAO,IAAI,UA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AM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,YAAY,GAAG,CAAC,CAAC;QAEvB,+BAA+B;QAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/C,8CAA8C;YAC9C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC;YACrE,MAAM,cAAc,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,IAAI,GAAG,cAAc,IAAI,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,iDAAiD;QACjD,IAAI,QAAQ,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;YACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,YAAY,CAAC;YACjD,MAAM,IAAI,UAAU,SAAS,SAAS,CAAC;QACzC,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,SAAiB;QACnC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ToolResult, EditorCommand } from "../types/index.js";
|
|
2
|
+
export declare class TextEditorTool {
|
|
3
|
+
private editHistory;
|
|
4
|
+
private confirmationService;
|
|
5
|
+
view(filePath: string, viewRange?: [number, number]): Promise<ToolResult>;
|
|
6
|
+
strReplace(filePath: string, oldStr: string, newStr: string, replaceAll?: boolean): Promise<ToolResult>;
|
|
7
|
+
create(filePath: string, content: string): Promise<ToolResult>;
|
|
8
|
+
replaceLines(filePath: string, startLine: number, endLine: number, newContent: string): Promise<ToolResult>;
|
|
9
|
+
insert(filePath: string, insertLine: number, content: string): Promise<ToolResult>;
|
|
10
|
+
undoEdit(): Promise<ToolResult>;
|
|
11
|
+
private findFuzzyMatch;
|
|
12
|
+
private normalizeForComparison;
|
|
13
|
+
private isSimilarStructure;
|
|
14
|
+
private generateDiff;
|
|
15
|
+
getEditHistory(): EditorCommand[];
|
|
16
|
+
}
|