shark-ai 0.4.15 → 0.4.16

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
@@ -1790,22 +1790,22 @@ async function interactiveSpecificationAgent(options = {}) {
1790
1790
  let initialContent = `# Technical Specification: {{PROJECT_NAME}}
1791
1791
 
1792
1792
  ## 1. Technology Stack
1793
- [TO BE ANALYZED]
1793
+ [TO BE ANALYZED - STACK]
1794
1794
  - Language: [e.g. TypeScript]
1795
1795
  - Framework: [e.g. Node.js / React]
1796
1796
  - Database: [e.g. SQLite / PostgreSQL]
1797
1797
  - Key Libraries: [Top 5 dependencies]
1798
1798
 
1799
1799
  ## 2. Architecture Overview
1800
- [TO BE ANALYZED]
1800
+ [TO BE ANALYZED - ARCHITECTURE]
1801
1801
  [Brief description of architectural pattern]
1802
1802
 
1803
1803
  ## 3. Data Model
1804
- [TO BE ANALYZED]
1804
+ [TO BE ANALYZED - DATA MODEL]
1805
1805
  [Schema/ERD definitions]
1806
1806
 
1807
1807
  ## 4. API / Interface Contracts
1808
- [TO BE ANALYZED]
1808
+ [TO BE ANALYZED - API]
1809
1809
  [Main endpoints or CLI commands]
1810
1810
 
1811
1811
  ## 5. Implementation Steps
@@ -1911,58 +1911,6 @@ async function runSpecLoop(initialMessage, targetPath, overrideAgentId) {
1911
1911
  let executionResults = "";
1912
1912
  let waitingForUser = false;
1913
1913
  let specUpdated = false;
1914
- if (lastResponse.message && lastResponse.message.includes("PHASE_COMPLETED")) {
1915
- if (currentPhase === 1) {
1916
- currentPhase = 2;
1917
- tui.log.success(`\u2705 Fase 1 Conclu\xEDda. Iniciando Fase 2 (Investiga\xE7\xE3o).`);
1918
- nextPrompt = `[System Message]
1919
- Voc\xEA completou a FASE 1 com sucesso.
1920
-
1921
- **VOC\xCA AGORA EST\xC1 NA FASE 2: INVESTIGA\xC7\xC3O**
1922
- - Use \`search_code\` e \`list_files\` para explorar os arquivos relevantes \xE0 tarefa.
1923
- - Prefira \`search_code\` em vez de \`read_file\` para buscar c\xF3digo sem inflar o contexto.
1924
- - N\xC3O leia o projeto inteiro de forma gen\xE9rica.
1925
- - REGRA DE OURO (READ-FIRST): Voc\xEA N\xC3O PODE referenciar um arquivo na especifica\xE7\xE3o t\xE9cnica que n\xE3o tenha investigado nesta fase.
1926
- - Quando achar que possui toda a clareza t\xE9cnica sobre onde e o que deve ser feito no c\xF3digo, emita "PHASE_COMPLETED" no summary.`;
1927
- continue;
1928
- } else if (currentPhase === 2) {
1929
- currentPhase = 3;
1930
- tui.log.success(`\u2705 Fase 2 Conclu\xEDda. Iniciando Fase 3 (Preenchimento).`);
1931
- nextPrompt = `[System Message]
1932
- Voc\xEA completou a FASE 2 com sucesso.
1933
-
1934
- **VOC\xCA AGORA EST\xC1 NA FASE 3: PREENCHIMENTO DO TEMPLATE**
1935
- - Use \`modify_file\` no arquivo \`${targetPath}\` para substituir os placeholders pelo conte\xFAdo real levantado na fase de investiga\xE7\xE3o.
1936
- - As se\xE7\xF5es 1-4 devem descrever o contexto da TAREFA, e n\xE3o o projeto como um todo.
1937
- - Passos de Implementa\xE7\xE3o (Implementation Steps): APENAS checkboxes markdown: \`- [ ] [Verbo de A\xE7\xE3o] [O Que] em [Caminho Relativo]\`.
1938
- - Quando TODOS os placeholders ([TO BE ANALYZED] ou [TO BE FILLED]) forem substitu\xEDdos e o trabalho conclu\xEDdo, emita "SPEC_UPDATED: Complete" no summary para finalizar.`;
1939
- continue;
1940
- }
1941
- }
1942
- if (lastResponse.message && lastResponse.message.includes("SPEC_UPDATED:")) {
1943
- if (currentPhase < 3) {
1944
- tui.log.warning(`O agente tentou finalizar prematuramente. For\xE7ando retorno para a fase atual...`);
1945
- nextPrompt = `[System Error]: Voc\xEA tentou finalizar a especifica\xE7\xE3o prematuramente emitindo SPEC_UPDATED, mas ainda est\xE1 na Fase ${currentPhase}. Voc\xEA s\xF3 pode finalizar quando estiver na Fase 3.
1946
-
1947
- Continue seu trabalho na Fase ${currentPhase} ou emita "PHASE_COMPLETED" se terminou esta etapa atual.`;
1948
- continue;
1949
- }
1950
- const content = fs5.existsSync(targetPath) ? fs5.readFileSync(targetPath, "utf-8") : "";
1951
- if (content.includes("[TO BE")) {
1952
- const pendingMatches = [...content.matchAll(/## ([^\n]+)[\s\S]*?\[TO BE/g)].map((m) => m[1]);
1953
- let missing = pendingMatches.length > 0 ? pendingMatches.join(", ") : "algumas se\xE7\xF5es";
1954
- tui.log.warning(`O agente tentou concluir prematuramente, mas h\xE1 placeholders pendentes. For\xE7ando retorno...`);
1955
- nextPrompt = `[System Error]: A valida\xE7\xE3o falhou e o bloqueio autom\xE1tico foi acionado.
1956
- Voc\xEA tentou concluir a tarefa, mas o arquivo AINDA possui placeholders '[TO BE ANALYZED]' ou '[TO BE FILLED]'.
1957
- As seguintes se\xE7\xF5es ainda cont\xEAm estes placeholders: ${missing}.
1958
- Voc\xEA \xE9 OBRIGADO a usar a action \`modify_file\` para preencher o conte\xFAdo de cada uma dessas se\xE7\xF5es. Use o placeholder exato no campo \`target_content\`. N\xC3O repita a conclus\xE3o da tarefa at\xE9 corrigir todas as pend\xEAncias.`;
1959
- continue;
1960
- } else {
1961
- const updateSummary = lastResponse.message.split("SPEC_UPDATED:")[1].trim();
1962
- tui.log.success(`\u2705 Spec Finalized: ${updateSummary}`);
1963
- return;
1964
- }
1965
- }
1966
1914
  for (const action of lastResponse.actions) {
1967
1915
  if (action.type === "talk_with_user") {
1968
1916
  tui.log.info(colors.primary("\u{1F916} Architect:"));
@@ -2032,7 +1980,7 @@ ${result}
2032
1980
  `;
2033
1981
  specUpdated = true;
2034
1982
  } else {
2035
- executionResults += `[Action modify_file]: Failed. Target content not found.
1983
+ executionResults += `[Action modify_file]: Failed. Target content not found or ambiguous.
2036
1984
  `;
2037
1985
  }
2038
1986
  } else {
@@ -2046,6 +1994,62 @@ ${result}
2046
1994
  }
2047
1995
  }
2048
1996
  }
