Commit Graph
6 Commits
Author SHA1 Message Date
abel533andCopilot bd375e6b15 fix+test: code quality improvements + 87 unit tests
Fixes:
- Resource leaks: process cleanup in BashTool, GrepTool, NotificationService
- Input validation: null/blank checks in BashTool, FileEditTool, GrepTool
- Path traversal: FileEditTool blocks ../ escape from workDir
- Thread safety: AgentLoop messageHistory now synchronizedList
- Error handling: log instead of silently swallow exceptions
- Bounds validation: RateLimiter constructor validates all params

Tests (87 total):
- TokenEstimationServiceTest: 14 tests (estimation, cost, formatting)
- RateLimiterTest: 12 tests (limits, cooldown, reset, concurrent)
- InternalLoggerTest: 12 tests (levels, structured, file output, export)
- NotificationServiceTest: 6 tests (config, disabled mode)
- FileEditToolTest: 8 tests (validation, traversal, core edit)
- BashToolTest: 9 tests (validation, dangerous commands, metadata)
- GrepToolTest: 5 tests (validation, metadata)
- Phase4CommandsTest: 21 tests (all Phase 4B+4D command metadata)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 11:48:00 +08:00
abel533andCopilot 08ebc72416 feat: enhance GrepTool with output_mode, case_insensitive, multiline, context lines
Add 7 new parameters to match TS GrepTool capabilities:
- output_mode: content/files_with_matches/count (3 modes like TS)
- case_insensitive: -i flag support
- multiline: cross-line pattern matching (ripgrep only)
- context_before/context_after: -B/-A context lines
- type: file type filter (e.g., 'java', 'py') for ripgrep
- head_limit: configurable result limit (was hardcoded 100)

All parameters correctly wired to rg, grep, and findstr backends.
Description updated with output mode documentation and escaping notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 09:07:23 +08:00
abel533andCopilot c5440a2b4c feat: enhance system prompt and tool descriptions to match TS version
Phase 1A implementation:

SystemPromptBuilder.java (142 lines -> ~290 lines):
- Add CyberRisk security boundary instruction
- Add System section (permission modes, prompt injection defense)
- Add Doing Tasks section (coding style, security, collaboration)
- Add Actions section (operation risk management, dangerous ops protection)
- Add Tone & Style section (emoji control, concise output, code references)
- Add Output Efficiency section (direct communication)
- Add Language preference support
- Restructure into modular section builder methods matching TS architecture

Tool description enhancements (8 tools):
- BashTool: add security boundaries, git best practices, no-substitute rule
- FileWriteTool: add must-Read-first rule, prefer-Edit guidance
- GrepTool: add never-use-Bash-grep rule, search guidance
- AgentTool: add when-to-use/not-use guidance, sub-prompt enhanced
- FileEditTool: add indentation preservation, prefer-edit-existing rule
- TodoWriteTool: add proactive usage guidance, state machine rules
- TaskUpdateTool: add status workflow documentation
- ConfigTool: add available settings list

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 09:06:04 +08:00
liuzh cc0d3f8b00 Revert "fix: 将所有emoji/Unicode特殊字符替换为ASCII安全字符"
This reverts commit 3cd67ffe451be2cc7a66b5c554966f1d5aa58c7c.
2026-04-01 20:43:31 +08:00
liuzhandCopilot eeceaaaea9 fix: 将所有emoji/Unicode特殊字符替换为ASCII安全字符
Windows cmd/PowerShell默认codepage下emoji显示为?号。
全局替换: 👋->移除, 💭->[Thinking], ⚙->*, ✓->[OK], ✗->[FAIL],
◆->>, ⚠->[!], ->[OK], •->|/-, →->>>, ✏️->[Edit]等。
❯保留(windows-vtp终端下正常显示)。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 20:37:55 +08:00
liuzhandCopilot d67f41358d feat: Phase1 项目骨架 - Maven项目结构、核心AgentLoop、6个工具、命令系统、控制台渲染、REPL会话
实现内容:
- pom.xml: JDK25 + Spring AI 2.0.0-M4 + JLine3 + Picocli
- core/AgentLoop: 基于ChatModel的显式工具循环(非ChatClient)
- tool/: Tool接口 + ToolRegistry + ToolCallbackAdapter(适配Spring AI)
- tool/impl/: BashTool, FileReadTool, FileWriteTool, FileEditTool, GlobTool, GrepTool
- command/: SlashCommand接口 + CommandRegistry + /help, /clear, /exit
- console/: AnsiStyle, BannerPrinter, ToolStatusRenderer, ThinkingRenderer, SpinnerAnimation, MarkdownRenderer
- context/: SystemPromptBuilder, ClaudeMdLoader(多级CLAUDE.md加载)
- repl/ReplSession: REPL主循环(Scanner降级方案)
- config/AppConfig: Spring Bean装配
- application.yml: Anthropic/OpenAI双模型配置

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:22:04 +08:00