Commit graph

1243 commits

Author SHA1 Message Date
Jiayuan Zhang
63df5dccda
Merge pull request #251 from multica-ai/forrestchang/agent-arch-analysis
feat(daemon): per-task isolated execution environments
2026-03-25 12:43:34 +08:00
Jiayuan Zhang
678266ec87 feat(daemon): add per-task isolated execution environments
Introduce the `execenv` package that creates isolated working directories
for each agent task. Supports git worktree mode (code tasks) and plain
directory mode (non-code tasks), with `.agent_context/issue_context.md`
injected into the workdir for Claude Code to discover.

Key changes:
- New `server/internal/daemon/execenv/` package (Prepare/Cleanup)
- `runTask()` now creates isolated env instead of using shared reposRoot
- Prompt updated to reference `.agent_context/` files
- Add `WorkspacesRoot` config (default ~/multica_workspaces)
- Add `KeepEnvAfterTask` config for debugging
- Default agent timeout increased from 20min to 2h
- `CompleteTask` now forwards branch name to server

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 12:41:52 +08:00
yushen
0ce25597d6 docs: update CLAUDE.md for post-merge architecture changes
- Update backend entry points (cmd/multica CLI replaces cmd/daemon + cmd/seed)
- Add Agent SDK, Daemon, and CLI package descriptions
- Remove stale frontend section referencing deleted lib/ files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 18:45:18 +08:00
Naiyuan Qing
57850934d0
Merge pull request #250 from multica-ai/feature/design-system-alignment
refactor(web): self-contained shadcn UI with design tokens
2026-03-24 18:26:39 +08:00
Jiayuan Zhang
9522cb0516
Merge pull request #249 from multica-ai/forrestchang/remove-issue-git-repo
refactor: remove repository field from issues
2026-03-24 18:24:36 +08:00
Naiyuan Qing
0629eb9d79 fix(web): add missing linkify-it dependency and types
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 18:24:30 +08:00
Naiyuan Qing
bf7ea14092 fix(web): add missing markdown dependencies (react-markdown, rehype-raw, remark-gfm, shiki)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 18:21:24 +08:00
Naiyuan Qing
66e99136c2 refactor(web): self-contained shadcn UI with base-nova style and design tokens
Migrate all shadcn components into apps/web/components/ui/ so the web app
is fully independent from packages/ui for its UI layer. Update to the
latest shadcn base-nova style. Add missing semantic color variables
(success, warning, info, canvas), font-mono mapping, scrollbar styling,
and wrap Select items in SelectGroup for proper padding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 18:19:26 +08:00
Jiayuan Zhang
e86768823e refactor: remove repository field from issues
The repository JSONB column on the issue table is unused. This removes
it end-to-end: migration to drop the column, sqlc queries, Go handler/
service/daemon/protocol structs, TypeScript types, and the
RepositoryEditor UI component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 18:12:06 +08:00
LinYushen
e3ea7bd02c
Merge pull request #243 from multica-ai/feature/multi-agent-backend
feat(daemon): unified agent SDK supporting Claude Code and Codex
2026-03-24 17:55:08 +08:00
yushen
0b7de54052 Merge remote-tracking branch 'origin/main' into feature/multi-agent-backend
Resolve conflicts:
- CLAUDE.md: merge feature-based frontend docs from main with comprehensive
  architecture docs from HEAD
- Makefile: merge .PHONY targets from both branches
- settings/page.tsx: keep Context field using main's Label component
- auth-context.test.tsx: accept main's deletion (moved to features/auth/)
- cmd/daemon/daemon.go: accept HEAD's deletion (moved to internal/daemon/)
- daemon/client.go: port requestError type and isWorkspaceNotFoundError from
  main's old daemon into the new internal/daemon package

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:53:24 +08:00
yushen
de0a983674 fix(server): remove debug logging and add error handling from review
- Remove debug log.Printf calls from handler/daemon.go and service/task.go
  that used the global log package instead of structured logging
- Remove unused truncate() helper from service/task.go
- Add error handling for EnqueueTaskForIssue in createAgentInitIssue
- Clean up verbose debug logging in daemon/daemon.go handleTask
- Add shutdown sequence comment to codex.go lifecycle goroutine

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:48:01 +08:00
yushen
a9bf22955d chore(daemon): add debug logging for task lifecycle troubleshooting
Add structured logging at key points in the task completion flow:
- Daemon: log result details before sending to server, log claim cycles
- Handler: log incoming CompleteTask requests
- TaskService: log each step of CompleteTask (DB update, issue status
  sync, comment creation, payload parsing)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:38:06 +08:00
yushen
994242d2db feat(agent): auto-create init issue on agent creation with workspace context
When a new agent is created, automatically create an initialization issue
assigned to it so the agent starts working immediately. The issue
description incorporates the workspace context field, giving the agent
background info to set up its environment (clone repos, etc.).