1997
+ if (lastResponse.message && lastResponse.message.includes("PHASE_COMPLETED")) {
1998
+ const extraContext = executionResults ? `
1999
+
2000
+ Resultados das \xFAltimas a\xE7\xF5es executadas antes da conclus\xE3o:
2001
+ ${executionResults}` : "";
2002
+ if (currentPhase === 1) {
2003
+ currentPhase = 2;
2004
+ tui.log.success(`\u2705 Fase 1 Conclu\xEDda. Iniciando Fase 2 (Investiga\xE7\xE3o).`);
2005
+ nextPrompt = `[System Message]
2006
+ Voc\xEA completou a FASE 1 com sucesso.
2007
+
2008
+ **VOC\xCA AGORA EST\xC1 NA FASE 2: INVESTIGA\xC7\xC3O**
2009
+ - Use \`search_code\` e \`list_files\` para explorar os arquivos relevantes \xE0 tarefa.
2010
+ - Prefira \`search_code\` em vez de \`read_file\` para buscar c\xF3digo sem inflar o contexto.
2011
+ - N\xC3O leia o projeto inteiro de forma gen\xE9rica.
2012
+ - REGRA DE OURO (READ-FIRST): Voc\xEA N\xC3O PODE referenciar um arquivo na especifica\xE7\xE3o t\xE9cnica que n\xE3o tenha investigado nesta fase.
2013
+ - Quando achar que possui toda a clareza t\xE9cnica sobre onde e o que deve ser feito no c\xF3digo, emita "PHASE_COMPLETED" no summary.${extraContext}`;
2014
+ continue;
2015
+ } else if (currentPhase === 2) {
2016
+ currentPhase = 3;
2017
+ tui.log.success(`\u2705 Fase 2 Conclu\xEDda. Iniciando Fase 3 (Preenchimento).`);
2018
+ nextPrompt = `[System Message]
2019
+ Voc\xEA completou a FASE 2 com sucesso.
2020
+
2021
+ **VOC\xCA AGORA EST\xC1 NA FASE 3: PREENCHIMENTO DO TEMPLATE**
2022
+ - Use \`modify_file\` no arquivo \`${targetPath}\` para substituir os placeholders pelo conte\xFAdo real levantado na fase de investiga\xE7\xE3o.
2023
+ - As se\xE7\xF5es 1-4 devem descrever o contexto da TAREFA, e n\xE3o o projeto como um todo.
2024
+ - Passos de Implementa\xE7\xE3o (Implementation Steps): APENAS checkboxes markdown: \`- [ ] [Verbo de A\xE7\xE3o] [O Que] em [Caminho Relativo]\`.
2025
+ - Quando TODOS os placeholders ([TO BE ANALYZED...] ou [TO BE FILLED]) forem substitu\xEDdos e o trabalho conclu\xEDdo, emita "SPEC_UPDATED: Complete" no summary para finalizar.${extraContext}`;
2026
+ continue;
2027
+ }
2028
+ }
2029
+ if (lastResponse.message && lastResponse.message.includes("SPEC_UPDATED:")) {
2030
+ if (currentPhase < 3) {
2031
+ tui.log.warning(`O agente tentou finalizar prematuramente. For\xE7ando retorno para a fase atual...`);
2032
+ nextPrompt = `[System Error]: Voc\xEA tentou finalizar a especifica\xE7\xE3o prematuramente emitindo SPEC_UPDATED, mas ainda est\xE1 na Fase ${currentPhase}. Voc\xEA s\xF3 pode finalizar quando estiver na Fase 3.
2033
+
2034
+ Continue seu trabalho na Fase ${currentPhase} ou emita "PHASE_COMPLETED" se terminou esta etapa atual.`;
2035
+ continue;
2036
+ }
2037
+ const content = fs5.existsSync(targetPath) ? fs5.readFileSync(targetPath, "utf-8") : "";
2038
+ if (content.includes("[TO BE")) {
2039
+ const pendingMatches = [...content.matchAll(/## ([^\n]+)[\s\S]*?\[TO BE/g)].map((m) => m[1]);
2040
+ let missing = pendingMatches.length > 0 ? pendingMatches.join(", ") : "algumas se\xE7\xF5es";
2041
+ tui.log.warning(`O agente tentou concluir prematuramente, mas h\xE1 placeholders pendentes. For\xE7ando retorno...`);
2042
+ nextPrompt = `[System Error]: A valida\xE7\xE3o falhou e o bloqueio autom\xE1tico foi acionado.
2043
+ Voc\xEA tentou concluir a tarefa, mas o arquivo AINDA possui placeholders '[TO BE ANALYZED...]' ou '[TO BE FILLED]'.
2044
+ As seguintes se\xE7\xF5es ainda cont\xEAm estes placeholders: ${missing}.
2045
+ Voc\xEA \xE9 OBRIGADO a usar a action \`modify_file\` para preencher o conte\xFAdo de cada uma dessas se\xE7\xF5es. Use o placeholder exato no campo \`target_content\`. N\xC3O repita a conclus\xE3o da tarefa at\xE9 corrigir todas as pend\xEAncias.`;
2046
+ continue;
2047
+ } else {
2048
+ const updateSummary = lastResponse.message.split("SPEC_UPDATED:")[1].trim();
2049
+ tui.log.success(`\u2705 Spec Finalized: ${updateSummary}`);
2050
+ return;
2051
+ }
2052
+ }
2049
2053
  if (waitingForUser) {
2050
2054
  const userReply = await tui.text({ message: "Your answer", placeholder: "Type your answer..." });
2051
2055
  if (tui.isCancel(userReply)) {
@@ -2068,6 +2072,8 @@ Por favor, envie uma nova action \`modify_file\` focada em uma destas se\xE7\xF5
2068
2072
  } else {
2069
2073
  systemMsg += "\n[System]: O arquivo parece completo! Se estiver satisfeito e possuir TODAS as implementa\xE7\xF5es descritas, retorne 'SPEC_UPDATED: Complete'.";
2070
2074
  }
2075
+ } else {
2076
+ systemMsg += "\n[System]: A modifica\xE7\xE3o do arquivo falhou. Verifique se o `target_content` que voc\xEA usou existe EXATAMENTE como no arquivo e se ele \xE9 \xDANICO na hora de usar a action `modify_file`.";
2071
2077
  }
2072
2078
  nextPrompt = `${executionResults}
2073
2079