@molecule/api-ai-tools 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +34 -3
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +2 -1
- package/package.json +1 -1
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAoB9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA+BnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAoB9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA+BnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CAmzCxF"}
|
package/dist/tools.js
CHANGED
|
@@ -379,6 +379,13 @@ export function buildTools(backend, config) {
|
|
|
379
379
|
// reads in one imported-app build were misses on files that never existed). Return
|
|
380
380
|
// ground truth in the SAME result — what the parent directory actually contains — so
|
|
381
381
|
// the next read uses a real name instead of another guess.
|
|
382
|
+
// A package's docs are one tool call away wherever node_modules happens to live.
|
|
383
|
+
const moleculePkg = /node_modules\/(@molecule\/[^/]+)\//.exec(path)?.[1];
|
|
384
|
+
if (moleculePkg && /No such file or directory/i.test(message)) {
|
|
385
|
+
return {
|
|
386
|
+
error: `No such file: ${path}. Read ${moleculePkg}'s documentation with read_molecule_doc("${moleculePkg}") instead of looking for it in node_modules.`,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
382
389
|
if (/No such file or directory/i.test(message)) {
|
|
383
390
|
const parent = path.replace(/\/[^/]*$/, '') || '/';
|
|
384
391
|
let listing;
|
|
@@ -413,7 +420,26 @@ export function buildTools(backend, config) {
|
|
|
413
420
|
return { path, entries: entries.map((e) => ({ name: e.name, type: e.type })) };
|
|
414
421
|
}
|
|
415
422
|
catch (e) {
|
|
416
|
-
|
|
423
|
+
const message = e.message;
|
|
424
|
+
// Same ground-truth answer as read_file's miss: a guessed path gets the parent's
|
|
425
|
+
// real contents back, so the next call names something that exists.
|
|
426
|
+
if (/No such file or directory|cannot access/i.test(message)) {
|
|
427
|
+
const parent = path.replace(/\/[^/]*$/, '') || '/';
|
|
428
|
+
try {
|
|
429
|
+
const siblings = await backend.readDir(parent);
|
|
430
|
+
return {
|
|
431
|
+
error: `No such directory: ${path}. ${parent} contains: ${siblings
|
|
432
|
+
.slice(0, 40)
|
|
433
|
+
.map((s) => s.name + (s.type === 'directory' ? '/' : ''))
|
|
434
|
+
.join(', ') || '(nothing)'}${siblings.length > 40 ? ', …' : ''}.`,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
catch (_parentErr) {
|
|
438
|
+
// The parent is missing too; the plain message below says so.
|
|
439
|
+
return { error: `No such directory: ${path} (and ${parent} does not exist either).` };
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return { error: `Failed to list ${path}: ${message}` };
|
|
417
443
|
}
|
|
418
444
|
},
|
|
419
445
|
async read_file(input) {
|
|
@@ -664,10 +690,15 @@ export function buildTools(backend, config) {
|
|
|
664
690
|
`indentation — or include more surrounding context to make it unique.`,
|
|
665
691
|
};
|
|
666
692
|
}
|
|
667
|
-
if (count > 1)
|
|
693
|
+
if (count > 1) {
|
|
694
|
+
// Say WHERE, so the retry can widen old_string around the one it means.
|
|
695
|
+
const lines = [];
|
|
696
|
+
for (let at = content.indexOf(oldString); at >= 0 && lines.length < 10; at = content.indexOf(oldString, at + 1))
|
|
697
|
+
lines.push(content.slice(0, at).split('\n').length);
|
|
668
698
|
return {
|
|
669
|
-
error: `old_string found ${count} times in ${path} — must be unique. Include more surrounding context.`,
|
|
699
|
+
error: `old_string found ${count} times in ${path} (starting at lines ${lines.join(', ')}${count > lines.length ? ', …' : ''}) — must be unique. Include more surrounding context from the one you mean, or make one edit per occurrence.`,
|
|
670
700
|
};
|
|
701
|
+
}
|
|
671
702
|
// Splice by index rather than `content.replace(oldString, newString)`:
|
|
672
703
|
// String.replace treats `$&`, `$$`, `` $` ``, `$'` in the REPLACEMENT as
|
|
673
704
|
// special patterns, so a new_string containing regex-replacement code
|
package/dist/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,MAEE,CAAA;AAyFhD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAUpF;AAED;;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;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAmBnE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAsCf;AAED,qEAAqE;AACrE,eAAO,MAAM,eAAe,QAA0C,CAAA;AAEtE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAU7D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,MAAM,GAAG,IAAI,CAKhB"}
|
package/dist/utilities.js
CHANGED
|
@@ -223,7 +223,8 @@ export function checkBlockedCommand(command) {
|
|
|
223
223
|
const envDumpSteer = ' You do NOT need to dump it: the managed service values (DATABASE_URL, etc.) are already ' +
|
|
224
224
|
'in the process environment — read them IN CODE via process.env / your config loader, or ' +
|
|
225
225
|
"check the project's provisioned env file to see WHICH services exist. Printing them only " +
|
|
226
|
-
'leaks secrets into the transcript.'
|
|
226
|
+
'leaks secrets into the transcript. To check whether ONE variable is set without printing ' +
|
|
227
|
+
'it: `test -n "$NAME" && echo set || echo missing`.';
|
|
227
228
|
if (BLOCKED_COMMANDS.test(command))
|
|
228
229
|
return `Command blocked: dumping environment variables is not allowed.${envDumpSteer}`;
|
|
229
230
|
if (BLOCKED_PROC_REDIRECT.test(command))
|