agentool 0.0.1 → 1.0.0
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 +627 -52
- package/dist/ask-user/index.cjs +8 -0
- package/dist/ask-user/index.d.cts +68 -0
- package/dist/ask-user/index.d.ts +68 -0
- package/dist/ask-user/index.js +8 -0
- package/dist/bash/index.cjs +8 -0
- package/dist/bash/index.d.cts +63 -0
- package/dist/bash/index.d.ts +63 -0
- package/dist/bash/index.js +8 -0
- package/dist/chunk-3EPGFWZV.cjs +30 -0
- package/dist/chunk-3VO6NETR.cjs +79 -0
- package/dist/chunk-4YI2H55A.js +142 -0
- package/dist/chunk-5NW4OGRI.cjs +99 -0
- package/dist/chunk-6MDPYALY.js +196 -0
- package/dist/chunk-6PQLFDGT.js +117 -0
- package/dist/chunk-7QL4BQCH.js +40 -0
- package/dist/chunk-CAEVLIQB.cjs +117 -0
- package/dist/chunk-CGTPF6IS.js +90 -0
- package/dist/chunk-EA3YV7ZG.js +79 -0
- package/dist/chunk-FAEGCFTO.js +136 -0
- package/dist/chunk-FV2R5FFQ.cjs +102 -0
- package/dist/chunk-FW3UJ622.cjs +59 -0
- package/dist/chunk-G3ITTPGX.js +99 -0
- package/dist/chunk-HDKXSKMO.js +30 -0
- package/dist/chunk-HZAQRHBT.js +99 -0
- package/dist/chunk-I3ONDY7P.js +46 -0
- package/dist/chunk-I6KFFQPV.cjs +58 -0
- package/dist/chunk-IMZQ7ELK.cjs +196 -0
- package/dist/chunk-JCTBB7H2.cjs +40 -0
- package/dist/chunk-K77GC2QI.js +59 -0
- package/dist/chunk-LPV5CN2K.js +58 -0
- package/dist/chunk-MF7CJVIZ.js +40 -0
- package/dist/chunk-MIYA7TNR.cjs +123 -0
- package/dist/chunk-MJCAXASI.js +123 -0
- package/dist/chunk-MXFW3XY6.cjs +73 -0
- package/dist/chunk-ONBH74ZV.cjs +90 -0
- package/dist/chunk-OXLQ7QVL.cjs +40 -0
- package/dist/chunk-QEJV2KZ4.cjs +159 -0
- package/dist/chunk-QZ5GS6HW.cjs +46 -0
- package/dist/chunk-S6QEY7UY.js +73 -0
- package/dist/chunk-SUSAPI5W.cjs +142 -0
- package/dist/chunk-TBVHHF3H.cjs +47 -0
- package/dist/chunk-U2YMJM25.cjs +115 -0
- package/dist/chunk-VLNDEVKS.js +102 -0
- package/dist/chunk-XKG2A3EW.js +159 -0
- package/dist/chunk-XLD2Y3SS.cjs +136 -0
- package/dist/chunk-Y7KOKDFP.js +115 -0
- package/dist/chunk-YPPPGGLA.cjs +99 -0
- package/dist/chunk-ZHCMEQJJ.js +47 -0
- package/dist/context-compaction/index.cjs +8 -0
- package/dist/context-compaction/index.d.cts +77 -0
- package/dist/context-compaction/index.d.ts +77 -0
- package/dist/context-compaction/index.js +8 -0
- package/dist/diff/index.cjs +9 -0
- package/dist/diff/index.d.cts +72 -0
- package/dist/diff/index.d.ts +72 -0
- package/dist/diff/index.js +9 -0
- package/dist/edit/index.cjs +10 -0
- package/dist/edit/index.d.cts +53 -0
- package/dist/edit/index.d.ts +53 -0
- package/dist/edit/index.js +10 -0
- package/dist/glob/index.cjs +10 -0
- package/dist/glob/index.d.cts +47 -0
- package/dist/glob/index.d.ts +47 -0
- package/dist/glob/index.js +10 -0
- package/dist/grep/index.cjs +10 -0
- package/dist/grep/index.d.cts +50 -0
- package/dist/grep/index.d.ts +50 -0
- package/dist/grep/index.js +10 -0
- package/dist/http-request/index.cjs +8 -0
- package/dist/http-request/index.d.cts +60 -0
- package/dist/http-request/index.d.ts +60 -0
- package/dist/http-request/index.js +8 -0
- package/dist/index.cjs +102 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +102 -0
- package/dist/lsp/index.cjs +10 -0
- package/dist/lsp/index.d.cts +38 -0
- package/dist/lsp/index.d.ts +38 -0
- package/dist/lsp/index.js +10 -0
- package/dist/memory/index.cjs +9 -0
- package/dist/memory/index.d.cts +63 -0
- package/dist/memory/index.d.ts +63 -0
- package/dist/memory/index.js +9 -0
- package/dist/multi-edit/index.cjs +11 -0
- package/dist/multi-edit/index.d.cts +72 -0
- package/dist/multi-edit/index.d.ts +72 -0
- package/dist/multi-edit/index.js +11 -0
- package/dist/read/index.cjs +10 -0
- package/dist/read/index.d.cts +67 -0
- package/dist/read/index.d.ts +67 -0
- package/dist/read/index.js +10 -0
- package/dist/sleep/index.cjs +8 -0
- package/dist/sleep/index.d.cts +60 -0
- package/dist/sleep/index.d.ts +60 -0
- package/dist/sleep/index.js +8 -0
- package/dist/task/index.cjs +8 -0
- package/dist/task/index.d.cts +67 -0
- package/dist/task/index.d.ts +67 -0
- package/dist/task/index.js +8 -0
- package/dist/types-3QPDuCXN.d.cts +45 -0
- package/dist/types-3QPDuCXN.d.ts +45 -0
- package/dist/web-fetch/index.cjs +8 -0
- package/dist/web-fetch/index.d.cts +56 -0
- package/dist/web-fetch/index.d.ts +56 -0
- package/dist/web-fetch/index.js +8 -0
- package/dist/write/index.cjs +10 -0
- package/dist/write/index.d.cts +47 -0
- package/dist/write/index.d.ts +47 -0
- package/dist/write/index.js +10 -0
- package/package.json +145 -20
- package/dist/core/index.d.ts +0 -20
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk5NW4OGRIcjs = require('./chunk-5NW4OGRI.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
9
|
+
|
|
10
|
+
// src/edit/index.ts
|
|
11
|
+
var _promises = require('fs/promises');
|
|
12
|
+
var _ai = require('ai');
|
|
13
|
+
var _zod = require('zod');
|
|
14
|
+
function createEdit(config = {}) {
|
|
15
|
+
return _ai.tool.call(void 0, {
|
|
16
|
+
description: "Perform an exact string replacement in a file. Locates old_string in the file and replaces it with new_string. Supports curly-quote fallback matching. When replace_all is false (default), old_string must appear exactly once.",
|
|
17
|
+
inputSchema: _zod.z.object({
|
|
18
|
+
file_path: _zod.z.string().describe("Path to the file to edit"),
|
|
19
|
+
old_string: _zod.z.string().describe("The exact string to find and replace"),
|
|
20
|
+
new_string: _zod.z.string().describe("The replacement string"),
|
|
21
|
+
replace_all: _zod.z.boolean().optional().default(false).describe("Replace all occurrences (default: false)")
|
|
22
|
+
}),
|
|
23
|
+
execute: async ({ file_path, old_string, new_string, replace_all }) => {
|
|
24
|
+
try {
|
|
25
|
+
const resolved = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, config.cwd);
|
|
26
|
+
let content;
|
|
27
|
+
try {
|
|
28
|
+
content = await _promises.readFile.call(void 0, resolved, "utf-8");
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
31
|
+
return `Error [edit]: Cannot read file "${resolved}": ${msg}`;
|
|
32
|
+
}
|
|
33
|
+
if (old_string === new_string) {
|
|
34
|
+
return "Error [edit]: old_string and new_string are identical \u2014 nothing to change.";
|
|
35
|
+
}
|
|
36
|
+
const actualOld = _chunk5NW4OGRIcjs.findActualString.call(void 0, content, old_string);
|
|
37
|
+
if (actualOld === null) {
|
|
38
|
+
const preview = content.slice(0, 200);
|
|
39
|
+
return `Error [edit]: old_string not found in "${resolved}". File starts with:
|
|
40
|
+
${preview}`;
|
|
41
|
+
}
|
|
42
|
+
if (!replace_all) {
|
|
43
|
+
let count = 0;
|
|
44
|
+
let pos = 0;
|
|
45
|
+
while (pos < content.length) {
|
|
46
|
+
const idx = content.indexOf(actualOld, pos);
|
|
47
|
+
if (idx === -1) break;
|
|
48
|
+
count++;
|
|
49
|
+
pos = idx + 1;
|
|
50
|
+
}
|
|
51
|
+
if (count > 1) {
|
|
52
|
+
return `Error [edit]: old_string appears ${count} times in "${resolved}". Use replace_all to replace every occurrence, or provide a more specific string.`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const styledNew = _chunk5NW4OGRIcjs.preserveQuoteStyle.call(void 0, old_string, actualOld, new_string);
|
|
56
|
+
const updated = _chunk5NW4OGRIcjs.applyEditToFile.call(void 0, content, actualOld, styledNew, replace_all);
|
|
57
|
+
await _promises.writeFile.call(void 0, resolved, updated, "utf-8");
|
|
58
|
+
const snippet = styledNew.length > 0 ? styledNew.slice(0, 200) : "(deletion)";
|
|
59
|
+
return `Successfully edited "${resolved}". Replacement snippet:
|
|
60
|
+
${snippet}`;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
63
|
+
return `Error [edit]: ${msg}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var edit = createEdit();
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
exports.createEdit = createEdit; exports.edit = edit;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
4
|
+
|
|
5
|
+
// src/diff/index.ts
|
|
6
|
+
var _promises = require('fs/promises');
|
|
7
|
+
var _ai = require('ai');
|
|
8
|
+
var _zod = require('zod');
|
|
9
|
+
|
|
10
|
+
// src/shared/diff.ts
|
|
11
|
+
|
|
12
|
+
var _diff = require('diff');
|
|
13
|
+
function diffStrings(oldContent, newContent, options) {
|
|
14
|
+
if (oldContent === newContent) {
|
|
15
|
+
return "No differences found.";
|
|
16
|
+
}
|
|
17
|
+
const context = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.context]), () => ( 3));
|
|
18
|
+
const oldLabel = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.oldLabel]), () => ( "a"));
|
|
19
|
+
const newLabel = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _3 => _3.newLabel]), () => ( "b"));
|
|
20
|
+
return _diff.createTwoFilesPatch.call(void 0,
|
|
21
|
+
oldLabel,
|
|
22
|
+
newLabel,
|
|
23
|
+
oldContent,
|
|
24
|
+
newContent,
|
|
25
|
+
void 0,
|
|
26
|
+
void 0,
|
|
27
|
+
{ context }
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
async function diffFiles(oldFilePath, newFilePath, options) {
|
|
31
|
+
const [oldContent, newContent] = await Promise.all([
|
|
32
|
+
_promises.readFile.call(void 0, oldFilePath, "utf-8"),
|
|
33
|
+
_promises.readFile.call(void 0, newFilePath, "utf-8")
|
|
34
|
+
]);
|
|
35
|
+
return diffStrings(oldContent, newContent, {
|
|
36
|
+
...options,
|
|
37
|
+
oldLabel: oldFilePath,
|
|
38
|
+
newLabel: newFilePath
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/diff/index.ts
|
|
43
|
+
function createDiff(config = {}) {
|
|
44
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
45
|
+
return _ai.tool.call(void 0, {
|
|
46
|
+
description: "Generate a unified diff between two files or two strings. Provide file_path + other_file_path to compare files, or old_content + new_content to compare strings. You can also provide file_path with old_content or new_content to compare a file against provided content.",
|
|
47
|
+
inputSchema: _zod.z.object({
|
|
48
|
+
file_path: _zod.z.string().optional().describe("Path to the first file (absolute or relative to cwd)"),
|
|
49
|
+
other_file_path: _zod.z.string().optional().describe("Path to the second file (absolute or relative to cwd)"),
|
|
50
|
+
old_content: _zod.z.string().optional().describe("The original content string"),
|
|
51
|
+
new_content: _zod.z.string().optional().describe("The modified content string")
|
|
52
|
+
}),
|
|
53
|
+
execute: async ({ file_path, other_file_path, old_content, new_content }) => {
|
|
54
|
+
try {
|
|
55
|
+
if (file_path && other_file_path) {
|
|
56
|
+
const resolvedOld = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
|
|
57
|
+
const resolvedNew = _chunkQZ5GS6HWcjs.expandPath.call(void 0, other_file_path, cwd);
|
|
58
|
+
return await diffFiles(resolvedOld, resolvedNew);
|
|
59
|
+
}
|
|
60
|
+
if (old_content !== void 0 && new_content !== void 0 && !file_path) {
|
|
61
|
+
return diffStrings(old_content, new_content);
|
|
62
|
+
}
|
|
63
|
+
if (file_path && (old_content !== void 0 || new_content !== void 0)) {
|
|
64
|
+
const resolvedPath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
|
|
65
|
+
const fileContent = await _promises.readFile.call(void 0, resolvedPath, "utf-8");
|
|
66
|
+
if (old_content !== void 0) {
|
|
67
|
+
return diffStrings(old_content, fileContent, {
|
|
68
|
+
oldLabel: "provided",
|
|
69
|
+
newLabel: resolvedPath
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return diffStrings(fileContent, new_content, {
|
|
73
|
+
oldLabel: resolvedPath,
|
|
74
|
+
newLabel: "provided"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return "Error [diff]: Insufficient parameters. Provide either: (1) file_path + other_file_path, (2) old_content + new_content, or (3) file_path + old_content/new_content.";
|
|
78
|
+
} catch (error) {
|
|
79
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
80
|
+
return `Error [diff]: ${msg}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var diff = createDiff();
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
exports.createDiff = createDiff; exports.diff = diff;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/sleep/index.ts
|
|
2
|
+
var _ai = require('ai');
|
|
3
|
+
var _zod = require('zod');
|
|
4
|
+
function createSleep(config = {}) {
|
|
5
|
+
const maxDuration = _nullishCoalesce(config.maxDuration, () => ( 3e5));
|
|
6
|
+
return _ai.tool.call(void 0, {
|
|
7
|
+
description: "Pause execution for a specified duration. Useful for rate limiting, polling intervals, or waiting for external processes. Maximum duration is 300 seconds (5 minutes).",
|
|
8
|
+
inputSchema: _ai.zodSchema.call(void 0,
|
|
9
|
+
_zod.z.object({
|
|
10
|
+
durationMs: _zod.z.number().describe("Duration to sleep in milliseconds"),
|
|
11
|
+
reason: _zod.z.string().optional().describe("Optional reason for the sleep")
|
|
12
|
+
})
|
|
13
|
+
),
|
|
14
|
+
execute: async ({ durationMs, reason }) => {
|
|
15
|
+
try {
|
|
16
|
+
const clamped = Math.max(0, Math.min(durationMs, maxDuration));
|
|
17
|
+
const start = Date.now();
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, clamped));
|
|
19
|
+
const elapsed = Date.now() - start;
|
|
20
|
+
const parts = [`Slept for ${elapsed}ms`];
|
|
21
|
+
if (reason) parts.push(`Reason: ${reason}`);
|
|
22
|
+
if (clamped !== durationMs) {
|
|
23
|
+
parts.push(
|
|
24
|
+
`(clamped from ${durationMs}ms to ${clamped}ms, max: ${maxDuration}ms)`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return parts.join(". ");
|
|
28
|
+
} catch (error) {
|
|
29
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
30
|
+
return `Sleep failed: ${message}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var sleep = createSleep();
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.createSleep = createSleep; exports.sleep = sleep;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkMIYA7TNRcjs = require('./chunk-MIYA7TNR.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
8
|
+
|
|
9
|
+
// src/grep/index.ts
|
|
10
|
+
var _promises = require('fs/promises');
|
|
11
|
+
var _ai = require('ai');
|
|
12
|
+
var _zod = require('zod');
|
|
13
|
+
var VCS_DIRS = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
14
|
+
var DEFAULT_HEAD_LIMIT = 250;
|
|
15
|
+
function applyHeadLimit(items, limit, offset = 0) {
|
|
16
|
+
if (limit === 0) return { items: items.slice(offset), appliedLimit: void 0 };
|
|
17
|
+
const cap = _nullishCoalesce(limit, () => ( DEFAULT_HEAD_LIMIT));
|
|
18
|
+
const sliced = items.slice(offset, offset + cap);
|
|
19
|
+
const truncated = items.length - offset > cap;
|
|
20
|
+
return { items: sliced, appliedLimit: truncated ? cap : void 0 };
|
|
21
|
+
}
|
|
22
|
+
function truncationSuffix(appliedLimit, offset) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (appliedLimit !== void 0) parts.push(`limit: ${appliedLimit}`);
|
|
25
|
+
if (offset > 0) parts.push(`offset: ${offset}`);
|
|
26
|
+
return parts.length > 0 ? `
|
|
27
|
+
|
|
28
|
+
[Results truncated. ${parts.join(", ")}]` : "";
|
|
29
|
+
}
|
|
30
|
+
function relativizeLine(line, baseCwd, last = false) {
|
|
31
|
+
const idx = last ? line.lastIndexOf(":") : line.indexOf(":");
|
|
32
|
+
if (idx > 0) {
|
|
33
|
+
return _chunkQZ5GS6HWcjs.toRelativePath.call(void 0, line.substring(0, idx), baseCwd) + line.substring(idx);
|
|
34
|
+
}
|
|
35
|
+
return line;
|
|
36
|
+
}
|
|
37
|
+
function parseGlobPatterns(globFilter) {
|
|
38
|
+
const patterns = [];
|
|
39
|
+
for (const raw of globFilter.split(/\s+/)) {
|
|
40
|
+
if (raw.includes("{") && raw.includes("}")) {
|
|
41
|
+
patterns.push(raw);
|
|
42
|
+
} else {
|
|
43
|
+
patterns.push(...raw.split(",").filter(Boolean));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return patterns;
|
|
47
|
+
}
|
|
48
|
+
function createGrep(config = {}) {
|
|
49
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
50
|
+
return _ai.tool.call(void 0, {
|
|
51
|
+
description: 'Search file contents using ripgrep. Supports regex patterns, context lines, and three output modes: "content" (matching lines), "files_with_matches" (file paths), and "count" (match counts).',
|
|
52
|
+
inputSchema: _zod.z.object({
|
|
53
|
+
pattern: _zod.z.string().describe("Regex pattern to search for"),
|
|
54
|
+
path: _zod.z.string().optional().describe("File or directory to search in"),
|
|
55
|
+
glob: _zod.z.string().optional().describe('Glob pattern to filter files (e.g. "*.js")'),
|
|
56
|
+
output_mode: _zod.z.enum(["content", "files_with_matches", "count"]).optional().describe('Output mode. Defaults to "files_with_matches".'),
|
|
57
|
+
"-B": _zod.z.number().optional().describe("Lines of context before each match"),
|
|
58
|
+
"-A": _zod.z.number().optional().describe("Lines of context after each match"),
|
|
59
|
+
"-C": _zod.z.number().optional().describe("Lines of context around each match"),
|
|
60
|
+
context: _zod.z.number().optional().describe("Context lines (alias for -C)"),
|
|
61
|
+
"-n": _zod.z.boolean().optional().describe("Show line numbers (content mode, default true)"),
|
|
62
|
+
"-i": _zod.z.boolean().optional().describe("Case insensitive search"),
|
|
63
|
+
type: _zod.z.string().optional().describe('File type filter (e.g. "js", "py")'),
|
|
64
|
+
head_limit: _zod.z.number().optional().describe("Max entries. Default 250, 0 = unlimited."),
|
|
65
|
+
offset: _zod.z.number().optional().describe("Skip first N entries. Default 0."),
|
|
66
|
+
multiline: _zod.z.boolean().optional().describe("Enable multiline matching")
|
|
67
|
+
}),
|
|
68
|
+
execute: async (input) => {
|
|
69
|
+
try {
|
|
70
|
+
const {
|
|
71
|
+
pattern,
|
|
72
|
+
path,
|
|
73
|
+
glob: globFilter,
|
|
74
|
+
type: typeFilter,
|
|
75
|
+
output_mode: outputMode = "files_with_matches",
|
|
76
|
+
"-B": ctxBefore,
|
|
77
|
+
"-A": ctxAfter,
|
|
78
|
+
"-C": ctxC,
|
|
79
|
+
context: ctxAlias,
|
|
80
|
+
"-n": showLineNumbers = true,
|
|
81
|
+
"-i": caseInsensitive = false,
|
|
82
|
+
head_limit: headLimit,
|
|
83
|
+
offset = 0,
|
|
84
|
+
multiline = false
|
|
85
|
+
} = input;
|
|
86
|
+
const absolutePath = path ? _chunkQZ5GS6HWcjs.expandPath.call(void 0, path, cwd) : cwd;
|
|
87
|
+
const args = ["--hidden"];
|
|
88
|
+
for (const dir of VCS_DIRS) args.push("--glob", `!${dir}`);
|
|
89
|
+
args.push("--max-columns", "500");
|
|
90
|
+
if (multiline) args.push("-U", "--multiline-dotall");
|
|
91
|
+
if (caseInsensitive) args.push("-i");
|
|
92
|
+
if (outputMode === "files_with_matches") args.push("-l");
|
|
93
|
+
else if (outputMode === "count") args.push("-c");
|
|
94
|
+
if (showLineNumbers && outputMode === "content") args.push("-n");
|
|
95
|
+
if (outputMode === "content") {
|
|
96
|
+
if (ctxAlias !== void 0) args.push("-C", ctxAlias.toString());
|
|
97
|
+
else if (ctxC !== void 0) args.push("-C", ctxC.toString());
|
|
98
|
+
else {
|
|
99
|
+
if (ctxBefore !== void 0) args.push("-B", ctxBefore.toString());
|
|
100
|
+
if (ctxAfter !== void 0) args.push("-A", ctxAfter.toString());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (pattern.startsWith("-")) args.push("-e", pattern);
|
|
104
|
+
else args.push(pattern);
|
|
105
|
+
if (typeFilter) args.push("--type", typeFilter);
|
|
106
|
+
if (globFilter) {
|
|
107
|
+
for (const gp of parseGlobPatterns(globFilter)) args.push("--glob", gp);
|
|
108
|
+
}
|
|
109
|
+
const results = await _chunkMIYA7TNRcjs.executeRipgrep.call(void 0, args, absolutePath);
|
|
110
|
+
if (results.length === 0) return "No matches found";
|
|
111
|
+
if (outputMode === "content") {
|
|
112
|
+
const { items: items2, appliedLimit: appliedLimit2 } = applyHeadLimit(results, headLimit, offset);
|
|
113
|
+
const lines = items2.map((l) => relativizeLine(l, cwd));
|
|
114
|
+
return lines.join("\n") + truncationSuffix(appliedLimit2, offset);
|
|
115
|
+
}
|
|
116
|
+
if (outputMode === "count") {
|
|
117
|
+
const { items: items2, appliedLimit: appliedLimit2 } = applyHeadLimit(results, headLimit, offset);
|
|
118
|
+
const lines = items2.map((l) => relativizeLine(l, cwd, true));
|
|
119
|
+
let totalMatches = 0;
|
|
120
|
+
let fileCount = 0;
|
|
121
|
+
for (const line of lines) {
|
|
122
|
+
const idx = line.lastIndexOf(":");
|
|
123
|
+
if (idx > 0) {
|
|
124
|
+
const n = parseInt(line.substring(idx + 1), 10);
|
|
125
|
+
if (!isNaN(n)) {
|
|
126
|
+
totalMatches += n;
|
|
127
|
+
fileCount += 1;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return lines.join("\n") + `
|
|
132
|
+
|
|
133
|
+
Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(appliedLimit2, offset);
|
|
134
|
+
}
|
|
135
|
+
const stats = await Promise.allSettled(results.map((f) => _promises.stat.call(void 0, f)));
|
|
136
|
+
const sorted = results.map((fp, i) => {
|
|
137
|
+
const r = stats[i];
|
|
138
|
+
const mt = r.status === "fulfilled" ? _nullishCoalesce(r.value.mtimeMs, () => ( 0)) : 0;
|
|
139
|
+
return [fp, mt];
|
|
140
|
+
}).sort((a, b) => {
|
|
141
|
+
const d = b[1] - a[1];
|
|
142
|
+
return d !== 0 ? d : a[0].localeCompare(b[0]);
|
|
143
|
+
}).map((e) => e[0]);
|
|
144
|
+
const { items, appliedLimit } = applyHeadLimit(sorted, headLimit, offset);
|
|
145
|
+
const relative = items.map((f) => _chunkQZ5GS6HWcjs.toRelativePath.call(void 0, f, cwd));
|
|
146
|
+
return relative.join("\n") + truncationSuffix(appliedLimit, offset);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
149
|
+
return `Error [grep]: Failed to search: ${msg}`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
var grep = createGrep();
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
exports.createGrep = createGrep; exports.grep = grep;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/shared/path.ts
|
|
2
|
+
var _os = require('os');
|
|
3
|
+
var _path = require('path');
|
|
4
|
+
function expandPath(inputPath, baseDir) {
|
|
5
|
+
const actualBaseDir = _nullishCoalesce(baseDir, () => ( process.cwd()));
|
|
6
|
+
if (typeof inputPath !== "string") {
|
|
7
|
+
throw new TypeError(
|
|
8
|
+
`Path must be a string, received ${typeof inputPath}`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
if (typeof actualBaseDir !== "string") {
|
|
12
|
+
throw new TypeError(
|
|
13
|
+
`Base directory must be a string, received ${typeof actualBaseDir}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (inputPath.includes("\0") || actualBaseDir.includes("\0")) {
|
|
17
|
+
throw new Error("Path contains null bytes");
|
|
18
|
+
}
|
|
19
|
+
const trimmed = inputPath.trim();
|
|
20
|
+
if (!trimmed) {
|
|
21
|
+
return _path.normalize.call(void 0, actualBaseDir);
|
|
22
|
+
}
|
|
23
|
+
if (trimmed === "~") {
|
|
24
|
+
return _os.homedir.call(void 0, );
|
|
25
|
+
}
|
|
26
|
+
if (trimmed.startsWith("~/")) {
|
|
27
|
+
return _path.join.call(void 0, _os.homedir.call(void 0, ), trimmed.slice(2));
|
|
28
|
+
}
|
|
29
|
+
if (_path.isAbsolute.call(void 0, trimmed)) {
|
|
30
|
+
return _path.normalize.call(void 0, trimmed);
|
|
31
|
+
}
|
|
32
|
+
return _path.resolve.call(void 0, actualBaseDir, trimmed);
|
|
33
|
+
}
|
|
34
|
+
function toRelativePath(absolutePath, baseDir) {
|
|
35
|
+
const rel = _path.relative.call(void 0, _nullishCoalesce(baseDir, () => ( process.cwd())), absolutePath);
|
|
36
|
+
return rel.startsWith("..") ? absolutePath : rel;
|
|
37
|
+
}
|
|
38
|
+
function containsPathTraversal(inputPath) {
|
|
39
|
+
return /(?:^|[\\/])\.\.(?:[\\/]|$)/.test(inputPath);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports.expandPath = expandPath; exports.toRelativePath = toRelativePath; exports.containsPathTraversal = containsPathTraversal;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyEditToFile,
|
|
3
|
+
findActualString,
|
|
4
|
+
preserveQuoteStyle
|
|
5
|
+
} from "./chunk-G3ITTPGX.js";
|
|
6
|
+
import {
|
|
7
|
+
expandPath
|
|
8
|
+
} from "./chunk-I3ONDY7P.js";
|
|
9
|
+
|
|
10
|
+
// src/edit/index.ts
|
|
11
|
+
import { readFile, writeFile } from "fs/promises";
|
|
12
|
+
import { tool } from "ai";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
function createEdit(config = {}) {
|
|
15
|
+
return tool({
|
|
16
|
+
description: "Perform an exact string replacement in a file. Locates old_string in the file and replaces it with new_string. Supports curly-quote fallback matching. When replace_all is false (default), old_string must appear exactly once.",
|
|
17
|
+
inputSchema: z.object({
|
|
18
|
+
file_path: z.string().describe("Path to the file to edit"),
|
|
19
|
+
old_string: z.string().describe("The exact string to find and replace"),
|
|
20
|
+
new_string: z.string().describe("The replacement string"),
|
|
21
|
+
replace_all: z.boolean().optional().default(false).describe("Replace all occurrences (default: false)")
|
|
22
|
+
}),
|
|
23
|
+
execute: async ({ file_path, old_string, new_string, replace_all }) => {
|
|
24
|
+
try {
|
|
25
|
+
const resolved = expandPath(file_path, config.cwd);
|
|
26
|
+
let content;
|
|
27
|
+
try {
|
|
28
|
+
content = await readFile(resolved, "utf-8");
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
31
|
+
return `Error [edit]: Cannot read file "${resolved}": ${msg}`;
|
|
32
|
+
}
|
|
33
|
+
if (old_string === new_string) {
|
|
34
|
+
return "Error [edit]: old_string and new_string are identical \u2014 nothing to change.";
|
|
35
|
+
}
|
|
36
|
+
const actualOld = findActualString(content, old_string);
|
|
37
|
+
if (actualOld === null) {
|
|
38
|
+
const preview = content.slice(0, 200);
|
|
39
|
+
return `Error [edit]: old_string not found in "${resolved}". File starts with:
|
|
40
|
+
${preview}`;
|
|
41
|
+
}
|
|
42
|
+
if (!replace_all) {
|
|
43
|
+
let count = 0;
|
|
44
|
+
let pos = 0;
|
|
45
|
+
while (pos < content.length) {
|
|
46
|
+
const idx = content.indexOf(actualOld, pos);
|
|
47
|
+
if (idx === -1) break;
|
|
48
|
+
count++;
|
|
49
|
+
pos = idx + 1;
|
|
50
|
+
}
|
|
51
|
+
if (count > 1) {
|
|
52
|
+
return `Error [edit]: old_string appears ${count} times in "${resolved}". Use replace_all to replace every occurrence, or provide a more specific string.`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const styledNew = preserveQuoteStyle(old_string, actualOld, new_string);
|
|
56
|
+
const updated = applyEditToFile(content, actualOld, styledNew, replace_all);
|
|
57
|
+
await writeFile(resolved, updated, "utf-8");
|
|
58
|
+
const snippet = styledNew.length > 0 ? styledNew.slice(0, 200) : "(deletion)";
|
|
59
|
+
return `Successfully edited "${resolved}". Replacement snippet:
|
|
60
|
+
${snippet}`;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
63
|
+
return `Error [edit]: ${msg}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var edit = createEdit();
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
createEdit,
|
|
72
|
+
edit
|
|
73
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/bash/index.ts
|
|
2
|
+
var _ai = require('ai');
|
|
3
|
+
var _zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/shared/shell.ts
|
|
6
|
+
var _child_process = require('child_process');
|
|
7
|
+
var MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
8
|
+
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
9
|
+
var SIGKILL_GRACE_MS = 5e3;
|
|
10
|
+
async function executeShell(command, options) {
|
|
11
|
+
const shellBin = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.shell]), () => ( process.env.SHELL)), () => ( "/bin/bash"));
|
|
12
|
+
const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.timeout]), () => ( DEFAULT_TIMEOUT_MS));
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const child = _child_process.spawn.call(void 0, shellBin, ["-c", command], {
|
|
15
|
+
cwd: _optionalChain([options, 'optionalAccess', _3 => _3.cwd]),
|
|
16
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
17
|
+
// Prevent visible console window on Windows (no-op elsewhere)
|
|
18
|
+
windowsHide: true
|
|
19
|
+
});
|
|
20
|
+
let stdout = "";
|
|
21
|
+
let stderr = "";
|
|
22
|
+
let stdoutBytes = 0;
|
|
23
|
+
let stderrBytes = 0;
|
|
24
|
+
let settled = false;
|
|
25
|
+
let timeoutId;
|
|
26
|
+
let graceId;
|
|
27
|
+
function cleanup() {
|
|
28
|
+
if (timeoutId !== void 0) {
|
|
29
|
+
clearTimeout(timeoutId);
|
|
30
|
+
timeoutId = void 0;
|
|
31
|
+
}
|
|
32
|
+
if (graceId !== void 0) {
|
|
33
|
+
clearTimeout(graceId);
|
|
34
|
+
graceId = void 0;
|
|
35
|
+
}
|
|
36
|
+
if (abortHandler && _optionalChain([options, 'optionalAccess', _4 => _4.signal])) {
|
|
37
|
+
options.signal.removeEventListener("abort", abortHandler);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function settle(result) {
|
|
41
|
+
if (settled) return;
|
|
42
|
+
settled = true;
|
|
43
|
+
cleanup();
|
|
44
|
+
resolve(result);
|
|
45
|
+
}
|
|
46
|
+
child.stdout.on("data", (chunk) => {
|
|
47
|
+
if (stdoutBytes >= MAX_BUFFER_BYTES) return;
|
|
48
|
+
const str = chunk.toString();
|
|
49
|
+
const remaining = MAX_BUFFER_BYTES - stdoutBytes;
|
|
50
|
+
if (chunk.length > remaining) {
|
|
51
|
+
stdout += str.slice(0, remaining);
|
|
52
|
+
stdoutBytes = MAX_BUFFER_BYTES;
|
|
53
|
+
} else {
|
|
54
|
+
stdout += str;
|
|
55
|
+
stdoutBytes += chunk.length;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
child.stderr.on("data", (chunk) => {
|
|
59
|
+
if (stderrBytes >= MAX_BUFFER_BYTES) return;
|
|
60
|
+
const str = chunk.toString();
|
|
61
|
+
const remaining = MAX_BUFFER_BYTES - stderrBytes;
|
|
62
|
+
if (chunk.length > remaining) {
|
|
63
|
+
stderr += str.slice(0, remaining);
|
|
64
|
+
stderrBytes = MAX_BUFFER_BYTES;
|
|
65
|
+
} else {
|
|
66
|
+
stderr += str;
|
|
67
|
+
stderrBytes += chunk.length;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
child.on("exit", (code, signal) => {
|
|
71
|
+
const exitCode = code !== null ? code : signal === "SIGKILL" ? 137 : signal === "SIGTERM" ? 143 : 1;
|
|
72
|
+
settle({ stdout, stderr, exitCode });
|
|
73
|
+
});
|
|
74
|
+
child.on("error", (err) => {
|
|
75
|
+
if (settled) return;
|
|
76
|
+
settled = true;
|
|
77
|
+
cleanup();
|
|
78
|
+
reject(err);
|
|
79
|
+
});
|
|
80
|
+
if (timeout > 0) {
|
|
81
|
+
timeoutId = setTimeout(() => {
|
|
82
|
+
timeoutId = void 0;
|
|
83
|
+
if (settled) return;
|
|
84
|
+
child.kill("SIGTERM");
|
|
85
|
+
graceId = setTimeout(() => {
|
|
86
|
+
graceId = void 0;
|
|
87
|
+
if (settled) return;
|
|
88
|
+
child.kill("SIGKILL");
|
|
89
|
+
}, SIGKILL_GRACE_MS);
|
|
90
|
+
}, timeout);
|
|
91
|
+
}
|
|
92
|
+
const abortHandler = _optionalChain([options, 'optionalAccess', _5 => _5.signal]) ? () => {
|
|
93
|
+
if (settled) return;
|
|
94
|
+
child.kill("SIGTERM");
|
|
95
|
+
} : void 0;
|
|
96
|
+
if (abortHandler && _optionalChain([options, 'optionalAccess', _6 => _6.signal])) {
|
|
97
|
+
if (options.signal.aborted) {
|
|
98
|
+
child.kill("SIGTERM");
|
|
99
|
+
} else {
|
|
100
|
+
options.signal.addEventListener("abort", abortHandler, { once: true });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/bash/index.ts
|
|
107
|
+
function createBash(config = {}) {
|
|
108
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
109
|
+
const timeout = _nullishCoalesce(config.timeout, () => ( 12e4));
|
|
110
|
+
return _ai.tool.call(void 0, {
|
|
111
|
+
description: "Execute a shell command and return its output. Runs the command in a bash shell with the configured working directory. Returns stdout, stderr, and exit code. Use this for running build commands, git operations, system administration, and any other shell tasks.",
|
|
112
|
+
inputSchema: _zod.z.object({
|
|
113
|
+
command: _zod.z.string().describe("The shell command to execute"),
|
|
114
|
+
timeout: _zod.z.number().optional().describe("Timeout in milliseconds (default: 120000)"),
|
|
115
|
+
description: _zod.z.string().optional().describe("Human-readable description of what the command does")
|
|
116
|
+
}),
|
|
117
|
+
execute: async ({ command, timeout: cmdTimeout }) => {
|
|
118
|
+
try {
|
|
119
|
+
const result = await executeShell(command, {
|
|
120
|
+
cwd,
|
|
121
|
+
timeout: _nullishCoalesce(cmdTimeout, () => ( timeout)),
|
|
122
|
+
shell: config.shell
|
|
123
|
+
});
|
|
124
|
+
const parts = [];
|
|
125
|
+
if (result.stdout) parts.push(result.stdout);
|
|
126
|
+
if (result.stderr) parts.push(`STDERR:
|
|
127
|
+
${result.stderr}`);
|
|
128
|
+
if (result.exitCode !== 0) parts.push(`Exit code: ${result.exitCode}`);
|
|
129
|
+
return parts.length > 0 ? parts.join("\n") : `Command completed with exit code ${result.exitCode}`;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
132
|
+
return `Error [bash]: Failed to execute command: ${msg}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
var bash = createBash();
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
exports.createBash = createBash; exports.bash = bash;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkCAEVLIQBcjs = require('./chunk-CAEVLIQB.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
8
|
+
|
|
9
|
+
// src/read/index.ts
|
|
10
|
+
var _ai = require('ai');
|
|
11
|
+
var _zod = require('zod');
|
|
12
|
+
function createRead(config = {}) {
|
|
13
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
14
|
+
const defaultMaxLines = _nullishCoalesce(config.maxLines, () => ( 2e3));
|
|
15
|
+
return _ai.tool.call(void 0, {
|
|
16
|
+
description: 'Read a file from the local filesystem and return its contents with line numbers. Supports absolute paths, relative paths (resolved against the working directory), and tilde (~) home directory expansion. Returns numbered lines in "lineNumber\\tcontent" format. Use offset and limit to read specific ranges of large files.',
|
|
17
|
+
inputSchema: _zod.z.object({
|
|
18
|
+
file_path: _zod.z.string().describe("The path to the file to read (absolute, relative, or ~/...)"),
|
|
19
|
+
offset: _zod.z.number().optional().describe("0-indexed line number to start reading from (default: 0)"),
|
|
20
|
+
limit: _zod.z.number().optional().describe("Maximum number of lines to return (default: 2000)")
|
|
21
|
+
}),
|
|
22
|
+
execute: async ({ file_path, offset, limit }) => {
|
|
23
|
+
try {
|
|
24
|
+
const absolutePath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
|
|
25
|
+
const result = await _chunkCAEVLIQBcjs.readFileInRange.call(void 0,
|
|
26
|
+
absolutePath,
|
|
27
|
+
_nullishCoalesce(offset, () => ( 0)),
|
|
28
|
+
_nullishCoalesce(limit, () => ( defaultMaxLines))
|
|
29
|
+
);
|
|
30
|
+
const numbered = _chunkCAEVLIQBcjs.addLineNumbers.call(void 0, {
|
|
31
|
+
content: result.content,
|
|
32
|
+
startLine: (_nullishCoalesce(offset, () => ( 0))) + 1
|
|
33
|
+
});
|
|
34
|
+
return numbered;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
37
|
+
return `Error [read]: ${msg}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var read = createRead();
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
exports.createRead = createRead; exports.read = read;
|