jivamai 0.1.4-dev.edce8f4 → 0.2.0-dev.03f9681
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.
- package/dist/assets/index-CnH2DbfK.js +31 -0
- package/dist/assets/index-Dxv8YLOA.css +10 -0
- package/dist/index.html +2 -2
- package/dist-server/index.js +1 -292
- package/package.json +7 -2
- package/dist/assets/index-CisS1YJo.css +0 -10
- package/dist/assets/index-DftBqc_W.js +0 -510
- package/dist-server/index.js.map +0 -1
- package/docs/README.md +0 -55
- package/docs/architecture/cloud-mode.md +0 -204
- package/docs/architecture/code-agent-integration.md +0 -276
- package/docs/architecture/ipc-contract.md +0 -162
- package/docs/architecture/jiva-core-integration.md +0 -147
- package/docs/architecture/overview.md +0 -87
- package/docs/architecture/startup-flow.md +0 -108
- package/docs/architecture/state-management.md +0 -153
- package/docs/guides/adding-features.md +0 -196
- package/docs/guides/design-guide.md +0 -308
- package/docs/release_notes/.gitkeep +0 -0
package/docs/README.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Jivam Documentation
|
|
2
|
-
|
|
3
|
-
Jivam is a cross-platform desktop application that provides a polished graphical interface for [jiva-core](https://www.npmjs.com/package/jiva-core) AI agents. It handles chat sessions, conversation history, persona switching, MCP server management, and workspace file browsing — all without exposing a terminal.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Tech Stack
|
|
8
|
-
|
|
9
|
-
| Layer | Technology | Version |
|
|
10
|
-
|-------|-----------|---------|
|
|
11
|
-
| Desktop shell | Electron | 33 |
|
|
12
|
-
| UI framework | React | 18 |
|
|
13
|
-
| Language | TypeScript | 5.9 |
|
|
14
|
-
| Build tool | Vite + vite-plugin-electron | 5 |
|
|
15
|
-
| Styling | Tailwind CSS | 3 |
|
|
16
|
-
| State management | Zustand | 4.5 |
|
|
17
|
-
| Animations | Framer Motion | 11 |
|
|
18
|
-
| AI engine | jiva-core (global npm) | latest |
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Prerequisites (development)
|
|
23
|
-
|
|
24
|
-
- Node.js 20+
|
|
25
|
-
- `jiva-core` installed globally: `npm install -g jiva-core`
|
|
26
|
-
- jiva-core configured with an API key (run `jiva setup` or configure via the in-app Settings)
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm install
|
|
34
|
-
npm run dev # Electron + Vite hot-reload
|
|
35
|
-
npm run build # Production build
|
|
36
|
-
npm run dist:mac # Package for macOS (DMG + ZIP)
|
|
37
|
-
npm run dist:win # Package for Windows (NSIS installer + portable)
|
|
38
|
-
npm run dist:linux # Package for Linux (AppImage + deb)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Documentation Index
|
|
44
|
-
|
|
45
|
-
| Section | Description |
|
|
46
|
-
|---------|-------------|
|
|
47
|
-
| [architecture/overview.md](architecture/overview.md) | System diagram, process model, key directories |
|
|
48
|
-
| [architecture/startup-flow.md](architecture/startup-flow.md) | Boot sequence from cold start to ready UI |
|
|
49
|
-
| [architecture/ipc-contract.md](architecture/ipc-contract.md) | All IPC channels with payloads and return types |
|
|
50
|
-
| [architecture/state-management.md](architecture/state-management.md) | Zustand stores, data flow patterns |
|
|
51
|
-
| [architecture/jiva-core-integration.md](architecture/jiva-core-integration.md) | How jiva-core is loaded, called, and configured |
|
|
52
|
-
| [architecture/code-agent-integration.md](architecture/code-agent-integration.md) | Code mode agent architecture and components |
|
|
53
|
-
| [guides/design-guide.md](guides/design-guide.md) | Colors, typography, spacing, components, animations |
|
|
54
|
-
| [guides/adding-features.md](guides/adding-features.md) | Step-by-step guide for adding new IPC-backed features |
|
|
55
|
-
| [release_notes/](release_notes/) | Release notes (see individual version files) |
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
# Cloud Mode Architecture
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Cloud mode lets users run Jivam without a local `jiva-core` install. Auth is
|
|
6
|
-
handled by Supabase; chat inference runs on a Google Cloud Run deployment
|
|
7
|
-
(`https://jiva-hdjcuspt2a-uc.a.run.app`).
|
|
8
|
-
|
|
9
|
-
Cloud mode is architected to support two hosts:
|
|
10
|
-
- **Electron desktop** — a separate `BrowserWindow` loaded with `?mode=cloud`
|
|
11
|
-
- **Web (jivamai.com)** — the same React app served statically, no Electron layer
|
|
12
|
-
|
|
13
|
-
The abstraction that makes this work is `src/lib/cloud-api.ts`.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Implementation Status
|
|
18
|
-
|
|
19
|
-
### Done ✓
|
|
20
|
-
|
|
21
|
-
| Area | File(s) | What was done |
|
|
22
|
-
|------|---------|---------------|
|
|
23
|
-
| Separate cloud window | `electron/main.ts` | `createCloudWindow()` opens a new `BrowserWindow` at `?mode=cloud`; clicking the cloud icon in TopBar fires `cloud:open-window` IPC |
|
|
24
|
-
| Cloud window detection | `src/store/auth.store.ts` | `isCloudWindow` reads URL param at module load; `isCloudMode` is permanently `true` in the cloud window |
|
|
25
|
-
| Auth store | `src/store/auth.store.ts` | Zustand store: `signIn`, `signUp`, `signOut`, `restoreSession`; session persisted to `localStorage` under key `jivam-cloud-session` |
|
|
26
|
-
| Sign-in UI | `src/components/setup/CloudSignIn.tsx` | Email/password form, sign-in / create account toggle, loading spinner, error display |
|
|
27
|
-
| Supabase auth (Electron) | `electron/cloud-auth.ts` | Fetch-based, no SDK: `cloudSignIn`, `cloudSignUp`, `cloudSignOut`, `initCloudSession` |
|
|
28
|
-
| API shim | `src/lib/cloud-api.ts` | `cloudApiSignIn/Up/Out/Init` — Electron delegates to IPC; web calls Supabase/Cloud Run directly |
|
|
29
|
-
| Cloud runner | `electron/cloud-runner.ts` | `CloudRunner` class: SSE streaming (`/api/chat/stream`) with non-streaming fallback (`/api/chat`). Configures via `configure(userId, sessionId)` |
|
|
30
|
-
| IPC routing | `electron/ipc-handlers.ts` | `jiva:send-message` checks `cloudRunner.isActive()` and routes accordingly; phase/log events sent to `event.sender` (not hardcoded main window) |
|
|
31
|
-
| IPC surface | `electron/preload.ts` + `src/types/electron.d.ts` | `window.electron.cloud.{openWindow, signIn, signUp, signOut, init}` |
|
|
32
|
-
| App.tsx routing | `src/App.tsx` | Cloud window without `cloudUser` shows `<CloudSignIn>`; skips local preflight and `startServer()` |
|
|
33
|
-
| TopBar | `src/components/layout/TopBar.tsx` | Cloud icon directly calls `openWindow()` (no dropdown in local mode); cloud mode shows badge with email + sign-out dropdown |
|
|
34
|
-
| Code tab guard | `src/components/code/CodeChatView.tsx` | "Local install required" overlay when `isCloudMode` |
|
|
35
|
-
|
|
36
|
-
### Known Broken / Untested ✗
|
|
37
|
-
|
|
38
|
-
| Issue | File | Notes |
|
|
39
|
-
|-------|------|-------|
|
|
40
|
-
| **Chat does not work end-to-end** | `electron/cloud-runner.ts` | ~~FIXED~~ `cloudRunner.startInit()` is called in `cloud:init` handler before the async HTTP call. `jiva:send-message` detects cloud senders via `event.sender.getURL().includes('mode=cloud')` and calls `cloudRunner.waitUntilReady(30_000)` if not yet active. Cloud Run cold starts up to 30s are handled. |
|
|
41
|
-
| **Supabase email confirmation** | `electron/cloud-auth.ts` + `src/lib/cloud-api.ts` | If the Supabase project has email confirmation enabled, `cloudSignUp` returns the user object at top-level with no `access_token`. This is handled defensively now (`data.user ?? data`), but the UX shows no "check your email" message — user just sees the app with an unconfigured session |
|
|
42
|
-
| **Session restoration** | `src/store/auth.store.ts` | `restoreSession()` fires and forgets `cloudApiInit`. If the cloud runner is never actually configured before a chat message, the message silently routes to the local runner |
|
|
43
|
-
| **Sign-out in cloud window** | `src/store/auth.store.ts` | `signOut` clears `localStorage` and calls `cloudApiSignOut`. But `cloudRunner.deactivate()` is called from `ipc-handlers.ts cloud:sign-out` — this path works. What doesn't work: the `cloudSignOut` IPC handler in `ipc-handlers.ts` passes no `accessToken` (it just calls `cloudRunner.deactivate()`), so Supabase session is not actually revoked server-side |
|
|
44
|
-
| **Activity log in cloud window** | `electron/cloud-runner.ts` | `onLog` is called with `Tool: ${msg}` for every SSE `status` event. Whether the Cloud Run backend actually emits these is untested |
|
|
45
|
-
| **Splash screen timing** | `src/App.tsx` | `showSplash` is set to `false` by the init effect before the user signs in. After sign-in, `showSplash` is already `false` — AppShell should render. This was still causing "Connecting to Jivam..." in testing; root cause not fully confirmed |
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## Architecture Diagram
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
USER CLICKS CLOUD ICON (TopBar, local window)
|
|
53
|
-
│
|
|
54
|
-
▼
|
|
55
|
-
window.electron.cloud.openWindow()
|
|
56
|
-
│
|
|
57
|
-
▼ IPC: cloud:open-window
|
|
58
|
-
electron/main.ts createCloudWindow()
|
|
59
|
-
│
|
|
60
|
-
▼
|
|
61
|
-
New BrowserWindow loads index.html?mode=cloud
|
|
62
|
-
│
|
|
63
|
-
▼
|
|
64
|
-
auth.store.ts → isCloudWindow = true → isCloudMode = true
|
|
65
|
-
│
|
|
66
|
-
▼ No existing session in localStorage
|
|
67
|
-
App.tsx → isCloudMode && !cloudUser → render <CloudSignIn>
|
|
68
|
-
│
|
|
69
|
-
▼ User submits credentials
|
|
70
|
-
auth.store.signIn/signUp()
|
|
71
|
-
1. cloudApiSignIn/Up() → window.electron.cloud.signIn/Up()
|
|
72
|
-
→ IPC: cloud:sign-in / cloud:sign-up
|
|
73
|
-
→ electron/cloud-auth.ts cloudSignIn/Up()
|
|
74
|
-
→ POST Supabase /auth/v1/token or /signup
|
|
75
|
-
2. set({ cloudUser }) ← immediately (non-blocking)
|
|
76
|
-
3. cloudApiInit() → fire-and-forget
|
|
77
|
-
→ window.electron.cloud.init()
|
|
78
|
-
→ IPC: cloud:init
|
|
79
|
-
→ electron/ipc-handlers.ts
|
|
80
|
-
→ initCloudSession() POST /api/session on Cloud Run
|
|
81
|
-
→ cloudRunner.configure(userId, sessionId)
|
|
82
|
-
│
|
|
83
|
-
▼ cloudUser is set
|
|
84
|
-
App.tsx → isCloudMode && cloudUser → render <AppShell>
|
|
85
|
-
│
|
|
86
|
-
▼ User sends a chat message
|
|
87
|
-
jiva.store.sendMessage()
|
|
88
|
-
→ window.electron.jiva.sendMessage()
|
|
89
|
-
→ IPC: jiva:send-message
|
|
90
|
-
→ ipc-handlers.ts
|
|
91
|
-
→ cloudRunner.isActive() ? cloudRunner.chat() : jivaRunner.chat()
|
|
92
|
-
→ POST https://jiva-hdjcuspt2a-uc.a.run.app/api/chat/stream (SSE)
|
|
93
|
-
→ SSE events → jiva:phase-update + jiva:jiva-log → sender window
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## Key Files
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
src/
|
|
102
|
-
lib/cloud-api.ts Environment shim (Electron IPC vs. direct fetch)
|
|
103
|
-
store/auth.store.ts Cloud auth state (Zustand)
|
|
104
|
-
components/
|
|
105
|
-
setup/CloudSignIn.tsx Sign-in / create account form
|
|
106
|
-
layout/TopBar.tsx Cloud icon → openWindow(); cloud badge when signed in
|
|
107
|
-
code/CodeChatView.tsx "Local only" overlay in cloud mode
|
|
108
|
-
App.tsx Cloud window routing: sign-in guard, skip local setup
|
|
109
|
-
|
|
110
|
-
electron/
|
|
111
|
-
main.ts createCloudWindow(), ipcMain.handle('cloud:open-window')
|
|
112
|
-
cloud-auth.ts Supabase fetch wrapper (Electron-side)
|
|
113
|
-
cloud-runner.ts HTTP/SSE client to Cloud Run
|
|
114
|
-
ipc-handlers.ts cloud:sign-in/up/out/init handlers; jiva:send-message routing
|
|
115
|
-
preload.ts window.electron.cloud.* IPC bridge
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Service Credentials
|
|
121
|
-
|
|
122
|
-
| Service | Value |
|
|
123
|
-
|---------|-------|
|
|
124
|
-
| Supabase project | `hcomegrnonxmjupvvyus` |
|
|
125
|
-
| Supabase URL | `https://hcomegrnonxmjupvvyus.supabase.co` |
|
|
126
|
-
| Supabase anon key | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...` (in `cloud-auth.ts` and `cloud-api.ts`) |
|
|
127
|
-
| Cloud Run URL | `https://jiva-hdjcuspt2a-uc.a.run.app` |
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## What Needs to Be Fixed Next
|
|
132
|
-
|
|
133
|
-
### Priority 1 — Chat must actually work ✓ FIXED
|
|
134
|
-
|
|
135
|
-
`cloudRunner.startInit()` is now called at the top of `cloud:init` before the async
|
|
136
|
-
`initCloudSession` HTTP call. `jiva:send-message` detects cloud senders via
|
|
137
|
-
`event.sender.getURL().includes('mode=cloud')` and awaits `cloudRunner.waitUntilReady(30_000)`
|
|
138
|
-
before routing. Cloud Run cold starts up to 30 s are handled.
|
|
139
|
-
|
|
140
|
-
### Priority 2 — Confirm Cloud Run API contract ✓ VERIFIED
|
|
141
|
-
|
|
142
|
-
The Cloud Run endpoints are confirmed via `~/dev/Jiva/docs/deployment/HTTP_API.md`:
|
|
143
|
-
|
|
144
|
-
| Endpoint | Method | Purpose |
|
|
145
|
-
|----------|--------|---------|
|
|
146
|
-
| `/api/session` | POST | Create/restore tenant session |
|
|
147
|
-
| `/api/chat/stream` | POST | SSE streaming chat |
|
|
148
|
-
| `/api/chat` | POST | Non-streaming chat fallback |
|
|
149
|
-
| `/api/chat/history` | DELETE | Reset conversation |
|
|
150
|
-
| `/api/chat/stop` | POST | Abort active generation |
|
|
151
|
-
|
|
152
|
-
Request headers: `x-tenant-id: userId`, `x-session-id: sessionId`
|
|
153
|
-
|
|
154
|
-
**These endpoints and their request/response shapes have not been verified.**
|
|
155
|
-
The Cloud Run service may have a different API. Check the backend source or
|
|
156
|
-
deploy logs before debugging further.
|
|
157
|
-
|
|
158
|
-
SSE event format (per `docs/deployment/HTTP_API.md` in the jiva-core repo):
|
|
159
|
-
```
|
|
160
|
-
event: status
|
|
161
|
-
data: {"message":"Processing request..."}
|
|
162
|
-
|
|
163
|
-
event: response
|
|
164
|
-
data: {"content":"...","iterations":3,"toolsUsed":[...]}
|
|
165
|
-
|
|
166
|
-
event: done
|
|
167
|
-
data: {"success":true}
|
|
168
|
-
|
|
169
|
-
event: error
|
|
170
|
-
data: {"message":"error text"}
|
|
171
|
-
```
|
|
172
|
-
The event type is carried in the SSE `event:` line, **not** as a `type` field inside the JSON body.
|
|
173
|
-
Non-streaming `/api/chat` response field is `response` (not `content`).
|
|
174
|
-
|
|
175
|
-
### Priority 3 — Supabase email confirmation
|
|
176
|
-
|
|
177
|
-
Check the Supabase dashboard for project `hcomegrnonxmjupvvyus`:
|
|
178
|
-
- If **email confirmation is ON**: sign-up returns no session. Need a "check
|
|
179
|
-
your email" screen instead of immediately transitioning to AppShell.
|
|
180
|
-
- If **email confirmation is OFF** (auto-confirm): the current flow should work.
|
|
181
|
-
|
|
182
|
-
### Priority 4 — Session token refresh
|
|
183
|
-
|
|
184
|
-
The `cloudUser` in `localStorage` stores `userId`, `email`, and `sessionId`
|
|
185
|
-
but **not** the Supabase `access_token` or `refresh_token`. These are needed
|
|
186
|
-
to make authenticated calls to Supabase APIs and to revoke sessions on sign-out.
|
|
187
|
-
Add `accessToken` and `refreshToken` to `CloudSession` in `auth.store.ts` and
|
|
188
|
-
pass them through from `cloud-auth.ts`.
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Web Export Notes (jivamai.com)
|
|
193
|
-
|
|
194
|
-
When `window.electron` is absent (web browser), `isCloudWindow` is `true` and
|
|
195
|
-
`cloud-api.ts` calls Supabase / Cloud Run directly via `fetch`. No IPC layer.
|
|
196
|
-
|
|
197
|
-
This is partially implemented. What still needs wiring for pure-web mode:
|
|
198
|
-
- Chat routing: `jiva.store.ts sendMessage` currently calls
|
|
199
|
-
`window.electron.jiva.sendMessage()` unconditionally. In cloud web mode,
|
|
200
|
-
this is `undefined`. Need to call `cloudApiChat()` from `cloud-api.ts`
|
|
201
|
-
instead (not yet implemented in the shim).
|
|
202
|
-
- The `cloudApiChat` function needs to be added to `src/lib/cloud-api.ts`,
|
|
203
|
-
replicating the SSE streaming logic from `cloud-runner.ts` but callable
|
|
204
|
-
from the renderer without an Electron IPC hop.
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
# Code Agent Integration
|
|
2
|
-
|
|
3
|
-
Jivam includes a specialized code agent mode that allows AI agents to directly manipulate files, run commands, and manage code within a user's workspace. This mode operates as a separate agent instance from the main chat interface but uses the same underlying jiva-core technology.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Architecture Overview
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
11
|
-
│ Renderer Process (React) │
|
|
12
|
-
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
|
|
13
|
-
│ │ Chat Interface │ │ Code Agent UI │ │ Git Panel │ │
|
|
14
|
-
│ │ │ │ │ │ │ │
|
|
15
|
-
│ │ • Message input │ │ • Code prompt │ │ • File list │ │
|
|
16
|
-
│ │ • Persona chip │ │ • Event cards │ │ • Diff view │ │
|
|
17
|
-
│ │ • History │ │ • Session mgmt │ │ • Branch │ │
|
|
18
|
-
│ └─────────────────┘ └─────────────────┘ └─────────────┘ │
|
|
19
|
-
│ │ │ │
|
|
20
|
-
│ └───────────────────────┼───────────────────────┘
|
|
21
|
-
│ │
|
|
22
|
-
│ ┌──────────────▼──────────────┐
|
|
23
|
-
│ │ window.electron.code API │
|
|
24
|
-
│ │ (Preload Bridge) │
|
|
25
|
-
│ └──────────────┬──────────────┘
|
|
26
|
-
│ │
|
|
27
|
-
│ ┌──────────────▼──────────────┐
|
|
28
|
-
│ │ Main Process │
|
|
29
|
-
│ │ ┌──────────────────────┐ │
|
|
30
|
-
│ │ │ CodeRunner │ │
|
|
31
|
-
│ │ │ ┌─────────────────┐ │ │
|
|
32
|
-
│ │ │ │ Log Parser │ │ │
|
|
33
|
-
│ │ │ │ Event Manager │ │ │
|
|
34
|
-
│ │ │ │ Agent Instance │ │ │
|
|
35
|
-
│ │ │ └─────────────────┘ │ │
|
|
36
|
-
│ │ └──────────────────────┘ │
|
|
37
|
-
│ └───────────────────────────┘
|
|
38
|
-
│ │
|
|
39
|
-
│ ┌──────────────▼──────────────┐
|
|
40
|
-
│ │ jiva-core SDK │
|
|
41
|
-
│ │ ┌──────────────────────┐ │
|
|
42
|
-
│ │ │ CodeAgent │ │
|
|
43
|
-
│ │ │ • File operations │ │
|
|
44
|
-
│ │ │ • Command execution│ │
|
|
45
|
-
│ │ │ • Tool usage │ │
|
|
46
|
-
│ │ └──────────────────────┘ │
|
|
47
|
-
│ └───────────────────────────┘
|
|
48
|
-
└─────────────────────────────────────────────────────────────┘
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Key Components
|
|
54
|
-
|
|
55
|
-
### CodeRunner (`electron/code-runner.ts`)
|
|
56
|
-
|
|
57
|
-
The `CodeRunner` class manages a dedicated code agent instance with the following responsibilities:
|
|
58
|
-
|
|
59
|
-
- **Log Event Parsing**: Intercepts stdout/stderr from jiva-core and converts structured log lines into `CodeLogEvent` objects
|
|
60
|
-
- **Event Management**: Accumulates important events (file edits, warnings, errors) during code execution
|
|
61
|
-
- **Resource Management**: Proper cleanup of agent instances and temporary resources
|
|
62
|
-
- **Real-time Communication**: Streams progress events to the renderer via IPC
|
|
63
|
-
|
|
64
|
-
#### Log Event Format
|
|
65
|
-
|
|
66
|
-
jiva-core logs follow this format:
|
|
67
|
-
```
|
|
68
|
-
2026-03-13T10:28:32.695Z [INFO] [CodeAgent] Tool: glob
|
|
69
|
-
2026-03-13T10:28:33.123Z [WARN] [CodeAgent] Doom loop: tool: write_file
|
|
70
|
-
2026-03-13T10:28:33.456Z [ERROR] [CodeAgent] Model error: Invalid file path
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### CodeLogEvent Interface
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
interface CodeLogEvent {
|
|
77
|
-
timestamp: string // ISO timestamp
|
|
78
|
-
level: 'info' | 'warn' | 'error'
|
|
79
|
-
tag: string // Usually 'CodeAgent'
|
|
80
|
-
message: string // Raw log message
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### CodeStore (`src/store/code.store.ts`)
|
|
87
|
-
|
|
88
|
-
The Zustand store that manages code agent state in the renderer:
|
|
89
|
-
|
|
90
|
-
#### State Management
|
|
91
|
-
|
|
92
|
-
| State | Type | Description |
|
|
93
|
-
|-------|------|-------------|
|
|
94
|
-
| `messages` | `CodeMessage[]` | Conversation history with code content |
|
|
95
|
-
| `isThinking` | `boolean` | Agent is processing a request |
|
|
96
|
-
| `currentAction` | `string \| null` | Current tool action (e.g., "Writing file...") |
|
|
97
|
-
| `pendingEvents` | `CodeEvent[]` | Events accumulated for current turn |
|
|
98
|
-
|
|
99
|
-
#### CodeMessage Interface
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
interface CodeMessage {
|
|
103
|
-
id: string
|
|
104
|
-
role: 'user' | 'agent'
|
|
105
|
-
content: string
|
|
106
|
-
timestamp: Date
|
|
107
|
-
events?: CodeEvent[] // Tool events, warnings, errors
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
#### CodeEvent Interface
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
interface CodeEvent {
|
|
115
|
-
id: string
|
|
116
|
-
type: 'tool' | 'warn' | 'error'
|
|
117
|
-
detail: string
|
|
118
|
-
timestamp: string
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
### Event Processing
|
|
125
|
-
|
|
126
|
-
#### Log to Action Mapping
|
|
127
|
-
|
|
128
|
-
The system maps log messages to user-friendly action descriptions:
|
|
129
|
-
|
|
130
|
-
| Log Pattern | Action Display |
|
|
131
|
-
|-------------|----------------|
|
|
132
|
-
| `Tool: read_file` | "Reading files..." |
|
|
133
|
-
| `Tool: write_file` | "Writing file..." |
|
|
134
|
-
| `Tool: edit_file` | "Editing file..." |
|
|
135
|
-
| `Tool: glob` | "Searching files..." |
|
|
136
|
-
| `Tool: grep` | "Searching content..." |
|
|
137
|
-
| `Tool: bash` | "Running command..." |
|
|
138
|
-
| `Nearing iteration limit` | "Wrapping up..." |
|
|
139
|
-
| `Final phase` | "Finalizing..." |
|
|
140
|
-
| `Repaired tool call` | "Retrying..." |
|
|
141
|
-
|
|
142
|
-
#### Important Event Detection
|
|
143
|
-
|
|
144
|
-
Events are marked as important and displayed if they:
|
|
145
|
-
|
|
146
|
-
- Have level `'warn'` or `'error'`
|
|
147
|
-
- Start with `Tool: edit_file`
|
|
148
|
-
- Start with `Tool: write_file`
|
|
149
|
-
- Start with `Tool: bash`
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## IPC Contract
|
|
154
|
-
|
|
155
|
-
### Code Mode Channels
|
|
156
|
-
|
|
157
|
-
| Channel | Direction | Description |
|
|
158
|
-
|---------|-----------|-------------|
|
|
159
|
-
| `code:send-message` | invoke | Send code prompt to agent |
|
|
160
|
-
| `code:stop-message` | invoke | Stop active code agent |
|
|
161
|
-
| `code:reset-session` | invoke | Tear down CodeRunner for fresh start |
|
|
162
|
-
| `code:init` | invoke | Initialize CodeRunner |
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## UI Components
|
|
167
|
-
|
|
168
|
-
### CodeChatView (`src/components/code/CodeChatView.tsx`)
|
|
169
|
-
|
|
170
|
-
The main code agent interface featuring:
|
|
171
|
-
|
|
172
|
-
- **Message Display**: User prompts and agent responses with Markdown rendering
|
|
173
|
-
- **Event Cards**: Shows tool execution events above agent responses
|
|
174
|
-
- **Example Prompts**: Quick-start suggestions for common code tasks
|
|
175
|
-
- **Session Management**: New session button to start fresh code work
|
|
176
|
-
|
|
177
|
-
#### Example Prompts
|
|
178
|
-
|
|
179
|
-
The interface provides suggested prompts for common code tasks:
|
|
180
|
-
- "Find and fix the bug causing tests to fail"
|
|
181
|
-
- "Refactor this module for better readability"
|
|
182
|
-
- "Add error handling to the API endpoints"
|
|
183
|
-
- "Write a script to automate this task"
|
|
184
|
-
|
|
185
|
-
### GitPanel (`src/components/code/GitPanel.tsx`)
|
|
186
|
-
|
|
187
|
-
Integrated Git functionality with:
|
|
188
|
-
|
|
189
|
-
- **Repository Status**: Shows current branch and sync status (↑ahead, ↓behind)
|
|
190
|
-
- **File List**: Displays changed files with status badges (M, A, D, ??)
|
|
191
|
-
- **Diff Viewer**: Syntax-highlighted diff display with file headers
|
|
192
|
-
- **Branch Information**: Current branch name and upstream tracking
|
|
193
|
-
|
|
194
|
-
#### Status Badges
|
|
195
|
-
|
|
196
|
-
| Status | Display | Meaning |
|
|
197
|
-
|--------|---------|---------|
|
|
198
|
-
| `M` / `MM` | ⚠️ M | Modified files |
|
|
199
|
-
| `A` | ✅ A | Added files |
|
|
200
|
-
| `D` | 🗑️ D | Deleted files |
|
|
201
|
-
| `??` | ❓ ? | Untracked files |
|
|
202
|
-
| `R` | 🔄 R | Renamed files |
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
## Data Flow
|
|
207
|
-
|
|
208
|
-
### Code Execution Flow
|
|
209
|
-
|
|
210
|
-
1. **User Input**: User types code prompt in CodeChatView
|
|
211
|
-
2. **IPC Call**: `window.electron.code.sendMessage(prompt)`
|
|
212
|
-
3. **Agent Initialization**: CodeRunner creates/configures CodeAgent instance
|
|
213
|
-
4. **Log Interception**: stdout/stderr captured and parsed into structured events
|
|
214
|
-
5. **Event Processing**: Important events accumulated and sent to renderer
|
|
215
|
-
6. **Response Delivery**: Final code response returned with event history
|
|
216
|
-
7. **UI Update**: CodeChatView displays response with event cards
|
|
217
|
-
|
|
218
|
-
### Event Flow
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
jiva-core stdout/stderr
|
|
222
|
-
↓
|
|
223
|
-
Log Parser (parseLogLine)
|
|
224
|
-
↓
|
|
225
|
-
CodeLogEvent objects
|
|
226
|
-
↓
|
|
227
|
-
isImportantEvent() filter
|
|
228
|
-
↓
|
|
229
|
-
CodeEvent objects
|
|
230
|
-
↓
|
|
231
|
-
window.electron.code.onCodeLog callback
|
|
232
|
-
↓
|
|
233
|
-
useCodeStore.pendingEvents update
|
|
234
|
-
↓
|
|
235
|
-
Event cards displayed in UI
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## Configuration
|
|
241
|
-
|
|
242
|
-
### Code Mode Settings
|
|
243
|
-
|
|
244
|
-
The code agent respects the same configuration as the main jiva-core system:
|
|
245
|
-
|
|
246
|
-
- **Model Configuration**: Reasoning model settings from `config.json`
|
|
247
|
-
- **Workspace Directory**: Current working directory for file operations
|
|
248
|
-
- **Persona System**: Can use different personas for code vs chat modes
|
|
249
|
-
- **MCP Servers**: Same tool servers available to both chat and code modes
|
|
250
|
-
|
|
251
|
-
### Workspace Security
|
|
252
|
-
|
|
253
|
-
Code operations are restricted to the user's home directory for security:
|
|
254
|
-
|
|
255
|
-
- File operations limited to `$HOME` (Windows: `%APPDATA%`)
|
|
256
|
-
- Path validation prevents directory traversal attacks
|
|
257
|
-
- Large files (>500KB) blocked from preview, require external editor
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## Error Handling
|
|
262
|
-
|
|
263
|
-
### Common Error Scenarios
|
|
264
|
-
|
|
265
|
-
- **Agent Not Initialized**: CodeRunner not ready, requires `code:init` first
|
|
266
|
-
- **Workspace Not Set**: No workspace directory configured
|
|
267
|
-
- **Permission Denied**: File operations blocked by system permissions
|
|
268
|
-
- **Large Files**: Files >500KB rejected for preview
|
|
269
|
-
- **Invalid Paths**: Non-existent or inaccessible directories
|
|
270
|
-
|
|
271
|
-
### Error Recovery
|
|
272
|
-
|
|
273
|
-
- **Session Reset**: `code:reset-session` clears corrupted state
|
|
274
|
-
- **Agent Restart**: Automatic re-initialization on errors
|
|
275
|
-
- **Graceful Degradation**: UI continues working even if agent fails
|
|
276
|
-
- **User Notifications**: Clear error messages with actionable guidance
|