draply-dev 1.4.4 → 1.4.5
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/bin/cli.js +4 -4
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -328,18 +328,18 @@ Return ONLY the patch blocks.`;
|
|
|
328
328
|
console.log("Full AI response context for debugging:");
|
|
329
329
|
console.log(apiResult);
|
|
330
330
|
|
|
331
|
-
// Forced fallback for creation if AI
|
|
332
|
-
|
|
331
|
+
// Forced fallback for creation if AI failed match but we have a creation request
|
|
332
|
+
const creationItem = items.find(it => it.type === 'create');
|
|
333
|
+
if (creationItem) {
|
|
333
334
|
console.log("Attempting forced creation fallback...");
|
|
334
335
|
const index = content.toLowerCase().lastIndexOf('</body>');
|
|
335
336
|
if (index >= 0) {
|
|
336
|
-
const creationItem = items.find(it => it.type === 'create');
|
|
337
337
|
const patched = content.slice(0, index) + creationItem.outerHTML + '\n' + content.slice(index);
|
|
338
338
|
const final = rawContent.includes('\r\n') ? patched.replace(/\n/g, '\r\n') : patched;
|
|
339
339
|
fs.writeFileSync(filePath, final, 'utf8');
|
|
340
340
|
console.log(` \x1b[32m✓\x1b[0m Forced creation applied to ${path.basename(filePath)}`);
|
|
341
341
|
items.forEach(item => results.push({ selector: item.selector, ok: true }));
|
|
342
|
-
|
|
342
|
+
continue;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
items.forEach(item => results.push({ selector: item.selector, ok: false, reason: 'AI patch failed to match' }));
|