Analyze a sample Python project for bugs, security issues, and quality improvements.
Uses CodeAnalysisPrompt — a TOON-aware prompt builder that understands the compact
notation and produces structured findings with file/line references.
from toonic.server.quick import run
run("./examples/code-analysis/sample-project/", goal="find bugs, security issues, suggest improvements", interval=0)from toonic.server.quick import watch
server = (
watch()
.code("./examples/code-analysis/sample-project/")
.goal("find bugs, security issues, suggest improvements")
.interval(0) # one-shot
.build()
)python -m toonic.server \
--source file:./examples/code-analysis/sample-project/ \
--goal "find bugs, security issues, and suggest improvements" \
--interval 0# Re-analyze every 60s — detects file changes via delta TOON
python -m toonic.server \
--source file:./examples/code-analysis/sample-project/ \
--goal "code review: find bugs, security issues, suggest improvements" \
--interval 60
# Combine with log monitoring for full-stack analysis
python -m toonic.server \
--source file:./examples/code-analysis/sample-project/ \
--source log:./app.log \
--goal "correlate code issues with runtime errors" \
--interval 30python -m toonic.server.client
toonic> status
toonic> analyze find all security vulnerabilities
toonic> convert examples/code-analysis/sample-project/main.py toon
toonic> history 10
toonic> query "findings with high severity"
toonic> sql SELECT target_path, content FROM exchanges WHERE action_type='code_fix'- FileWatcher scans
sample-project/and converts to TOON format - LLM Pipeline auto-selects
CodeAnalysisPrompt(detects code category + goal keywords) CodeAnalysisPromptbuilds TOON-aware prompt: explains M/c/f/m/i/e notation to LLM- LLM returns structured JSON with
findings[]— file, line, severity, description, fix - ResponseParser extracts JSON from markdown fences or raw response
- Results stored in
toonic_data/history.dband shown in Web UI
The select_prompt_builder() function auto-selects based on goal + data categories:
| Condition | Builder | Optimized for |
|---|---|---|
| Video sources + CCTV keywords | CCTVEventPrompt |
Event analysis |
| Code/config sources or code keywords | CodeAnalysisPrompt |
TOON-aware code review |
| Everything else | GenericPrompt |
General analysis |
The sample project has intentional issues:
- Bug:
deactivate_user()— no existence check, KeyError on missing user - Bug:
create_order()— no validation ontotal, could be negative - Security:
process_payment()— hardcoded API key - Performance:
get_orders()— O(n) linear scan instead of indexed lookup
README.md— this filesample-project/main.py— Python code with intentional bugssample-project/config.py— Config file with hardcoded secrets