Also adds workspace context to the task context snapshot for all tasks,
and renders it in the daemon prompt so agents always have workspace
background when executing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:38:00 +08:00
yushen
828b75c76d fix(daemon): resolve codex app-server deadlock after turn completion
The codex backend spawns a long-running app-server process that doesn't
exit after completing a turn. The lifecycle goroutine was waiting on
<-readerDone which blocks on scanner.Scan() until stdout closes — but
stdout never closes because the process stays alive. This caused the
entire poll loop to freeze, preventing any further task processing.

Fix: explicitly close stdin and cancel the context after the turn
completes, which terminates the codex process and unblocks the reader.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:37:52 +08:00
Naiyuan Qing
0b09a8a69f
Merge pull request #248 from multica-ai/refactor/web-features-restructure
refactor(web): feature-based architecture with zustand stores
2026-03-24 16:12:51 +08:00
Naiyuan Qing
616f026f42 fix(web): update pair/local test mocks for new store imports
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:09:44 +08:00
Naiyuan Qing
618be9c2d6 fix(web): add overflow-hidden to SidebarInset for rounded corners
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:08:36 +08:00
Naiyuan Qing
a2d7501d57 refactor(web): restructure to feature-based architecture with zustand stores
- Remove tab system entirely (tab-store, tab-bar, tab-link)
- Split monolithic AuthContext into zustand auth + workspace stores
- Move issue components/config to features/issues/
- Move WebSocket provider to features/realtime/
- Move api.ts to shared/
- Migrate all consumers from useAuth() to direct store imports
- Simplify sidebar: replace hand-built dropdown with shadcn DropdownMenu,
  replace custom layout wrapper with SidebarInset
- Remove unused @multica/store and @multica/hooks dependencies
- Add @/ path alias and zustand dependency
- Update CLAUDE.md with feature-based architecture conventions

Net change: +293 / -2435 lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:08:36 +08:00
yushen
c4a7cf9726 fix(web): allow clearing workspace description and context fields
Previously `|| undefined` prevented sending empty strings, making it
impossible to clear these fields once set. Now always send the current
value so the backend COALESCE correctly updates the column.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:03:39 +08:00
yushen
680668ffdb feat(workspace): add context field for AI agent background info
Add a `context` text field to workspaces, allowing users to provide
background information and context for AI agents working in the
workspace. Full stack: migration, sqlc queries, Go handler, TS types,
SDK, and settings page UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:59:11 +08:00
yushen
3293607bef fix(cli): address code review findings
1. Add Client.SendHeartbeat/Register methods — no more direct postJSON calls
2. Use url.Values for query params to prevent URL injection
3. Unexport helpers (envOrDefault, durationFromEnv, sleepWithContext)
4. CLI resolveWorkspaceID falls back to daemon.json
5. Implement agent stop (PUT /api/agents/{id} with status=offline)
6. Add --output flag to agent get for consistent UX
7. Add server/multica to .gitignore for stray builds
8. Inject version/commit via -ldflags in Makefile build target

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:49:32 +08:00
yushen
707b5ac6e7 refactor(cli): unify daemon into multica-cli binary with cobra subcommands
Extract daemon logic from cmd/daemon/ into internal/daemon/ package and
create a new unified CLI entry point at cmd/multica/ using cobra. The CLI
supports `daemon` as a long-running subcommand plus ctrl subcommands for
agent/runtime management, config, status, and version.

Server, migrate, and seed binaries remain unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:44:49 +08:00
Jiayuan Zhang
768a555a80
Merge pull request #247 from multica-ai/codex/default-workspace-daemon-pairing-fixes
Provision default workspaces and harden daemon pairing
2026-03-24 15:25:29 +08:00
Jiayuan Zhang
4c6eb81789 Provision default workspaces and harden daemon pairing 2026-03-24 15:19:27 +08:00
yushen
41b9698dbf chore: update Makefile daemon target to use MULTICA_REPOS_ROOT
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:41:38 +08:00
yushen
edbe474807 chore: gitignore .claude/ and dist-electron
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:37:52 +08:00
yushen
f2228e4f22 refactor(daemon): rename DefaultWorkdir to ReposRoot for clarity
MULTICA_AGENT_WORKDIR → MULTICA_REPOS_ROOT to make it clear this is
the parent directory containing all repos, not a single project workdir.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:36:09 +08:00
Jiayuan Zhang
2e5e24f194
Merge pull request #246 from multica-ai/codex/shared-postgres-local-dev
refactor(dev): share postgres across main and worktrees
2026-03-24 14:31:34 +08:00
Jiayuan Zhang
6b6e8ac4e4 fix(ci): provision postgres for backend tests 2026-03-24 14:29:56 +08:00
Jiayuan Zhang
2c28c4cba2 refactor(dev): share postgres across main and worktrees 2026-03-24 14:27:35 +08:00
yushen
d1e4228aa7 chore: add server/daemon binary to .gitignore
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:26:53 +08:00
yushen
b7728ff802 docs: expand CLAUDE.md with architecture details and update lockfile
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:25:33 +08:00
yushen
96cfdc2e27 fix(agent): fix data races, add tests, and fix raw protocol detection
- Fix data race on output strings.Builder in codex backend by adding
  mutex and waiting for reader goroutine before reading final output
