refactor(semantics): migrate TIER system to adaptive COMPLEXITY 1-5 scale
- Replaced rigid TIERs with continuous COMPLEXITY 1-5 scale in semantics.md - Updated generate_semantic_map.py to parse and score based on Complexity - Added backward compatibility mapping for legacy TIERs - Migrated all .ai/shots examples to use @COMPLEXITY and updated relation syntax - Added trivial_utility.py shot to demonstrate implicit Complexity 1 token savings
This commit is contained in:
40
.ai/shots/trivial_utility.py
Normal file
40
.ai/shots/trivial_utility.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# [DEF:TrivialUtilityShot:Module]
|
||||
# @COMPLEXITY: 1
|
||||
# @PURPOSE: Reference implementation of a zero-overhead utility using implicit Complexity 1.
|
||||
|
||||
import re
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional
|
||||
|
||||
# [DEF:slugify:Function]
|
||||
# @PURPOSE: Converts a string to a URL-safe slug.
|
||||
def slugify(text: str) -> str:
|
||||
if not text:
|
||||
return ""
|
||||
text = text.lower().strip()
|
||||
text = re.sub(r'[^\w\s-]', '', text)
|
||||
return re.sub(r'[-\s]+', '-', text)
|
||||
# [/DEF:slugify:Function]
|
||||
|
||||
# [DEF:get_utc_now:Function]
|
||||
def get_utc_now() -> datetime:
|
||||
"""Returns current UTC datetime (purpose is omitted because it's obvious)."""
|
||||
return datetime.now(timezone.utc)
|
||||
# [/DEF:get_utc_now:Function]
|
||||
|
||||
# [DEF:PaginationDTO:Class]
|
||||
class PaginationDTO:
|
||||
# [DEF:__init__:Function]
|
||||
def __init__(self, page: int = 1, size: int = 50):
|
||||
self.page = max(1, page)
|
||||
self.size = min(max(1, size), 1000)
|
||||
# [/DEF:__init__:Function]
|
||||
|
||||
# [DEF:offset:Function]
|
||||
@property
|
||||
def offset(self) -> int:
|
||||
return (self.page - 1) * self.size
|
||||
# [/DEF:offset:Function]
|
||||
# [/DEF:PaginationDTO:Class]
|
||||
|
||||
# [/DEF:TrivialUtilityShot:Module]
|
||||
Reference in New Issue
Block a user