shark-ai 0.4.10 → 0.4.11

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/bin/shark.js CHANGED
@@ -1861,9 +1861,21 @@ async function runSpecLoop(initialMessage, targetPath, overrideAgentId) {
1861
1861
  let waitingForUser = false;
1862
1862
  let specUpdated = false;
1863
1863
  if (lastResponse.message && lastResponse.message.includes("SPEC_UPDATED:")) {
1864
- const updateSummary = lastResponse.message.split("SPEC_UPDATED:")[1].trim();
1865
- tui.log.success(`\u2705 Spec Finalized: ${updateSummary}`);
1866
- return;
1864
+ const content = fs5.existsSync(targetPath) ? fs5.readFileSync(targetPath, "utf-8") : "";
1865
+ if (content.includes("[TO BE")) {
1866
+ const pendingMatches = [...content.matchAll(/## ([^\n]+)[\s\S]*?\[TO BE/g)].map((m) => m[1]);
1867
+ let missing = pendingMatches.length > 0 ? pendingMatches.join(", ") : "algumas se\xE7\xF5es";
1868
+ tui.log.warning(`O agente tentou concluir prematuramente, mas h\xE1 placeholders pendentes. For\xE7ando retorno...`);
1869
+ nextPrompt = `[System Error]: Voc\xEA tentou enviar 'SPEC_UPDATED: Complete', mas o arquivo AINDA possui placeholders '[TO BE...]'.
1870
+ As seguintes se\xE7\xF5es parecem incompletas: ${missing}.
1871
+
1872
+ Por favor, retome a FASE 3 e continue editando o arquivo at\xE9 que NENHUM placeholder reste. Lembre-se, use \`modify_file\` para cada uma dessas se\xE7\xF5es e foque na tarefa discutida.`;
1873
+ continue;
1874
+ } else {
1875
+ const updateSummary = lastResponse.message.split("SPEC_UPDATED:")[1].trim();
1876
+ tui.log.success(`\u2705 Spec Finalized: ${updateSummary}`);
1877
+ return;
1878
+ }
1867
1879
  }
1868
1880
  for (const action of lastResponse.actions) {
1869
1881
  if (action.type === "talk_with_user") {
@@ -1952,9 +1964,12 @@ User Reply: ${userReply}`;
1952
1964
  let systemMsg = "Execu\xE7\xE3o da ferramenta conclu\xEDda.";
1953
1965
  if (specUpdated) {
1954
1966
  if (content.includes("[TO BE")) {
1955
- systemMsg += "\n[System]: Se\xE7\xE3o atualizada. Por favor, continue harmonizando e preenchendo os placeholders '[TO BE ...]' restantes.";
1967
+ const pendingMatches = [...content.matchAll(/## ([^\n]+)[\s\S]*?\[TO BE/g)].map((m) => m[1]);
1968
+ let missing = pendingMatches.length > 0 ? pendingMatches.join(", ") : "v\xE1rias se\xE7\xF5es";
1969
+ systemMsg += `
1970
+ [System]: Se\xE7\xE3o atualizada. Por favor, continue preenchendo os placeholders '[TO BE ...]' restantes nas seguintes se\xE7\xF5es: ${missing}.`;
1956
1971
  } else {
1957
- systemMsg += "\n[System]: O arquivo parece completo! Se estiver satisfeito, retorne 'SPEC_UPDATED: Complete'.";
1972
+ systemMsg += "\n[System]: O arquivo parece completo! Se estiver satisfeito e possuir TODAS as implementa\xE7\xF5es descritas, retorne 'SPEC_UPDATED: Complete'.";
1958
1973
  }
1959
1974
  }
1960
1975
  nextPrompt = `${executionResults}