Step 226: OpenAI tool definitions
This commit is contained in:
@@ -741,6 +741,7 @@ vcpkg's imgui 1.91.9 removed the `sdl2-binding` feature (only `sdl3-binding` exi
|
||||
| 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 226: OpenAI tool definitions (function schema + system prompt). 1/1 tests pass (step226_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. |
|
||||
|
||||
@@ -1161,6 +1161,9 @@ 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(step226_test tests/step226_test.cpp)
|
||||
target_include_directories(step226_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/step226_test.cpp
Normal file
34
editor/tests/step226_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Step 226: OpenAI 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/openai/functions.json");
|
||||
const std::string prompt = readFile("../tools/openai/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("step226_test: all assertions passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ Optimized tool definitions and prompts for specific LLM families.
|
||||
- Few-shot examples embedded in tool descriptions
|
||||
*New:* `tools/claude/` directory with tool definitions + system prompt
|
||||
|
||||
- [ ] **Step 226: Codex / GPT tool definitions**
|
||||
- [x] **Step 226: Codex / GPT tool definitions**
|
||||
OpenAI-format function definitions for Codex and GPT models:
|
||||
- Each tool as an OpenAI `function` definition
|
||||
- Descriptions tuned for OpenAI models (concise, example-heavy)
|
||||
|
||||
174
tools/openai/functions.json
Normal file
174
tools/openai/functions.json
Normal file
@@ -0,0 +1,174 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"provider": "openai",
|
||||
"tools": [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_get_ast",
|
||||
"description": "Get the current AST (Abstract Syntax Tree) of the active buffer as JSON.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_mutate",
|
||||
"description": "Apply a single mutation to the AST (setProperty, updateNode, deleteNode, insertNode).",
|
||||
"parameters": {
|
||||
"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"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_batch_mutate",
|
||||
"description": "Apply multiple mutations atomically (all succeed or rollback).",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mutations": {
|
||||
"type": "array",
|
||||
"items": { "type": "object" }
|
||||
}
|
||||
},
|
||||
"required": ["mutations"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_get_scope",
|
||||
"description": "Get all symbols in scope at a given AST node.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" }
|
||||
},
|
||||
"required": ["nodeId"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_get_call_hierarchy",
|
||||
"description": "Get call hierarchy for a function node (callers and callees).",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"functionId": { "type": "string" }
|
||||
},
|
||||
"required": ["functionId"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_suggest_annotations",
|
||||
"description": "Get memory annotation suggestions for a node or line/col location.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" },
|
||||
"line": { "type": "integer" },
|
||||
"col": { "type": "integer" }
|
||||
}
|
||||
},
|
||||
"strict": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_apply_annotation",
|
||||
"description": "Apply a memory annotation suggestion to the AST.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeId": { "type": "string" },
|
||||
"annotationType": { "type": "string" },
|
||||
"strategy": { "type": "string" },
|
||||
"reason": { "type": "string" },
|
||||
"confidence": { "type": "number" }
|
||||
},
|
||||
"required": ["nodeId", "annotationType", "strategy"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_generate_code",
|
||||
"description": "Generate code from a natural language spec, optionally preferring imports.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"spec": { "type": "string" },
|
||||
"preferImports": { "type": "boolean" }
|
||||
},
|
||||
"required": ["spec"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_run_pipeline",
|
||||
"description": "Run full pipeline: parse, infer annotations, validate, optimize, generate.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source": { "type": "string" },
|
||||
"sourceLanguage": { "type": "string" },
|
||||
"targetLanguage": { "type": "string" }
|
||||
},
|
||||
"required": ["source", "sourceLanguage", "targetLanguage"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "whetstone_project_language",
|
||||
"description": "Project current AST to a different target language.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"targetLanguage": { "type": "string" }
|
||||
},
|
||||
"required": ["targetLanguage"]
|
||||
},
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
9
tools/openai/system_prompt.txt
Normal file
9
tools/openai/system_prompt.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
You are a Whetstone coding assistant with access to AST and annotation tools.
|
||||
|
||||
Rules:
|
||||
- Prefer tool calls to inspect or modify ASTs rather than guessing.
|
||||
- Keep edits minimal and validate after multi-step changes.
|
||||
- When asked to add annotations, call whetstone_suggest_annotations then
|
||||
whetstone_apply_annotation using the highest-confidence suggestion.
|
||||
- For refactors, use whetstone_get_ast and whetstone_mutate or
|
||||
whetstone_batch_mutate. Use whetstone_run_pipeline when validation is requested.
|
||||
Reference in New Issue
Block a user