holoscript 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- holoscript-1.0.0/.gitignore +47 -0
- holoscript-1.0.0/PKG-INFO +113 -0
- holoscript-1.0.0/README.md +80 -0
- holoscript-1.0.0/holoscript/__init__.py +48 -0
- holoscript-1.0.0/holoscript/client.py +266 -0
- holoscript-1.0.0/holoscript/generator.py +417 -0
- holoscript-1.0.0/holoscript/parser.py +241 -0
- holoscript-1.0.0/holoscript/renderer.py +132 -0
- holoscript-1.0.0/holoscript/sharer.py +134 -0
- holoscript-1.0.0/holoscript/traits.py +284 -0
- holoscript-1.0.0/holoscript/validator.py +238 -0
- holoscript-1.0.0/pyproject.toml +61 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build output
|
|
5
|
+
dist/
|
|
6
|
+
*.tsbuildinfo
|
|
7
|
+
|
|
8
|
+
# IDE
|
|
9
|
+
.idea/
|
|
10
|
+
.vscode/
|
|
11
|
+
*.swp
|
|
12
|
+
*.swo
|
|
13
|
+
|
|
14
|
+
# OS
|
|
15
|
+
.DS_Store
|
|
16
|
+
Thumbs.db
|
|
17
|
+
|
|
18
|
+
# Environment
|
|
19
|
+
.env
|
|
20
|
+
.env.local
|
|
21
|
+
.env.*.local
|
|
22
|
+
|
|
23
|
+
# Logs
|
|
24
|
+
*.log
|
|
25
|
+
npm-debug.log*
|
|
26
|
+
pnpm-debug.log*
|
|
27
|
+
|
|
28
|
+
# Test coverage
|
|
29
|
+
coverage/
|
|
30
|
+
|
|
31
|
+
# AI Workspace (Proprietary Research)
|
|
32
|
+
.ai-workspace/
|
|
33
|
+
|
|
34
|
+
# Proprietary Training Data
|
|
35
|
+
*.jsonl
|
|
36
|
+
training_audit.csv
|
|
37
|
+
synthetic_*.txt
|
|
38
|
+
scripts/data/
|
|
39
|
+
scripts/*synthetic*.py
|
|
40
|
+
scripts/*train*.py
|
|
41
|
+
scripts/inference_test.py
|
|
42
|
+
scripts/debug_gen.py
|
|
43
|
+
|
|
44
|
+
# Package manager
|
|
45
|
+
pnpm-lock.yaml
|
|
46
|
+
package-lock.json
|
|
47
|
+
yarn.lock
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: holoscript
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python bindings for HoloScript - VR scene description language
|
|
5
|
+
Project-URL: Homepage, https://holoscript.dev
|
|
6
|
+
Project-URL: Documentation, https://holoscript.dev/python
|
|
7
|
+
Project-URL: Repository, https://github.com/brianonbased-dev/Holoscript
|
|
8
|
+
Project-URL: Issues, https://github.com/brianonbased-dev/Holoscript/issues
|
|
9
|
+
Author-email: Brian X Base Team <team@holoscript.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Keywords: 3d,ar,holoscript,metaverse,scene-description,vr,xr
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Rendering
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Requires-Dist: pydantic>=2.0.0
|
|
25
|
+
Requires-Dist: requests>=2.28.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: pyodide
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# HoloScript Python Bindings
|
|
35
|
+
|
|
36
|
+
Python bindings for HoloScript - parse, validate, and generate HoloScript code from Python.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install holoscript
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from holoscript import HoloScript, parse, validate, generate
|
|
48
|
+
|
|
49
|
+
# Initialize
|
|
50
|
+
hs = HoloScript()
|
|
51
|
+
|
|
52
|
+
# Parse HoloScript code
|
|
53
|
+
ast = hs.parse("""
|
|
54
|
+
composition "My Scene" {
|
|
55
|
+
object "Crystal" @grabbable @glowing {
|
|
56
|
+
geometry: "sphere"
|
|
57
|
+
color: "#00ffff"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
""")
|
|
61
|
+
|
|
62
|
+
# Validate code
|
|
63
|
+
result = hs.validate(ast)
|
|
64
|
+
if result.valid:
|
|
65
|
+
print("✅ Valid HoloScript!")
|
|
66
|
+
else:
|
|
67
|
+
for error in result.errors:
|
|
68
|
+
print(f"❌ Line {error.line}: {error.message}")
|
|
69
|
+
|
|
70
|
+
# Generate from natural language
|
|
71
|
+
scene = hs.generate("a floating island with glowing crystals")
|
|
72
|
+
print(scene.code)
|
|
73
|
+
|
|
74
|
+
# Create shareable link
|
|
75
|
+
share = hs.share(scene.code, title="My VR Scene", platform="x")
|
|
76
|
+
print(f"Playground: {share.playground_url}")
|
|
77
|
+
print(f"Tweet: {share.tweet_text}")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Features
|
|
81
|
+
|
|
82
|
+
- **Parsing**: Parse `.hs`, `.hsplus`, and `.holo` files
|
|
83
|
+
- **Validation**: Validate syntax with AI-friendly error messages
|
|
84
|
+
- **Generation**: Generate HoloScript from natural language
|
|
85
|
+
- **Rendering**: Generate preview images/GIFs
|
|
86
|
+
- **Sharing**: Create X-optimized shareable links
|
|
87
|
+
|
|
88
|
+
## For AI Agents (Grok, etc.)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
# Grok integration example
|
|
92
|
+
from holoscript import HoloScript
|
|
93
|
+
|
|
94
|
+
hs = HoloScript(api_key="your-api-key") # Optional for remote rendering
|
|
95
|
+
|
|
96
|
+
# Generate scene from user prompt
|
|
97
|
+
user_prompt = "Create a VR scene with a floating castle"
|
|
98
|
+
scene = hs.generate(user_prompt)
|
|
99
|
+
|
|
100
|
+
# Validate
|
|
101
|
+
if hs.validate(scene.code).valid:
|
|
102
|
+
# Create shareable preview
|
|
103
|
+
preview = hs.render(scene.code, format="gif", duration=3000)
|
|
104
|
+
share = hs.share(scene.code, title="Floating Castle", platform="x")
|
|
105
|
+
|
|
106
|
+
# Return to user
|
|
107
|
+
print(f"Here's your VR scene: {share.playground_url}")
|
|
108
|
+
print(f"Preview: {preview.url}")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API Reference
|
|
112
|
+
|
|
113
|
+
See [full documentation](https://holoscript.dev/python) for complete API reference.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# HoloScript Python Bindings
|
|
2
|
+
|
|
3
|
+
Python bindings for HoloScript - parse, validate, and generate HoloScript code from Python.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install holoscript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from holoscript import HoloScript, parse, validate, generate
|
|
15
|
+
|
|
16
|
+
# Initialize
|
|
17
|
+
hs = HoloScript()
|
|
18
|
+
|
|
19
|
+
# Parse HoloScript code
|
|
20
|
+
ast = hs.parse("""
|
|
21
|
+
composition "My Scene" {
|
|
22
|
+
object "Crystal" @grabbable @glowing {
|
|
23
|
+
geometry: "sphere"
|
|
24
|
+
color: "#00ffff"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
""")
|
|
28
|
+
|
|
29
|
+
# Validate code
|
|
30
|
+
result = hs.validate(ast)
|
|
31
|
+
if result.valid:
|
|
32
|
+
print("✅ Valid HoloScript!")
|
|
33
|
+
else:
|
|
34
|
+
for error in result.errors:
|
|
35
|
+
print(f"❌ Line {error.line}: {error.message}")
|
|
36
|
+
|
|
37
|
+
# Generate from natural language
|
|
38
|
+
scene = hs.generate("a floating island with glowing crystals")
|
|
39
|
+
print(scene.code)
|
|
40
|
+
|
|
41
|
+
# Create shareable link
|
|
42
|
+
share = hs.share(scene.code, title="My VR Scene", platform="x")
|
|
43
|
+
print(f"Playground: {share.playground_url}")
|
|
44
|
+
print(f"Tweet: {share.tweet_text}")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Parsing**: Parse `.hs`, `.hsplus`, and `.holo` files
|
|
50
|
+
- **Validation**: Validate syntax with AI-friendly error messages
|
|
51
|
+
- **Generation**: Generate HoloScript from natural language
|
|
52
|
+
- **Rendering**: Generate preview images/GIFs
|
|
53
|
+
- **Sharing**: Create X-optimized shareable links
|
|
54
|
+
|
|
55
|
+
## For AI Agents (Grok, etc.)
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
# Grok integration example
|
|
59
|
+
from holoscript import HoloScript
|
|
60
|
+
|
|
61
|
+
hs = HoloScript(api_key="your-api-key") # Optional for remote rendering
|
|
62
|
+
|
|
63
|
+
# Generate scene from user prompt
|
|
64
|
+
user_prompt = "Create a VR scene with a floating castle"
|
|
65
|
+
scene = hs.generate(user_prompt)
|
|
66
|
+
|
|
67
|
+
# Validate
|
|
68
|
+
if hs.validate(scene.code).valid:
|
|
69
|
+
# Create shareable preview
|
|
70
|
+
preview = hs.render(scene.code, format="gif", duration=3000)
|
|
71
|
+
share = hs.share(scene.code, title="Floating Castle", platform="x")
|
|
72
|
+
|
|
73
|
+
# Return to user
|
|
74
|
+
print(f"Here's your VR scene: {share.playground_url}")
|
|
75
|
+
print(f"Preview: {preview.url}")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API Reference
|
|
79
|
+
|
|
80
|
+
See [full documentation](https://holoscript.dev/python) for complete API reference.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HoloScript Python Bindings
|
|
3
|
+
|
|
4
|
+
Parse, validate, generate, and render HoloScript code from Python.
|
|
5
|
+
Perfect for AI agents like Grok to build VR experiences.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from holoscript.client import HoloScript
|
|
9
|
+
from holoscript.parser import parse, parse_holo, parse_hsplus
|
|
10
|
+
from holoscript.validator import validate, ValidationResult, ValidationError
|
|
11
|
+
from holoscript.generator import generate, generate_object, generate_scene
|
|
12
|
+
from holoscript.renderer import render, RenderResult
|
|
13
|
+
from holoscript.sharer import share, ShareResult
|
|
14
|
+
from holoscript.traits import list_traits, explain_trait, suggest_traits
|
|
15
|
+
|
|
16
|
+
__version__ = "1.0.0"
|
|
17
|
+
__all__ = [
|
|
18
|
+
# Main client
|
|
19
|
+
"HoloScript",
|
|
20
|
+
|
|
21
|
+
# Parsing
|
|
22
|
+
"parse",
|
|
23
|
+
"parse_holo",
|
|
24
|
+
"parse_hsplus",
|
|
25
|
+
|
|
26
|
+
# Validation
|
|
27
|
+
"validate",
|
|
28
|
+
"ValidationResult",
|
|
29
|
+
"ValidationError",
|
|
30
|
+
|
|
31
|
+
# Generation
|
|
32
|
+
"generate",
|
|
33
|
+
"generate_object",
|
|
34
|
+
"generate_scene",
|
|
35
|
+
|
|
36
|
+
# Rendering
|
|
37
|
+
"render",
|
|
38
|
+
"RenderResult",
|
|
39
|
+
|
|
40
|
+
# Sharing
|
|
41
|
+
"share",
|
|
42
|
+
"ShareResult",
|
|
43
|
+
|
|
44
|
+
# Traits
|
|
45
|
+
"list_traits",
|
|
46
|
+
"explain_trait",
|
|
47
|
+
"suggest_traits",
|
|
48
|
+
]
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HoloScript Client - Main interface for HoloScript operations.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional, Dict, Any, List
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from holoscript.parser import parse, parse_holo, parse_hsplus, ParseResult
|
|
9
|
+
from holoscript.validator import validate, ValidationResult
|
|
10
|
+
from holoscript.generator import generate_object, generate_scene, GenerateResult
|
|
11
|
+
from holoscript.renderer import render, RenderResult
|
|
12
|
+
from holoscript.sharer import share, ShareResult
|
|
13
|
+
from holoscript.traits import list_traits, explain_trait, suggest_traits
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HoloScript:
|
|
17
|
+
"""
|
|
18
|
+
Main HoloScript client for AI agents and Python applications.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
>>> hs = HoloScript()
|
|
22
|
+
>>> scene = hs.generate("a glowing crystal in a dark cave")
|
|
23
|
+
>>> if hs.validate(scene.code).valid:
|
|
24
|
+
... share = hs.share(scene.code, platform="x")
|
|
25
|
+
... print(share.playground_url)
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
DEFAULT_API_URL = "https://api.holoscript.dev"
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
api_key: Optional[str] = None,
|
|
33
|
+
api_url: Optional[str] = None,
|
|
34
|
+
local_mode: bool = False
|
|
35
|
+
):
|
|
36
|
+
"""
|
|
37
|
+
Initialize HoloScript client.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
api_key: Optional API key for remote rendering/services
|
|
41
|
+
api_url: Custom API URL (defaults to https://api.holoscript.dev)
|
|
42
|
+
local_mode: If True, use local parsing only (no remote calls)
|
|
43
|
+
"""
|
|
44
|
+
self.api_key = api_key
|
|
45
|
+
self.api_url = api_url or self.DEFAULT_API_URL
|
|
46
|
+
self.local_mode = local_mode
|
|
47
|
+
|
|
48
|
+
self._session = requests.Session()
|
|
49
|
+
if api_key:
|
|
50
|
+
self._session.headers["Authorization"] = f"Bearer {api_key}"
|
|
51
|
+
|
|
52
|
+
# === Parsing ===
|
|
53
|
+
|
|
54
|
+
def parse(self, code: str, format: str = "auto") -> ParseResult:
|
|
55
|
+
"""
|
|
56
|
+
Parse HoloScript code into an AST.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
code: HoloScript source code
|
|
60
|
+
format: Format hint - "hs", "hsplus", "holo", or "auto"
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
ParseResult with AST and any errors
|
|
64
|
+
"""
|
|
65
|
+
if format == "holo" or (format == "auto" and "composition" in code):
|
|
66
|
+
return parse_holo(code)
|
|
67
|
+
else:
|
|
68
|
+
return parse_hsplus(code)
|
|
69
|
+
|
|
70
|
+
# === Validation ===
|
|
71
|
+
|
|
72
|
+
def validate(
|
|
73
|
+
self,
|
|
74
|
+
code: str,
|
|
75
|
+
include_warnings: bool = True,
|
|
76
|
+
include_suggestions: bool = True
|
|
77
|
+
) -> ValidationResult:
|
|
78
|
+
"""
|
|
79
|
+
Validate HoloScript code for errors.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
code: HoloScript source code or ParseResult
|
|
83
|
+
include_warnings: Include warnings in result
|
|
84
|
+
include_suggestions: Include fix suggestions
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
ValidationResult with errors, warnings, and suggestions
|
|
88
|
+
"""
|
|
89
|
+
return validate(
|
|
90
|
+
code,
|
|
91
|
+
include_warnings=include_warnings,
|
|
92
|
+
include_suggestions=include_suggestions
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# === Generation ===
|
|
96
|
+
|
|
97
|
+
def generate(
|
|
98
|
+
self,
|
|
99
|
+
description: str,
|
|
100
|
+
format: str = "holo",
|
|
101
|
+
style: str = "detailed"
|
|
102
|
+
) -> GenerateResult:
|
|
103
|
+
"""
|
|
104
|
+
Generate HoloScript code from natural language.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
description: Natural language description of the scene
|
|
108
|
+
format: Output format - "hs", "hsplus", or "holo"
|
|
109
|
+
style: Style - "minimal", "detailed", or "production"
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
GenerateResult with code and metadata
|
|
113
|
+
"""
|
|
114
|
+
return generate_scene(description, format=format, style=style)
|
|
115
|
+
|
|
116
|
+
def generate_object(
|
|
117
|
+
self,
|
|
118
|
+
description: str,
|
|
119
|
+
format: str = "hsplus"
|
|
120
|
+
) -> GenerateResult:
|
|
121
|
+
"""
|
|
122
|
+
Generate a single object from description.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
description: Natural language description of the object
|
|
126
|
+
format: Output format
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
GenerateResult with object code
|
|
130
|
+
"""
|
|
131
|
+
return generate_object(description, format=format)
|
|
132
|
+
|
|
133
|
+
# === Rendering ===
|
|
134
|
+
|
|
135
|
+
def render(
|
|
136
|
+
self,
|
|
137
|
+
code: str,
|
|
138
|
+
format: str = "png",
|
|
139
|
+
resolution: tuple = (800, 600),
|
|
140
|
+
camera_position: tuple = (0, 2, 5),
|
|
141
|
+
duration: int = 3000,
|
|
142
|
+
quality: str = "preview"
|
|
143
|
+
) -> RenderResult:
|
|
144
|
+
"""
|
|
145
|
+
Render HoloScript code to an image or video.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
code: HoloScript source code
|
|
149
|
+
format: Output format - "png", "gif", "mp4", "webp"
|
|
150
|
+
resolution: (width, height) tuple
|
|
151
|
+
camera_position: (x, y, z) camera position
|
|
152
|
+
duration: Animation duration in ms (for gif/mp4)
|
|
153
|
+
quality: "draft", "preview", or "production"
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
RenderResult with URL or base64 data
|
|
157
|
+
"""
|
|
158
|
+
return render(
|
|
159
|
+
code,
|
|
160
|
+
format=format,
|
|
161
|
+
resolution=resolution,
|
|
162
|
+
camera_position=camera_position,
|
|
163
|
+
duration=duration,
|
|
164
|
+
quality=quality,
|
|
165
|
+
api_url=self.api_url if not self.local_mode else None,
|
|
166
|
+
api_key=self.api_key
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# === Sharing ===
|
|
170
|
+
|
|
171
|
+
def share(
|
|
172
|
+
self,
|
|
173
|
+
code: str,
|
|
174
|
+
title: str = "HoloScript Scene",
|
|
175
|
+
description: str = "Interactive 3D scene built with HoloScript",
|
|
176
|
+
platform: str = "x"
|
|
177
|
+
) -> ShareResult:
|
|
178
|
+
"""
|
|
179
|
+
Create shareable links for the code.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
code: HoloScript source code
|
|
183
|
+
title: Scene title
|
|
184
|
+
description: Scene description
|
|
185
|
+
platform: Target platform - "x", "generic", "codesandbox", "stackblitz"
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
ShareResult with URLs and embed codes
|
|
189
|
+
"""
|
|
190
|
+
return share(
|
|
191
|
+
code,
|
|
192
|
+
title=title,
|
|
193
|
+
description=description,
|
|
194
|
+
platform=platform
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
# === Traits ===
|
|
198
|
+
|
|
199
|
+
def list_traits(self, category: Optional[str] = None) -> Dict[str, List[str]]:
|
|
200
|
+
"""
|
|
201
|
+
List available VR traits.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
category: Filter by category (interaction, physics, visual, etc.)
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
Dictionary of traits by category
|
|
208
|
+
"""
|
|
209
|
+
return list_traits(category)
|
|
210
|
+
|
|
211
|
+
def explain_trait(self, trait: str) -> Dict[str, Any]:
|
|
212
|
+
"""
|
|
213
|
+
Get detailed documentation for a trait.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
trait: Trait name (with or without @)
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
Trait documentation dictionary
|
|
220
|
+
"""
|
|
221
|
+
return explain_trait(trait)
|
|
222
|
+
|
|
223
|
+
def suggest_traits(
|
|
224
|
+
self,
|
|
225
|
+
description: str,
|
|
226
|
+
context: Optional[str] = None
|
|
227
|
+
) -> Dict[str, Any]:
|
|
228
|
+
"""
|
|
229
|
+
Suggest appropriate traits for an object.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
description: Object description
|
|
233
|
+
context: Additional context
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
Suggested traits with reasoning
|
|
237
|
+
"""
|
|
238
|
+
return suggest_traits(description, context)
|
|
239
|
+
|
|
240
|
+
# === Utility ===
|
|
241
|
+
|
|
242
|
+
def quick_test(self, code: str) -> Dict[str, Any]:
|
|
243
|
+
"""
|
|
244
|
+
Quick test: parse, validate, and return summary.
|
|
245
|
+
|
|
246
|
+
Args:
|
|
247
|
+
code: HoloScript source code
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
Dictionary with parse result, validation, and stats
|
|
251
|
+
"""
|
|
252
|
+
parse_result = self.parse(code)
|
|
253
|
+
validation = self.validate(code)
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
"parsed": parse_result.success,
|
|
257
|
+
"valid": validation.valid,
|
|
258
|
+
"errors": validation.errors,
|
|
259
|
+
"warnings": validation.warnings,
|
|
260
|
+
"stats": {
|
|
261
|
+
"lines": len(code.split("\n")),
|
|
262
|
+
"characters": len(code),
|
|
263
|
+
"objects": len(parse_result.objects) if hasattr(parse_result, "objects") else 0,
|
|
264
|
+
"traits": len(parse_result.traits) if hasattr(parse_result, "traits") else 0,
|
|
265
|
+
}
|
|
266
|
+
}
|