Workspace fs:grep loses surrounding lines for multiple matches with ripgrep
Los mantenedores suelen responder en 1 día
@chenqing0106 ya está trabajando en esto.
Desde el 18/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- backend
Línea de trabajo
Empieza en packages/agent-core-v2/src/workspace/workspaceFs/fsService.ts, líneas 1257-1284, donde el analizador de flujo de ripgrep acumula líneas de contexto en un array pending y lo vacía en cada coincidencia, y en las líneas 1312-1323, donde finalize solo rellena after para la última coincidencia. Usa el helper makeSession de fsService.test.ts para ejecutar los cuatro fixtures descritos (separated, overlapping, adjacent, single) con ambos backends. La corrección debería conservar las líneas coincidentes en el contexto pending entre coincidencias consecutivas, para que los arrays before y after estén completos para cada coincidencia.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version and environment
Current main: 5b936697670ed15444bcb4720bd91e6ee776a941 (@moonshot-ai/agent-core-v2 0.4.3).
Windows x64, Node 24.19.0, pnpm 10.33.0, ripgrep 15.1.0.
No model/subscription is involved in this file-service reproduction.
Actual behavior
WorkspaceFsService.grep drops surrounding lines when ripgrep reports multiple matches in one file. For separated matches, the first match's after is empty. For adjacent/overlapping matches, the later match's before also omits nearby matching lines. The response reports truncated: false.
This concerns the workspace file service exposed through the server's fs:grep route; I have not reproduced it through the model-facing Grep tool or a running HTTP server.
Reproduction
Create src/a.ts with:
a
hit
b
c
d
hit
e
f
Run WorkspaceFsService.grep with this request (the existing makeSession helper in fsService.test.ts can exercise it):
{
"pattern": "hit",
"regex": false,
"case_sensitive": true,
"follow_gitignore": false,
"max_files": 200,
"max_matches_per_file": 50,
"max_total_matches": 5000,
"context_lines": 2
}
The stream used by the test was captured from actual ripgrep:
rg --json --context 2 --fixed-strings hit src/a.ts
The real WorkspaceFsService parses that stream through its existing process-service test seam. Its match results are:
[
{"line":2,"col":1,"text":"hit","before":["a"],"after":[]},
{"line":6,"col":1,"text":"hit","before":["c","d"],"after":["e","f"]}
]
Expected behavior
The first match should have after: ["b", "c"]. Removing ripgrep and exercising the Node fallback on identical content returns this expected context for both matches.
With a\nhit\nb\nhit\nc\nd\n, the second match should have before: ["hit", "b"], but the rg path returns ["b"]. With adjacent hits, its before is empty instead of ["a", "hit"].
Investigation and focused validation
The context/match handling accumulates context in one pending array and clears it on every match. finalize fills after only for the last match. Matching lines are not retained for neighboring matches' context.
Four fixtures (separated, overlapping, adjacent, single), each tested through both real service backends: 3 rg multi-match failures; 5 passing controls (all four Node cases and the single-match rg case). Production code was unchanged. These are focused service tests, not a claim that the full Windows suite passes.
Contribution
- I am willing to submit a focused fix and regression tests after a maintainer's
/approve.
- Lenguaje dominante
- TypeScript
- Estrellas
- 8k
- Forks
- 1.3k
- Merge medio
- 17 h 52 min
- PR fusionados (30 d)
- 163
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MoonshotAI/kimi-code
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MoonshotAI/kimi-code#4548 ·
Los mantenedores suelen responder en 1 día
-
VS Code extension: clickable file links in chat drop the :line suffix, never jump to the lineAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
MoonshotAI/kimi-code#4398 ·
Los mantenedores suelen responder en 1 día
-
[Bug] vis reports legacy tool-triggered swarm sessions as activePosiblemente ocupada @louisss1016 la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
MoonshotAI/kimi-code#4395 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
MoonshotAI/kimi-code#4392 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
MoonshotAI/kimi-code#4381 ·
Los mantenedores suelen responder en 1 día
Todos los issues de MoonshotAI/kimi-code
Issues similares
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Export the Hemi Earn Router address and the Router and Agent ABIs from `@vetro-protocol/earn`Abiertohemi-earn
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
vetro-protocol/vetro-monorepo#1043 ·
Los mantenedores suelen responder en 1 día
-
stage 2: bare names resolve against PATH differently from the shell (empty and relative entries)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
STRML/omp-classifier#206 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
atlassian-labs/mermaid-diagrams-viewer#188 ·
Los mantenedores suelen responder en 1 día
-
dashboard enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Olanetsoft/agent-lookout#225 ·
Los mantenedores suelen responder en 1 día