Step 225: Claude tool definitions
This commit is contained in:
@@ -740,6 +740,7 @@ vcpkg's imgui 1.91.9 removed the `sdl2-binding` feature (only `sdl3-binding` exi
|
||||
| 2026-02-10 | Codex | Step 222: Evaluation workflow task suite (20 multi-step tasks). 1/1 tests pass (step222_test). |
|
||||
| 2026-02-10 | Codex | Step 223: Evaluation runner CLI (whetstone_eval, task/trace/report pipeline). 1/1 tests pass (step223_test). |
|
||||
| 2026-02-10 | Codex | Step 224: Evaluation harness tests (good/bad/partial scoring). 1/1 tests pass (step224_test). |
|
||||
| 2026-02-10 | Codex | Step 225: Claude tool definitions (Anthropic tool schema + system prompt). 1/1 tests pass (step225_test). |
|
||||
| 2026-02-10 | Codex | Step 166: Extract main.cpp into panel headers marked complete (already implemented). step166_test passes; file_limits_test 4/4 passes. |
|
||||
| 2026-02-10 | Claude Opus 4.6 | Sprint 7 Phase 7a (Steps 202–206): API docs (AGENT_API.md, 23 methods), JSON schemas (20 files), exposed ContextAPI/BatchMutationAPI/Pipeline via RPC, permission policy updates. 51/51 tests pass. |
|
||||
| 2026-02-10 | Claude Opus 4.6 | Sprint 7 Phase 7b (Steps 207–213): MCPServer.h (10 tools, 5 resources, 4 prompts, JSON-RPC 2.0 initialize handshake), MCPBridge.h (stdio transport). 90/90 tests pass. |
|
||||
|
||||
@@ -1158,6 +1158,9 @@ target_include_directories(step223_test PRIVATE src)
|
||||
add_executable(step224_test tests/step224_test.cpp)
|
||||
target_include_directories(step224_test PRIVATE src)
|
||||
target_link_libraries(step224_test PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
add_executable(step225_test tests/step225_test.cpp)
|
||||
target_include_directories(step225_test PRIVATE src)
|
||||
add_executable(step213_test tests/step213_test.cpp)
|
||||
target_include_directories(step213_test PRIVATE src)
|
||||
target_link_libraries(step213_test PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
34
editor/tests/step225_test.cpp
Normal file
34
editor/tests/step225_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Step 225: Claude tool definitions.
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
static std::string readFile(const std::string& path) {
|
||||
std::ifstream f(path);
|
||||
if (!f.is_open()) return {};
|
||||
return std::string((std::istreambuf_iterator<char>(f)),
|
||||
std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
static void assertContains(const std::string& text, const std::string& needle) {
|
||||
assert(text.find(needle) != std::string::npos);
|
||||
}
|
||||
|
||||
int main() {
|
||||
const std::string tools = readFile("../tools/claude/tools.json");
|
||||
const std::string prompt = readFile("../tools/claude/system_prompt.txt");
|
||||
assertContains(tools, "whetstone_get_ast");
|
||||
assertContains(tools, "whetstone_mutate");
|
||||
assertContains(tools, "whetstone_batch_mutate");
|
||||
assertContains(tools, "whetstone_get_scope");
|
||||
assertContains(tools, "whetstone_get_call_hierarchy");
|
||||
assertContains(tools, "whetstone_suggest_annotations");
|
||||
assertContains(tools, "whetstone_apply_annotation");
|
||||
assertContains(tools, "whetstone_generate_code");
|
||||
assertContains(tools, "whetstone_run_pipeline");
|
||||
assertContains(tools, "whetstone_project_language");
|
||||
assertContains(prompt, "Whetstone coding assistant");
|
||||
printf("step225_test: all assertions passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ Test suites that measure how accurately an LLM can use Whetstone tools.
|
||||
|
||||
Optimized tool definitions and prompts for specific LLM families.
|
||||
|
||||
- [ ] **Step 225: Claude tool definitions**
|
||||
- [x] **Step 225: Claude tool definitions**
|
||||
Anthropic-format tool definitions optimized for Claude:
|
||||
- Each Whetstone MCP tool as a Claude `tool_use` definition
|
||||
- Descriptions tuned for Claude's strengths (detailed, structured)
|
||||
|
||||
12
tools/claude/system_prompt.txt
Normal file
12
tools/claude/system_prompt.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
You are a Whetstone coding assistant with access to semantic annotations and AST tools.
|
||||
|
||||
Guidelines:
|
||||
- Use tools to read or mutate the AST instead of guessing structure.
|
||||
- Prefer safe, minimal mutations. Validate after multi-step changes.
|
||||
- If asked to annotate memory strategy, call whetstone_suggest_annotations then
|
||||
whetstone_apply_annotation with the highest-confidence suggestion.
|
||||
- When generating code from a spec, call whetstone_generate_code and explain any assumptions.
|
||||
- For refactors, use whetstone_get_ast to locate targets, then whetstone_mutate or
|
||||
whetstone_batch_mutate. Re-run whetstone_run_pipeline if asked to validate.
|
||||
|
||||
You must follow user instructions carefully. If a step is ambiguous, ask a brief clarifying question.
|
||||
164
tools/claude/tools.json
Normal file
164
tools/claude/tools.json
Normal file
@@ -0,0 +1,164 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"provider": "anthropic",
|
||||
"tools": [
|
||||
{
|
||||
"name": "whetstone_get_ast",
|
||||
"description": "Get the current AST (Abstract Syntax Tree) of the active buffer as JSON.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"examples": [
|
||||
{}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_mutate",
|
||||
"description": "Apply a single mutation to the AST (setProperty, updateNode, deleteNode, insertNode).",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["setProperty", "updateNode", "deleteNode", "insertNode"]
|
||||
},
|
||||
"nodeId": { "type": "string" },
|
||||
"property": { "type": "string" },
|
||||
"value": { "type": "string" },
|
||||
"parentId": { "type": "string" },
|
||||
"role": { "type": "string" },
|
||||
"node": { "type": "object" }
|
||||
},
|
||||
"required": ["type"]
|
||||
},
|
||||
"examples": [
|
||||
{ "type": "setProperty", "nodeId": "fn1", "property": "name", "value": "rename_me" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_batch_mutate",
|
||||
"description": "Apply multiple mutations atomically (all succeed or rollback).",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mutations": {
|
||||
"type": "array",
|
||||
"items": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"required": ["mutations"]
|
||||
},
|
||||
"examples": [
|
||||
{ "mutations": [{ "type": "deleteNode", "nodeId": "n42" }] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_get_scope",
|
||||
"description": "Get all symbols in scope at a given AST node.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" }
|
||||
},
|
||||
"required": ["nodeId"]
|
||||
},
|
||||
"examples": [
|
||||
{ "nodeId": "fn1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_get_call_hierarchy",
|
||||
"description": "Get call hierarchy for a function node (callers and callees).",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"functionId": { "type": "string" }
|
||||
},
|
||||
"required": ["functionId"]
|
||||
},
|
||||
"examples": [
|
||||
{ "functionId": "fn1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_suggest_annotations",
|
||||
"description": "Get memory annotation suggestions for a node or line/col location.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" },
|
||||
"line": { "type": "integer" },
|
||||
"col": { "type": "integer" }
|
||||
}
|
||||
},
|
||||
"examples": [
|
||||
{ "nodeId": "fn1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_apply_annotation",
|
||||
"description": "Apply a memory annotation suggestion to the AST.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" },
|
||||
"annotationType": { "type": "string" },
|
||||
"strategy": { "type": "string" },
|
||||
"reason": { "type": "string" },
|
||||
"confidence": { "type": "number" }
|
||||
},
|
||||
"required": ["nodeId", "annotationType", "strategy"]
|
||||
},
|
||||
"examples": [
|
||||
{ "nodeId": "fn1", "annotationType": "ReclaimAnnotation", "strategy": "Tracing" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_generate_code",
|
||||
"description": "Generate code from a natural language spec, optionally preferring imports.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"spec": { "type": "string" },
|
||||
"preferImports": { "type": "boolean" }
|
||||
},
|
||||
"required": ["spec"]
|
||||
},
|
||||
"examples": [
|
||||
{ "spec": "Create a function that sums a list of integers.", "preferImports": true }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_run_pipeline",
|
||||
"description": "Run full pipeline: parse, infer annotations, validate, optimize, generate.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source": { "type": "string" },
|
||||
"sourceLanguage": { "type": "string" },
|
||||
"targetLanguage": { "type": "string" }
|
||||
},
|
||||
"required": ["source", "sourceLanguage", "targetLanguage"]
|
||||
},
|
||||
"examples": [
|
||||
{ "source": "def add(a,b): return a+b", "sourceLanguage": "python", "targetLanguage": "cpp" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "whetstone_project_language",
|
||||
"description": "Project current AST to a different target language.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"targetLanguage": { "type": "string" }
|
||||
},
|
||||
"required": ["targetLanguage"]
|
||||
},
|
||||
"examples": [
|
||||
{ "targetLanguage": "rust" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user