kiosapi 0.1.22 → 0.1.24

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.
Files changed (2) hide show
  1. package/dist/agent/run.js +27 -5
  2. package/package.json +1 -1
package/dist/agent/run.js CHANGED
@@ -550,10 +550,23 @@ export async function runTurn(s, userText) {
550
550
  if (count > 1 && READ_ONLY_TOOLS.has(call.function.name) && toolCache.has(sig)) {
551
551
  const toolName = call.function.name;
552
552
  const cachedOut = toolCache.get(sig) ?? '';
553
- const warn = count >= COUNT_LIMIT - 1
554
- ? `⚠ STOP: "${toolName}" sudah dipanggil ${count}× dengan argumen yang sama — hasilnya tidak berubah. WAJIB gunakan tool "selesai" atau eksplorasi path BERBEDA.`
555
- : `[Cache identik dengan panggilan sebelumnya]\n${cachedOut}\n\n⚠ Kamu sudah memanggil "${toolName}" dengan argumen yang sama ${count}×. Jangan ulangi masuk ke subfolder spesifik atau gunakan "selesai".`;
556
- console.log(dim(` ↩ ${toolName} (cache ke-${count})`));
553
+ // Always include the cached content so the model has the data it needs even after
554
+ // trimContext drops old messages from its window. The escalating warning text
555
+ // discourages repetition; withholding the content at count=3+ only causes the model
556
+ // to keep retrying — counter-productive to stopping the loop.
557
+ const stopNote = count >= COUNT_LIMIT - 1
558
+ ? `\n\n⚠ STOP (ke-${count}): JANGAN panggil "${toolName}" lagi dengan argumen yang sama. Gunakan tool "selesai" dan jelaskan kendalanya, atau gunakan cari/baca_file dengan path/range BERBEDA.`
559
+ : `\n\n⚠ Cache ke-${count}: "${toolName}" sudah dipanggil ${count}× dengan argumen sama. Gunakan cari atau baca_file(path, mulai=N) untuk bagian berbeda.`;
560
+ const warn = `[Cache ke-${count}]\n${cachedOut}${stopNote}`;
561
+ const cachePathHint = (() => {
562
+ try {
563
+ return ` ${JSON.parse(call.function.arguments).path ?? ''}`;
564
+ }
565
+ catch {
566
+ return '';
567
+ }
568
+ })();
569
+ console.log(dim(` ↩ ${toolName}${cachePathHint} (cache ke-${count})`));
557
570
  s.messages.push({ role: 'tool', content: warn, tool_call_id: call.id });
558
571
  continue;
559
572
  }
@@ -567,8 +580,17 @@ export async function runTurn(s, userText) {
567
580
  ? `${result.output.slice(0, MAX_STORED_RESULT)}\n…[dipotong — gunakan baca_file(path, baris_lanjutan) untuk membaca sisa file]`
568
581
  : result.output;
569
582
  s.messages.push({ role: 'tool', content: stored, tool_call_id: call.id });
570
- if (result.modifiedPath)
583
+ if (result.modifiedPath) {
571
584
  stepModified.add(result.modifiedPath);
585
+ // Invalidate cached reads for the modified file so the model can verify
586
+ // its own edits without getting stale content or spurious loop warnings.
587
+ for (const cacheSig of [...toolCache.keys()]) {
588
+ if (cacheSig.includes(result.modifiedPath)) {
589
+ toolCache.delete(cacheSig);
590
+ callCounts.delete(cacheSig);
591
+ }
592
+ }
593
+ }
572
594
  if (READ_ONLY_TOOLS.has(call.function.name))
573
595
  toolCache.set(sig, stored);
574
596
  if (result.done) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiosapi",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "description": "CLI Kiosapi.id berbahasa Indonesia — bangun aplikasimu pakai API key Kiosapi (agen + multimodal).",
6
6
  "keywords": [