- Fix data race on onTurnDone by initializing it before reader starts
- Fix bug where notificationProtocol zero value "" never matched
  "unknown", silently dropping all raw v2 notifications from codex
- Add round-robin polling to prevent runtime starvation in poll loop
- Log errors in claude handleControlRequest instead of silently dropping
- Add 35 tests for pkg/agent covering claude parsing, codex JSON-RPC,
  protocol detection, event handling, and helper functions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:21:10 +08:00
Naiyuan Qing
4bab6f71fc
Merge pull request #245 from multica-ai/feature/issues-ui-ux-optimization
refactor(web): unify design system with shadcn components
2026-03-24 14:19:16 +08:00
Jiayuan Zhang
7d38614a84
Merge pull request #244 from multica-ai/codex/claude-verification-opt-in
docs: make CLAUDE verification opt-in
2026-03-24 14:14:04 +08:00
Naiyuan Qing
8f4680c0e9 refactor(web): unify design system with shadcn components and semantic tokens
- Add success/warning/info semantic design tokens to globals.css
- Replace all raw HTML elements (input, select, textarea, button, label)
  with shadcn components (Input, Select, Textarea, Button, Label, Dialog)
  across settings, issues, agents, inbox, knowledge-base, and pair pages
- Replace all hardcoded Tailwind colors with design tokens
  (text-red-500 → text-destructive, text-green-600 → text-success, etc.)
- Extract shared ActorAvatar component to packages/ui/components/common
- Update status and priority configs to use semantic tokens
- Update CLAUDE.md with component organization guidelines
- Fix login page tests to use label-based queries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:13:55 +08:00
Jiayuan Zhang
3bdd1191a7 docs: make CLAUDE verification opt-in 2026-03-24 14:12:24 +08:00
yushen
0d9b687d92 fix(agent): address code review feedback
- Replace deprecated strings.Title with manual capitalize
- Fix race: set codexClient.onMessage before starting reader goroutine
- Remove unused msgCh parameter from codexClient.handleLine
- Route agent stderr through logger instead of dumping to os.Stderr
- Use deterministic agent order in ensurePaired (prefer codex)
- Increase message channel buffer from 64 to 256
- Rename test to match function rename (buildPrompt)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:10:08 +08:00
yushen
bb45f17cf9 feat(daemon): unified agent SDK supporting Claude Code and Codex
Add a reusable Go agent package (server/pkg/agent/) that provides a
unified Backend interface for executing prompts via either Claude Code
or Codex. The daemon now auto-detects which CLIs are available at
startup, registers a runtime for each, and routes tasks to the correct
backend based on task.Context.Runtime.Provider.

Key changes:
- server/pkg/agent/agent.go: Backend interface, Message/Result types, factory
- server/pkg/agent/claude.go: Spawns claude CLI with stream-json, parses output
- server/pkg/agent/codex.go: Spawns codex app-server, JSON-RPC 2.0 protocol
- server/cmd/daemon/daemon.go: Multi-runtime registration, round-robin polling,
  provider-based backend selection. Removes old runCodexExec/codexResultSchema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:05:03 +08:00
Naiyuan Qing
fc035c47c0 Merge remote-tracking branch 'origin/main' into feature/issues-ui-ux-optimization 2026-03-24 13:17:01 +08:00
Naiyuan Qing
a8e18cc15c refactor(web): replace raw HTML with shadcn components on login page
Use Card, Input, Button, and Label from @multica/ui for consistent design system.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 13:16:55 +08:00
Jiayuan Zhang
94c9b07bfb
Merge pull request #242 from multica-ai/codex/local-codex-runtime-pairing
Add local Codex daemon pairing flow
2026-03-24 12:08:54 +08:00
Jiayuan Zhang
20f5022664 fix(web): wrap search params pages in suspense 2026-03-24 12:07:20 +08:00
Jiayuan Zhang
cdfa63af15 feat(runtime): add local codex daemon pairing 2026-03-24 12:03:14 +08:00
Jiayuan Zhang
c6960d39b9 chore(claude): default to replacing stale flows 2026-03-24 12:02:44 +08:00
Naiyuan Qing
5d993531d1
Merge pull request #240 from multica-ai/feature/issue-ui-ux
feat: issue UI/UX enhancements with comment CRUD and tab navigation
2026-03-23 20:34:24 +08:00
Naiyuan Qing
8668b1e3c1 docs: update CLAUDE.md with E2E test patterns and env.example
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 20:23:33 +08:00
Naiyuan Qing
0afff49728 feat(web): enhance issue detail page with comment editing, deletion, and real-time updates
- Add inline comment editing and delete functionality
- Wire up WebSocket events for comment create/update/delete
- Expand issue property editing (due date, acceptance criteria, context refs)
- Add real-time issue updates via WebSocket

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 20:23:33 +08:00
Jiayuan Zhang
1a1f18ce8e
Merge pull request #241 from multica-ai/codex/disable-setup-seeding
Stop seeding example data during setup
2026-03-23 20:20:23 +08:00