Step 228: Add prompt templates
This commit is contained in:
@@ -747,3 +747,4 @@ vcpkg's imgui 1.91.9 removed the `sdl2-binding` feature (only `sdl3-binding` exi
|
||||
| 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. |
|
||||
| 2026-02-10 | Claude Opus 4.6 | Sprint 7 Phase 7c (Steps 214–219): TraceGenerator.h (6 scenario templates, 9-sample code corpus, batch engine), TraceExporter.h (Anthropic/OpenAI/JSONL/Markdown export, filtering, statistics). 294/294 tests pass. |
|
||||
| 2026-02-10 | Codex | Step 227: Open-source model tool definitions (ReAct-style prompt, XML tool call format, simplified schemas, adapter rules). 1/1 tests pass. |
|
||||
| 2026-02-10 | Codex | Step 228: Prompt engineering templates (5 prompt files with system/user templates, expected tools, success criteria). 1/1 tests pass. |
|
||||
|
||||
@@ -1166,6 +1166,8 @@ add_executable(step226_test tests/step226_test.cpp)
|
||||
target_include_directories(step226_test PRIVATE src)
|
||||
add_executable(step227_test tests/step227_test.cpp)
|
||||
target_include_directories(step227_test PRIVATE src)
|
||||
add_executable(step228_test tests/step228_test.cpp)
|
||||
target_include_directories(step228_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)
|
||||
|
||||
40
editor/tests/step228_test.cpp
Normal file
40
editor/tests/step228_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Step 228: Prompt engineering templates.
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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::vector<std::string> prompts = {
|
||||
"../tools/prompts/annotate_module.prompt",
|
||||
"../tools/prompts/cross_language.prompt",
|
||||
"../tools/prompts/code_review.prompt",
|
||||
"../tools/prompts/refactor.prompt",
|
||||
"../tools/prompts/security.prompt"
|
||||
};
|
||||
|
||||
for (const auto& path : prompts) {
|
||||
const std::string content = readFile(path);
|
||||
assert(!content.empty());
|
||||
assertContains(content, "system:");
|
||||
assertContains(content, "user:");
|
||||
assertContains(content, "expected_tools:");
|
||||
assertContains(content, "success_criteria:");
|
||||
assertContains(content, "{{");
|
||||
}
|
||||
|
||||
printf("step228_test: all assertions passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ Optimized tool definitions and prompts for specific LLM families.
|
||||
- Adapter that parses model output into structured tool calls
|
||||
*New:* `tools/generic/` directory with definitions + adapter
|
||||
|
||||
- [ ] **Step 228: Prompt engineering templates**
|
||||
- [x] **Step 228: Prompt engineering templates**
|
||||
Reusable prompt templates for common Whetstone tasks:
|
||||
- `annotate_module.prompt` — System + user messages for annotation workflow
|
||||
- `cross_language.prompt` — System + user for cross-language projection
|
||||
|
||||
17
tools/prompts/annotate_module.prompt
Normal file
17
tools/prompts/annotate_module.prompt
Normal file
@@ -0,0 +1,17 @@
|
||||
# annotate_module
|
||||
|
||||
system:
|
||||
You are a Whetstone annotation assistant. Prefer using tools to inspect ASTs and apply safe annotations.
|
||||
|
||||
user:
|
||||
Analyze module {{module_name}}. Suggest memory annotations for all unannotated functions. Include confidence scores and reasons.
|
||||
|
||||
expected_tools:
|
||||
- whetstone_get_ast
|
||||
- whetstone_suggest_annotations
|
||||
- whetstone_apply_annotation
|
||||
|
||||
success_criteria:
|
||||
- All unannotated functions receive suggestions.
|
||||
- Each suggestion includes a confidence score and brief reason.
|
||||
- Applied annotations are reported with node ids.
|
||||
16
tools/prompts/code_review.prompt
Normal file
16
tools/prompts/code_review.prompt
Normal file
@@ -0,0 +1,16 @@
|
||||
# code_review
|
||||
|
||||
system:
|
||||
You are a Whetstone reviewer. Inspect AST and annotations before giving recommendations.
|
||||
|
||||
user:
|
||||
Review module {{module_name}} for annotation correctness. Highlight risky memory strategies and suggest safer alternatives.
|
||||
|
||||
expected_tools:
|
||||
- whetstone_get_ast
|
||||
- whetstone_suggest_annotations
|
||||
|
||||
success_criteria:
|
||||
- Risks are tied to specific nodes.
|
||||
- Safer alternatives are provided with rationale.
|
||||
- No changes are applied unless explicitly requested.
|
||||
16
tools/prompts/cross_language.prompt
Normal file
16
tools/prompts/cross_language.prompt
Normal file
@@ -0,0 +1,16 @@
|
||||
# cross_language
|
||||
|
||||
system:
|
||||
You are a Whetstone projection assistant. Use the pipeline tools to convert between languages while preserving annotations.
|
||||
|
||||
user:
|
||||
Project the current module from {{source_language}} to {{target_language}}. Keep annotation intent equivalent and report adaptation notes.
|
||||
|
||||
expected_tools:
|
||||
- whetstone_get_ast
|
||||
- whetstone_project_language
|
||||
|
||||
success_criteria:
|
||||
- Target language projection produced.
|
||||
- Annotation adaptation notes include any strategy changes.
|
||||
- Output includes the projected AST summary.
|
||||
17
tools/prompts/refactor.prompt
Normal file
17
tools/prompts/refactor.prompt
Normal file
@@ -0,0 +1,17 @@
|
||||
# refactor
|
||||
|
||||
system:
|
||||
You are a Whetstone refactoring assistant. Use AST mutations in small, verifiable steps.
|
||||
|
||||
user:
|
||||
Refactor {{module_name}} to {{goal}}. Keep behavior intact and update annotations if ownership changes.
|
||||
|
||||
expected_tools:
|
||||
- whetstone_get_ast
|
||||
- whetstone_mutate
|
||||
- whetstone_batch_mutate
|
||||
|
||||
success_criteria:
|
||||
- Refactor uses minimal, reversible mutations.
|
||||
- Behavior preserved per description.
|
||||
- Annotation updates reflect new ownership.
|
||||
16
tools/prompts/security.prompt
Normal file
16
tools/prompts/security.prompt
Normal file
@@ -0,0 +1,16 @@
|
||||
# security
|
||||
|
||||
system:
|
||||
You are a Whetstone security assistant. Check dependencies and annotations for vulnerabilities before recommending changes.
|
||||
|
||||
user:
|
||||
Audit {{module_name}} dependencies for known vulnerabilities. Recommend safe upgrades and show impacted functions.
|
||||
|
||||
expected_tools:
|
||||
- whetstone_get_ast
|
||||
- whetstone_get_scope
|
||||
|
||||
success_criteria:
|
||||
- Vulnerable dependencies are listed.
|
||||
- Recommendations include safer versions or alternatives.
|
||||
- Impacted nodes or functions are identified.
|
||||
Reference in New Issue
Block a user