god-code 0.1.0__tar.gz → 0.1.1__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.
Files changed (82) hide show
  1. god_code-0.1.1/.github/workflows/publish.yml +34 -0
  2. god_code-0.1.1/CLAUDE.md +215 -0
  3. {god_code-0.1.0 → god_code-0.1.1}/PKG-INFO +2 -2
  4. {god_code-0.1.0 → god_code-0.1.1}/pyproject.toml +2 -2
  5. {god_code-0.1.0 → god_code-0.1.1}/.gitignore +0 -0
  6. {god_code-0.1.0 → god_code-0.1.1}/CHANGELOG.md +0 -0
  7. {god_code-0.1.0 → god_code-0.1.1}/CONTRIBUTING.md +0 -0
  8. {god_code-0.1.0 → god_code-0.1.1}/LICENSE +0 -0
  9. {god_code-0.1.0 → god_code-0.1.1}/README.md +0 -0
  10. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/__init__.py +0 -0
  11. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/cli.py +0 -0
  12. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/__init__.py +0 -0
  13. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/collision_planner.py +0 -0
  14. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/consistency_checker.py +0 -0
  15. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/dependency_graph.py +0 -0
  16. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/gdscript_linter.py +0 -0
  17. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/pattern_advisor.py +0 -0
  18. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/project.py +0 -0
  19. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/resource_validator.py +0 -0
  20. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/scene_parser.py +0 -0
  21. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/scene_writer.py +0 -0
  22. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/godot/tscn_validator.py +0 -0
  23. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/llm/__init__.py +0 -0
  24. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/llm/client.py +0 -0
  25. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/llm/streaming.py +0 -0
  26. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/llm/vision.py +0 -0
  27. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/prompts/__init__.py +0 -0
  28. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/prompts/build_discipline.py +0 -0
  29. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/prompts/godot_playbook.py +0 -0
  30. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/prompts/knowledge_selector.py +0 -0
  31. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/prompts/system.py +0 -0
  32. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/py.typed +0 -0
  33. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/__init__.py +0 -0
  34. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/auth.py +0 -0
  35. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/config.py +0 -0
  36. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/context_manager.py +0 -0
  37. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/engine.py +0 -0
  38. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/error_loop.py +0 -0
  39. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/oauth.py +0 -0
  40. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/runtime/session.py +0 -0
  41. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/__init__.py +0 -0
  42. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/base.py +0 -0
  43. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/file_ops.py +0 -0
  44. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/git.py +0 -0
  45. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/godot_cli.py +0 -0
  46. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/list_dir.py +0 -0
  47. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/registry.py +0 -0
  48. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/screenshot.py +0 -0
  49. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/search.py +0 -0
  50. {god_code-0.1.0 → god_code-0.1.1}/godot_agent/tools/shell.py +0 -0
  51. {god_code-0.1.0 → god_code-0.1.1}/tests/__init__.py +0 -0
  52. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/__init__.py +0 -0
  53. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_collision_planner.py +0 -0
  54. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_consistency.py +0 -0
  55. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_dependency_graph.py +0 -0
  56. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_linter.py +0 -0
  57. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_pattern_advisor.py +0 -0
  58. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_project.py +0 -0
  59. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_resource_validator.py +0 -0
  60. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_scene_parser.py +0 -0
  61. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_scene_writer.py +0 -0
  62. {god_code-0.1.0 → god_code-0.1.1}/tests/godot/test_tscn_validator.py +0 -0
  63. {god_code-0.1.0 → god_code-0.1.1}/tests/llm/__init__.py +0 -0
  64. {god_code-0.1.0 → god_code-0.1.1}/tests/llm/test_client.py +0 -0
  65. {god_code-0.1.0 → god_code-0.1.1}/tests/llm/test_vision.py +0 -0
  66. {god_code-0.1.0 → god_code-0.1.1}/tests/prompts/__init__.py +0 -0
  67. {god_code-0.1.0 → god_code-0.1.1}/tests/prompts/test_knowledge_selector.py +0 -0
  68. {god_code-0.1.0 → god_code-0.1.1}/tests/prompts/test_system_prompt.py +0 -0
  69. {god_code-0.1.0 → god_code-0.1.1}/tests/runtime/__init__.py +0 -0
  70. {god_code-0.1.0 → god_code-0.1.1}/tests/runtime/test_config.py +0 -0
  71. {god_code-0.1.0 → god_code-0.1.1}/tests/runtime/test_context_manager.py +0 -0
  72. {god_code-0.1.0 → god_code-0.1.1}/tests/runtime/test_engine.py +0 -0
  73. {god_code-0.1.0 → god_code-0.1.1}/tests/runtime/test_error_loop.py +0 -0
  74. {god_code-0.1.0 → god_code-0.1.1}/tests/test_e2e.py +0 -0
  75. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/__init__.py +0 -0
  76. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_file_ops.py +0 -0
  77. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_git.py +0 -0
  78. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_godot_cli.py +0 -0
  79. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_list_dir.py +0 -0
  80. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_registry.py +0 -0
  81. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_search.py +0 -0
  82. {god_code-0.1.0 → god_code-0.1.1}/tests/tools/test_shell.py +0 -0
