Skip to content

Commit b5ec8f8

Browse files
authored
Merge pull request #35 from UseTheFork/development
Version 1
2 parents 23e98a8 + f569667 commit b5ec8f8

332 files changed

Lines changed: 26687 additions & 6811 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.byte/config.yaml

Lines changed: 82 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -60,49 +60,71 @@ lsp:
6060
timeout: 30
6161
servers:
6262
python:
63-
command:
64-
- uv
65-
- run
66-
- jedi-language-server
63+
preset: ty
64+
server_type: local
6765
languages:
6866
- python
6967
presets:
7068
- id: base
7169
load_on_boot: false
7270
conventions:
73-
- CODE_STYLEGUIDE.md
71+
- CODE_PATTERNS.md
72+
- COMMENT_STYLEGUIDE.md
73+
- PROJECT_ARCHITECTURE.md
74+
- PYTHON_STYLEGUIDE.md
75+
read_only_files:
76+
- src/byte/foundation/container.py
77+
- src/byte/foundation/application.py
78+
- src/byte/foundation/console/kernel.py
79+
- src/byte/foundation/console/console.py
80+
- src/byte/config/config.py
81+
- src/byte/support/utils/**
82+
- src/byte/support/service_provider.py
83+
- src/byte/support/service.py
84+
editable_files:
85+
- src/tests/base_test.py
86+
87+
- id: files
88+
load_on_boot: false
89+
conventions:
90+
- CODE_PATTERNS.md
7491
- COMMENT_STYLEGUIDE.md
7592
- PROJECT_ARCHITECTURE.md
7693
- PYTHON_STYLEGUIDE.md
7794
read_only_files:
78-
- src/byte/bootstrap.py
79-
- src/byte/container.py
80-
- src/byte/core/cli.py
81-
- src/byte/core/config/config.py
82-
- src/byte/main.py
83-
- src/byte/core/mixins/**
84-
- src/byte/core/utils/**
85-
- src/byte/core/service/base_service.py
86-
- src/byte/core/service_provider.py
95+
- src/byte/foundation/container.py
96+
- src/byte/foundation/application.py
97+
- src/byte/foundation/console/kernel.py
98+
- src/byte/foundation/console/console.py
99+
- src/byte/config/config.py
100+
- src/byte/support/utils/**
101+
- src/byte/support/service_provider.py
102+
- src/byte/support/service.py
103+
editable_files:
104+
- src/tests/base_test.py
105+
- src/byte/files/**
106+
- src/tests/files/**
87107

88108
- id: command
89109
conventions:
90-
- CODE_STYLEGUIDE.md
110+
- CODE_PATTERNS.md
91111
- COMMENT_STYLEGUIDE.md
92112
- PROJECT_ARCHITECTURE.md
93113
- PYTHON_STYLEGUIDE.md
94114
read_only_files:
95-
- src/byte/bootstrap.py
96-
- src/byte/container.py
97-
- src/byte/core/cli.py
98-
- src/byte/core/config/config.py
99-
- src/byte/main.py
100-
- src/byte/domain/cli/service/command_registry.py
101-
- src/byte/core/mixins/user_interactive.py
102-
- src/byte/domain/files/command/add_file_command.py
103-
- src/byte/domain/files/command/drop_file_command.py
104-
- src/byte/domain/knowledge/command/web_command.py
105-
- src/byte/domain/git/command/commit_command.py
115+
- src/byte/foundation/container.py
116+
- src/byte/foundation/application.py
117+
- src/byte/foundation/console/kernel.py
118+
- src/byte/foundation/console/console.py
119+
- src/byte/config/config.py
120+
- src/byte/support/utils/**
121+
- src/byte/support/mixins/user_interactive.py
122+
- src/byte/cli/service/command_registry.py
123+
- src/byte/files/command/add_file_command.py
124+
- src/byte/files/command/drop_file_command.py
125+
- src/byte/knowledge/command/web_command.py
126+
- src/byte/git/command/commit_command.py
127+
106128
- id: mkdocs
107129
prompt: 'Using the `MKDOCS_STYLEGUIDE` and existing docs as examples, document '
108130
conventions:
@@ -117,43 +139,52 @@ presets:
117139
- docs/concepts/lint.md
118140
- docs/concepts/file-context.md
119141
- .byte/config.yaml
142+
120143
- id: agent
121144
conventions:
122145
- CODE_STYLEGUIDE.md
123146
- COMMENT_STYLEGUIDE.md
124147
- PROJECT_ARCHITECTURE.md
125148
- PYTHON_STYLEGUIDE.md
126149
read_only_files:
127-
- src/byte/bootstrap.py
128-
- src/byte/container.py
129-
- src/byte/core/cli.py
130-
- src/byte/core/config/config.py
131-
- src/byte/main.py
150+
- src/byte/foundation/container.py
151+
- src/byte/foundation/application.py
152+
- src/byte/foundation/console/kernel.py
153+
- src/byte/foundation/console/console.py
154+
- src/byte/config/config.py
155+
- src/byte/support/utils/**
156+
- src/byte/support/mixins/**
157+
- src/byte/support/service_provider.py
158+
- src/byte/support/service.py
132159
editable_files:
133-
- src/byte/domain/agent/state.py
134-
- src/byte/domain/agent/reducers.py
135-
- src/byte/domain/agent/schemas.py
136-
- src/byte/domain/agent/service_provider.py
137-
- src/byte/domain/agent/implementations/base.py
138-
- src/byte/domain/agent/implementations/ask/**
139-
- src/byte/domain/agent/implementations/coder/**
140-
- src/byte/domain/agent/implementations/commit/**
141-
- src/byte/domain/agent/nodes/**
160+
- src/byte/agent/state.py
161+
- src/byte/agent/reducers.py
162+
- src/byte/agent/schemas.py
163+
- src/byte/agent/service_provider.py
164+
- src/byte/agent/implementations/base.py
165+
- src/byte/agent/nodes/base_node.py
166+
- src/tests/agent/test_commit_agent.py
167+
- src/byte/agent/nodes/start_node.py
168+
- src/byte/agent/nodes/end_node.py
169+
- src/byte/agent/nodes/assistant_node.py
170+
142171
- id: parser
143172
conventions:
144-
- CODE_STYLEGUIDE.md
173+
- CODE_PATTERNS.md
145174
- COMMENT_STYLEGUIDE.md
146175
- PROJECT_ARCHITECTURE.md
147176
- PYTHON_STYLEGUIDE.md
148177
read_only_files:
149-
- src/byte/bootstrap.py
150-
- src/byte/container.py
151-
- src/byte/core/cli.py
152-
- src/byte/core/config/config.py
153-
- src/byte/main.py
154-
- src/byte/core/mixins/**
155-
- src/byte/core/utils/**
156-
- src/byte/core/service/base_service.py
157-
- src/byte/core/service_provider.py
178+
- src/byte/foundation/container.py
179+
- src/byte/foundation/application.py
180+
- src/byte/foundation/console/kernel.py
181+
- src/byte/foundation/console/console.py
182+
- src/byte/config/config.py
183+
- src/byte/support/utils/**
184+
- src/byte/support/service_provider.py
185+
- src/byte/support/service.py
158186
editable_files:
159-
- src/byte/domain/prompt_format/**
187+
- src/byte/agent/nodes/parse_blocks_node.py
188+
- src/tests/base_test.py
189+
- src/byte/prompt_format/**
190+
- src/tests/prompt_format/**

.byte/conventions/CODE_PATTERNS.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Code Patterns & Design Conventions
2+
3+
## Key Principles
4+
5+
- **Mixin composition over inheritance**: Services compose behavior through mixins (`Bootable`, `Injectable`, `Eventable`, `Configurable`)
6+
- **Two-phase initialization**: Register bindings first (`register()`), boot dependencies second (`boot()`)
7+
- **Lazy resolution with auto-boot**: Services instantiated on first `make()` call, automatically booted via `ensure_booted()`
8+
- **Event-driven communication**: Cross-domain communication via `EventBus` with typed `Payload` objects
9+
10+
## Dependency Injection
11+
12+
```python
13+
# Service with container injection
14+
class MyService(Service):
15+
def boot(self, **kwargs) -> None:
16+
self._cache = {}
17+
18+
async def handle(self, **kwargs) -> Any:
19+
other_service = self.app.make(OtherService)
20+
return await other_service.process()
21+
22+
# ServiceProvider registration
23+
class MyServiceProvider(ServiceProvider):
24+
def services(self) -> List[Type[Service]]:
25+
return [MyService, OtherService] # Auto-registered as singletons
26+
27+
async def boot(self) -> None:
28+
event_bus = self.app.make(EventBus)
29+
event_bus.on(EventType.MY_EVENT.value, self.handle_event)
30+
```
31+
32+
## Async/Await Patterns
33+
34+
- All service methods are async
35+
- Use validate-then-handle pattern: `await self.validate()` then `await self.handle()`
36+
- Handle cancellation in long-running operations with `asyncio.CancelledError`
37+
38+
## Error Handling
39+
40+
- Domain-specific exceptions inherit from `ByteException`
41+
- Return `False`/`None` for expected failures, not exceptions
42+
- Retry loops with user confirmation for recoverable errors
43+
- Catch specific exceptions, never broad `Exception`
44+
45+
## Event Communication
46+
47+
```python
48+
# Emit events from Eventable services
49+
await self.emit(Payload(event_type=EventType.FILE_ADDED, data={...}))
50+
51+
# Register listeners in ServiceProvider.boot()
52+
event_bus.on(EventType.FILE_ADDED.value, self.handle_file_added)
53+
54+
# Transform payloads in hooks
55+
async def hook(self, payload: Payload) -> Payload:
56+
data = payload.get("key", [])
57+
data.extend(["new_item"])
58+
return payload.set("key", data)
59+
```
60+
61+
## Common Patterns
62+
63+
- **Lazy initialization**: Cache expensive objects, build on first access
64+
- **Wildcard support**: Check for `*`, `?`, `[` in paths, use `glob.glob()`
65+
- **Property-based computed values**: Use `@property` for derived attributes
66+
- **Graceful degradation**: Return boolean success indicators
67+
68+
## Things to Avoid
69+
70+
- ❌ Direct instantiation → use `self.app.make(ServiceClass)`
71+
- ❌ Sync methods in services → all service methods should be async
72+
- ❌ Booting in `__init__` → use `boot()` for container-dependent initialization
73+
- ❌ Broad exception catching → catch specific exceptions only

.byte/conventions/CODE_STYLEGUIDE.md

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)