agent-sh 0.12.5 → 0.12.7
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/tools/edit-file.js +2 -1
- package/dist/agent/tools/expand-home.d.ts +1 -0
- package/dist/agent/tools/expand-home.js +8 -0
- package/dist/agent/tools/glob.js +2 -1
- package/dist/agent/tools/grep.js +2 -1
- package/dist/agent/tools/ls.js +2 -1
- package/dist/agent/tools/read-file.js +2 -1
- package/dist/agent/tools/write-file.js +2 -1
- package/dist/shell/shell.js +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { computeEditDiff } from "../../utils/diff.js";
|
|
4
|
+
import { expandHome } from "./expand-home.js";
|
|
4
5
|
/**
|
|
5
6
|
* Find the closest matching region in the file content to help diagnose
|
|
6
7
|
* why an exact match failed. Returns a hint string.
|
|
@@ -75,7 +76,7 @@ export function createEditFileTool(getCwd) {
|
|
|
75
76
|
return m ? { summary: m[1] } : {};
|
|
76
77
|
},
|
|
77
78
|
async execute(args, onChunk) {
|
|
78
|
-
const filePath = args.path;
|
|
79
|
+
const filePath = expandHome(args.path);
|
|
79
80
|
const oldText = args.old_text;
|
|
80
81
|
const newText = args.new_text;
|
|
81
82
|
const replaceAll = args.replace_all ?? false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function expandHome(p: string): string;
|
package/dist/agent/tools/glob.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { executeCommand } from "../../executor.js";
|
|
4
|
+
import { expandHome } from "./expand-home.js";
|
|
4
5
|
export function createGlobTool(getCwd) {
|
|
5
6
|
return {
|
|
6
7
|
name: "glob",
|
|
@@ -39,7 +40,7 @@ export function createGlobTool(getCwd) {
|
|
|
39
40
|
}),
|
|
40
41
|
async execute(args) {
|
|
41
42
|
const pattern = args.pattern;
|
|
42
|
-
const searchPath = args.path ?? ".";
|
|
43
|
+
const searchPath = expandHome(args.path ?? ".");
|
|
43
44
|
// Use ripgrep for correct glob matching + .gitignore awareness
|
|
44
45
|
const shellEsc = (s) => "'" + s.replace(/'/g, "'\\''") + "'";
|
|
45
46
|
const parts = [
|
package/dist/agent/tools/grep.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeCommand } from "../../executor.js";
|
|
2
|
+
import { expandHome } from "./expand-home.js";
|
|
2
3
|
export function createGrepTool(getCwd) {
|
|
3
4
|
return {
|
|
4
5
|
name: "grep",
|
|
@@ -80,7 +81,7 @@ export function createGrepTool(getCwd) {
|
|
|
80
81
|
}),
|
|
81
82
|
async execute(args) {
|
|
82
83
|
const pattern = args.pattern;
|
|
83
|
-
const searchPath = args.path ?? ".";
|
|
84
|
+
const searchPath = expandHome(args.path ?? ".");
|
|
84
85
|
const include = args.include;
|
|
85
86
|
const mode = args.output_mode ?? "files_with_matches";
|
|
86
87
|
const caseInsensitive = args.case_insensitive;
|
package/dist/agent/tools/ls.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { expandHome } from "./expand-home.js";
|
|
3
4
|
function formatSize(bytes) {
|
|
4
5
|
if (bytes < 1024)
|
|
5
6
|
return `${bytes}B`;
|
|
@@ -38,7 +39,7 @@ export function createLsTool(getCwd) {
|
|
|
38
39
|
return { summary: `${lines.length} entries` };
|
|
39
40
|
},
|
|
40
41
|
async execute(args) {
|
|
41
|
-
const dirPath = args.path ?? ".";
|
|
42
|
+
const dirPath = expandHome(args.path ?? ".");
|
|
42
43
|
const absPath = path.resolve(getCwd(), dirPath);
|
|
43
44
|
try {
|
|
44
45
|
const entries = await fs.readdir(absPath, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { expandHome } from "./expand-home.js";
|
|
3
4
|
export function createReadFileTool(getCwd, cache) {
|
|
4
5
|
return {
|
|
5
6
|
name: "read_file",
|
|
@@ -39,7 +40,7 @@ export function createReadFileTool(getCwd, cache) {
|
|
|
39
40
|
return { summary: `${lines.length} lines` };
|
|
40
41
|
},
|
|
41
42
|
async execute(args) {
|
|
42
|
-
const filePath = args.path;
|
|
43
|
+
const filePath = expandHome(args.path);
|
|
43
44
|
const absPath = path.resolve(getCwd(), filePath);
|
|
44
45
|
const reqOffset = args.offset ?? 1;
|
|
45
46
|
const reqLimit = args.limit;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { computeDiff } from "../../utils/diff.js";
|
|
4
|
+
import { expandHome } from "./expand-home.js";
|
|
4
5
|
export function createWriteFileTool(getCwd) {
|
|
5
6
|
return {
|
|
6
7
|
name: "write_file",
|
|
@@ -35,7 +36,7 @@ export function createWriteFileTool(getCwd) {
|
|
|
35
36
|
return m ? { summary: m[1] } : {};
|
|
36
37
|
},
|
|
37
38
|
async execute(args, onChunk) {
|
|
38
|
-
const filePath = args.path;
|
|
39
|
+
const filePath = expandHome(args.path);
|
|
39
40
|
const content = args.content;
|
|
40
41
|
const absPath = path.resolve(getCwd(), filePath);
|
|
41
42
|
try {
|
package/dist/shell/shell.js
CHANGED
|
@@ -97,6 +97,7 @@ export class Shell {
|
|
|
97
97
|
...(showIndicator ? [` ${titleCmd}`] : []),
|
|
98
98
|
" __agent_sh_preexec_ran=0",
|
|
99
99
|
"}",
|
|
100
|
+
`PROMPT_COMMAND="\${PROMPT_COMMAND%;}"`,
|
|
100
101
|
`PROMPT_COMMAND="\${PROMPT_COMMAND:+\$PROMPT_COMMAND;}__agent_sh_precmd"`,
|
|
101
102
|
"",
|
|
102
103
|
"# Preexec hook via DEBUG trap: emit actual command text so agent-sh",
|