@probelabs/probe 0.6.0-rc258 → 0.6.0-rc259
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/bin/binaries/{probe-v0.6.0-rc258-aarch64-apple-darwin.tar.gz → probe-v0.6.0-rc259-aarch64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/probe-v0.6.0-rc259-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/{probe-v0.6.0-rc258-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc259-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/probe-v0.6.0-rc259-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc259-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +13 -0
- package/build/agent/index.js +177 -19
- package/build/agent/probeTool.js +9 -0
- package/build/agent/tools.js +8 -0
- package/build/index.js +7 -2
- package/build/tools/common.js +56 -23
- package/build/tools/edit.js +139 -6
- package/build/tools/index.js +5 -2
- package/cjs/agent/ProbeAgent.cjs +177 -19
- package/cjs/index.cjs +187 -19
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +13 -0
- package/src/agent/probeTool.js +9 -0
- package/src/agent/tools.js +8 -0
- package/src/index.js +7 -2
- package/src/tools/common.js +56 -23
- package/src/tools/edit.js +139 -6
- package/src/tools/index.js +5 -2
- package/bin/binaries/probe-v0.6.0-rc258-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc258-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc258-x86_64-unknown-linux-musl.tar.gz +0 -0
package/src/tools/edit.js
CHANGED
|
@@ -363,7 +363,7 @@ Parameters:
|
|
|
363
363
|
required: ['file_path', 'new_string']
|
|
364
364
|
},
|
|
365
365
|
|
|
366
|
-
execute: async ({ file_path, old_string, new_string, replace_all = false, symbol, position, start_line, end_line }) => {
|
|
366
|
+
execute: async ({ file_path, old_string, new_string, replace_all = false, symbol, position, start_line, end_line, workingDirectory }) => {
|
|
367
367
|
try {
|
|
368
368
|
// Validate input parameters
|
|
369
369
|
if (!file_path || typeof file_path !== 'string' || file_path.trim() === '') {
|
|
@@ -373,8 +373,9 @@ Parameters:
|
|
|
373
373
|
return `Error editing file: Invalid new_string - must be a string. Provide the replacement content as a string value (empty string "" is valid for deletions).`;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
// Resolve the file path
|
|
377
|
-
const
|
|
376
|
+
// Resolve the file path (workingDirectory from runtime takes priority over cwd from tool creation)
|
|
377
|
+
const effectiveCwd = workingDirectory || cwd || process.cwd();
|
|
378
|
+
const resolvedPath = isAbsolute(file_path) ? file_path : resolve(effectiveCwd, file_path);
|
|
378
379
|
|
|
379
380
|
if (debug) {
|
|
380
381
|
console.error(`[Edit] Attempting to edit file: ${resolvedPath}`);
|
|
@@ -530,7 +531,7 @@ Important:
|
|
|
530
531
|
required: ['file_path', 'content']
|
|
531
532
|
},
|
|
532
533
|
|
|
533
|
-
execute: async ({ file_path, content, overwrite = false }) => {
|
|
534
|
+
execute: async ({ file_path, content, overwrite = false, workingDirectory }) => {
|
|
534
535
|
try {
|
|
535
536
|
// Validate input parameters
|
|
536
537
|
if (!file_path || typeof file_path !== 'string' || file_path.trim() === '') {
|
|
@@ -540,8 +541,9 @@ Important:
|
|
|
540
541
|
return `Error creating file: Invalid content - must be a string. Provide the file content as a string value (empty string "" is valid for an empty file).`;
|
|
541
542
|
}
|
|
542
543
|
|
|
543
|
-
// Resolve the file path
|
|
544
|
-
const
|
|
544
|
+
// Resolve the file path (workingDirectory from runtime takes priority over cwd from tool creation)
|
|
545
|
+
const effectiveCwd = workingDirectory || cwd || process.cwd();
|
|
546
|
+
const resolvedPath = isAbsolute(file_path) ? file_path : resolve(effectiveCwd, file_path);
|
|
545
547
|
|
|
546
548
|
if (debug) {
|
|
547
549
|
console.error(`[Create] Attempting to create file: ${resolvedPath}`);
|
|
@@ -587,6 +589,86 @@ Important:
|
|
|
587
589
|
});
|
|
588
590
|
};
|
|
589
591
|
|
|
592
|
+
/**
|
|
593
|
+
* Multi-edit tool — apply multiple edit operations in a single call.
|
|
594
|
+
* Reuses the edit tool internally; edits are applied sequentially.
|
|
595
|
+
*
|
|
596
|
+
* @param {Object} [options] - Same configuration as editTool
|
|
597
|
+
* @returns {Object} Configured multi_edit tool
|
|
598
|
+
*/
|
|
599
|
+
export const multiEditTool = (options = {}) => {
|
|
600
|
+
const editInstance = editTool(options);
|
|
601
|
+
|
|
602
|
+
return tool({
|
|
603
|
+
name: 'multi_edit',
|
|
604
|
+
description: 'Apply multiple file edits in a single tool call. Accepts a JSON array of edit operations.',
|
|
605
|
+
|
|
606
|
+
inputSchema: {
|
|
607
|
+
type: 'object',
|
|
608
|
+
properties: {
|
|
609
|
+
edits: {
|
|
610
|
+
type: 'string',
|
|
611
|
+
description: 'JSON array of edit operations. Each object supports: file_path, old_string, new_string, replace_all, symbol, position, start_line, end_line.'
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
required: ['edits']
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
execute: async ({ edits: rawEdits }) => {
|
|
618
|
+
let edits;
|
|
619
|
+
if (typeof rawEdits === 'string') {
|
|
620
|
+
try {
|
|
621
|
+
edits = JSON.parse(rawEdits);
|
|
622
|
+
} catch (e) {
|
|
623
|
+
return `Error: Invalid JSON in edits parameter - ${e.message}. Provide a raw JSON array between <edits> tags.`;
|
|
624
|
+
}
|
|
625
|
+
} else if (Array.isArray(rawEdits)) {
|
|
626
|
+
edits = rawEdits;
|
|
627
|
+
} else {
|
|
628
|
+
return 'Error: edits must be a JSON array of edit operations.';
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (!Array.isArray(edits) || edits.length === 0) {
|
|
632
|
+
return 'Error: edits must be a non-empty JSON array.';
|
|
633
|
+
}
|
|
634
|
+
if (edits.length > 50) {
|
|
635
|
+
return `Error: Too many edits (${edits.length}). Maximum 50 per batch.`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const results = [];
|
|
639
|
+
let successCount = 0;
|
|
640
|
+
let failCount = 0;
|
|
641
|
+
|
|
642
|
+
for (let i = 0; i < edits.length; i++) {
|
|
643
|
+
const editOp = edits[i];
|
|
644
|
+
if (!editOp || typeof editOp !== 'object' || Array.isArray(editOp)) {
|
|
645
|
+
results.push(`[${i + 1}] FAIL: Invalid edit operation - must be an object`);
|
|
646
|
+
failCount++;
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
try {
|
|
650
|
+
const result = await editInstance.execute(editOp);
|
|
651
|
+
const isError = typeof result === 'string' && result.startsWith('Error');
|
|
652
|
+
if (isError) {
|
|
653
|
+
results.push(`[${i + 1}] FAIL: ${result}`);
|
|
654
|
+
failCount++;
|
|
655
|
+
} else {
|
|
656
|
+
results.push(`[${i + 1}] OK: ${result}`);
|
|
657
|
+
successCount++;
|
|
658
|
+
}
|
|
659
|
+
} catch (error) {
|
|
660
|
+
results.push(`[${i + 1}] FAIL: ${error.message}`);
|
|
661
|
+
failCount++;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const summary = `Multi-edit: ${successCount}/${edits.length} succeeded` +
|
|
666
|
+
(failCount > 0 ? `, ${failCount} failed` : '');
|
|
667
|
+
return summary + '\n\n' + results.join('\n');
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
|
|
590
672
|
// Export schemas for tool definitions
|
|
591
673
|
export const editSchema = {
|
|
592
674
|
type: 'object',
|
|
@@ -647,9 +729,21 @@ export const createSchema = {
|
|
|
647
729
|
required: ['file_path', 'content']
|
|
648
730
|
};
|
|
649
731
|
|
|
732
|
+
export const multiEditSchema = {
|
|
733
|
+
type: 'object',
|
|
734
|
+
properties: {
|
|
735
|
+
edits: {
|
|
736
|
+
type: 'string',
|
|
737
|
+
description: 'JSON array of edit operations'
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
required: ['edits']
|
|
741
|
+
};
|
|
742
|
+
|
|
650
743
|
// Tool descriptions for XML definitions
|
|
651
744
|
export const editDescription = 'Edit files using text replacement, AST-aware symbol operations, or line-targeted editing. Supports fuzzy matching for text edits and optional hash-based integrity verification for line edits.';
|
|
652
745
|
export const createDescription = 'Create new files with specified content. Will create parent directories if needed.';
|
|
746
|
+
export const multiEditDescription = 'Apply multiple file edits in a single tool call. Accepts a JSON array of edit operations, each supporting the same modes as the edit tool.';
|
|
653
747
|
|
|
654
748
|
// XML tool definitions
|
|
655
749
|
export const editToolDefinition = `
|
|
@@ -808,3 +902,42 @@ Examples:
|
|
|
808
902
|
This is a new project.</content>
|
|
809
903
|
<overwrite>true</overwrite>
|
|
810
904
|
</create>`;
|
|
905
|
+
|
|
906
|
+
export const multiEditToolDefinition = `
|
|
907
|
+
## multi_edit
|
|
908
|
+
Description: ${multiEditDescription}
|
|
909
|
+
|
|
910
|
+
Apply multiple edits in one call. Each operation in the array uses the same parameters as the edit tool:
|
|
911
|
+
- file_path, old_string, new_string (text mode)
|
|
912
|
+
- file_path, symbol, new_string (symbol replace)
|
|
913
|
+
- file_path, symbol, new_string, position (symbol insert)
|
|
914
|
+
- file_path, start_line, new_string (line-targeted)
|
|
915
|
+
|
|
916
|
+
Edits are applied sequentially. Failures do not stop remaining edits. Maximum 50 edits per call.
|
|
917
|
+
|
|
918
|
+
Parameters:
|
|
919
|
+
- edits: (required) JSON array of edit objects. Place raw JSON between tags.
|
|
920
|
+
|
|
921
|
+
When to use multi_edit vs edit:
|
|
922
|
+
- Use edit for a single change to one file
|
|
923
|
+
- Use multi_edit when making 2+ related changes across files (e.g., rename a function and update all call sites)
|
|
924
|
+
- Use multi_edit for coordinated multi-file refactoring where order matters
|
|
925
|
+
|
|
926
|
+
Examples:
|
|
927
|
+
|
|
928
|
+
Multiple text replacements across files:
|
|
929
|
+
<multi_edit>
|
|
930
|
+
<edits>[
|
|
931
|
+
{"file_path": "src/main.js", "old_string": "return false;", "new_string": "return true;"},
|
|
932
|
+
{"file_path": "src/config.js", "old_string": "debug: false", "new_string": "debug: true"}
|
|
933
|
+
]</edits>
|
|
934
|
+
</multi_edit>
|
|
935
|
+
|
|
936
|
+
Mixed edit modes in one batch:
|
|
937
|
+
<multi_edit>
|
|
938
|
+
<edits>[
|
|
939
|
+
{"file_path": "src/utils.js", "symbol": "oldHelper", "new_string": "function newHelper() { return 42; }"},
|
|
940
|
+
{"file_path": "src/main.js", "old_string": "oldHelper()", "new_string": "newHelper()", "replace_all": true},
|
|
941
|
+
{"file_path": "src/index.js", "start_line": "10", "end_line": "12", "new_string": "export { newHelper };"}
|
|
942
|
+
]</edits>
|
|
943
|
+
</multi_edit>`;
|
package/src/tools/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Export Vercel AI SDK tool generators
|
|
7
7
|
export { searchTool, queryTool, extractTool, delegateTool } from './vercel.js';
|
|
8
8
|
export { bashTool } from './bash.js';
|
|
9
|
-
export { editTool, createTool } from './edit.js';
|
|
9
|
+
export { editTool, createTool, multiEditTool } from './edit.js';
|
|
10
10
|
|
|
11
11
|
// Export LangChain tools
|
|
12
12
|
export { createSearchTool, createQueryTool, createExtractTool } from './langchain.js';
|
|
@@ -39,10 +39,13 @@ export {
|
|
|
39
39
|
export {
|
|
40
40
|
editSchema,
|
|
41
41
|
createSchema,
|
|
42
|
+
multiEditSchema,
|
|
42
43
|
editDescription,
|
|
43
44
|
createDescription,
|
|
45
|
+
multiEditDescription,
|
|
44
46
|
editToolDefinition,
|
|
45
|
-
createToolDefinition
|
|
47
|
+
createToolDefinition,
|
|
48
|
+
multiEditToolDefinition
|
|
46
49
|
} from './edit.js';
|
|
47
50
|
|
|
48
51
|
// Export system message
|
|
Binary file
|
|
Binary file
|
|
Binary file
|