@pellux/goodvibes-sdk 0.18.24 → 0.18.25
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/_internal/platform/tools/edit/core.js +1 -1
- package/dist/_internal/platform/tools/edit/match.d.ts +2 -2
- package/dist/_internal/platform/tools/edit/match.d.ts.map +1 -1
- package/dist/_internal/platform/tools/edit/match.js +15 -4
- package/dist/_internal/platform/tools/find/structural.d.ts.map +1 -1
- package/dist/_internal/platform/tools/find/structural.js +15 -3
- package/package.json +1 -1
|
@@ -362,7 +362,7 @@ async function executeTextEdits(input, env) {
|
|
|
362
362
|
}
|
|
363
363
|
let editResult;
|
|
364
364
|
if (matchMode === 'ast_pattern') {
|
|
365
|
-
editResult = computeAstPatternEdit(currentContent, item, resolvedPath);
|
|
365
|
+
editResult = await computeAstPatternEdit(currentContent, item, resolvedPath);
|
|
366
366
|
}
|
|
367
367
|
else if (matchMode === 'ast') {
|
|
368
368
|
editResult = await computeAstEdit(currentContent, item, resolvedPath);
|
|
@@ -50,12 +50,12 @@ export declare function computeAstEdit(fileContent: string, item: EditItem, file
|
|
|
50
50
|
} | {
|
|
51
51
|
error: string;
|
|
52
52
|
}>;
|
|
53
|
-
export declare function computeAstPatternEdit(fileContent: string, item: EditItem, filePath: string): {
|
|
53
|
+
export declare function computeAstPatternEdit(fileContent: string, item: EditItem, filePath: string): Promise<{
|
|
54
54
|
newContent: string;
|
|
55
55
|
occurrencesReplaced: number;
|
|
56
56
|
} | {
|
|
57
57
|
error: string;
|
|
58
|
-
}
|
|
58
|
+
}>;
|
|
59
59
|
export declare function classifyEditFailure(message: string): EditResultStatus;
|
|
60
60
|
export declare function buildFailedEditResult(item: EditItem, error: string, status: EditResultStatus): EditResult;
|
|
61
61
|
export declare function computeSingleEdit(fileContent: string, item: EditItem, mode: 'exact' | 'fuzzy' | 'regex', caseSensitive: boolean, whitespaceSensitive?: boolean, multiline?: boolean): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/edit/match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/edit/match.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKzF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AASD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CA+CrF;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,EACjC,aAAa,EAAE,OAAO,EACtB,mBAAmB,GAAE,OAAc,EACnC,SAAS,GAAE,OAAe,GACzB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAoElC;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3C,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EACxB,QAAQ,CAAC,EAAE,MAAM,GAChB;IAAE,SAAS,EAAE;QAAE,KAAK,EAAE,MAA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,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA0ElF;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAKrE;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,GACvB,UAAU,CAQZ;AAED,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,EACjC,aAAa,EAAE,OAAO,EACtB,mBAAmB,GAAE,OAAc,EACnC,SAAS,GAAE,OAAe,GACzB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAsE1G"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { extname } from 'node:path';
|
|
2
|
-
import * as astGrep from '@ast-grep/napi';
|
|
3
2
|
import { logger } from '../../utils/logger.js';
|
|
4
3
|
import { CodeIntelligence } from '../../intelligence/index.js';
|
|
5
4
|
import { summarizeError } from '../../utils/error-display.js';
|
|
@@ -248,7 +247,12 @@ export function applyReplacements(content, selections, find, replace, mode, case
|
|
|
248
247
|
}
|
|
249
248
|
return result;
|
|
250
249
|
}
|
|
251
|
-
|
|
250
|
+
let astGrepModulePromise = null;
|
|
251
|
+
async function loadAstGrep() {
|
|
252
|
+
astGrepModulePromise ??= import('@ast-grep/napi');
|
|
253
|
+
return astGrepModulePromise;
|
|
254
|
+
}
|
|
255
|
+
function getAstGrepLang(astGrep, filePath) {
|
|
252
256
|
const lang = extname(filePath).slice(1).toLowerCase();
|
|
253
257
|
switch (lang) {
|
|
254
258
|
case 'ts': return astGrep.ts;
|
|
@@ -318,10 +322,17 @@ export function computeAstEdit(fileContent, item, filePath) {
|
|
|
318
322
|
return { newContent, occurrencesReplaced: selResult.selected.length };
|
|
319
323
|
}).catch(() => computeExactEdit(fileContent, item));
|
|
320
324
|
}
|
|
321
|
-
export function computeAstPatternEdit(fileContent, item, filePath) {
|
|
325
|
+
export async function computeAstPatternEdit(fileContent, item, filePath) {
|
|
322
326
|
const findStr = item.find_base64 ? decodeBase64(item.find_base64) : item.find;
|
|
323
327
|
const replaceStr = item.replace_base64 ? decodeBase64(item.replace_base64) : item.replace;
|
|
324
|
-
|
|
328
|
+
let astGrep;
|
|
329
|
+
try {
|
|
330
|
+
astGrep = await loadAstGrep();
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return computeExactEdit(fileContent, item);
|
|
334
|
+
}
|
|
335
|
+
const parser = getAstGrepLang(astGrep, filePath);
|
|
325
336
|
if (!parser) {
|
|
326
337
|
return computeExactEdit(fileContent, item);
|
|
327
338
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structural.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/find/structural.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"structural.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/find/structural.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA+BlE,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0ElC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { extname } from 'node:path';
|
|
2
|
-
import * as astGrep from '@ast-grep/napi';
|
|
3
2
|
import { collectFilesForSearch, makeCountResult, makeFilesResult, makeLocationsResult, readTextFile, validateSearchPath } from './shared.js';
|
|
4
|
-
|
|
3
|
+
let astGrepModulePromise = null;
|
|
4
|
+
async function loadAstGrep() {
|
|
5
|
+
astGrepModulePromise ??= import('@ast-grep/napi');
|
|
6
|
+
return astGrepModulePromise;
|
|
7
|
+
}
|
|
8
|
+
function getAstGrepLang(astGrep, filePath, override) {
|
|
5
9
|
const lang = override ?? extname(filePath).slice(1).toLowerCase();
|
|
6
10
|
switch (lang) {
|
|
7
11
|
case 'ts': return astGrep.ts;
|
|
@@ -23,6 +27,14 @@ export async function executeStructuralQuery(query, output, projectRoot) {
|
|
|
23
27
|
if (!query.pattern) {
|
|
24
28
|
return { error: 'structural mode requires pattern' };
|
|
25
29
|
}
|
|
30
|
+
let astGrep;
|
|
31
|
+
try {
|
|
32
|
+
astGrep = await loadAstGrep();
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
36
|
+
return { error: `structural mode requires @ast-grep/napi at runtime: ${message}` };
|
|
37
|
+
}
|
|
26
38
|
const format = output.format ?? 'matches';
|
|
27
39
|
const maxPerFile = output.max_per_item ?? 10;
|
|
28
40
|
const maxTotal = output.max_total_matches ?? output.max_results ?? 100;
|
|
@@ -33,7 +45,7 @@ export async function executeStructuralQuery(query, output, projectRoot) {
|
|
|
33
45
|
outer: for (const file of files) {
|
|
34
46
|
if (totalMatches >= maxTotal)
|
|
35
47
|
break;
|
|
36
|
-
const parser = getAstGrepLang(file, query.lang);
|
|
48
|
+
const parser = getAstGrepLang(astGrep, file, query.lang);
|
|
37
49
|
if (!parser)
|
|
38
50
|
continue;
|
|
39
51
|
const content = await readTextFile(file);
|
package/package.json
CHANGED