@morphllm/morphsdk 0.2.56 → 0.2.58
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/anthropic-CaFUHxBW.d.ts +89 -0
- package/dist/{chunk-SALJ2K6S.js → chunk-2CASO3ZO.js} +60 -98
- package/dist/chunk-2CASO3ZO.js.map +1 -0
- package/dist/chunk-374N3GIA.js +118 -0
- package/dist/chunk-374N3GIA.js.map +1 -0
- package/dist/chunk-3IQIT6MC.js +65 -0
- package/dist/chunk-3IQIT6MC.js.map +1 -0
- package/dist/chunk-4VGOBA2J.js +57 -0
- package/dist/chunk-4VGOBA2J.js.map +1 -0
- package/dist/chunk-527P5X2E.js +98 -0
- package/dist/chunk-527P5X2E.js.map +1 -0
- package/dist/chunk-6N6ZYZYD.js +74 -0
- package/dist/chunk-6N6ZYZYD.js.map +1 -0
- package/dist/chunk-6Y5JB4JC.js +195 -0
- package/dist/chunk-6Y5JB4JC.js.map +1 -0
- package/dist/{chunk-WSSSSBWU.js → chunk-7EIHYJSG.js} +18 -18
- package/dist/chunk-7EIHYJSG.js.map +1 -0
- package/dist/{chunk-TICMYDII.js → chunk-APP75CBN.js} +33 -16
- package/dist/chunk-APP75CBN.js.map +1 -0
- package/dist/chunk-ILJ3J5IA.js +72 -0
- package/dist/chunk-ILJ3J5IA.js.map +1 -0
- package/dist/chunk-ISWL67SF.js +1 -0
- package/dist/chunk-KW7OEGZK.js +9 -0
- package/dist/chunk-KW7OEGZK.js.map +1 -0
- package/dist/chunk-Q5AHGIQO.js +205 -0
- package/dist/chunk-Q5AHGIQO.js.map +1 -0
- package/dist/{chunk-TJIUA27P.js → chunk-XT5ZO6ES.js} +9 -5
- package/dist/chunk-XT5ZO6ES.js.map +1 -0
- package/dist/{chunk-LVPVVLTI.js → chunk-YV75OQTE.js} +105 -17
- package/dist/chunk-YV75OQTE.js.map +1 -0
- package/dist/{chunk-ZJIIICRA.js → chunk-ZO4PPFCZ.js} +60 -29
- package/dist/chunk-ZO4PPFCZ.js.map +1 -0
- package/dist/{client-CFoR--IU.d.ts → client-CextMMm9.d.ts} +10 -15
- package/dist/client.cjs +698 -466
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +3 -2
- package/dist/client.js +14 -15
- package/dist/finish-kXAcUJyB.d.ts +33 -0
- package/dist/gemini-CE80Pbdy.d.ts +117 -0
- package/dist/index.cjs +711 -466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +16 -16
- package/dist/openai-Fvpqln7F.d.ts +89 -0
- package/dist/tools/warp_grep/agent/config.cjs +8 -4
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +7 -2
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.cjs +32 -15
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/formatter.d.ts +1 -1
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +104 -17
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.d.ts +3 -5
- package/dist/tools/warp_grep/agent/parser.js +1 -3
- package/dist/tools/warp_grep/agent/prompt.cjs +132 -56
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +466 -313
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.d.ts +1 -0
- package/dist/tools/warp_grep/agent/runner.js +6 -9
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +9 -2
- package/dist/tools/warp_grep/anthropic.cjs +656 -380
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +4 -74
- package/dist/tools/warp_grep/anthropic.js +13 -16
- package/dist/tools/warp_grep/client.cjs +1593 -0
- package/dist/tools/warp_grep/client.cjs.map +1 -0
- package/dist/tools/warp_grep/client.d.ts +87 -0
- package/dist/tools/warp_grep/client.js +26 -0
- package/dist/tools/warp_grep/gemini.cjs +1587 -0
- package/dist/tools/warp_grep/gemini.cjs.map +1 -0
- package/dist/tools/warp_grep/gemini.d.ts +7 -0
- package/dist/tools/warp_grep/gemini.js +34 -0
- package/dist/tools/warp_grep/harness.cjs +1195 -0
- package/dist/tools/warp_grep/harness.cjs.map +1 -0
- package/dist/tools/warp_grep/harness.d.ts +107 -0
- package/dist/tools/warp_grep/harness.js +68 -0
- package/dist/tools/warp_grep/harness.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +818 -466
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +11 -6
- package/dist/tools/warp_grep/index.js +43 -23
- package/dist/tools/warp_grep/openai.cjs +656 -378
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +4 -74
- package/dist/tools/warp_grep/openai.js +13 -14
- package/dist/tools/warp_grep/providers/local.cjs +66 -27
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +4 -9
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +211 -0
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/remote.d.ts +67 -0
- package/dist/tools/warp_grep/providers/remote.js +9 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/types.d.ts +7 -15
- package/dist/tools/warp_grep/vercel.cjs +668 -397
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +4 -51
- package/dist/tools/warp_grep/vercel.js +16 -15
- package/dist/types-a_hxdPI6.d.ts +144 -0
- package/dist/vercel-3yjvfmVB.d.ts +66 -0
- package/package.json +17 -2
- package/dist/chunk-4ZHDBKBY.js +0 -83
- package/dist/chunk-4ZHDBKBY.js.map +0 -1
- package/dist/chunk-73RQWOQC.js +0 -16
- package/dist/chunk-73RQWOQC.js.map +0 -1
- package/dist/chunk-7OQOOB3R.js +0 -1
- package/dist/chunk-EK7OQPWD.js +0 -44
- package/dist/chunk-EK7OQPWD.js.map +0 -1
- package/dist/chunk-GJURLQ3L.js +0 -77
- package/dist/chunk-GJURLQ3L.js.map +0 -1
- package/dist/chunk-HQO45BAJ.js +0 -14
- package/dist/chunk-HQO45BAJ.js.map +0 -1
- package/dist/chunk-LVPVVLTI.js.map +0 -1
- package/dist/chunk-NDZO5IPV.js +0 -121
- package/dist/chunk-NDZO5IPV.js.map +0 -1
- package/dist/chunk-QVRXBAMM.js +0 -107
- package/dist/chunk-QVRXBAMM.js.map +0 -1
- package/dist/chunk-SALJ2K6S.js.map +0 -1
- package/dist/chunk-TICMYDII.js.map +0 -1
- package/dist/chunk-TJIUA27P.js.map +0 -1
- package/dist/chunk-UIRJE422.js +0 -70
- package/dist/chunk-UIRJE422.js.map +0 -1
- package/dist/chunk-WETRQJGU.js +0 -129
- package/dist/chunk-WETRQJGU.js.map +0 -1
- package/dist/chunk-WSSSSBWU.js.map +0 -1
- package/dist/chunk-ZJIIICRA.js.map +0 -1
- package/dist/core-CpkYEi_T.d.ts +0 -158
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +0 -148
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/grep_helpers.js +0 -14
- package/dist/tools/warp_grep/tools/analyse.cjs +0 -40
- package/dist/tools/warp_grep/tools/analyse.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/analyse.d.ts +0 -10
- package/dist/tools/warp_grep/tools/analyse.js +0 -8
- package/dist/tools/warp_grep/tools/finish.cjs +0 -69
- package/dist/tools/warp_grep/tools/finish.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/finish.d.ts +0 -10
- package/dist/tools/warp_grep/tools/finish.js +0 -10
- package/dist/tools/warp_grep/tools/grep.cjs +0 -38
- package/dist/tools/warp_grep/tools/grep.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/grep.d.ts +0 -8
- package/dist/tools/warp_grep/tools/grep.js +0 -15
- package/dist/tools/warp_grep/tools/grep.js.map +0 -1
- package/dist/tools/warp_grep/tools/read.cjs +0 -38
- package/dist/tools/warp_grep/tools/read.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/read.d.ts +0 -9
- package/dist/tools/warp_grep/tools/read.js +0 -8
- package/dist/tools/warp_grep/tools/read.js.map +0 -1
- package/dist/tools/warp_grep/utils/format.cjs +0 -42
- package/dist/tools/warp_grep/utils/format.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/format.d.ts +0 -4
- package/dist/tools/warp_grep/utils/format.js +0 -18
- package/dist/tools/warp_grep/utils/format.js.map +0 -1
- /package/dist/{chunk-7OQOOB3R.js.map → chunk-ISWL67SF.js.map} +0 -0
- /package/dist/tools/warp_grep/{agent/grep_helpers.js.map → client.js.map} +0 -0
- /package/dist/tools/warp_grep/{tools/analyse.js.map → gemini.js.map} +0 -0
- /package/dist/tools/warp_grep/{tools/finish.js.map → providers/remote.js.map} +0 -0
package/dist/core-CpkYEi_T.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { WarpGrepProvider } from './tools/warp_grep/providers/types.js';
|
|
2
|
-
import { RetryConfig } from './tools/utils/resilience.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for WarpGrepClient
|
|
6
|
-
*/
|
|
7
|
-
interface WarpGrepClientConfig {
|
|
8
|
-
/** Morph API key (defaults to MORPH_API_KEY env var) */
|
|
9
|
-
apiKey?: string;
|
|
10
|
-
/** Enable debug logging */
|
|
11
|
-
debug?: boolean;
|
|
12
|
-
/** Request timeout in milliseconds */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/** Retry configuration */
|
|
15
|
-
retryConfig?: RetryConfig;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Input for warp grep execution
|
|
19
|
-
*/
|
|
20
|
-
interface WarpGrepInput {
|
|
21
|
-
/** Free-form repository question */
|
|
22
|
-
query: string;
|
|
23
|
-
/** Root directory of the repository to search */
|
|
24
|
-
repoRoot: string;
|
|
25
|
-
/** Optional custom provider (defaults to LocalRipgrepProvider) */
|
|
26
|
-
provider?: WarpGrepProvider;
|
|
27
|
-
/** Glob patterns to exclude from search */
|
|
28
|
-
excludes?: string[];
|
|
29
|
-
/** Glob patterns to include in search */
|
|
30
|
-
includes?: string[];
|
|
31
|
-
/** Enable debug logging for this request */
|
|
32
|
-
debug?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A single context result with file path and content
|
|
36
|
-
*/
|
|
37
|
-
interface WarpGrepContext {
|
|
38
|
-
/** File path relative to repo root */
|
|
39
|
-
file: string;
|
|
40
|
-
/** Content of the relevant code section */
|
|
41
|
-
content: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Result from warp grep execution
|
|
45
|
-
*/
|
|
46
|
-
interface WarpGrepResult {
|
|
47
|
-
/** Whether the search completed successfully */
|
|
48
|
-
success: boolean;
|
|
49
|
-
/** Relevant code contexts found */
|
|
50
|
-
contexts?: WarpGrepContext[];
|
|
51
|
-
/** Summary of what was found */
|
|
52
|
-
summary?: string;
|
|
53
|
-
/** Error message if search failed */
|
|
54
|
-
error?: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Configuration for creating a warp grep tool
|
|
58
|
-
*/
|
|
59
|
-
interface WarpGrepToolConfig {
|
|
60
|
-
/** Root directory of the repository to search */
|
|
61
|
-
repoRoot: string;
|
|
62
|
-
/** Optional custom provider (defaults to LocalRipgrepProvider) */
|
|
63
|
-
provider?: WarpGrepProvider;
|
|
64
|
-
/** Glob patterns to exclude from search */
|
|
65
|
-
excludes?: string[];
|
|
66
|
-
/** Glob patterns to include in search */
|
|
67
|
-
includes?: string[];
|
|
68
|
-
/** Enable debug logging */
|
|
69
|
-
debug?: boolean;
|
|
70
|
-
/** Morph API key (defaults to MORPH_API_KEY env var) */
|
|
71
|
-
apiKey?: string;
|
|
72
|
-
/** Custom tool name (defaults to 'warpgrep_codebase_search') */
|
|
73
|
-
name?: string;
|
|
74
|
-
/** Custom tool description */
|
|
75
|
-
description?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Core implementation for morph-warp-grep
|
|
80
|
-
* Provides a client class for programmatic code search
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* WarpGrep client for programmatic code search
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* import { WarpGrepClient } from '@morphllm/morphsdk';
|
|
89
|
-
*
|
|
90
|
-
* const client = new WarpGrepClient({ apiKey: process.env.MORPH_API_KEY });
|
|
91
|
-
*
|
|
92
|
-
* // Simple usage - defaults to LocalRipgrepProvider
|
|
93
|
-
* const result = await client.execute({
|
|
94
|
-
* query: 'Find authentication middleware',
|
|
95
|
-
* repoRoot: '.'
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* // With custom excludes
|
|
99
|
-
* const result = await client.execute({
|
|
100
|
-
* query: 'Find database models',
|
|
101
|
-
* repoRoot: '.',
|
|
102
|
-
* excludes: ['node_modules', '.git', 'dist']
|
|
103
|
-
* });
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
declare class WarpGrepClient {
|
|
107
|
-
private config;
|
|
108
|
-
constructor(config?: WarpGrepClientConfig);
|
|
109
|
-
/**
|
|
110
|
-
* Execute a code search query
|
|
111
|
-
*
|
|
112
|
-
* @param input - Search parameters including query, repoRoot, and optional provider
|
|
113
|
-
* @returns Search results with relevant code contexts
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const result = await client.execute({
|
|
118
|
-
* query: 'Find authentication middleware',
|
|
119
|
-
* repoRoot: '.'
|
|
120
|
-
* });
|
|
121
|
-
*
|
|
122
|
-
* if (result.success) {
|
|
123
|
-
* for (const ctx of result.contexts) {
|
|
124
|
-
* console.log(`File: ${ctx.file}`);
|
|
125
|
-
* console.log(ctx.content);
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
execute(input: WarpGrepInput): Promise<WarpGrepResult>;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Execute a warp grep search directly
|
|
134
|
-
*
|
|
135
|
-
* @param input - Search parameters
|
|
136
|
-
* @param config - Optional client configuration
|
|
137
|
-
* @returns Search results
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* import { executeWarpGrep } from '@morphllm/morphsdk/tools/warp-grep';
|
|
142
|
-
*
|
|
143
|
-
* const result = await executeWarpGrep({
|
|
144
|
-
* query: 'Find authentication middleware',
|
|
145
|
-
* repoRoot: '.'
|
|
146
|
-
* });
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
declare function executeWarpGrep(input: WarpGrepInput, config?: WarpGrepClientConfig): Promise<WarpGrepResult>;
|
|
150
|
-
/**
|
|
151
|
-
* Format warp grep results for display or tool responses
|
|
152
|
-
*
|
|
153
|
-
* @param result - The search result
|
|
154
|
-
* @returns Formatted string representation
|
|
155
|
-
*/
|
|
156
|
-
declare function formatResult(result: WarpGrepResult): string;
|
|
157
|
-
|
|
158
|
-
export { WarpGrepClient as W, type WarpGrepClientConfig as a, type WarpGrepInput as b, type WarpGrepResult as c, type WarpGrepContext as d, type WarpGrepToolConfig as e, formatResult as f, executeWarpGrep as g };
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/agent/grep_helpers.ts
|
|
21
|
-
var grep_helpers_exports = {};
|
|
22
|
-
__export(grep_helpers_exports, {
|
|
23
|
-
GrepState: () => GrepState,
|
|
24
|
-
MAX_GREP_OUTPUT_CHARS_PER_TURN: () => MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
25
|
-
formatTurnGrepOutput: () => formatTurnGrepOutput,
|
|
26
|
-
parseAndFilterGrepOutput: () => parseAndFilterGrepOutput
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(grep_helpers_exports);
|
|
29
|
-
var GrepState = class {
|
|
30
|
-
seenLines = /* @__PURE__ */ new Set();
|
|
31
|
-
isNew(path, lineNumber) {
|
|
32
|
-
const key = this.makeKey(path, lineNumber);
|
|
33
|
-
return !this.seenLines.has(key);
|
|
34
|
-
}
|
|
35
|
-
add(path, lineNumber) {
|
|
36
|
-
this.seenLines.add(this.makeKey(path, lineNumber));
|
|
37
|
-
}
|
|
38
|
-
makeKey(path, lineNumber) {
|
|
39
|
-
return `${path}:${lineNumber}`;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
|
|
43
|
-
function extractMatchFields(payload) {
|
|
44
|
-
const text = payload.replace(/\r?\n$/, "");
|
|
45
|
-
if (!text || text.startsWith("[error]")) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const firstSep = text.indexOf(":");
|
|
49
|
-
if (firstSep === -1) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
let filePath = text.slice(0, firstSep).trim();
|
|
53
|
-
if (!filePath) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
|
|
57
|
-
filePath = filePath.slice(2);
|
|
58
|
-
}
|
|
59
|
-
const remainder = text.slice(firstSep + 1);
|
|
60
|
-
const secondSep = remainder.indexOf(":");
|
|
61
|
-
if (secondSep === -1) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const linePart = remainder.slice(0, secondSep);
|
|
65
|
-
const lineNumber = Number.parseInt(linePart, 10);
|
|
66
|
-
if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
let contentSegment = remainder.slice(secondSep + 1);
|
|
70
|
-
const columnSep = contentSegment.indexOf(":");
|
|
71
|
-
if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
|
|
72
|
-
contentSegment = contentSegment.slice(columnSep + 1);
|
|
73
|
-
}
|
|
74
|
-
const content = contentSegment.trim();
|
|
75
|
-
if (!content) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
return { path: filePath, lineNumber, content };
|
|
79
|
-
}
|
|
80
|
-
function parseAndFilterGrepOutput(rawOutput, state) {
|
|
81
|
-
const matches = [];
|
|
82
|
-
if (typeof rawOutput !== "string" || !rawOutput.trim()) {
|
|
83
|
-
return matches;
|
|
84
|
-
}
|
|
85
|
-
for (const line of rawOutput.split(/\r?\n/)) {
|
|
86
|
-
const fields = extractMatchFields(line);
|
|
87
|
-
if (!fields) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (state.isNew(fields.path, fields.lineNumber)) {
|
|
91
|
-
matches.push(fields);
|
|
92
|
-
state.add(fields.path, fields.lineNumber);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return matches;
|
|
96
|
-
}
|
|
97
|
-
function truncateOutput(payload, maxChars) {
|
|
98
|
-
if (payload.length <= maxChars) {
|
|
99
|
-
return payload;
|
|
100
|
-
}
|
|
101
|
-
const note = "... (output truncated)";
|
|
102
|
-
const available = maxChars - note.length - 1;
|
|
103
|
-
if (available <= 0) {
|
|
104
|
-
return note;
|
|
105
|
-
}
|
|
106
|
-
if (payload.length <= available) {
|
|
107
|
-
return `${payload.slice(0, available).replace(/\n$/, "")}
|
|
108
|
-
${note}`;
|
|
109
|
-
}
|
|
110
|
-
const core = payload.slice(0, Math.max(0, available - 1));
|
|
111
|
-
const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
|
|
112
|
-
const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
|
|
113
|
-
return `${snippet}
|
|
114
|
-
${note}`;
|
|
115
|
-
}
|
|
116
|
-
function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
|
|
117
|
-
if (!matches || matches.length === 0) {
|
|
118
|
-
return "No new matches found.";
|
|
119
|
-
}
|
|
120
|
-
const matchesByFile = /* @__PURE__ */ new Map();
|
|
121
|
-
for (const match of matches) {
|
|
122
|
-
if (!matchesByFile.has(match.path)) {
|
|
123
|
-
matchesByFile.set(match.path, []);
|
|
124
|
-
}
|
|
125
|
-
matchesByFile.get(match.path).push(match);
|
|
126
|
-
}
|
|
127
|
-
const lines = [];
|
|
128
|
-
const sortedPaths = Array.from(matchesByFile.keys()).sort();
|
|
129
|
-
sortedPaths.forEach((filePath, index) => {
|
|
130
|
-
if (index > 0) {
|
|
131
|
-
lines.push("");
|
|
132
|
-
}
|
|
133
|
-
lines.push(filePath);
|
|
134
|
-
const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
|
|
135
|
-
for (const match of sortedMatches) {
|
|
136
|
-
lines.push(`${match.lineNumber}:${match.content}`);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
return truncateOutput(lines.join("\n"), maxChars);
|
|
140
|
-
}
|
|
141
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
-
0 && (module.exports = {
|
|
143
|
-
GrepState,
|
|
144
|
-
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
145
|
-
formatTurnGrepOutput,
|
|
146
|
-
parseAndFilterGrepOutput
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=grep_helpers.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/agent/grep_helpers.ts"],"sourcesContent":["export interface GrepMatch {\n\tpath: string;\n\tlineNumber: number;\n\tcontent: string;\n}\n\nexport class GrepState {\n\tprivate readonly seenLines = new Set<string>();\n\n\tisNew(path: string, lineNumber: number): boolean {\n\t\tconst key = this.makeKey(path, lineNumber);\n\t\treturn !this.seenLines.has(key);\n\t}\n\n\tadd(path: string, lineNumber: number): void {\n\t\tthis.seenLines.add(this.makeKey(path, lineNumber));\n\t}\n\n\tprivate makeKey(path: string, lineNumber: number): string {\n\t\treturn `${path}:${lineNumber}`;\n\t}\n}\n\nexport const MAX_GREP_OUTPUT_CHARS_PER_TURN = 60_000;\n\nfunction extractMatchFields(payload: string): GrepMatch | null {\n\tconst text = payload.replace(/\\r?\\n$/, \"\");\n\tif (!text || text.startsWith(\"[error]\")) {\n\t\treturn null;\n\t}\n\n\tconst firstSep = text.indexOf(\":\");\n\tif (firstSep === -1) {\n\t\treturn null;\n\t}\n\tlet filePath = text.slice(0, firstSep).trim();\n\tif (!filePath) {\n\t\treturn null;\n\t}\n\tif (filePath.startsWith(\"./\") || filePath.startsWith(\".\\\\\")) {\n\t\tfilePath = filePath.slice(2);\n\t}\n\n\tconst remainder = text.slice(firstSep + 1);\n\tconst secondSep = remainder.indexOf(\":\");\n\tif (secondSep === -1) {\n\t\treturn null;\n\t}\n\n\tconst linePart = remainder.slice(0, secondSep);\n\tconst lineNumber = Number.parseInt(linePart, 10);\n\tif (!Number.isInteger(lineNumber) || lineNumber <= 0) {\n\t\treturn null;\n\t}\n\n\tlet contentSegment = remainder.slice(secondSep + 1);\n\tconst columnSep = contentSegment.indexOf(\":\");\n\tif (columnSep !== -1 && /^\\d+$/.test(contentSegment.slice(0, columnSep))) {\n\t\tcontentSegment = contentSegment.slice(columnSep + 1);\n\t}\n\n\tconst content = contentSegment.trim();\n\tif (!content) {\n\t\treturn null;\n\t}\n\n\treturn { path: filePath, lineNumber, content };\n}\n\nexport function parseAndFilterGrepOutput(rawOutput: string, state: GrepState): GrepMatch[] {\n\tconst matches: GrepMatch[] = [];\n\tif (typeof rawOutput !== \"string\" || !rawOutput.trim()) {\n\t\treturn matches;\n\t}\n\n\tfor (const line of rawOutput.split(/\\r?\\n/)) {\n\t\tconst fields = extractMatchFields(line);\n\t\tif (!fields) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (state.isNew(fields.path, fields.lineNumber)) {\n\t\t\tmatches.push(fields);\n\t\t\tstate.add(fields.path, fields.lineNumber);\n\t\t}\n\t}\n\n\treturn matches;\n}\n\nfunction truncateOutput(payload: string, maxChars: number): string {\n\tif (payload.length <= maxChars) {\n\t\treturn payload;\n\t}\n\n\tconst note = \"... (output truncated)\";\n\tconst available = maxChars - note.length - 1;\n\tif (available <= 0) {\n\t\treturn note;\n\t}\n\n\tif (payload.length <= available) {\n\t\treturn `${payload.slice(0, available).replace(/\\n$/, \"\")}\\n${note}`;\n\t}\n\n\tconst core = payload.slice(0, Math.max(0, available - 1));\n\tconst trimmed = core.replace(/\\n$/, \"\").replace(/\\s+$/, \"\");\n\tconst snippet = trimmed ? `${trimmed}…` : \"…\";\n\treturn `${snippet}\\n${note}`;\n}\n\nexport function formatTurnGrepOutput(\n\tmatches: GrepMatch[],\n\tmaxChars: number = MAX_GREP_OUTPUT_CHARS_PER_TURN\n): string {\n\tif (!matches || matches.length === 0) {\n\t\treturn \"No new matches found.\";\n\t}\n\n\tconst matchesByFile = new Map<string, GrepMatch[]>();\n\tfor (const match of matches) {\n\t\tif (!matchesByFile.has(match.path)) {\n\t\t\tmatchesByFile.set(match.path, []);\n\t\t}\n\t\tmatchesByFile.get(match.path)!.push(match);\n\t}\n\n\tconst lines: string[] = [];\n\tconst sortedPaths = Array.from(matchesByFile.keys()).sort();\n\tsortedPaths.forEach((filePath, index) => {\n\t\tif (index > 0) {\n\t\t\tlines.push(\"\");\n\t\t}\n\t\tlines.push(filePath);\n\t\tconst sortedMatches = matchesByFile\n\t\t\t.get(filePath)!\n\t\t\t.slice()\n\t\t\t.sort((a, b) => a.lineNumber - b.lineNumber);\n\t\tfor (const match of sortedMatches) {\n\t\t\tlines.push(`${match.lineNumber}:${match.content}`);\n\t\t}\n\t});\n\n\treturn truncateOutput(lines.join(\"\\n\"), maxChars);\n}\n\n\n"],"mappings":"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","names":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface GrepMatch {
|
|
2
|
-
path: string;
|
|
3
|
-
lineNumber: number;
|
|
4
|
-
content: string;
|
|
5
|
-
}
|
|
6
|
-
declare class GrepState {
|
|
7
|
-
private readonly seenLines;
|
|
8
|
-
isNew(path: string, lineNumber: number): boolean;
|
|
9
|
-
add(path: string, lineNumber: number): void;
|
|
10
|
-
private makeKey;
|
|
11
|
-
}
|
|
12
|
-
declare const MAX_GREP_OUTPUT_CHARS_PER_TURN = 60000;
|
|
13
|
-
declare function parseAndFilterGrepOutput(rawOutput: string, state: GrepState): GrepMatch[];
|
|
14
|
-
declare function formatTurnGrepOutput(matches: GrepMatch[], maxChars?: number): string;
|
|
15
|
-
|
|
16
|
-
export { type GrepMatch, GrepState, MAX_GREP_OUTPUT_CHARS_PER_TURN, formatTurnGrepOutput, parseAndFilterGrepOutput };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GrepState,
|
|
3
|
-
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
4
|
-
formatTurnGrepOutput,
|
|
5
|
-
parseAndFilterGrepOutput
|
|
6
|
-
} from "../../../chunk-NDZO5IPV.js";
|
|
7
|
-
import "../../../chunk-PZ5AY32C.js";
|
|
8
|
-
export {
|
|
9
|
-
GrepState,
|
|
10
|
-
MAX_GREP_OUTPUT_CHARS_PER_TURN,
|
|
11
|
-
formatTurnGrepOutput,
|
|
12
|
-
parseAndFilterGrepOutput
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=grep_helpers.js.map
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/tools/analyse.ts
|
|
21
|
-
var analyse_exports = {};
|
|
22
|
-
__export(analyse_exports, {
|
|
23
|
-
toolAnalyse: () => toolAnalyse
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(analyse_exports);
|
|
26
|
-
async function toolAnalyse(provider, args) {
|
|
27
|
-
const list = await provider.analyse({
|
|
28
|
-
path: args.path,
|
|
29
|
-
pattern: args.pattern ?? null,
|
|
30
|
-
maxResults: args.maxResults ?? 100,
|
|
31
|
-
maxDepth: args.maxDepth ?? 2
|
|
32
|
-
});
|
|
33
|
-
if (!list.length) return "empty";
|
|
34
|
-
return list.map((e) => `${" ".repeat(e.depth)}- ${e.type === "dir" ? "[D]" : "[F]"} ${e.name}`).join("\n");
|
|
35
|
-
}
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
toolAnalyse
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=analyse.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/tools/analyse.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolAnalyse(\n provider: WarpGrepProvider,\n args: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }\n): Promise<string> {\n const list = await provider.analyse({\n path: args.path,\n pattern: args.pattern ?? null,\n maxResults: args.maxResults ?? 100,\n maxDepth: args.maxDepth ?? 2,\n });\n if (!list.length) return 'empty';\n return list\n .map((e) => `${' '.repeat(e.depth)}- ${e.type === 'dir' ? '[D]' : '[F]'} ${e.name}`)\n .join('\\n');\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAAsB,YACpB,UACA,MACiB;AACjB,QAAM,OAAO,MAAM,SAAS,QAAQ;AAAA,IAClC,MAAM,KAAK;AAAA,IACX,SAAS,KAAK,WAAW;AAAA,IACzB,YAAY,KAAK,cAAc;AAAA,IAC/B,UAAU,KAAK,YAAY;AAAA,EAC7B,CAAC;AACD,MAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,SAAO,KACJ,IAAI,CAAC,MAAM,GAAG,KAAK,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,QAAQ,QAAQ,KAAK,IAAI,EAAE,IAAI,EAAE,EACnF,KAAK,IAAI;AACd;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WarpGrepProvider } from '../providers/types.js';
|
|
2
|
-
|
|
3
|
-
declare function toolAnalyse(provider: WarpGrepProvider, args: {
|
|
4
|
-
path: string;
|
|
5
|
-
pattern?: string | null;
|
|
6
|
-
maxResults?: number;
|
|
7
|
-
maxDepth?: number;
|
|
8
|
-
}): Promise<string>;
|
|
9
|
-
|
|
10
|
-
export { toolAnalyse };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/tools/finish.ts
|
|
21
|
-
var finish_exports = {};
|
|
22
|
-
__export(finish_exports, {
|
|
23
|
-
normalizeFinishFiles: () => normalizeFinishFiles,
|
|
24
|
-
readFinishFiles: () => readFinishFiles
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(finish_exports);
|
|
27
|
-
function normalizeFinishFiles(files) {
|
|
28
|
-
return files.map((f) => {
|
|
29
|
-
const merged = mergeRanges(f.lines);
|
|
30
|
-
return { path: f.path, lines: merged };
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async function readFinishFiles(repoRoot, files, reader) {
|
|
34
|
-
const out = [];
|
|
35
|
-
for (const f of files) {
|
|
36
|
-
const ranges = mergeRanges(f.lines);
|
|
37
|
-
const chunks = [];
|
|
38
|
-
for (const [s, e] of ranges) {
|
|
39
|
-
const lines = await reader(f.path, s, e);
|
|
40
|
-
chunks.push(lines.join("\n"));
|
|
41
|
-
}
|
|
42
|
-
out.push({ path: f.path, ranges, content: chunks.join("\n") });
|
|
43
|
-
}
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
function mergeRanges(ranges) {
|
|
47
|
-
if (!ranges.length) return [];
|
|
48
|
-
const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
|
|
49
|
-
const merged = [];
|
|
50
|
-
let [cs, ce] = sorted[0];
|
|
51
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
52
|
-
const [s, e] = sorted[i];
|
|
53
|
-
if (s <= ce + 1) {
|
|
54
|
-
ce = Math.max(ce, e);
|
|
55
|
-
} else {
|
|
56
|
-
merged.push([cs, ce]);
|
|
57
|
-
cs = s;
|
|
58
|
-
ce = e;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
merged.push([cs, ce]);
|
|
62
|
-
return merged;
|
|
63
|
-
}
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
normalizeFinishFiles,
|
|
67
|
-
readFinishFiles
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=finish.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/tools/finish.ts"],"sourcesContent":["import type { FinishFileSpec } from '../agent/types.js';\nimport fs from 'fs/promises';\n\nexport function normalizeFinishFiles(files: FinishFileSpec[]): FinishFileSpec[] {\n return files.map((f) => {\n const merged = mergeRanges(f.lines);\n return { path: f.path, lines: merged };\n });\n}\n\nexport async function readFinishFiles(\n repoRoot: string,\n files: FinishFileSpec[],\n reader: (path: string, start: number, end: number) => Promise<string[]>\n): Promise<{ path: string; ranges: Array<[number, number]>; content: string }[]> {\n const out: { path: string; ranges: Array<[number, number]>; content: string }[] = [];\n for (const f of files) {\n const ranges = mergeRanges(f.lines);\n const chunks: string[] = [];\n for (const [s, e] of ranges) {\n const lines = await reader(f.path, s, e);\n chunks.push(lines.join('\\n'));\n }\n out.push({ path: f.path, ranges, content: chunks.join('\\n') });\n }\n return out;\n}\n\nfunction mergeRanges(ranges: Array<[number, number]>): Array<[number, number]> {\n if (!ranges.length) return [];\n const sorted = [...ranges].sort((a, b) => a[0] - b[0]);\n const merged: Array<[number, number]> = [];\n let [cs, ce] = sorted[0];\n for (let i = 1; i < sorted.length; i++) {\n const [s, e] = sorted[i];\n if (s <= ce + 1) {\n ce = Math.max(ce, e);\n } else {\n merged.push([cs, ce]);\n cs = s;\n ce = e;\n }\n }\n merged.push([cs, ce]);\n return merged;\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,qBAAqB,OAA2C;AAC9E,SAAO,MAAM,IAAI,CAAC,MAAM;AACtB,UAAM,SAAS,YAAY,EAAE,KAAK;AAClC,WAAO,EAAE,MAAM,EAAE,MAAM,OAAO,OAAO;AAAA,EACvC,CAAC;AACH;AAEA,eAAsB,gBACpB,UACA,OACA,QAC+E;AAC/E,QAAM,MAA4E,CAAC;AACnF,aAAW,KAAK,OAAO;AACrB,UAAM,SAAS,YAAY,EAAE,KAAK;AAClC,UAAM,SAAmB,CAAC;AAC1B,eAAW,CAAC,GAAG,CAAC,KAAK,QAAQ;AAC3B,YAAM,QAAQ,MAAM,OAAO,EAAE,MAAM,GAAG,CAAC;AACvC,aAAO,KAAK,MAAM,KAAK,IAAI,CAAC;AAAA,IAC9B;AACA,QAAI,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,SAAS,OAAO,KAAK,IAAI,EAAE,CAAC;AAAA,EAC/D;AACA,SAAO;AACT;AAEA,SAAS,YAAY,QAA0D;AAC7E,MAAI,CAAC,OAAO,OAAQ,QAAO,CAAC;AAC5B,QAAM,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AACrD,QAAM,SAAkC,CAAC;AACzC,MAAI,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC;AACvB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC;AACvB,QAAI,KAAK,KAAK,GAAG;AACf,WAAK,KAAK,IAAI,IAAI,CAAC;AAAA,IACrB,OAAO;AACL,aAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACpB,WAAK;AACL,WAAK;AAAA,IACP;AAAA,EACF;AACA,SAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACpB,SAAO;AACT;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FinishFileSpec } from '../agent/types.js';
|
|
2
|
-
|
|
3
|
-
declare function normalizeFinishFiles(files: FinishFileSpec[]): FinishFileSpec[];
|
|
4
|
-
declare function readFinishFiles(repoRoot: string, files: FinishFileSpec[], reader: (path: string, start: number, end: number) => Promise<string[]>): Promise<{
|
|
5
|
-
path: string;
|
|
6
|
-
ranges: Array<[number, number]>;
|
|
7
|
-
content: string;
|
|
8
|
-
}[]>;
|
|
9
|
-
|
|
10
|
-
export { normalizeFinishFiles, readFinishFiles };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/tools/grep.ts
|
|
21
|
-
var grep_exports = {};
|
|
22
|
-
__export(grep_exports, {
|
|
23
|
-
toolGrep: () => toolGrep
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(grep_exports);
|
|
26
|
-
async function toolGrep(provider, args) {
|
|
27
|
-
const result = await provider.grep({ pattern: args.pattern, path: args.path });
|
|
28
|
-
if (result.error) {
|
|
29
|
-
return `[ERROR] ${result.error}`;
|
|
30
|
-
}
|
|
31
|
-
if (!result.lines.length) return "no new matches";
|
|
32
|
-
return result.lines.join("\n");
|
|
33
|
-
}
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
toolGrep
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=grep.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/tools/grep.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolGrep(\n provider: WarpGrepProvider,\n args: { pattern: string; path: string }\n): Promise<string> {\n const result = await provider.grep({ pattern: args.pattern, path: args.path });\n // Return error message if present (graceful handling)\n if (result.error) {\n return `[ERROR] ${result.error}`;\n }\n if (!result.lines.length) return 'no new matches';\n return result.lines.join('\\n');\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,QAAM,SAAS,MAAM,SAAS,KAAK,EAAE,SAAS,KAAK,SAAS,MAAM,KAAK,KAAK,CAAC;AAE7E,MAAI,OAAO,OAAO;AAChB,WAAO,WAAW,OAAO,KAAK;AAAA,EAChC;AACA,MAAI,CAAC,OAAO,MAAM,OAAQ,QAAO;AACjC,SAAO,OAAO,MAAM,KAAK,IAAI;AAC/B;","names":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-PZ5AY32C.js";
|
|
2
|
-
|
|
3
|
-
// tools/warp_grep/tools/grep.ts
|
|
4
|
-
async function toolGrep(provider, args) {
|
|
5
|
-
const result = await provider.grep({ pattern: args.pattern, path: args.path });
|
|
6
|
-
if (result.error) {
|
|
7
|
-
return `[ERROR] ${result.error}`;
|
|
8
|
-
}
|
|
9
|
-
if (!result.lines.length) return "no new matches";
|
|
10
|
-
return result.lines.join("\n");
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
toolGrep
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=grep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/tools/grep.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolGrep(\n provider: WarpGrepProvider,\n args: { pattern: string; path: string }\n): Promise<string> {\n const result = await provider.grep({ pattern: args.pattern, path: args.path });\n // Return error message if present (graceful handling)\n if (result.error) {\n return `[ERROR] ${result.error}`;\n }\n if (!result.lines.length) return 'no new matches';\n return result.lines.join('\\n');\n}\n\n\n"],"mappings":";;;AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,QAAM,SAAS,MAAM,SAAS,KAAK,EAAE,SAAS,KAAK,SAAS,MAAM,KAAK,KAAK,CAAC;AAE7E,MAAI,OAAO,OAAO;AAChB,WAAO,WAAW,OAAO,KAAK;AAAA,EAChC;AACA,MAAI,CAAC,OAAO,MAAM,OAAQ,QAAO;AACjC,SAAO,OAAO,MAAM,KAAK,IAAI;AAC/B;","names":[]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// tools/warp_grep/tools/read.ts
|
|
21
|
-
var read_exports = {};
|
|
22
|
-
__export(read_exports, {
|
|
23
|
-
toolRead: () => toolRead
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(read_exports);
|
|
26
|
-
async function toolRead(provider, args) {
|
|
27
|
-
const res = await provider.read({ path: args.path, start: args.start, end: args.end });
|
|
28
|
-
if (res.error) {
|
|
29
|
-
return res.error;
|
|
30
|
-
}
|
|
31
|
-
if (!res.lines.length) return "(empty file)";
|
|
32
|
-
return res.lines.join("\n");
|
|
33
|
-
}
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
toolRead
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=read.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/tools/read.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../providers/types.js';\n\nexport async function toolRead(\n provider: WarpGrepProvider,\n args: { path: string; start?: number; end?: number }\n): Promise<string> {\n const res = await provider.read({ path: args.path, start: args.start, end: args.end });\n // Return error message if present (graceful handling)\n if (res.error) {\n return res.error;\n }\n if (!res.lines.length) return '(empty file)';\n return res.lines.join('\\n');\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,QAAM,MAAM,MAAM,SAAS,KAAK,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,OAAO,KAAK,KAAK,IAAI,CAAC;AAErF,MAAI,IAAI,OAAO;AACb,WAAO,IAAI;AAAA,EACb;AACA,MAAI,CAAC,IAAI,MAAM,OAAQ,QAAO;AAC9B,SAAO,IAAI,MAAM,KAAK,IAAI;AAC5B;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|