feat: add Soroban-specific AI prompt actions#82
Merged
Atharv777 merged 4 commits intokentuckyfriedcode:mainfrom Apr 20, 2026
Merged
feat: add Soroban-specific AI prompt actions#82Atharv777 merged 4 commits intokentuckyfriedcode:mainfrom
Atharv777 merged 4 commits intokentuckyfriedcode:mainfrom
Conversation
Closes kentuckyfriedcode#48 ## What was added ### server/utils/contract_templates.py (new) Template registry and generator with 4 starter templates: - hello_world: minimal greeting contract (beginner) - token: fungible token with initialize/transfer/balance (intermediate) - nft: non-fungible token with mint/transfer/owner_of/token_uri (intermediate) - governance: DAO proposal + voting with quorum threshold (advanced) Functions: list_templates(), get_template(id), generate_template(id, path, name) Each template generates: Cargo.toml, src/lib.rs, README.md ### server/routes/template_routes.py (new) Three endpoints registered under /api/templates/: GET /api/templates - Lists all 4 templates with id, name, description, difficulty, tags GET /api/templates/<template_id> - Returns metadata for one template, 404 with available list if not found POST /api/templates/generate - Validates session ownership and resolves instance_dir - Validates project_name with regex (alphanumeric, hyphens, underscores) - Blocks path traversal - Generates template files into session workspace - Returns files_created list and project_path ### server/start.py Registered templates_bp blueprint ### server/tests/test_contract_templates.py (new) 28 tests covering all components: - list_templates: count, required fields, expected IDs - get_template: valid/invalid IDs, all templates retrievable - generate_template: all 4 templates, Cargo.toml content, src/lib.rs has soroban_sdk, README mentions template name, raises for unknown template, raises if path exists, files_created list correct - GET /api/templates: 200, returns 4, required fields - GET /api/templates/<id>: 200 valid, 404 unknown, available list on 404 - POST /api/templates/generate: missing fields, session not found, path traversal blocked, invalid project_name, unknown template 404, successful generation with files on disk ## Results Tests: 88 passed, 0 failed (full suite)
Closes kentuckyfriedcode#54 ## What was added ### server/utils/soroban_prompts.py (new) 4 prebuilt Soroban prompt templates: - generate_contract: generate complete contract from description - explain_contract: explain contract in plain language - generate_tests: generate Rust test suite - security_review: security audit with severity ratings Functions: list_prompt_templates(), get_prompt_template(id), build_soroban_prompt(id, description, context_code) ### server/routes/soroban_prompt_routes.py (new) 4 endpoints under /api/prompts/soroban/: GET /api/prompts/soroban — list all templates GET /api/prompts/soroban/<id> — get template metadata POST /api/prompts/soroban/build — build prompt text only (no AI call) POST /api/prompts/soroban/execute — build + execute via Gemini, persists to chat history, validates session ownership ### server/start.py Registered soroban_prompts_bp blueprint ### server/tests/test_soroban_prompts.py (new) 33 tests covering all components ## Results Tests: 142 passed, 0 failed (33 new + all existing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #54
Adds 4 prebuilt Soroban-specific AI prompt templates that produce focused, domain-specific results — far better than generic AI prompts for Stellar/Soroban development.
What was added
server/utils/soroban_prompts.py(new)4 prompt templates with carefully engineered system prompts:
generate_contractexplain_contractgenerate_testssecurity_reviewEach prompt is purpose-built for Soroban:
generate_contract— produces completesrc/lib.rswith#[contract],#[contractimpl], typedDataKey,require_auth(), and#[cfg(test)]explain_contract— covers purpose, storage, functions, auth, events, limitationsgenerate_tests— usestestutils::Address,mock_all_auths(), happy + failure pathssecurity_review— 10-point checklist with severity ratings (Critical/High/Medium/Low)Functions:
list_prompt_templates(),get_prompt_template(id),build_soroban_prompt(id, description, context_code)server/routes/soroban_prompt_routes.py(new)4 endpoints under
/api/prompts/soroban/:GET /api/prompts/soroban— list all templates with metadataGET /api/prompts/soroban/<id>— get single template; 404 returns available listPOST /api/prompts/soroban/build— builds full prompt text without AI call (for frontend preview)POST /api/prompts/soroban/execute— builds prompt + calls Gemini, persists result to chat history viaadd_chat_message, validates session ownershipserver/start.pyRegistered
soroban_prompts_bpblueprintserver/tests/test_soroban_prompts.py(new)33 tests covering all components
Results