@taj-special/dravix-code 1.3.3 → 1.3.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/dist/cli/repl.js +31 -22
- package/package.json +1 -1
package/dist/cli/repl.js
CHANGED
|
@@ -2351,20 +2351,8 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
2351
2351
|
if (readFileContinue) {
|
|
2352
2352
|
readFileContinue = false;
|
|
2353
2353
|
readFileTurnCount++;
|
|
2354
|
-
//
|
|
2355
|
-
|
|
2356
|
-
const rawUserMsg = lastUserLine.trim();
|
|
2357
|
-
const msgLines = rawUserMsg.split('\n').map(l => l.trim()).filter(Boolean);
|
|
2358
|
-
let userReminder = '';
|
|
2359
|
-
if (msgLines.length > 0) {
|
|
2360
|
-
const first = msgLines[0].slice(0, 100);
|
|
2361
|
-
const last = msgLines[msgLines.length - 1].slice(0, 150);
|
|
2362
|
-
const display = msgLines.length <= 2 ? msgLines.join(' / ').slice(0, 200) : `${first} [...] ${last}`;
|
|
2363
|
-
userReminder = `The user's request: "${display}". `;
|
|
2364
|
-
}
|
|
2365
|
-
const taskInstruction = userReminder
|
|
2366
|
-
? `The user's exact request was: "${rawUserMsg.slice(0, 300)}"\nNow execute THIS request and ONLY this request — nothing else. Do not invent, add, or change anything the user did not ask for. Use <edit_file> with targeted <find>/<replace> — never use <write_file> on existing files. Use the file content above to find the exact text and apply the change.`
|
|
2367
|
-
: `Execute the user's request using the file content above. Use <edit_file> for existing files, <write_file> only for new files.`;
|
|
2354
|
+
// Keep auto-continue prompt SHORT — large prompts time out DeepSeek reasoning model
|
|
2355
|
+
const taskInstruction = `Continue. All necessary file contents are above in context. Complete the task now — do NOT read more files. Output operations with <edit_file> or <run_command> tags.`;
|
|
2368
2356
|
// Keep using FLASH_MODEL after file reads
|
|
2369
2357
|
if (readFileTurnCount > 5 && !forcedEditMode) {
|
|
2370
2358
|
forcedEditMode = true;
|
|
@@ -2479,11 +2467,13 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
2479
2467
|
history.splice(1, history.length - 22);
|
|
2480
2468
|
}
|
|
2481
2469
|
// ── Auto-inject mentioned file contents ──────────────────────
|
|
2482
|
-
//
|
|
2470
|
+
// Reduced from 3000 → keeps prompt small enough for DeepSeek reasoning model
|
|
2483
2471
|
const FILE_PATTERN = /[\w\-.\/\\]+\.\w{2,5}/g;
|
|
2484
2472
|
const mentioned = [...new Set(line.match(FILE_PATTERN) ?? [])];
|
|
2485
2473
|
let fileContext = '';
|
|
2486
|
-
const FULL_INJECT_LINES =
|
|
2474
|
+
const FULL_INJECT_LINES = 400;
|
|
2475
|
+
const MAX_INJECT_CHARS = 25000;
|
|
2476
|
+
let injectedChars = 0;
|
|
2487
2477
|
for (const fname of mentioned) {
|
|
2488
2478
|
const fullPath = path.resolve(activeCwd, fname);
|
|
2489
2479
|
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
|
|
@@ -2491,8 +2481,15 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
2491
2481
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
2492
2482
|
const fileLines = content.split('\n');
|
|
2493
2483
|
const lineCount = fileLines.length;
|
|
2494
|
-
if (lineCount <= FULL_INJECT_LINES) {
|
|
2495
|
-
|
|
2484
|
+
if (lineCount <= FULL_INJECT_LINES && injectedChars < MAX_INJECT_CHARS) {
|
|
2485
|
+
const toAdd = `\n\n[File: ${fname} — ${lineCount} lines — FULL]\n` + content;
|
|
2486
|
+
if (injectedChars + toAdd.length > MAX_INJECT_CHARS) {
|
|
2487
|
+
fileContext += `\n\n[File: ${fname} — ${lineCount} lines — skipped (prompt limit)]`;
|
|
2488
|
+
}
|
|
2489
|
+
else {
|
|
2490
|
+
fileContext += toAdd;
|
|
2491
|
+
injectedChars += toAdd.length;
|
|
2492
|
+
}
|
|
2496
2493
|
}
|
|
2497
2494
|
else {
|
|
2498
2495
|
fileContext += `\n\n[File: ${fname} — ${lineCount} lines]\n` +
|
|
@@ -3003,6 +3000,8 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
3003
3000
|
// Trailing newline — skip when read ops follow (they start on current line)
|
|
3004
3001
|
if (hasRenderedContent && readOps.length === 0)
|
|
3005
3002
|
process.stdout.write('\n');
|
|
3003
|
+
// Synchronisation flag: ops/else must wait for readOps to finish
|
|
3004
|
+
let readOpsDone = readOps.length === 0;
|
|
3006
3005
|
// ── Handle read_file ops ──────────────────────────────
|
|
3007
3006
|
// forcedEditMode: block further reads — AI must use existing context
|
|
3008
3007
|
if (readOps.length > 0 && forcedEditMode) {
|
|
@@ -3013,6 +3012,7 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
3013
3012
|
readFileContinue = true;
|
|
3014
3013
|
}
|
|
3015
3014
|
else if (readOps.length > 0) {
|
|
3015
|
+
readOpsDone = false;
|
|
3016
3016
|
// Absorb blank lines so reading block starts immediately after user message
|
|
3017
3017
|
if (hasRenderedContent) {
|
|
3018
3018
|
// Ensure cursor is on a new line, then absorb excess trailing blank lines
|
|
@@ -3190,18 +3190,22 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
3190
3190
|
}
|
|
3191
3191
|
process.stdout.write(` ` + BC('╰' + '─'.repeat(boxW - 2) + '╯') + `\n`);
|
|
3192
3192
|
readFileContinue = true;
|
|
3193
|
-
|
|
3193
|
+
readOpsDone = true;
|
|
3194
3194
|
}
|
|
3195
3195
|
catch (e) {
|
|
3196
3196
|
logError('readOps', e);
|
|
3197
|
-
|
|
3197
|
+
readFileContinue = true;
|
|
3198
|
+
readOpsDone = true;
|
|
3198
3199
|
}
|
|
3199
3200
|
})();
|
|
3200
|
-
return;
|
|
3201
3201
|
} // end else if (readOps.length > 0)
|
|
3202
|
+
// Process write/run/mkdir/delete ops — waits for readOps to finish first
|
|
3202
3203
|
if (ops.length > 0) {
|
|
3203
3204
|
(async () => {
|
|
3204
3205
|
try {
|
|
3206
|
+
// Wait for any pending read operations to finish
|
|
3207
|
+
while (!readOpsDone)
|
|
3208
|
+
await new Promise(r => setTimeout(r, 20));
|
|
3205
3209
|
const skippedPaths = new Set();
|
|
3206
3210
|
const runOutputs = [];
|
|
3207
3211
|
const fileOpErrors = [];
|
|
@@ -3340,7 +3344,12 @@ The summary should feel like a natural conversation close — informative, brief
|
|
|
3340
3344
|
})();
|
|
3341
3345
|
}
|
|
3342
3346
|
else {
|
|
3343
|
-
resolve
|
|
3347
|
+
// No ops — just wait for readOps to finish, then resolve
|
|
3348
|
+
(async () => {
|
|
3349
|
+
while (!readOpsDone)
|
|
3350
|
+
await new Promise(r => setTimeout(r, 20));
|
|
3351
|
+
resolve();
|
|
3352
|
+
})();
|
|
3344
3353
|
}
|
|
3345
3354
|
}, (err) => {
|
|
3346
3355
|
clearInterval(spinnerInterval);
|