agentool 1.0.0 → 1.1.1
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 +132 -21
- package/dist/ask-user/index.cjs +5 -2
- package/dist/ask-user/index.d.cts +10 -1
- package/dist/ask-user/index.d.ts +10 -1
- package/dist/ask-user/index.js +5 -2
- package/dist/bash/index.cjs +5 -2
- package/dist/bash/index.d.cts +14 -1
- package/dist/bash/index.d.ts +14 -1
- package/dist/bash/index.js +5 -2
- package/dist/chunk-2JBLVFB7.cjs +74 -0
- package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
- package/dist/{chunk-XKG2A3EW.js → chunk-2WSZCOJP.js} +54 -18
- package/dist/chunk-3FT4ZPB2.cjs +65 -0
- package/dist/{chunk-VLNDEVKS.js → chunk-3LGXZLBH.js} +46 -8
- package/dist/{chunk-G3ITTPGX.js → chunk-4MXDQEPA.js} +12 -1
- package/dist/{chunk-CGTPF6IS.js → chunk-4UUSERSH.js} +31 -7
- package/dist/{chunk-I6KFFQPV.cjs → chunk-5T3SQYI4.cjs} +34 -4
- package/dist/chunk-6ULQG2W2.cjs +99 -0
- package/dist/chunk-ABXTBB2N.cjs +67 -0
- package/dist/{chunk-CAEVLIQB.cjs → chunk-BIAODQ2P.cjs} +17 -1
- package/dist/chunk-CJA76MKM.js +59 -0
- package/dist/chunk-CM3VRCNX.cjs +59 -0
- package/dist/{chunk-SUSAPI5W.cjs → chunk-CXBWF5ON.cjs} +51 -4
- package/dist/{chunk-U2YMJM25.cjs → chunk-G6ZVJA4V.cjs} +31 -8
- package/dist/chunk-GPHCXS2S.js +99 -0
- package/dist/chunk-HG5T47NA.cjs +77 -0
- package/dist/chunk-HO4NIRU5.js +65 -0
- package/dist/{chunk-HZAQRHBT.js → chunk-IBC4QCGR.js} +27 -2
- package/dist/chunk-JYTOARJV.cjs +69 -0
- package/dist/chunk-KONXT2SF.cjs +8 -0
- package/dist/chunk-KUFZFNPT.cjs +61 -0
- package/dist/chunk-L7R4UZSK.js +61 -0
- package/dist/{chunk-FV2R5FFQ.cjs → chunk-LNAR3NJQ.cjs} +47 -9
- package/dist/chunk-M74OQYNK.js +69 -0
- package/dist/{chunk-IMZQ7ELK.cjs → chunk-NQIV6LBH.cjs} +51 -14
- package/dist/chunk-NTGDU5X3.js +67 -0
- package/dist/{chunk-ONBH74ZV.cjs → chunk-OYLTQJXT.cjs} +32 -8
- package/dist/{chunk-6PQLFDGT.js → chunk-PWBVB6MN.js} +17 -1
- package/dist/{chunk-QEJV2KZ4.cjs → chunk-RIGL3JTS.cjs} +55 -19
- package/dist/chunk-SFDZRLSX.cjs +91 -0
- package/dist/chunk-T6STO7PS.cjs +126 -0
- package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
- package/dist/chunk-TM5L4HA5.js +126 -0
- package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
- package/dist/chunk-UCA6LURO.js +74 -0
- package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
- package/dist/chunk-VHLY7LQE.js +53 -0
- package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
- package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
- package/dist/chunk-VQSWMGG7.cjs +53 -0
- package/dist/{chunk-Y7KOKDFP.js → chunk-VZRXTFS4.js} +29 -6
- package/dist/chunk-WCR62UZ3.js +67 -0
- package/dist/chunk-X6ZY2KFU.js +8 -0
- package/dist/chunk-XGDE7S2D.cjs +67 -0
- package/dist/chunk-XPTW45XY.js +77 -0
- package/dist/{chunk-YPPPGGLA.cjs → chunk-YCWJVQYO.cjs} +28 -3
- package/dist/chunk-YGXLT6SS.js +91 -0
- package/dist/{chunk-5NW4OGRI.cjs → chunk-YTPZHJDC.cjs} +12 -1
- package/dist/{chunk-6MDPYALY.js → chunk-ZHVRP3EH.js} +49 -12
- package/dist/context-compaction/index.cjs +5 -2
- package/dist/context-compaction/index.d.cts +11 -1
- package/dist/context-compaction/index.d.ts +11 -1
- package/dist/context-compaction/index.js +5 -2
- package/dist/diff/index.cjs +6 -2
- package/dist/diff/index.d.cts +12 -2
- package/dist/diff/index.d.ts +12 -2
- package/dist/diff/index.js +7 -3
- package/dist/edit/index.cjs +7 -3
- package/dist/edit/index.d.cts +15 -5
- package/dist/edit/index.d.ts +15 -5
- package/dist/edit/index.js +8 -4
- package/dist/glob/index.cjs +5 -2
- package/dist/glob/index.d.cts +13 -3
- package/dist/glob/index.d.ts +13 -3
- package/dist/glob/index.js +5 -2
- package/dist/grep/index.cjs +6 -2
- package/dist/grep/index.d.cts +13 -3
- package/dist/grep/index.d.ts +13 -3
- package/dist/grep/index.js +6 -2
- package/dist/http-request/index.cjs +5 -2
- package/dist/http-request/index.d.cts +11 -1
- package/dist/http-request/index.d.ts +11 -1
- package/dist/http-request/index.js +5 -2
- package/dist/index.cjs +93 -19
- package/dist/index.d.cts +21 -16
- package/dist/index.d.ts +21 -16
- package/dist/index.js +113 -39
- package/dist/lsp/index.cjs +6 -2
- package/dist/lsp/index.d.cts +16 -10
- package/dist/lsp/index.d.ts +16 -10
- package/dist/lsp/index.js +6 -2
- package/dist/memory/index.cjs +6 -2
- package/dist/memory/index.d.cts +10 -1
- package/dist/memory/index.d.ts +10 -1
- package/dist/memory/index.js +6 -2
- package/dist/multi-edit/index.cjs +7 -4
- package/dist/multi-edit/index.d.cts +12 -2
- package/dist/multi-edit/index.d.ts +12 -2
- package/dist/multi-edit/index.js +7 -4
- package/dist/read/index.cjs +6 -3
- package/dist/read/index.d.cts +11 -1
- package/dist/read/index.d.ts +11 -1
- package/dist/read/index.js +6 -3
- package/dist/sleep/index.cjs +5 -2
- package/dist/sleep/index.d.cts +11 -1
- package/dist/sleep/index.d.ts +11 -1
- package/dist/sleep/index.js +5 -2
- package/dist/task-create/index.cjs +13 -0
- package/dist/task-create/index.d.cts +28 -0
- package/dist/task-create/index.d.ts +28 -0
- package/dist/task-create/index.js +13 -0
- package/dist/task-get/index.cjs +13 -0
- package/dist/task-get/index.d.cts +24 -0
- package/dist/task-get/index.d.ts +24 -0
- package/dist/task-get/index.js +13 -0
- package/dist/task-list/index.cjs +13 -0
- package/dist/task-list/index.d.cts +20 -0
- package/dist/task-list/index.d.ts +20 -0
- package/dist/task-list/index.js +13 -0
- package/dist/task-update/index.cjs +13 -0
- package/dist/task-update/index.d.cts +40 -0
- package/dist/task-update/index.d.ts +40 -0
- package/dist/task-update/index.js +13 -0
- package/dist/tool-search/index.cjs +11 -0
- package/dist/tool-search/index.d.cts +27 -0
- package/dist/tool-search/index.d.ts +27 -0
- package/dist/tool-search/index.js +11 -0
- package/dist/web-fetch/index.cjs +5 -2
- package/dist/web-fetch/index.d.cts +11 -3
- package/dist/web-fetch/index.d.ts +11 -3
- package/dist/web-fetch/index.js +5 -2
- package/dist/web-search/index.cjs +11 -0
- package/dist/web-search/index.d.cts +30 -0
- package/dist/web-search/index.d.ts +30 -0
- package/dist/web-search/index.js +11 -0
- package/dist/write/index.cjs +6 -3
- package/dist/write/index.d.cts +13 -3
- package/dist/write/index.d.ts +13 -3
- package/dist/write/index.js +6 -3
- package/package.json +31 -6
- package/dist/chunk-3EPGFWZV.cjs +0 -30
- package/dist/chunk-7QL4BQCH.js +0 -40
- package/dist/chunk-FAEGCFTO.js +0 -136
- package/dist/chunk-HDKXSKMO.js +0 -30
- package/dist/chunk-JCTBB7H2.cjs +0 -40
- package/dist/chunk-MF7CJVIZ.js +0 -40
- package/dist/chunk-MXFW3XY6.cjs +0 -73
- package/dist/chunk-OXLQ7QVL.cjs +0 -40
- package/dist/chunk-S6QEY7UY.js +0 -73
- package/dist/chunk-TBVHHF3H.cjs +0 -47
- package/dist/chunk-XLD2Y3SS.cjs +0 -136
- package/dist/chunk-ZHCMEQJJ.js +0 -47
- package/dist/task/index.cjs +0 -8
- package/dist/task/index.d.cts +0 -67
- package/dist/task/index.d.ts +0 -67
- package/dist/task/index.js +0 -8
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
4
10
|
|
|
11
|
+
|
|
12
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
13
|
+
|
|
5
14
|
// src/memory/index.ts
|
|
6
15
|
var _ai = require('ai');
|
|
7
16
|
var _zod = require('zod');
|
|
8
|
-
var _promises = require('fs/promises');
|
|
9
17
|
var _path = require('path');
|
|
18
|
+
|
|
19
|
+
// src/memory/prompt.ts
|
|
20
|
+
function getPrompt() {
|
|
21
|
+
return `File-based key-value memory store for persisting notes, context, or any text data across conversations.
|
|
22
|
+
|
|
23
|
+
Entries are stored as individual .md files in the memory directory.
|
|
24
|
+
|
|
25
|
+
## Operations
|
|
26
|
+
- **write**: Store content under a key (creates or overwrites)
|
|
27
|
+
- **read**: Retrieve content by key
|
|
28
|
+
- **list**: List all stored keys
|
|
29
|
+
- **delete**: Remove a key and its content
|
|
30
|
+
|
|
31
|
+
## When to Use
|
|
32
|
+
- To persist information that should survive across conversations or sessions
|
|
33
|
+
- To store user preferences, project notes, or context summaries
|
|
34
|
+
- To keep a running log of decisions, findings, or important details
|
|
35
|
+
|
|
36
|
+
## When NOT to Use
|
|
37
|
+
- For temporary data within a single conversation \u2014 just keep it in context
|
|
38
|
+
- For structured task tracking \u2014 use the task management tools instead
|
|
39
|
+
|
|
40
|
+
## Usage Guidelines
|
|
41
|
+
- Keys are sanitized to prevent path traversal (no ../ allowed)
|
|
42
|
+
- The \`key\` parameter is required for read, write, and delete operations
|
|
43
|
+
- The \`content\` parameter is required for write operations
|
|
44
|
+
- Use descriptive key names for easy discovery (e.g., "user-preferences", "project-architecture")`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/memory/index.ts
|
|
10
48
|
function sanitizeKey(key) {
|
|
11
49
|
if (!key || key.trim() === "") {
|
|
12
50
|
return { err: "Error [memory]: Key must not be empty." };
|
|
@@ -24,7 +62,7 @@ function createMemory(config = {}) {
|
|
|
24
62
|
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
25
63
|
const memoryDir = _nullishCoalesce(config.memoryDir, () => ( _path.join.call(void 0, cwd, ".agentool", "memory")));
|
|
26
64
|
return _ai.tool.call(void 0, {
|
|
27
|
-
description:
|
|
65
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
28
66
|
inputSchema: _zod.z.object({
|
|
29
67
|
action: _zod.z.enum(["read", "write", "list", "delete"]).describe(
|
|
30
68
|
"The operation to perform: read, write, list, or delete"
|
|
@@ -55,7 +93,7 @@ function createMemory(config = {}) {
|
|
|
55
93
|
return `Error [memory]: Unknown action "${String(action)}".`;
|
|
56
94
|
}
|
|
57
95
|
} catch (error) {
|
|
58
|
-
const msg =
|
|
96
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
59
97
|
return `Error [memory]: ${msg}`;
|
|
60
98
|
}
|
|
61
99
|
}
|
|
@@ -65,20 +103,19 @@ async function writeEntry(dir, key, content) {
|
|
|
65
103
|
if (!content && content !== "") {
|
|
66
104
|
return "Error [memory]: Content is required for write action.";
|
|
67
105
|
}
|
|
68
|
-
await
|
|
69
|
-
await _promises.writeFile.call(void 0, _path.join.call(void 0, dir, `${key}.md`), content, "utf-8");
|
|
106
|
+
await _chunkBIAODQ2Pcjs.writeTextContent.call(void 0, _path.join.call(void 0, dir, `${key}.md`), content);
|
|
70
107
|
return `Saved memory "${key}".`;
|
|
71
108
|
}
|
|
72
109
|
async function readEntry(dir, key) {
|
|
73
110
|
try {
|
|
74
|
-
return await
|
|
111
|
+
return await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, _path.join.call(void 0, dir, `${key}.md`));
|
|
75
112
|
} catch (e) {
|
|
76
113
|
return `Error [memory]: Key "${key}" not found.`;
|
|
77
114
|
}
|
|
78
115
|
}
|
|
79
116
|
async function listKeys(dir) {
|
|
80
117
|
try {
|
|
81
|
-
const files = await
|
|
118
|
+
const files = await _chunkBIAODQ2Pcjs.listDirectory.call(void 0, dir);
|
|
82
119
|
const keys = files.filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3));
|
|
83
120
|
if (keys.length === 0) return "No memory entries found.";
|
|
84
121
|
return keys.join("\n");
|
|
@@ -88,7 +125,7 @@ async function listKeys(dir) {
|
|
|
88
125
|
}
|
|
89
126
|
async function deleteEntry(dir, key) {
|
|
90
127
|
try {
|
|
91
|
-
await
|
|
128
|
+
await _chunkBIAODQ2Pcjs.removeFile.call(void 0, _path.join.call(void 0, dir, `${key}.md`));
|
|
92
129
|
return `Deleted memory "${key}".`;
|
|
93
130
|
} catch (e3) {
|
|
94
131
|
return `Error [memory]: Key "${key}" not found.`;
|
|
@@ -99,4 +136,5 @@ var memory = createMemory();
|
|
|
99
136
|
|
|
100
137
|
|
|
101
138
|
|
|
102
|
-
|
|
139
|
+
|
|
140
|
+
exports.getPrompt = getPrompt; exports.createMemory = createMemory; exports.memory = memory;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
5
|
+
// src/sleep/index.ts
|
|
6
|
+
import { tool, zodSchema } from "ai";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/sleep/prompt.ts
|
|
10
|
+
function getPrompt(config = {}) {
|
|
11
|
+
const maxDuration = config.maxDuration ?? 3e5;
|
|
12
|
+
const maxSec = maxDuration / 1e3;
|
|
13
|
+
return `Pause execution for a specified duration. Maximum duration: ${maxSec} seconds (${maxDuration}ms).
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
- When rate-limited by an external API and need to wait before retrying
|
|
17
|
+
- When waiting for an external process to complete
|
|
18
|
+
- Prefer this over shell sleep commands \u2014 it doesn't hold a shell process
|
|
19
|
+
|
|
20
|
+
## When NOT to Use
|
|
21
|
+
- Don't sleep between commands that can run immediately \u2014 just run them
|
|
22
|
+
- Don't retry failing commands in a sleep loop \u2014 diagnose the root cause first
|
|
23
|
+
- Avoid long sleeps that block the user \u2014 keep durations short when possible
|
|
24
|
+
|
|
25
|
+
## Usage Guidelines
|
|
26
|
+
- Durations exceeding the maximum are automatically clamped to ${maxDuration}ms
|
|
27
|
+
- Provide a \`reason\` parameter to document why the sleep is needed
|
|
28
|
+
- Each sleep costs an API turn \u2014 use judiciously`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/sleep/index.ts
|
|
32
|
+
function createSleep(config = {}) {
|
|
33
|
+
const maxDuration = config.maxDuration ?? 3e5;
|
|
34
|
+
return tool({
|
|
35
|
+
description: config.description ?? getPrompt(config),
|
|
36
|
+
inputSchema: zodSchema(
|
|
37
|
+
z.object({
|
|
38
|
+
durationMs: z.number().describe("Duration to sleep in milliseconds"),
|
|
39
|
+
reason: z.string().optional().describe("Optional reason for the sleep")
|
|
40
|
+
})
|
|
41
|
+
),
|
|
42
|
+
execute: async ({ durationMs, reason }) => {
|
|
43
|
+
try {
|
|
44
|
+
const clamped = Math.max(0, Math.min(durationMs, maxDuration));
|
|
45
|
+
const start = Date.now();
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, clamped));
|
|
47
|
+
const elapsed = Date.now() - start;
|
|
48
|
+
const parts = [`Slept for ${elapsed}ms`];
|
|
49
|
+
if (reason) parts.push(`Reason: ${reason}`);
|
|
50
|
+
if (clamped !== durationMs) {
|
|
51
|
+
parts.push(
|
|
52
|
+
`(clamped from ${durationMs}ms to ${clamped}ms, max: ${maxDuration}ms)`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return parts.join(". ");
|
|
56
|
+
} catch (error) {
|
|
57
|
+
const message = extractErrorMessage(error);
|
|
58
|
+
return `Sleep failed: ${message}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
var sleep = createSleep();
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
getPrompt,
|
|
67
|
+
createSleep,
|
|
68
|
+
sleep
|
|
69
|
+
};
|
|
@@ -1,10 +1,45 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
7
|
+
|
|
8
|
+
// src/lsp/index.ts
|
|
2
9
|
var _ai = require('ai');
|
|
3
10
|
var _zod = require('zod');
|
|
4
11
|
var _child_process = require('child_process');
|
|
5
|
-
var _promises = require('fs/promises');
|
|
6
12
|
var _url = require('url');
|
|
7
13
|
var _path = require('path');
|
|
14
|
+
|
|
15
|
+
// src/lsp/prompt.ts
|
|
16
|
+
function getPrompt() {
|
|
17
|
+
return `Interact with Language Server Protocol (LSP) servers to get code intelligence features.
|
|
18
|
+
|
|
19
|
+
## Supported Operations
|
|
20
|
+
- **goToDefinition**: Find where a symbol is defined
|
|
21
|
+
- **findReferences**: Find all references to a symbol
|
|
22
|
+
- **hover**: Get hover information (documentation, type info) for a symbol
|
|
23
|
+
- **documentSymbol**: Get all symbols (functions, classes, variables) in a document
|
|
24
|
+
- **workspaceSymbol**: Search for symbols across the entire workspace
|
|
25
|
+
- **goToImplementation**: Find implementations of an interface or abstract method
|
|
26
|
+
- **prepareCallHierarchy**: Get call hierarchy item at a position
|
|
27
|
+
- **incomingCalls**: Find all functions/methods that call the function at a position
|
|
28
|
+
- **outgoingCalls**: Find all functions/methods called by the function at a position
|
|
29
|
+
|
|
30
|
+
## When to Use
|
|
31
|
+
- To navigate code: find definitions, references, implementations
|
|
32
|
+
- To understand code structure: list symbols in a file or workspace
|
|
33
|
+
- To analyze call graphs: trace incoming/outgoing calls
|
|
34
|
+
|
|
35
|
+
## Usage Guidelines
|
|
36
|
+
- All operations require \`filePath\`, \`line\`, and \`character\` parameters
|
|
37
|
+
- Line and character are **1-based** (as shown in editors), not 0-based
|
|
38
|
+
- An LSP server must be configured for the file's language via \`servers\` config
|
|
39
|
+
- Operations that don't need a position (documentSymbol, workspaceSymbol) still require filePath`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/lsp/index.ts
|
|
8
43
|
var nextId = 1;
|
|
9
44
|
function encodeJsonRpc(msg) {
|
|
10
45
|
const body = JSON.stringify(msg);
|
|
@@ -39,13 +74,14 @@ function operationToMethod(operation) {
|
|
|
39
74
|
documentSymbol: "textDocument/documentSymbol",
|
|
40
75
|
workspaceSymbol: "workspace/symbol",
|
|
41
76
|
goToImplementation: "textDocument/implementation",
|
|
77
|
+
prepareCallHierarchy: "textDocument/prepareCallHierarchy",
|
|
42
78
|
incomingCalls: "textDocument/prepareCallHierarchy",
|
|
43
79
|
outgoingCalls: "textDocument/prepareCallHierarchy"
|
|
44
80
|
};
|
|
45
81
|
return _nullishCoalesce(map[operation], () => ( operation));
|
|
46
82
|
}
|
|
47
|
-
function buildRequestParams(op, uri, line, char
|
|
48
|
-
if (op === "workspaceSymbol") return { query:
|
|
83
|
+
function buildRequestParams(op, uri, line, char) {
|
|
84
|
+
if (op === "workspaceSymbol") return { query: "" };
|
|
49
85
|
const td = { uri };
|
|
50
86
|
if (op === "documentSymbol") return { textDocument: td };
|
|
51
87
|
const pos = { line, character: char };
|
|
@@ -122,13 +158,13 @@ async function executeLspOperation(serverConfig, params, timeoutMs) {
|
|
|
122
158
|
const rpc = (id) => Promise.race([waitForResponse(proc, id, timeoutMs), spawnError]);
|
|
123
159
|
await rpc(initId);
|
|
124
160
|
sendNotification(proc, "initialized", {});
|
|
125
|
-
const content = await
|
|
161
|
+
const content = await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, absolutePath);
|
|
126
162
|
const langId = _path.extname.call(void 0, absolutePath).replace(".", "") || "plaintext";
|
|
127
163
|
sendNotification(proc, "textDocument/didOpen", {
|
|
128
164
|
textDocument: { uri, languageId: langId, version: 1, text: content }
|
|
129
165
|
});
|
|
130
166
|
const method = operationToMethod(params.operation);
|
|
131
|
-
const reqParams = buildRequestParams(params.operation, uri, _nullishCoalesce(params.line, () => ( 0)), _nullishCoalesce(params.character, () => ( 0))
|
|
167
|
+
const reqParams = buildRequestParams(params.operation, uri, _nullishCoalesce(params.line, () => ( 0)), _nullishCoalesce(params.character, () => ( 0)));
|
|
132
168
|
let response = await rpc(sendRequest(proc, method, reqParams));
|
|
133
169
|
if (response.error) return `Error [lsp]: Server error: ${response.error.message} (code ${response.error.code})`;
|
|
134
170
|
if ((params.operation === "incomingCalls" || params.operation === "outgoingCalls") && Array.isArray(response.result) && response.result.length > 0) {
|
|
@@ -150,21 +186,21 @@ var LSP_OPERATIONS = [
|
|
|
150
186
|
"documentSymbol",
|
|
151
187
|
"workspaceSymbol",
|
|
152
188
|
"goToImplementation",
|
|
189
|
+
"prepareCallHierarchy",
|
|
153
190
|
"incomingCalls",
|
|
154
191
|
"outgoingCalls"
|
|
155
192
|
];
|
|
156
193
|
function createLsp(config = {}) {
|
|
157
194
|
const timeoutMs = _nullishCoalesce(config.timeout, () => ( 3e4));
|
|
158
195
|
return _ai.tool.call(void 0, {
|
|
159
|
-
description:
|
|
196
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
160
197
|
inputSchema: _zod.z.object({
|
|
161
198
|
operation: _zod.z.enum(LSP_OPERATIONS).describe("The LSP operation to perform"),
|
|
162
199
|
filePath: _zod.z.string().describe("Path to the file"),
|
|
163
|
-
line: _zod.z.number().
|
|
164
|
-
character: _zod.z.number().
|
|
165
|
-
query: _zod.z.string().optional().describe("Search query for workspaceSymbol")
|
|
200
|
+
line: _zod.z.number().int().positive().describe("The line number (1-based, as shown in editors)"),
|
|
201
|
+
character: _zod.z.number().int().positive().describe("The character offset (1-based, as shown in editors)")
|
|
166
202
|
}),
|
|
167
|
-
execute: async ({ operation, filePath, line, character
|
|
203
|
+
execute: async ({ operation, filePath, line, character }) => {
|
|
168
204
|
if (!config.servers || Object.keys(config.servers).length === 0) {
|
|
169
205
|
return 'Error [lsp]: No LSP servers configured. Provide server configuration via createLsp({ servers: { ".ts": { command: "typescript-language-server", args: ["--stdio"] } } })';
|
|
170
206
|
}
|
|
@@ -177,11 +213,11 @@ function createLsp(config = {}) {
|
|
|
177
213
|
try {
|
|
178
214
|
return await executeLspOperation(
|
|
179
215
|
serverConfig,
|
|
180
|
-
{ operation, filePath, line, character
|
|
216
|
+
{ operation, filePath, line: line - 1, character: character - 1, cwd: _nullishCoalesce(config.cwd, () => ( process.cwd())) },
|
|
181
217
|
timeoutMs
|
|
182
218
|
);
|
|
183
219
|
} catch (error) {
|
|
184
|
-
const msg =
|
|
220
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
185
221
|
return `Error [lsp]: ${operation} failed for ${filePath}: ${msg}`;
|
|
186
222
|
}
|
|
187
223
|
}
|
|
@@ -193,4 +229,5 @@ var lsp = createLsp();
|
|
|
193
229
|
|
|
194
230
|
|
|
195
231
|
|
|
196
|
-
|
|
232
|
+
|
|
233
|
+
exports.getPrompt = getPrompt; exports.executeLspOperation = executeLspOperation; exports.createLsp = createLsp; exports.lsp = lsp;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pathExists,
|
|
3
|
+
writeTextContent
|
|
4
|
+
} from "./chunk-PWBVB6MN.js";
|
|
5
|
+
import {
|
|
6
|
+
expandPath
|
|
7
|
+
} from "./chunk-I3ONDY7P.js";
|
|
8
|
+
import {
|
|
9
|
+
extractErrorMessage
|
|
10
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
11
|
+
|
|
12
|
+
// src/write/index.ts
|
|
13
|
+
import { tool } from "ai";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
// src/write/prompt.ts
|
|
17
|
+
function getPrompt() {
|
|
18
|
+
return `Write text content to a file, creating parent directories as needed. If the file already exists it is overwritten entirely.
|
|
19
|
+
|
|
20
|
+
Supports absolute paths, relative paths, and tilde (~) expansion.
|
|
21
|
+
|
|
22
|
+
## When to Use
|
|
23
|
+
- To create new files that don't exist yet
|
|
24
|
+
- To completely rewrite an existing file's content
|
|
25
|
+
- When the changes are so extensive that targeted editing would be impractical
|
|
26
|
+
|
|
27
|
+
## When NOT to Use
|
|
28
|
+
- To make small, targeted changes to an existing file \u2014 use the file editing tool instead (it only changes what you specify and is less error-prone)
|
|
29
|
+
- Prefer the editing tool for modifications; reserve this tool for creating new files or complete rewrites
|
|
30
|
+
|
|
31
|
+
## Usage Guidelines
|
|
32
|
+
- This tool overwrites the entire file \u2014 make sure you include all desired content, not just the changes
|
|
33
|
+
- Parent directories are created automatically if they don't exist
|
|
34
|
+
- Read the existing file first before overwriting it, so you don't accidentally lose content`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/write/index.ts
|
|
38
|
+
function createWrite(config = {}) {
|
|
39
|
+
const cwd = config.cwd ?? process.cwd();
|
|
40
|
+
return tool({
|
|
41
|
+
description: config.description ?? getPrompt(),
|
|
42
|
+
inputSchema: z.object({
|
|
43
|
+
file_path: z.string().describe("The absolute path to the file to write (must be absolute, not relative)"),
|
|
44
|
+
content: z.string().describe("Text content to write to the file")
|
|
45
|
+
}),
|
|
46
|
+
execute: async ({ file_path, content }) => {
|
|
47
|
+
try {
|
|
48
|
+
const absolutePath = expandPath(file_path, cwd);
|
|
49
|
+
const existed = await pathExists(absolutePath);
|
|
50
|
+
await writeTextContent(absolutePath, content);
|
|
51
|
+
const bytes = Buffer.byteLength(content, "utf-8");
|
|
52
|
+
const verb = existed ? "Updated" : "Created";
|
|
53
|
+
return `${verb} file: ${absolutePath} (${bytes} bytes)`;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const message = extractErrorMessage(error);
|
|
56
|
+
return `Error [write]: Failed to write file: ${message}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
var write = createWrite();
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
getPrompt,
|
|
65
|
+
createWrite,
|
|
66
|
+
write
|
|
67
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
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
2
|
|
|
3
|
+
var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
4
7
|
|
|
8
|
+
|
|
9
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
10
|
+
|
|
5
11
|
// src/diff/index.ts
|
|
6
|
-
var _promises = require('fs/promises');
|
|
7
12
|
var _ai = require('ai');
|
|
8
13
|
var _zod = require('zod');
|
|
9
14
|
|
|
10
15
|
// src/shared/diff.ts
|
|
11
|
-
|
|
12
16
|
var _diff = require('diff');
|
|
13
17
|
function diffStrings(oldContent, newContent, options) {
|
|
14
18
|
if (oldContent === newContent) {
|
|
@@ -29,8 +33,8 @@ function diffStrings(oldContent, newContent, options) {
|
|
|
29
33
|
}
|
|
30
34
|
async function diffFiles(oldFilePath, newFilePath, options) {
|
|
31
35
|
const [oldContent, newContent] = await Promise.all([
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
_chunkBIAODQ2Pcjs.readTextContent.call(void 0, oldFilePath),
|
|
37
|
+
_chunkBIAODQ2Pcjs.readTextContent.call(void 0, newFilePath)
|
|
34
38
|
]);
|
|
35
39
|
return diffStrings(oldContent, newContent, {
|
|
36
40
|
...options,
|
|
@@ -39,11 +43,30 @@ async function diffFiles(oldFilePath, newFilePath, options) {
|
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
// src/diff/prompt.ts
|
|
47
|
+
function getPrompt() {
|
|
48
|
+
return `Generate a unified diff between two files or two strings.
|
|
49
|
+
|
|
50
|
+
Supports three modes:
|
|
51
|
+
1. **Two file paths**: \`file_path\` + \`other_file_path\` \u2014 compares the contents of both files
|
|
52
|
+
2. **Two strings**: \`old_content\` + \`new_content\` \u2014 compares the provided strings directly
|
|
53
|
+
3. **File + string**: \`file_path\` + \`old_content\` or \`new_content\` \u2014 compares a file against provided content
|
|
54
|
+
|
|
55
|
+
## When to Use
|
|
56
|
+
- To preview what changes would look like before making edits
|
|
57
|
+
- To compare two versions of a file or text
|
|
58
|
+
- To generate a diff for review or documentation purposes
|
|
59
|
+
|
|
60
|
+
## When NOT to Use
|
|
61
|
+
- To actually apply changes to a file \u2014 use the file editing tool instead
|
|
62
|
+
- To read file contents \u2014 use the file reading tool instead`;
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
// src/diff/index.ts
|
|
43
66
|
function createDiff(config = {}) {
|
|
44
67
|
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
45
68
|
return _ai.tool.call(void 0, {
|
|
46
|
-
description:
|
|
69
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
47
70
|
inputSchema: _zod.z.object({
|
|
48
71
|
file_path: _zod.z.string().optional().describe("Path to the first file (absolute or relative to cwd)"),
|
|
49
72
|
other_file_path: _zod.z.string().optional().describe("Path to the second file (absolute or relative to cwd)"),
|
|
@@ -62,7 +85,7 @@ function createDiff(config = {}) {
|
|
|
62
85
|
}
|
|
63
86
|
if (file_path && (old_content !== void 0 || new_content !== void 0)) {
|
|
64
87
|
const resolvedPath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
|
|
65
|
-
const fileContent = await
|
|
88
|
+
const fileContent = await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, resolvedPath);
|
|
66
89
|
if (old_content !== void 0) {
|
|
67
90
|
return diffStrings(old_content, fileContent, {
|
|
68
91
|
oldLabel: "provided",
|
|
@@ -76,7 +99,7 @@ function createDiff(config = {}) {
|
|
|
76
99
|
}
|
|
77
100
|
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
101
|
} catch (error) {
|
|
79
|
-
const msg =
|
|
102
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
80
103
|
return `Error [diff]: ${msg}`;
|
|
81
104
|
}
|
|
82
105
|
}
|
|
@@ -87,4 +110,5 @@ var diff = createDiff();
|
|
|
87
110
|
|
|
88
111
|
|
|
89
112
|
|
|
90
|
-
|
|
113
|
+
|
|
114
|
+
exports.getPrompt = getPrompt; exports.createDiff = createDiff; exports.diff = diff;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/shared/file.ts
|
|
2
2
|
import { createReadStream } from "fs";
|
|
3
|
-
import { mkdir, readFile, stat, writeFile } from "fs/promises";
|
|
3
|
+
import { mkdir, readFile, readdir, stat, unlink, writeFile } from "fs/promises";
|
|
4
4
|
import { dirname } from "path";
|
|
5
5
|
var FAST_PATH_MAX_SIZE = 10 * 1024 * 1024;
|
|
6
6
|
function addLineNumbers({
|
|
@@ -25,6 +25,18 @@ async function pathExists(path) {
|
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
async function readTextContent(filePath) {
|
|
29
|
+
return readFile(filePath, "utf-8");
|
|
30
|
+
}
|
|
31
|
+
async function listDirectory(dirPath) {
|
|
32
|
+
return readdir(dirPath);
|
|
33
|
+
}
|
|
34
|
+
async function removeFile(filePath) {
|
|
35
|
+
await unlink(filePath);
|
|
36
|
+
}
|
|
37
|
+
async function getFileStats(filePath) {
|
|
38
|
+
return stat(filePath);
|
|
39
|
+
}
|
|
28
40
|
async function readFileInRange(filePath, offset = 0, maxLines) {
|
|
29
41
|
const stats = await stat(filePath);
|
|
30
42
|
if (stats.isDirectory()) {
|
|
@@ -113,5 +125,9 @@ export {
|
|
|
113
125
|
addLineNumbers,
|
|
114
126
|
writeTextContent,
|
|
115
127
|
pathExists,
|
|
128
|
+
readTextContent,
|
|
129
|
+
listDirectory,
|
|
130
|
+
removeFile,
|
|
131
|
+
getFileStats,
|
|
116
132
|
readFileInRange
|
|
117
133
|
};
|
|
@@ -3,13 +3,48 @@
|
|
|
3
3
|
var _chunkMIYA7TNRcjs = require('./chunk-MIYA7TNR.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
8
11
|
|
|
12
|
+
|
|
13
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
14
|
+
|
|
9
15
|
// src/grep/index.ts
|
|
10
|
-
var _promises = require('fs/promises');
|
|
11
16
|
var _ai = require('ai');
|
|
12
17
|
var _zod = require('zod');
|
|
18
|
+
|
|
19
|
+
// src/grep/prompt.ts
|
|
20
|
+
function getPrompt() {
|
|
21
|
+
return `Search file contents using ripgrep. Supports regex patterns, context lines, and multiple output modes.
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
- To find where a function, variable, string, or pattern is used across files
|
|
25
|
+
- To search for specific code patterns, error messages, or configuration values
|
|
26
|
+
- To count occurrences of a pattern across a codebase
|
|
27
|
+
|
|
28
|
+
## When NOT to Use
|
|
29
|
+
- To find files by name/extension \u2014 use the dedicated file search tool instead
|
|
30
|
+
- To read a specific file \u2014 use the file reading tool instead
|
|
31
|
+
- Don't use shell commands (grep, rg) for content search when this tool is available
|
|
32
|
+
|
|
33
|
+
## Output Modes
|
|
34
|
+
- \`files_with_matches\` (default): Returns file paths containing matches, sorted by modification time. Best for discovering which files contain a pattern.
|
|
35
|
+
- \`content\`: Returns matching lines with optional context. Supports \`-A\` (after), \`-B\` (before), \`-C\` (context) for surrounding lines and \`-n\` for line numbers (default: true).
|
|
36
|
+
- \`count\`: Returns match counts per file with totals.
|
|
37
|
+
|
|
38
|
+
## Usage Guidelines
|
|
39
|
+
- Uses ripgrep regex syntax (not grep). Literal braces need escaping: use \`interface\\{\\}\` to find \`interface{}\`
|
|
40
|
+
- Filter files with the \`glob\` parameter (e.g., "*.js", "*.{ts,tsx}") or \`type\` parameter (e.g., "js", "py")
|
|
41
|
+
- Default head_limit is 250 entries. Pass \`head_limit: 0\` for unlimited (use sparingly \u2014 large results waste context)
|
|
42
|
+
- Use \`offset\` to paginate through large result sets
|
|
43
|
+
- Enable \`multiline: true\` for patterns that span lines (e.g., \`struct \\{[\\s\\S]*?field\`)
|
|
44
|
+
- Use \`-i: true\` for case-insensitive search`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/grep/index.ts
|
|
13
48
|
var VCS_DIRS = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
14
49
|
var DEFAULT_HEAD_LIMIT = 250;
|
|
15
50
|
function applyHeadLimit(items, limit, offset = 0) {
|
|
@@ -48,22 +83,22 @@ function parseGlobPatterns(globFilter) {
|
|
|
48
83
|
function createGrep(config = {}) {
|
|
49
84
|
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
50
85
|
return _ai.tool.call(void 0, {
|
|
51
|
-
description:
|
|
86
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
52
87
|
inputSchema: _zod.z.object({
|
|
53
|
-
pattern: _zod.z.string().describe("
|
|
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(
|
|
58
|
-
"-A": _zod.z.number().optional().describe(
|
|
59
|
-
"-C": _zod.z.number().optional().describe("
|
|
60
|
-
context: _zod.z.number().optional().describe(
|
|
61
|
-
"-n": _zod.z.boolean().optional().describe(
|
|
62
|
-
"-i": _zod.z.boolean().optional().describe("Case insensitive search"),
|
|
63
|
-
type: _zod.z.string().optional().describe(
|
|
64
|
-
head_limit: _zod.z.number().optional().describe("
|
|
65
|
-
offset: _zod.z.number().optional().describe(
|
|
66
|
-
multiline: _zod.z.boolean().optional().describe("Enable multiline
|
|
88
|
+
pattern: _zod.z.string().describe("The regular expression pattern to search for in file contents"),
|
|
89
|
+
path: _zod.z.string().optional().describe("File or directory to search in (rg PATH). Defaults to current working directory."),
|
|
90
|
+
glob: _zod.z.string().optional().describe('Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}") - maps to rg --glob'),
|
|
91
|
+
output_mode: _zod.z.enum(["content", "files_with_matches", "count"]).optional().describe('Output mode: "content" shows matching lines (supports -A/-B/-C context, -n line numbers, head_limit), "files_with_matches" shows file paths (supports head_limit), "count" shows match counts (supports head_limit). Defaults to "files_with_matches".'),
|
|
92
|
+
"-B": _zod.z.number().optional().describe('Number of lines to show before each match (rg -B). Requires output_mode: "content", ignored otherwise.'),
|
|
93
|
+
"-A": _zod.z.number().optional().describe('Number of lines to show after each match (rg -A). Requires output_mode: "content", ignored otherwise.'),
|
|
94
|
+
"-C": _zod.z.number().optional().describe("Alias for context."),
|
|
95
|
+
context: _zod.z.number().optional().describe('Number of lines to show before and after each match (rg -C). Requires output_mode: "content", ignored otherwise.'),
|
|
96
|
+
"-n": _zod.z.boolean().optional().describe('Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise. Defaults to true.'),
|
|
97
|
+
"-i": _zod.z.boolean().optional().describe("Case insensitive search (rg -i)"),
|
|
98
|
+
type: _zod.z.string().optional().describe("File type to search (rg --type). Common types: js, py, rust, go, java, etc. More efficient than include for standard file types."),
|
|
99
|
+
head_limit: _zod.z.number().optional().describe('Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 250 when unspecified. Pass 0 for unlimited (use sparingly \u2014 large result sets waste context).'),
|
|
100
|
+
offset: _zod.z.number().optional().describe('Skip first N lines/entries before applying head_limit, equivalent to "| tail -n +N | head -N". Works across all output modes. Defaults to 0.'),
|
|
101
|
+
multiline: _zod.z.boolean().optional().describe("Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false.")
|
|
67
102
|
}),
|
|
68
103
|
execute: async (input) => {
|
|
69
104
|
try {
|
|
@@ -132,7 +167,7 @@ function createGrep(config = {}) {
|
|
|
132
167
|
|
|
133
168
|
Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(appliedLimit2, offset);
|
|
134
169
|
}
|
|
135
|
-
const stats = await Promise.allSettled(results.map((f) =>
|
|
170
|
+
const stats = await Promise.allSettled(results.map((f) => _chunkBIAODQ2Pcjs.getFileStats.call(void 0, f)));
|
|
136
171
|
const sorted = results.map((fp, i) => {
|
|
137
172
|
const r = stats[i];
|
|
138
173
|
const mt = r.status === "fulfilled" ? _nullishCoalesce(r.value.mtimeMs, () => ( 0)) : 0;
|
|
@@ -145,7 +180,7 @@ Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(applied
|
|
|
145
180
|
const relative = items.map((f) => _chunkQZ5GS6HWcjs.toRelativePath.call(void 0, f, cwd));
|
|
146
181
|
return relative.join("\n") + truncationSuffix(appliedLimit, offset);
|
|
147
182
|
} catch (error) {
|
|
148
|
-
const msg =
|
|
183
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
149
184
|
return `Error [grep]: Failed to search: ${msg}`;
|
|
150
185
|
}
|
|
151
186
|
}
|
|
@@ -156,4 +191,5 @@ var grep = createGrep();
|
|
|
156
191
|
|
|
157
192
|
|
|
158
193
|
|
|
159
|
-
|
|
194
|
+
|
|
195
|
+
exports.getPrompt = getPrompt; exports.createGrep = createGrep; exports.grep = grep;
|