@morphllm/morphsdk 0.2.68 → 0.2.70
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/{chunk-6RFT7K7F.js → chunk-26QXQFLZ.js} +88 -23
- package/dist/chunk-26QXQFLZ.js.map +1 -0
- package/dist/{chunk-RTDKF6NS.js → chunk-5QIWYEHJ.js} +2 -2
- package/dist/{chunk-BYNVJ4ON.js → chunk-7CJPKJEE.js} +2 -2
- package/dist/{chunk-SXE54MIC.js → chunk-AB27WETH.js} +8 -8
- package/dist/chunk-B5A4XLSQ.js +10 -0
- package/dist/chunk-B5A4XLSQ.js.map +1 -0
- package/dist/{chunk-VDJGZIQ5.js → chunk-BGSHC2UK.js} +2 -2
- package/dist/{chunk-VLZEBK7S.js → chunk-E4434A4Y.js} +3 -3
- package/dist/{chunk-QEGH3CWQ.js → chunk-GZP6HY5W.js} +4 -20
- package/dist/{chunk-QEGH3CWQ.js.map → chunk-GZP6HY5W.js.map} +1 -1
- package/dist/{chunk-JPGX6WEV.js → chunk-I2GXV3BQ.js} +3 -16
- package/dist/{chunk-JPGX6WEV.js.map → chunk-I2GXV3BQ.js.map} +1 -1
- package/dist/{chunk-W76ICQKY.js → chunk-IUG2FHNN.js} +2 -2
- package/dist/{chunk-K3EHH3C4.js → chunk-PT3DGIUF.js} +3 -15
- package/dist/{chunk-K3EHH3C4.js.map → chunk-PT3DGIUF.js.map} +1 -1
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/{chunk-223ZMZP6.js → chunk-QIG7YPFW.js} +89 -30
- package/dist/chunk-QIG7YPFW.js.map +1 -0
- package/dist/{chunk-HBWJLKNM.js → chunk-QZNGKOCZ.js} +2 -2
- package/dist/{chunk-AAIUUX4Y.js → chunk-X4WPMVCM.js} +2 -2
- package/dist/client.cjs +174 -434
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +11 -12
- package/dist/git/client.js +1 -1
- package/dist/git/config.js +1 -1
- package/dist/git/index.js +1 -1
- package/dist/index.cjs +179 -446
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -14
- package/dist/modelrouter/core.js +1 -1
- package/dist/modelrouter/index.js +1 -1
- package/dist/tools/browser/anthropic.js +2 -2
- package/dist/tools/browser/core.js +1 -1
- package/dist/tools/browser/index.js +4 -4
- package/dist/tools/browser/live.js +1 -1
- package/dist/tools/browser/openai.js +2 -2
- package/dist/tools/browser/prompts.js +1 -1
- package/dist/tools/browser/vercel.js +2 -2
- package/dist/tools/codebase_search/anthropic.js +1 -1
- package/dist/tools/codebase_search/core.js +1 -1
- package/dist/tools/codebase_search/index.js +1 -1
- package/dist/tools/codebase_search/openai.js +1 -1
- package/dist/tools/codebase_search/prompts.js +1 -1
- package/dist/tools/codebase_search/vercel.js +1 -1
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/core.js +1 -1
- package/dist/tools/fastapply/index.js +4 -4
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/prompts.js +1 -1
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +4 -4
- package/dist/tools/utils/resilience.js +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.js +1 -1
- package/dist/tools/warp_grep/anthropic.cjs +174 -434
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +78 -3
- package/dist/tools/warp_grep/anthropic.js +5 -6
- package/dist/tools/warp_grep/client.cjs +174 -434
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +4 -5
- package/dist/tools/warp_grep/gemini.cjs +176 -437
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +109 -3
- package/dist/tools/warp_grep/gemini.js +48 -12
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.cjs +88 -417
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.js +2 -3
- package/dist/tools/warp_grep/harness.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +180 -621
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +89 -9
- package/dist/tools/warp_grep/index.js +7 -21
- package/dist/tools/warp_grep/openai.cjs +174 -434
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +78 -3
- package/dist/tools/warp_grep/openai.js +5 -6
- package/dist/tools/warp_grep/providers/local.cjs +88 -417
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +0 -6
- package/dist/tools/warp_grep/providers/local.js +2 -3
- package/dist/tools/warp_grep/providers/remote.cjs +86 -408
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +0 -7
- package/dist/tools/warp_grep/providers/remote.js +2 -3
- package/dist/tools/warp_grep/utils/files.js +1 -1
- package/dist/tools/warp_grep/utils/paths.js +1 -1
- package/dist/tools/warp_grep/utils/ripgrep.js +1 -1
- package/dist/tools/warp_grep/vercel.cjs +174 -434
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +56 -3
- package/dist/tools/warp_grep/vercel.js +5 -6
- package/package.json +1 -1
- package/dist/anthropic-BC-AMEIN.d.ts +0 -89
- package/dist/chunk-223ZMZP6.js.map +0 -1
- package/dist/chunk-6RFT7K7F.js.map +0 -1
- package/dist/chunk-FURFQDXF.js +0 -75
- package/dist/chunk-FURFQDXF.js.map +0 -1
- package/dist/chunk-HKJ2B2AA.js +0 -15
- package/dist/chunk-ISWL67SF.js +0 -1
- package/dist/chunk-ISWL67SF.js.map +0 -1
- package/dist/chunk-S6KU22MU.js +0 -396
- package/dist/chunk-S6KU22MU.js.map +0 -1
- package/dist/gemini-BIFBiIjY.d.ts +0 -119
- package/dist/openai-Beb9escY.d.ts +0 -89
- package/dist/vercel-Bo84tpBe.d.ts +0 -66
- /package/dist/{chunk-RTDKF6NS.js.map → chunk-5QIWYEHJ.js.map} +0 -0
- /package/dist/{chunk-BYNVJ4ON.js.map → chunk-7CJPKJEE.js.map} +0 -0
- /package/dist/{chunk-SXE54MIC.js.map → chunk-AB27WETH.js.map} +0 -0
- /package/dist/{chunk-VDJGZIQ5.js.map → chunk-BGSHC2UK.js.map} +0 -0
- /package/dist/{chunk-VLZEBK7S.js.map → chunk-E4434A4Y.js.map} +0 -0
- /package/dist/{chunk-W76ICQKY.js.map → chunk-IUG2FHNN.js.map} +0 -0
- /package/dist/{chunk-HKJ2B2AA.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/dist/{chunk-HBWJLKNM.js.map → chunk-QZNGKOCZ.js.map} +0 -0
- /package/dist/{chunk-AAIUUX4Y.js.map → chunk-X4WPMVCM.js.map} +0 -0
package/dist/chunk-S6KU22MU.js
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS
|
|
3
|
-
} from "./chunk-HKJ2B2AA.js";
|
|
4
|
-
|
|
5
|
-
// node_modules/ignore/index.js
|
|
6
|
-
var require_ignore = __commonJS({
|
|
7
|
-
"node_modules/ignore/index.js"(exports, module) {
|
|
8
|
-
"use strict";
|
|
9
|
-
function makeArray(subject) {
|
|
10
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
11
|
-
}
|
|
12
|
-
var EMPTY = "";
|
|
13
|
-
var SPACE = " ";
|
|
14
|
-
var ESCAPE = "\\";
|
|
15
|
-
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
16
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
17
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
18
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
19
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
20
|
-
var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
|
|
21
|
-
var SLASH = "/";
|
|
22
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
23
|
-
if (typeof Symbol !== "undefined") {
|
|
24
|
-
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
25
|
-
}
|
|
26
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
27
|
-
var define = (object, key, value) => Object.defineProperty(object, key, { value });
|
|
28
|
-
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
29
|
-
var RETURN_FALSE = () => false;
|
|
30
|
-
var sanitizeRange = (range) => range.replace(
|
|
31
|
-
REGEX_REGEXP_RANGE,
|
|
32
|
-
(match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
|
|
33
|
-
);
|
|
34
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
35
|
-
const { length } = slashes;
|
|
36
|
-
return slashes.slice(0, length - length % 2);
|
|
37
|
-
};
|
|
38
|
-
var REPLACERS = [
|
|
39
|
-
[
|
|
40
|
-
// remove BOM
|
|
41
|
-
// TODO:
|
|
42
|
-
// Other similar zero-width characters?
|
|
43
|
-
/^\uFEFF/,
|
|
44
|
-
() => EMPTY
|
|
45
|
-
],
|
|
46
|
-
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
47
|
-
[
|
|
48
|
-
// (a\ ) -> (a )
|
|
49
|
-
// (a ) -> (a)
|
|
50
|
-
// (a ) -> (a)
|
|
51
|
-
// (a \ ) -> (a )
|
|
52
|
-
/((?:\\\\)*?)(\\?\s+)$/,
|
|
53
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
54
|
-
],
|
|
55
|
-
// replace (\ ) with ' '
|
|
56
|
-
// (\ ) -> ' '
|
|
57
|
-
// (\\ ) -> '\\ '
|
|
58
|
-
// (\\\ ) -> '\\ '
|
|
59
|
-
[
|
|
60
|
-
/(\\+?)\s/g,
|
|
61
|
-
(_, m1) => {
|
|
62
|
-
const { length } = m1;
|
|
63
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
// Escape metacharacters
|
|
67
|
-
// which is written down by users but means special for regular expressions.
|
|
68
|
-
// > There are 12 characters with special meanings:
|
|
69
|
-
// > - the backslash \,
|
|
70
|
-
// > - the caret ^,
|
|
71
|
-
// > - the dollar sign $,
|
|
72
|
-
// > - the period or dot .,
|
|
73
|
-
// > - the vertical bar or pipe symbol |,
|
|
74
|
-
// > - the question mark ?,
|
|
75
|
-
// > - the asterisk or star *,
|
|
76
|
-
// > - the plus sign +,
|
|
77
|
-
// > - the opening parenthesis (,
|
|
78
|
-
// > - the closing parenthesis ),
|
|
79
|
-
// > - and the opening square bracket [,
|
|
80
|
-
// > - the opening curly brace {,
|
|
81
|
-
// > These special characters are often called "metacharacters".
|
|
82
|
-
[
|
|
83
|
-
/[\\$.|*+(){^]/g,
|
|
84
|
-
(match) => `\\${match}`
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
// > a question mark (?) matches a single character
|
|
88
|
-
/(?!\\)\?/g,
|
|
89
|
-
() => "[^/]"
|
|
90
|
-
],
|
|
91
|
-
// leading slash
|
|
92
|
-
[
|
|
93
|
-
// > A leading slash matches the beginning of the pathname.
|
|
94
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
95
|
-
// A leading slash matches the beginning of the pathname
|
|
96
|
-
/^\//,
|
|
97
|
-
() => "^"
|
|
98
|
-
],
|
|
99
|
-
// replace special metacharacter slash after the leading slash
|
|
100
|
-
[
|
|
101
|
-
/\//g,
|
|
102
|
-
() => "\\/"
|
|
103
|
-
],
|
|
104
|
-
[
|
|
105
|
-
// > A leading "**" followed by a slash means match in all directories.
|
|
106
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
107
|
-
// > the same as pattern "foo".
|
|
108
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
109
|
-
// > under directory "foo".
|
|
110
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
111
|
-
/^\^*\\\*\\\*\\\//,
|
|
112
|
-
// '**/foo' <-> 'foo'
|
|
113
|
-
() => "^(?:.*\\/)?"
|
|
114
|
-
],
|
|
115
|
-
// starting
|
|
116
|
-
[
|
|
117
|
-
// there will be no leading '/'
|
|
118
|
-
// (which has been replaced by section "leading slash")
|
|
119
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
120
|
-
/^(?=[^^])/,
|
|
121
|
-
function startingReplacer() {
|
|
122
|
-
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
// two globstars
|
|
126
|
-
[
|
|
127
|
-
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
128
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
129
|
-
// Zero, one or several directories
|
|
130
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
131
|
-
// Check if it is not the last `'/**'`
|
|
132
|
-
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
133
|
-
],
|
|
134
|
-
// normal intermediate wildcards
|
|
135
|
-
[
|
|
136
|
-
// Never replace escaped '*'
|
|
137
|
-
// ignore rule '\*' will match the path '*'
|
|
138
|
-
// 'abc.*/' -> go
|
|
139
|
-
// 'abc.*' -> skip this rule,
|
|
140
|
-
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
141
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
142
|
-
// '*.js' matches '.js'
|
|
143
|
-
// '*.js' doesn't match 'abc'
|
|
144
|
-
(_, p1, p2) => {
|
|
145
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
146
|
-
return p1 + unescaped;
|
|
147
|
-
}
|
|
148
|
-
],
|
|
149
|
-
[
|
|
150
|
-
// unescape, revert step 3 except for back slash
|
|
151
|
-
// For example, if a user escape a '\\*',
|
|
152
|
-
// after step 3, the result will be '\\\\\\*'
|
|
153
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
154
|
-
() => ESCAPE
|
|
155
|
-
],
|
|
156
|
-
[
|
|
157
|
-
// '\\\\' -> '\\'
|
|
158
|
-
/\\\\/g,
|
|
159
|
-
() => ESCAPE
|
|
160
|
-
],
|
|
161
|
-
[
|
|
162
|
-
// > The range notation, e.g. [a-zA-Z],
|
|
163
|
-
// > can be used to match one of the characters in a range.
|
|
164
|
-
// `\` is escaped by step 3
|
|
165
|
-
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
166
|
-
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
167
|
-
],
|
|
168
|
-
// ending
|
|
169
|
-
[
|
|
170
|
-
// 'js' will not match 'js.'
|
|
171
|
-
// 'ab' will not match 'abc'
|
|
172
|
-
/(?:[^*])$/,
|
|
173
|
-
// WTF!
|
|
174
|
-
// https://git-scm.com/docs/gitignore
|
|
175
|
-
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
176
|
-
// which re-fixes #24, #38
|
|
177
|
-
// > If there is a separator at the end of the pattern then the pattern
|
|
178
|
-
// > will only match directories, otherwise the pattern can match both
|
|
179
|
-
// > files and directories.
|
|
180
|
-
// 'js*' will not match 'a.js'
|
|
181
|
-
// 'js/' will not match 'a.js'
|
|
182
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
183
|
-
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
184
|
-
],
|
|
185
|
-
// trailing wildcard
|
|
186
|
-
[
|
|
187
|
-
/(\^|\\\/)?\\\*$/,
|
|
188
|
-
(_, p1) => {
|
|
189
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
190
|
-
return `${prefix}(?=$|\\/$)`;
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
];
|
|
194
|
-
var regexCache = /* @__PURE__ */ Object.create(null);
|
|
195
|
-
var makeRegex = (pattern, ignoreCase) => {
|
|
196
|
-
let source = regexCache[pattern];
|
|
197
|
-
if (!source) {
|
|
198
|
-
source = REPLACERS.reduce(
|
|
199
|
-
(prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
|
|
200
|
-
pattern
|
|
201
|
-
);
|
|
202
|
-
regexCache[pattern] = source;
|
|
203
|
-
}
|
|
204
|
-
return ignoreCase ? new RegExp(source, "i") : new RegExp(source);
|
|
205
|
-
};
|
|
206
|
-
var isString = (subject) => typeof subject === "string";
|
|
207
|
-
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
208
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF);
|
|
209
|
-
var IgnoreRule = class {
|
|
210
|
-
constructor(origin, pattern, negative, regex) {
|
|
211
|
-
this.origin = origin;
|
|
212
|
-
this.pattern = pattern;
|
|
213
|
-
this.negative = negative;
|
|
214
|
-
this.regex = regex;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
var createRule = (pattern, ignoreCase) => {
|
|
218
|
-
const origin = pattern;
|
|
219
|
-
let negative = false;
|
|
220
|
-
if (pattern.indexOf("!") === 0) {
|
|
221
|
-
negative = true;
|
|
222
|
-
pattern = pattern.substr(1);
|
|
223
|
-
}
|
|
224
|
-
pattern = pattern.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
225
|
-
const regex = makeRegex(pattern, ignoreCase);
|
|
226
|
-
return new IgnoreRule(
|
|
227
|
-
origin,
|
|
228
|
-
pattern,
|
|
229
|
-
negative,
|
|
230
|
-
regex
|
|
231
|
-
);
|
|
232
|
-
};
|
|
233
|
-
var throwError = (message, Ctor) => {
|
|
234
|
-
throw new Ctor(message);
|
|
235
|
-
};
|
|
236
|
-
var checkPath = (path, originalPath, doThrow) => {
|
|
237
|
-
if (!isString(path)) {
|
|
238
|
-
return doThrow(
|
|
239
|
-
`path must be a string, but got \`${originalPath}\``,
|
|
240
|
-
TypeError
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
if (!path) {
|
|
244
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
245
|
-
}
|
|
246
|
-
if (checkPath.isNotRelative(path)) {
|
|
247
|
-
const r = "`path.relative()`d";
|
|
248
|
-
return doThrow(
|
|
249
|
-
`path should be a ${r} string, but got "${originalPath}"`,
|
|
250
|
-
RangeError
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
return true;
|
|
254
|
-
};
|
|
255
|
-
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
256
|
-
checkPath.isNotRelative = isNotRelative;
|
|
257
|
-
checkPath.convert = (p) => p;
|
|
258
|
-
var Ignore = class {
|
|
259
|
-
constructor({
|
|
260
|
-
ignorecase = true,
|
|
261
|
-
ignoreCase = ignorecase,
|
|
262
|
-
allowRelativePaths = false
|
|
263
|
-
} = {}) {
|
|
264
|
-
define(this, KEY_IGNORE, true);
|
|
265
|
-
this._rules = [];
|
|
266
|
-
this._ignoreCase = ignoreCase;
|
|
267
|
-
this._allowRelativePaths = allowRelativePaths;
|
|
268
|
-
this._initCache();
|
|
269
|
-
}
|
|
270
|
-
_initCache() {
|
|
271
|
-
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
272
|
-
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
273
|
-
}
|
|
274
|
-
_addPattern(pattern) {
|
|
275
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
276
|
-
this._rules = this._rules.concat(pattern._rules);
|
|
277
|
-
this._added = true;
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (checkPattern(pattern)) {
|
|
281
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
282
|
-
this._added = true;
|
|
283
|
-
this._rules.push(rule);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
// @param {Array<string> | string | Ignore} pattern
|
|
287
|
-
add(pattern) {
|
|
288
|
-
this._added = false;
|
|
289
|
-
makeArray(
|
|
290
|
-
isString(pattern) ? splitPattern(pattern) : pattern
|
|
291
|
-
).forEach(this._addPattern, this);
|
|
292
|
-
if (this._added) {
|
|
293
|
-
this._initCache();
|
|
294
|
-
}
|
|
295
|
-
return this;
|
|
296
|
-
}
|
|
297
|
-
// legacy
|
|
298
|
-
addPattern(pattern) {
|
|
299
|
-
return this.add(pattern);
|
|
300
|
-
}
|
|
301
|
-
// | ignored : unignored
|
|
302
|
-
// negative | 0:0 | 0:1 | 1:0 | 1:1
|
|
303
|
-
// -------- | ------- | ------- | ------- | --------
|
|
304
|
-
// 0 | TEST | TEST | SKIP | X
|
|
305
|
-
// 1 | TESTIF | SKIP | TEST | X
|
|
306
|
-
// - SKIP: always skip
|
|
307
|
-
// - TEST: always test
|
|
308
|
-
// - TESTIF: only test if checkUnignored
|
|
309
|
-
// - X: that never happen
|
|
310
|
-
// @param {boolean} whether should check if the path is unignored,
|
|
311
|
-
// setting `checkUnignored` to `false` could reduce additional
|
|
312
|
-
// path matching.
|
|
313
|
-
// @returns {TestResult} true if a file is ignored
|
|
314
|
-
_testOne(path, checkUnignored) {
|
|
315
|
-
let ignored = false;
|
|
316
|
-
let unignored = false;
|
|
317
|
-
this._rules.forEach((rule) => {
|
|
318
|
-
const { negative } = rule;
|
|
319
|
-
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const matched = rule.regex.test(path);
|
|
323
|
-
if (matched) {
|
|
324
|
-
ignored = !negative;
|
|
325
|
-
unignored = negative;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
return {
|
|
329
|
-
ignored,
|
|
330
|
-
unignored
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
// @returns {TestResult}
|
|
334
|
-
_test(originalPath, cache, checkUnignored, slices) {
|
|
335
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
336
|
-
checkPath(
|
|
337
|
-
path,
|
|
338
|
-
originalPath,
|
|
339
|
-
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
340
|
-
);
|
|
341
|
-
return this._t(path, cache, checkUnignored, slices);
|
|
342
|
-
}
|
|
343
|
-
_t(path, cache, checkUnignored, slices) {
|
|
344
|
-
if (path in cache) {
|
|
345
|
-
return cache[path];
|
|
346
|
-
}
|
|
347
|
-
if (!slices) {
|
|
348
|
-
slices = path.split(SLASH);
|
|
349
|
-
}
|
|
350
|
-
slices.pop();
|
|
351
|
-
if (!slices.length) {
|
|
352
|
-
return cache[path] = this._testOne(path, checkUnignored);
|
|
353
|
-
}
|
|
354
|
-
const parent = this._t(
|
|
355
|
-
slices.join(SLASH) + SLASH,
|
|
356
|
-
cache,
|
|
357
|
-
checkUnignored,
|
|
358
|
-
slices
|
|
359
|
-
);
|
|
360
|
-
return cache[path] = parent.ignored ? parent : this._testOne(path, checkUnignored);
|
|
361
|
-
}
|
|
362
|
-
ignores(path) {
|
|
363
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
364
|
-
}
|
|
365
|
-
createFilter() {
|
|
366
|
-
return (path) => !this.ignores(path);
|
|
367
|
-
}
|
|
368
|
-
filter(paths) {
|
|
369
|
-
return makeArray(paths).filter(this.createFilter());
|
|
370
|
-
}
|
|
371
|
-
// @returns {TestResult}
|
|
372
|
-
test(path) {
|
|
373
|
-
return this._test(path, this._testCache, true);
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
var factory = (options) => new Ignore(options);
|
|
377
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
378
|
-
factory.isPathValid = isPathValid;
|
|
379
|
-
factory.default = factory;
|
|
380
|
-
module.exports = factory;
|
|
381
|
-
if (
|
|
382
|
-
// Detect `process` so that it can run in browsers.
|
|
383
|
-
typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32")
|
|
384
|
-
) {
|
|
385
|
-
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
386
|
-
checkPath.convert = makePosix;
|
|
387
|
-
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
388
|
-
checkPath.isNotRelative = (path) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
export {
|
|
394
|
-
require_ignore
|
|
395
|
-
};
|
|
396
|
-
//# sourceMappingURL=chunk-S6KU22MU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/ignore/index.js"],"sourcesContent":["// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\\\]|^)\\\\$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n// /foo,\n// ./foo,\n// ../foo,\n// .\n// ..\nconst REGEX_TEST_INVALID_PATH = /^\\.*\\/|^\\.+$/\n\nconst SLASH = '/'\n\n// Do not use ternary expression here, since \"istanbul ignore next\" is buggy\nlet TMP_KEY_IGNORE = 'node-ignore'\n/* istanbul ignore else */\nif (typeof Symbol !== 'undefined') {\n TMP_KEY_IGNORE = Symbol.for('node-ignore')\n}\nconst KEY_IGNORE = TMP_KEY_IGNORE\n\nconst define = (object, key, value) =>\n Object.defineProperty(object, key, {value})\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\nconst RETURN_FALSE = () => false\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n [\n // remove BOM\n // TODO:\n // Other similar zero-width characters?\n /^\\uFEFF/,\n () => EMPTY\n ],\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /((?:\\\\\\\\)*?)(\\\\?\\s+)$/,\n (_, m1, m2) => m1 + (\n m2.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n )\n ],\n\n // replace (\\ ) with ' '\n // (\\ ) -> ' '\n // (\\\\ ) -> '\\\\ '\n // (\\\\\\ ) -> '\\\\ '\n [\n /(\\\\+?)\\s/g,\n (_, m1) => {\n const {length} = m1\n return m1.slice(0, length - length % 2) + SPACE\n }\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // normal intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule,\n // coz trailing single wildcard will be handed by [trailing wildcard]\n /(^|[^\\\\]+)(\\\\\\*)+(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1, p2) => {\n // 1.\n // > An asterisk \"*\" matches anything except a slash.\n // 2.\n // > Other consecutive asterisks are considered regular asterisks\n // > and will match according to the previous rules.\n const unescaped = p2.replace(/\\\\\\*/g, '[^\\\\/]*')\n return p1 + unescaped\n }\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ],\n\n // trailing wildcard\n [\n /(\\^|\\\\\\/)?\\\\\\*$/,\n (_, p1) => {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n ],\n]\n\n// A simple cache, because an ignore rule only has only one certain meaning\nconst regexCache = Object.create(null)\n\n// @param {pattern}\nconst makeRegex = (pattern, ignoreCase) => {\n let source = regexCache[pattern]\n\n if (!source) {\n source = REPLACERS.reduce(\n (prev, [matcher, replacer]) =>\n prev.replace(matcher, replacer.bind(pattern)),\n pattern\n )\n regexCache[pattern] = source\n }\n\n return ignoreCase\n ? new RegExp(source, 'i')\n : new RegExp(source)\n}\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF)\n\nclass IgnoreRule {\n constructor (\n origin,\n pattern,\n negative,\n regex\n ) {\n this.origin = origin\n this.pattern = pattern\n this.negative = negative\n this.regex = regex\n }\n}\n\nconst createRule = (pattern, ignoreCase) => {\n const origin = pattern\n let negative = false\n\n // > An optional prefix \"!\" which negates the pattern;\n if (pattern.indexOf('!') === 0) {\n negative = true\n pattern = pattern.substr(1)\n }\n\n pattern = pattern\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regex = makeRegex(pattern, ignoreCase)\n\n return new IgnoreRule(\n origin,\n pattern,\n negative,\n regex\n )\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\ncheckPath.convert = p => p\n\nclass Ignore {\n constructor ({\n ignorecase = true,\n ignoreCase = ignorecase,\n allowRelativePaths = false\n } = {}) {\n define(this, KEY_IGNORE, true)\n\n this._rules = []\n this._ignoreCase = ignoreCase\n this._allowRelativePaths = allowRelativePaths\n this._initCache()\n }\n\n _initCache () {\n this._ignoreCache = Object.create(null)\n this._testCache = Object.create(null)\n }\n\n _addPattern (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules)\n this._added = true\n return\n }\n\n if (checkPattern(pattern)) {\n const rule = createRule(pattern, this._ignoreCase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._addPattern, this)\n\n // Some rules have just added to the ignore,\n // making the behavior changed.\n if (this._added) {\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // | ignored : unignored\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n\n // @param {boolean} whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n\n // @returns {TestResult} true if a file is ignored\n _testOne (path, checkUnignored) {\n let ignored = false\n let unignored = false\n\n this._rules.forEach(rule => {\n const {negative} = rule\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule.regex.test(path)\n\n if (matched) {\n ignored = !negative\n unignored = negative\n }\n })\n\n return {\n ignored,\n unignored\n }\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(\n path,\n originalPath,\n this._allowRelativePaths\n ? RETURN_FALSE\n : throwError\n )\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n _t (path, cache, checkUnignored, slices) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._testOne(path, checkUnignored)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._testOne(path, checkUnignored)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, RETURN_FALSE)\n\nfactory.isPathValid = isPathValid\n\n// Fixes typescript\nfactory.default = factory\n\nmodule.exports = factory\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore if */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && (\n process.env && process.env.IGNORE_TEST_WIN32\n || process.platform === 'win32'\n )\n) {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AACA,aAAS,UAAW,SAAS;AAC3B,aAAO,MAAM,QAAQ,OAAO,IACxB,UACA,CAAC,OAAO;AAAA,IACd;AAEA,QAAM,QAAQ;AACd,QAAM,QAAQ;AACd,QAAM,SAAS;AACf,QAAM,wBAAwB;AAC9B,QAAM,mCAAmC;AACzC,QAAM,4CAA4C;AAClD,QAAM,qCAAqC;AAC3C,QAAM,sBAAsB;AAM5B,QAAM,0BAA0B;AAEhC,QAAM,QAAQ;AAGd,QAAI,iBAAiB;AAErB,QAAI,OAAO,WAAW,aAAa;AACjC,uBAAiB,OAAO,IAAI,aAAa;AAAA,IAC3C;AACA,QAAM,aAAa;AAEnB,QAAM,SAAS,CAAC,QAAQ,KAAK,UAC3B,OAAO,eAAe,QAAQ,KAAK,EAAC,MAAK,CAAC;AAE5C,QAAM,qBAAqB;AAE3B,QAAM,eAAe,MAAM;AAI3B,QAAM,gBAAgB,WAAS,MAAM;AAAA,MACnC;AAAA,MACA,CAAC,OAAO,MAAM,OAAO,KAAK,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,IACtD,QAGA;AAAA,IACN;AAGA,QAAM,sBAAsB,aAAW;AACrC,YAAM,EAAC,OAAM,IAAI;AACjB,aAAO,QAAQ,MAAM,GAAG,SAAS,SAAS,CAAC;AAAA,IAC7C;AAaA,QAAM,YAAY;AAAA,MAEhB;AAAA;AAAA;AAAA;AAAA,QAIE;AAAA,QACA,MAAM;AAAA,MACR;AAAA;AAAA,MAGA;AAAA;AAAA;AAAA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AAc,UAClB,UAAU,QAAQ,UAAU,QAAQ,IAAI,GAAG,MAAM,YAAY;AAE/D,YAAQ,cAAc;AAGtB,YAAQ,UAAU;AAElB,WAAO,UAAU;AAKjB;AAAA;AAAA,MAEE,OAAO,YAAY,gBAEjB,QAAQ,OAAO,QAAQ,IAAI,qBACxB,QAAQ,aAAa;AAAA,MAE1B;AAEA,YAAM,YAAY,SAAO,YAAY,KAAK,GAAG,KAC1C,wBAAwB,KAAK,GAAG,IAC/B,MACA,IAAI,QAAQ,OAAO,GAAG;AAE1B,gBAAU,UAAU;AAIpB,YAAM,iCAAiC;AACvC,gBAAU,gBAAgB,UACxB,+BAA+B,KAAK,IAAI,KACrC,cAAc,IAAI;AAAA,IACzB;AAAA;AAAA;","names":[]}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { FunctionDeclaration } from '@google/generative-ai';
|
|
2
|
-
import { formatResult } from './tools/warp_grep/client.js';
|
|
3
|
-
import { getSystemPrompt } from './tools/warp_grep/agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from './types-CnvVDM63.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Google Gemini SDK adapter for morph-warp-grep tool
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Gemini-native warp grep function declaration
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
16
|
-
* import { warpGrepFunctionDeclaration, execute } from '@morphllm/morphsdk/tools/warp-grep/gemini';
|
|
17
|
-
*
|
|
18
|
-
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
19
|
-
* const model = genAI.getGenerativeModel({
|
|
20
|
-
* model: 'gemini-2.0-flash',
|
|
21
|
-
* tools: [{ functionDeclarations: [warpGrepFunctionDeclaration] }]
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* const chat = model.startChat();
|
|
25
|
-
* const result = await chat.sendMessage('Find authentication middleware');
|
|
26
|
-
*
|
|
27
|
-
* // Handle function call
|
|
28
|
-
* const call = result.response.functionCalls()?.[0];
|
|
29
|
-
* if (call) {
|
|
30
|
-
* const searchResult = await execute(call.args, { repoRoot: '.' });
|
|
31
|
-
* console.log(searchResult);
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
declare const warpGrepFunctionDeclaration: FunctionDeclaration;
|
|
36
|
-
/**
|
|
37
|
-
* Execute warp grep search
|
|
38
|
-
*
|
|
39
|
-
* @param input - Tool input with query
|
|
40
|
-
* @param config - Configuration with repoRoot and optional provider
|
|
41
|
-
* @returns Search results
|
|
42
|
-
*/
|
|
43
|
-
declare function execute(input: {
|
|
44
|
-
query: string;
|
|
45
|
-
} | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gemini tool with execute method attached
|
|
49
|
-
*/
|
|
50
|
-
interface GeminiWarpGrepTool extends FunctionDeclaration {
|
|
51
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
52
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
53
|
-
getSystemPrompt: () => string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a custom warp grep tool with configuration and methods
|
|
57
|
-
*
|
|
58
|
-
* @param config - Configuration options
|
|
59
|
-
* @returns Function declaration with execute and formatResult methods
|
|
60
|
-
*
|
|
61
|
-
* @example Local usage
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
64
|
-
* import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';
|
|
65
|
-
*
|
|
66
|
-
* const tool = createMorphWarpGrepTool({ repoRoot: '.' });
|
|
67
|
-
*
|
|
68
|
-
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
69
|
-
* const model = genAI.getGenerativeModel({
|
|
70
|
-
* model: 'gemini-2.0-flash',
|
|
71
|
-
* tools: [{ functionDeclarations: [tool] }]
|
|
72
|
-
* });
|
|
73
|
-
*
|
|
74
|
-
* const chat = model.startChat();
|
|
75
|
-
* const result = await chat.sendMessage('Find authentication middleware');
|
|
76
|
-
*
|
|
77
|
-
* // Handle function call
|
|
78
|
-
* const call = result.response.functionCalls()?.[0];
|
|
79
|
-
* if (call && call.name === tool.name) {
|
|
80
|
-
* const searchResult = await tool.execute(call.args);
|
|
81
|
-
* console.log(tool.formatResult(searchResult));
|
|
82
|
-
*
|
|
83
|
-
* // Send result back to model
|
|
84
|
-
* await chat.sendMessage([{
|
|
85
|
-
* functionResponse: {
|
|
86
|
-
* name: call.name,
|
|
87
|
-
* response: { result: tool.formatResult(searchResult) }
|
|
88
|
-
* }
|
|
89
|
-
* }]);
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @example Remote sandbox (E2B, Modal, etc.)
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const tool = createMorphWarpGrepTool({
|
|
96
|
-
* repoRoot: '/home/repo',
|
|
97
|
-
* remoteCommands: {
|
|
98
|
-
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
99
|
-
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
100
|
-
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
101
|
-
* },
|
|
102
|
-
* });
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
declare function createWarpGrepTool(config: WarpGrepToolConfig): GeminiWarpGrepTool;
|
|
106
|
-
declare const createMorphWarpGrepTool: typeof createWarpGrepTool;
|
|
107
|
-
|
|
108
|
-
type gemini_GeminiWarpGrepTool = GeminiWarpGrepTool;
|
|
109
|
-
declare const gemini_createMorphWarpGrepTool: typeof createMorphWarpGrepTool;
|
|
110
|
-
declare const gemini_createWarpGrepTool: typeof createWarpGrepTool;
|
|
111
|
-
declare const gemini_execute: typeof execute;
|
|
112
|
-
declare const gemini_formatResult: typeof formatResult;
|
|
113
|
-
declare const gemini_getSystemPrompt: typeof getSystemPrompt;
|
|
114
|
-
declare const gemini_warpGrepFunctionDeclaration: typeof warpGrepFunctionDeclaration;
|
|
115
|
-
declare namespace gemini {
|
|
116
|
-
export { type gemini_GeminiWarpGrepTool as GeminiWarpGrepTool, gemini_createMorphWarpGrepTool as createMorphWarpGrepTool, gemini_createWarpGrepTool as createWarpGrepTool, warpGrepFunctionDeclaration as default, gemini_execute as execute, gemini_formatResult as formatResult, gemini_getSystemPrompt as getSystemPrompt, gemini_warpGrepFunctionDeclaration as warpGrepFunctionDeclaration };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { type GeminiWarpGrepTool as G, createMorphWarpGrepTool as a, createWarpGrepTool as c, execute as e, gemini as g, warpGrepFunctionDeclaration as w };
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { ChatCompletionTool } from 'openai/resources/chat/completions';
|
|
2
|
-
import { formatResult } from './tools/warp_grep/client.js';
|
|
3
|
-
import { getSystemPrompt } from './tools/warp_grep/agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from './types-CnvVDM63.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* OpenAI SDK adapter for morph-warp-grep tool
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* OpenAI-native warp grep tool definition
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import OpenAI from 'openai';
|
|
16
|
-
* import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
17
|
-
*
|
|
18
|
-
* const client = new OpenAI();
|
|
19
|
-
* const response = await client.chat.completions.create({
|
|
20
|
-
* model: 'gpt-4o',
|
|
21
|
-
* tools: [warpGrepTool],
|
|
22
|
-
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // Execute the tool call
|
|
26
|
-
* const result = await execute({ query: '...' }, { repoRoot: '.' });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare const warpGrepTool: ChatCompletionTool;
|
|
30
|
-
/**
|
|
31
|
-
* Execute warp grep search
|
|
32
|
-
*
|
|
33
|
-
* @param input - Tool input with query
|
|
34
|
-
* @param config - Configuration with repoRoot and optional provider
|
|
35
|
-
* @returns Search results
|
|
36
|
-
*/
|
|
37
|
-
declare function execute(input: {
|
|
38
|
-
query: string;
|
|
39
|
-
} | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Create a custom warp grep tool with configuration and methods
|
|
43
|
-
*
|
|
44
|
-
* @param config - Configuration options
|
|
45
|
-
* @returns Tool definition with execute and formatResult methods
|
|
46
|
-
*
|
|
47
|
-
* @example Local usage
|
|
48
|
-
* ```typescript
|
|
49
|
-
* import OpenAI from 'openai';
|
|
50
|
-
* import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
51
|
-
*
|
|
52
|
-
* const tool = createWarpGrepTool({ repoRoot: '.' });
|
|
53
|
-
*
|
|
54
|
-
* const client = new OpenAI();
|
|
55
|
-
* const response = await client.chat.completions.create({
|
|
56
|
-
* model: 'gpt-4o',
|
|
57
|
-
* tools: [tool],
|
|
58
|
-
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @example Remote sandbox (E2B, Modal, etc.)
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const tool = createMorphWarpGrepTool({
|
|
65
|
-
* repoRoot: '/home/repo',
|
|
66
|
-
* remoteCommands: {
|
|
67
|
-
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
68
|
-
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
69
|
-
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
70
|
-
* },
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
declare function createWarpGrepTool(config: WarpGrepToolConfig): ChatCompletionTool & {
|
|
75
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
76
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
77
|
-
getSystemPrompt: () => string;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
declare const openai_createWarpGrepTool: typeof createWarpGrepTool;
|
|
81
|
-
declare const openai_execute: typeof execute;
|
|
82
|
-
declare const openai_formatResult: typeof formatResult;
|
|
83
|
-
declare const openai_getSystemPrompt: typeof getSystemPrompt;
|
|
84
|
-
declare const openai_warpGrepTool: typeof warpGrepTool;
|
|
85
|
-
declare namespace openai {
|
|
86
|
-
export { openai_createWarpGrepTool as createWarpGrepTool, warpGrepTool as default, openai_execute as execute, openai_formatResult as formatResult, openai_getSystemPrompt as getSystemPrompt, openai_warpGrepTool as warpGrepTool };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { createWarpGrepTool as c, execute as e, openai as o, warpGrepTool as w };
|