@@ -0,0 +1,34 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install -e ".[dev]"
17
+ - run: python -m pytest tests/ -v
18
+
19
+ publish:
20
+ needs: test
21
+ runs-on: ubuntu-latest
22
+ permissions:
23
+ id-token: write
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.12"
29
+ - run: pip install build twine
30
+ - run: python -m build
31
+ - run: twine upload dist/*
32
+ env:
33
+ TWINE_USERNAME: __token__
34
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,215 @@
1
+ # CLAUDE.md — God Code Development Guide
2
+
3
+ > AI coding agent specialized for Godot 4.4 game development. This file guides Claude Code when working on the god-code codebase itself.
4
+
5
+ ## Project Identity
6
+
7
+ **god-code** — a Python CLI agent that understands GDScript, .tscn scenes, collision layers, and Godot architecture patterns. It calls LLM APIs with Godot-specific tools and enforces incremental build-and-verify discipline.
8
+
9
+ **PyPI**: `pip install god-code`
10
+ **GitHub**: https://github.com/888wing/god-code
11
+ **License**: GPL-3.0
12
+
13
+ ## Tech Stack
14
+
15
+ - **Language**: Python 3.12+
16
+ - **CLI**: click
17
+ - **HTTP**: httpx (async)
18
+ - **Models**: pydantic v2 (tool schemas, config)
19
+ - **Image**: Pillow (screenshot encoding)
20
+ - **Test**: pytest + pytest-asyncio
21
+ - **Build**: hatchling
22
+ - **CI**: GitHub Actions (auto-publish to PyPI on tag)
23
+
24
+ ## Current Version: 0.1.0
25
+
26
+ **Completed**: CLI (ask/chat/info/setup/login/logout/status), 10 tools, LLM client with OpenAI-compatible API, Godot Playbook knowledge system (17 sections), .tscn parser/writer/validator, GDScript linter, collision planner, dependency graph, pattern advisor, consistency checker, error loop, context manager, first-run setup wizard, PyPI published.
27
+
28
+ **157 tests**, ~4,000 lines production code.
29
+
30
+ ## Architecture
31
+
32
+ ```
33
+ godot_agent/
34
+ ├── cli.py # Click CLI entry point + setup wizard
35
+ ├── runtime/
36
+ │ ├── engine.py # Conversation loop (tool calling + context compaction + error loop)
37
+ │ ├── config.py # AgentConfig (pydantic) + load from file/env
38
+ │ ├── session.py # Session persistence (.agent_sessions/*.json)
39
+ │ ├── oauth.py # Codex refresh token flow
40
+ │ ├── error_loop.py # Godot output parsing + fix suggestions
41
+ │ ├── context_manager.py # Message compaction + file relevance scoring
42
+ │ └── auth.py # AuthContext dataclass
43
+ ├── llm/
44
+ │ ├── client.py # LLMClient (OpenAI-compatible, retry, content filter handling)
45
+ │ ├── streaming.py # SSE streaming
46
+ │ └── vision.py # Image → base64 encoding
47
+ ├── tools/ # 10 function-calling tools
48
+ │ ├── base.py # BaseTool ABC + ToolResult
49
+ │ ├── registry.py # ToolRegistry (register, execute, to_openai_tools)
50
+ │ ├── file_ops.py # read_file, write_file, edit_file (path-contained)
51
+ │ ├── search.py # grep, glob
52
+ │ ├── list_dir.py # list_dir
53
+ │ ├── git.py # git (shlex-parsed)
54
+ │ ├── shell.py # run_shell (blocked patterns)
55
+ │ ├── godot_cli.py # run_godot (GUT, validate, output parser)
56
+ │ └── screenshot.py # screenshot_scene (headless)
57
+ ├── godot/ # Godot-specific analysis
58
+ │ ├── project.py # project.godot parser → GodotProject
59
+ │ ├── scene_parser.py # .tscn → TscnScene (nodes, resources, connections)
60
+ │ ├── scene_writer.py # add_node, set_property, remove_node, add_connection
61
+ │ ├── tscn_validator.py # Format validation + auto-fix ordering
62
+ │ ├── gdscript_linter.py # Naming, ordering, type annotations, anti-patterns
63
+ │ ├── collision_planner.py # Standard 8-layer scheme
64
+ │ ├── consistency_checker.py # Cross-file collision/signal/resource/group checks
65
+ │ ├── dependency_graph.py # Project-wide scene→script→resource graph
66
+ │ ├── pattern_advisor.py # Object pool, component, state machine suggestions
67
+ │ └── resource_validator.py # res:// path existence check
68
+ └── prompts/
69
+ ├── system.py # Builds system prompt (identity + knowledge + discipline + context)
70
+ ├── godot_playbook.py # 17 indexed knowledge sections
71
+ ├── knowledge_selector.py # Context-aware section scoring + injection
72
+ └── build_discipline.py # Incremental build-and-verify rules
73
+ ```
74
+
75
+ ## Key Patterns
76
+
77
+ ### Tool System
78
+ Every tool inherits `BaseTool` with pydantic `Input`/`Output` models. The registry auto-generates OpenAI function calling schemas.
79
+
80
+ ```python
81
+ class MyTool(BaseTool):
82
+ name = "my_tool"
83
+ description = "Does something"
84
+ class Input(BaseModel):
85
+ param: str = Field(description="...")
86
+ class Output(BaseModel):
87
+ result: str
88
+ async def execute(self, input: Input) -> ToolResult:
89
+ return ToolResult(output=self.Output(result="done"))
90
+ ```
91
+
92
+ Register in `cli.py:build_registry()`.
93
+
94
+ ### Path Containment
95
+ `file_ops.py` has a module-level `_project_root` set by CLI on startup. All read/write/edit operations validate paths are within project root. `set_project_root()` is called in `build_engine()`.
96
+
97
+ ### Engine Flow
98
+ ```
99
+ user message → _maybe_compact() → client.chat() → tool_calls?
100
+ → yes: execute tools → _post_tool_validate() → loop
101
+ → no: return content
102
+ ```
103
+ - Compaction triggers at ~80K estimated tokens
104
+ - Post-tool validation runs `godot --headless --quit` after write_file/edit_file
105
+ - Max tool rounds default: 20
106
+
107
+ ### Knowledge Injection
108
+ `knowledge_selector.py` scores Playbook sections by keyword overlap with user prompt + file extensions. Top 4 sections injected (~2K tokens instead of full ~15K).
109
+
110
+ ### Error Loop Integration
111
+ After any file-mutating tool call, engine runs Godot headless validation. If errors found, injects a system message telling the LLM to fix them before proceeding.
112
+
113
+ ## Development Rules
114
+
115
+ ### CRITICAL: Read Before Modify
116
+ Never modify files without reading them first. This applies to both god-code source AND Godot project files the agent operates on.
117
+
118
+ ### Adding a New Tool
119
+ 1. Create `godot_agent/tools/your_tool.py` inheriting `BaseTool`
120
+ 2. Define `Input` and `Output` as pydantic `BaseModel`
121
+ 3. Implement `async execute()`
122
+ 4. Register in `cli.py:build_registry()`
123
+ 5. Add tests in `tests/tools/test_your_tool.py`
124
+ 6. Update README tool list
125
+
126
+ ### Adding Godot Knowledge
127
+ Edit `godot_agent/prompts/godot_playbook.py`:
128
+ - Each section: `(title, [keywords], content_string)`
129
+ - Keywords drive auto-selection in `knowledge_selector.py`
130
+ - Keep sections concise (~200 tokens each)
131
+
132
+ ### Adding Godot Analysis
133
+ New analyzers go in `godot_agent/godot/`. Follow existing patterns:
134
+ - Pure functions, no side effects
135
+ - Return structured dataclasses
136
+ - Include `format_*()` for LLM-readable output
137
+
138
+ ### Config
139
+ `~/.config/god-code/config.json` with `GODOT_AGENT_*` env overrides:
140
+
141
+ | Field | Default | Env Var |
142
+ |-------|---------|---------|
143
+ | api_key | "" | GODOT_AGENT_API_KEY |
144
+ | base_url | https://api.openai.com/v1 | GODOT_AGENT_BASE_URL |
145
+ | model | gpt-5.4 | GODOT_AGENT_MODEL |
146
+ | godot_path | godot | GODOT_AGENT_GODOT_PATH |
147
+ | oauth_token | null | GODOT_AGENT_OAUTH_TOKEN |
148
+
149
+ OAuth client_id configurable via `GODOT_AGENT_OAUTH_CLIENT_ID`.
150
+
151
+ ## Testing
152
+
153
+ ```bash
154
+ # Full suite (157 tests)
155
+ python -m pytest tests/ -v
156
+
157
+ # Specific module
158
+ python -m pytest tests/godot/test_tscn_validator.py -v
159
+
160
+ # E2E with mocked LLM
161
+ python -m pytest tests/test_e2e.py -v
162
+ ```
163
+
164
+ All tests use `tmp_path` fixture for isolation. LLM tests mock `httpx` responses. No real API calls in tests.
165
+
166
+ ## Release Process
167
+
168
+ Automated via GitHub Actions:
169
+
170
+ ```bash
171
+ # 1. Bump version in pyproject.toml
172
+ # 2. Commit + tag
173
+ git commit -am "release: v0.2.0"
174
+ git tag v0.2.0
175
+ git push && git push --tags
176
+ # → GitHub Actions runs tests → publishes to PyPI
177
+ ```
178
+
179
+ Requires `PYPI_API_TOKEN` in GitHub repo secrets.
180
+
181
+ ## Security Model
182
+
183
+ - **File ops**: Restricted to project root (symlink-aware)
184
+ - **Shell**: Blocked patterns (rm -rf /, sudo, curl|sh, etc.)
185
+ - **Git**: shlex.split() for proper argument parsing
186
+ - **API keys**: Stored with 600 permissions, masked in CLI output
187
+ - **Content filter**: 400 errors retried, graceful fallback message
188
+
189
+ ## Roadmap
190
+
191
+ ### Phase 2: Editor Plugin Bridge
192
+ - Godot EditorPlugin with WebSocket server
193
+ - `editor_bridge.py` Python WebSocket client
194
+ - Tier 1 operations: scene tree, properties, signals, run/stop game
195
+ - Live viewport screenshots from editor
196
+
197
+ ### Phase 3: Hosted API
198
+ - Cloudflare Worker proxy with Google OAuth
199
+ - Free tier (50 req/day, gpt-4o-mini)
200
+ - Pro tier ($12/mo, gpt-5.4 + vision)
201
+ - Small model routing for simple tasks
202
+ - Prompt caching for session continuity
203
+
204
+ ## Key Files
205
+
206
+ | File | Purpose |
207
+ |------|---------|
208
+ | `pyproject.toml` | Package metadata, version, dependencies |
209
+ | `CHANGELOG.md` | Version history |
210
+ | `README.md` | User-facing documentation |
211
+ | `CONTRIBUTING.md` | Contributor guide |
212
+ | `.github/workflows/publish.yml` | Auto-publish to PyPI on tag |
213
+ | `godot_agent/cli.py` | CLI commands + setup wizard |
214
+ | `godot_agent/runtime/engine.py` | Core conversation loop |
215
+ | `godot_agent/prompts/godot_playbook.py` | Godot knowledge base |
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: god-code
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: AI coding agent specialized for Godot game development
5
5
  Project-URL: Homepage, https://github.com/chuisiufai/god-code
6
6
  Project-URL: Repository, https://github.com/chuisiufai/god-code
7
7
  Author: chuisiufai
8
8
  License: GPL-3.0-or-later
9
9
  License-File: LICENSE
10
- Requires-Python: >=3.12
10
+ Requires-Python: >=3.10
11
11
  Requires-Dist: click>=8.1
12
12
  Requires-Dist: httpx>=0.27
13
13
  Requires-Dist: pillow>=10.3
@@ -1,8 +1,8 @@
1
1
  [project]
2
2
  name = "god-code"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "AI coding agent specialized for Godot game development"
5
- requires-python = ">=3.12"
5
+ requires-python = ">=3.10"
6
6
  license = {text = "GPL-3.0-or-later"}
7
7
  authors = [{name = "chuisiufai"}]
8
8
  dependencies = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes