You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`apps/twig` - Twig Electron desktop app (React + Vite)
7
+
-`apps/cli` - CLI tool (thin wrapper around @twig/core)
8
+
-`apps/mobile` - React Native mobile app (Expo)
7
9
-`packages/agent` - TypeScript agent framework wrapping Claude Agent SDK
10
+
-`packages/core` - Shared business logic for jj/GitHub operations
11
+
-`packages/electron-trpc` - Custom tRPC package for Electron IPC
8
12
9
13
## Commands
10
14
@@ -59,13 +63,13 @@ Import directly from source files instead.
59
63
60
64
## Architecture
61
65
62
-
See [ARCHITECTURE.md](./ARCHITECTURE.md) for detailed patterns (DI, services, tRPC, state management).
66
+
See [ARCHITECTURE.md](./apps/twig/ARCHITECTURE.md) for detailed patterns (DI, services, tRPC, state management).
63
67
64
68
### Electron App (apps/twig)
65
69
66
70
-**Main process** (`src/main/`) - Stateless services, tRPC routers, system I/O
67
71
-**Renderer process** (`src/renderer/`) - React app, all application state
68
-
-**IPC**: tRPC over Electron IPC (type-safe)
72
+
-**IPC**: tRPC over Electron IPC (type-safe via @posthog/electron-trpc)
69
73
-**DI**: InversifyJS in both processes (`src/main/di/`, `src/renderer/di/`)
70
74
-**State**: Zustand stores in renderer only - main is stateless
71
75
-**Testing**: Vitest with React Testing Library
@@ -88,22 +92,264 @@ See [ARCHITECTURE.md](./ARCHITECTURE.md) for detailed patterns (DI, services, tR
88
92
89
93
- Shared business logic for jj/GitHub operations
90
94
95
+
## Agent Integration Guidelines
96
+
97
+
-**No rawInput**: Don't use Claude Code SDK's `rawInput` - only use Zod validated meta fields. This keeps us agent agnostic and gives us a maintainable, extensible format for logs.
98
+
-**Use ACP SDK types**: Don't roll your own types for things available in the ACP SDK. Import types directly from `@anthropic-ai/claude-agent-sdk` TypeScript SDK.
99
+
-**Permissions via tool calls**: If something requires user input/approval, implement it through a tool call with a permission instead of custom methods + notifications. Avoid patterns like `_array/permission_request`.
100
+
91
101
## Key Libraries
92
102
93
-
- React 18, Radix UI Themes, Tailwind CSS
103
+
- React 19, Radix UI Themes, Tailwind CSS
94
104
- TanStack Query for data fetching
95
105
- xterm.js for terminal emulation
96
106
- CodeMirror for code editing
97
107
- Tiptap for rich text
98
108
- Zod for schema validation
109
+
- InversifyJS for dependency injection
110
+
- Sonner for toast notifications
111
+
112
+
## Code Patterns
113
+
114
+
### React Components
115
+
116
+
Components are functional with hooks. Props typed with interfaces:
**Rule of thumb**: If it can be tested without Electron running, use a unit test. If it requires the full app context or tests user-facing behavior, use E2E.
270
+
271
+
### Test File Location
272
+
273
+
Tests are colocated with source code using `.test.ts` or `.test.tsx` extension. E2E tests live in `tests/e2e/`.
0 commit comments