Package com.tnsai.server.tools
Class ServerGitTools
java.lang.Object
com.tnsai.server.tools.ServerGitTools
Function-shape git tools for tnsai-server. Replaces the legacy
GitTool (read-only) + GitWriteTool (Phase 3b sweep,
issue #188).
Read operations follow the legacy ToolRisk.READ_ONLY contract;
write operations preserve the legacy risk classification (LOW / MEDIUM /
HIGH / CRITICAL per ADR-7) — see classifyWriteRisk(String, String).
| Method | Risk | Idempotent |
|---|---|---|
gitRead(java.lang.String, java.lang.String) | READ_ONLY | true |
gitWrite(java.lang.String, java.lang.String, java.lang.String) | WRITE / DESTRUCTIVE (per command) | false (mutates VCS state) |
The same JSON envelope as the legacy tools — {"command": "...", "args": "...", "message": "..."}.
- Since:
- 0.5.7 (Phase 3b — server-tool migration to function shape, see #188)
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ServerGitTools
-
-
Method Details
-
gitRead
@Tool(name="git_read", description="Run a read-only git command. {command} is one of status / log / diff / blame / branch / show / stash. Optional {args} are extra arguments (e.g. \"--oneline -10\"). branch with -d/-D/--delete/--copy is rejected \u2014 use git_write. stash with anything other than \"list\" is rejected \u2014 use git_write. Returns JSON {stdout, stderr, exitCode}. READ_ONLY risk.", keywords={"git","vcs","status","log","diff","blame"}, idempotent=true) public String gitRead(@ToolParam(description="Git subcommand: status / log / diff / blame / branch / show / stash") String command, @ToolParam(description="Additional arguments (optional)",required=false,defaultValue="") String args) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
gitWrite
@Tool(name="git_write", description="Run a git write command. {command} is one of add / commit / push / pull / checkout / branch / merge / rebase / stash / tag / reset. Optional {args} for extra arguments. Optional {message} is used by commit (passed as -m \"...\"). Force push to main/master is always rejected. Network commands (push/pull) get a 60s timeout. Returns JSON {stdout, stderr, exitCode}.", keywords={"git","vcs","commit","push","pull","merge"}, idempotent=false) public String gitWrite(@ToolParam(description="Git subcommand: add / commit / push / pull / checkout / branch / merge / rebase / stash / tag / reset") String command, @ToolParam(description="Additional arguments (optional, required for most commands)",required=false,defaultValue="") String args, @ToolParam(description="Commit message (used with commit -m)",required=false,defaultValue="") String message) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
classifyWriteRisk
Risk classification per ADR-7 (preserved verbatim from legacy GitWriteTool).
-