Languagetool Integration#9
Open
BingqingLyu wants to merge 3 commits into
Open
Conversation
… Core Integations, Preprocessing Helpers & Correction Strategies for Qwen-Code
…t, allowing for automatic grammar checking of user inputs. It includes configuration details and usage instructions.
…ng total requests, tokens used, and cache efficiency, with formatted numbers and color-coded highlights.
This was referenced Apr 28, 2026
This was referenced May 7, 2026
Owner
Author
Conflict Group 1This PR shares modified functions with 9 other PR(s): #106, #107, #55, #6, #62, #74, #86, #87, #96. These PRs should be reviewed as a batch — merging one may affect the others.
graph LR
PR9["PR #9"]
FloadCommands_7884["loadCommands<br>BuiltinCommandLoader.ts"]
PR9 -->|modifies| FloadCommands_7884
PR107["PR #107"]
PR107 -->|modifies| FloadCommands_7884
PR86["PR #86"]
PR86 -->|modifies| FloadCommands_7884
PR87["PR #87"]
PR87 -->|modifies| FloadCommands_7884
PR96["PR #96"]
PR96 -->|modifies| FloadCommands_7884
FshowCitations_6790["showCitations<br>useGeminiStream.ts"]
PR9 -->|modifies| FshowCitations_6790
PR106["PR #106"]
PR106 -->|modifies| FshowCitations_6790
PR55["PR #55"]
PR55 -->|modifies| FshowCitations_6790
PR6["PR #6"]
PR6 -->|modifies| FshowCitations_6790
PR96 -->|modifies| FshowCitations_6790
FuseCommandCompletion_8197["useCommandCompletion<br>useCommandCompletion.tsx"]
PR9 -->|modifies| FuseCommandCompletion_8197
PR62["PR #62"]
PR62 -->|modifies| FuseCommandCompletion_8197
PR74["PR #74"]
PR74 -->|modifies| FuseCommandCompletion_8197
Posted by codegraph-ai conflict detection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integra LanguageTool ao Qwen Code em três camadas: (1) documentação e
/ltcommand, (2) verificação ao vivo no prompt com sublinhado e painel de sugestões, e (3) tool estruturadalanguage_tool_checkdisponível ao modelo. Também melhora formatação determinística de números no painel de estatísticas, aperfeiçoa autocomplete de arquivos no@topo do workspace e torna mensagens de “finish reason” mais claras.Dive Deeper
O que foi adicionado
Docs & UX
/lt(placeholder informativo por ora, útil para smoke test de argumentos).CLI (Ink) / Editor
useLiveLanguageTool: faz debounce, chamaPOST /v2/check, aplica sugestões (estratégia “first”) e expõe:matches(erros),corrected,changes,busy,error.LanguageToolDisplay:AnnotatedText: sublinha em vermelho os trechos com problema.LanguageToolIndicator: contador de problemas, sugestões e erros de rede.InputPrompt: integra o preview (histórico → edição → preview → sugestões).Integração com fluxo do modelo
useGeminiStream:processWithLanguageTool(...)antes de enviar ao modelo (hook atual é no-op controlado por política; pronto para trocar pelo preprocess real).Core
languageTool.ts(tool):language_tool_checkcom schema tipado (texto, idioma, policyfirst|best|none, regras, nível).ltClient.ts: cliente fetch nativo +applySuggestionsestável por offset.preprocess.ts: pipeline reutilizável (políticasoff | confirm | auto-first | auto-best) +preprocess.d.ts.ltConfig.ts: defaults sensatos via env:LT_ENABLED(default on),LT_POLICY(defaultconfirm),LT_SERVER(defaulthttps://api.languagetool.org/),LT_LANG(defaultauto),LT_MOTHER_TONGUE,LT_RULES_ON,LT_RULES_OFF(merge comUPPERCASE_SENTENCE_START),LT_LEVEL(default).Registro do tool no
Configpara descoberta automática.Qualidade de vida
StatsDisplay: formatação en-US determinística para inteiros (padroniza contagens).
Autocomplete de arquivos:
@) retornando diretórios (glob commark: true).FileDiscoveryServicepode ser nulo./.Tipagem/enum para
FinishReasoneMessageType.Considerações de privacidade e desempenho
https://api.languagetool.org/. Para dados sensíveis, recomenda-se rodar localmente (java ... HTTPServer --port 8081) e definirLT_SERVER=http://localhost:8081.preprocessreal com política.Itens futuros (seguimento sugerido)
useLanguageToolpara usarpreprocessUserInput(...)(comconfirmFnem TTY)./lt(invocarlanguage_tool_checke/oupreprocess).LT_POLICYe idioma detectado.Reviewer Test Plan
Setup do LanguageTool (opção A – local recomendado)
wget https://languagetool.org/download/LanguageTool-6.0.zip && unzip LanguageTool-6.0.zip && cd LanguageTool-6.0java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8081export LT_SERVER=http://localhost:8081Ou (opção B – API pública)
LT_SERVERdefault.Variáveis de ambiente
export LT_ENABLED=1export LT_POLICY=confirm(testar tambémauto-firsteauto-best)export LT_LANG=autoexport LT_MOTHER_TONGUE=pt-BRexport LT_RULES_OFF=UPPERCASE_SENTENCE_START,EN_QUOTES(ver impacto)Rodar CLI
npm ina raiz;npm run buildenpm run dev(ou o fluxo do seu workspace).Digite um texto com erros no prompt (ex.: “Isto eh um teste.” / “Eu vai no mercado ontem.”).
Verifique:
Comando
/lt/lt Este eh um teste basico.Integração com envio ao modelo
LT_POLICY=auto-firste observe no log o passo de pré-processamento.Tool estruturada
language_tool_checkvia tool-call (prompt do modelo pedindo revisão).Verifique o JSON de saída (
original,corrected,changes,matches).Autocomplete de arquivos
@/prefixo vazio e confira a listagem de diretórios de topo./e valide resultados consistentes.StatsDisplay
Testing Matrix
npm run buildnpxLinked issues / bugs
Se quiser, troco os IDs acima pelos da sua lista real de issues.