feat(daemon): multi-workspace support with hot-reload
- Add `multica workspace watch/unwatch/list` CLI commands - Daemon watches multiple workspaces from config's `watched_workspaces` - Registers runtimes per workspace, polls all runtime IDs in round-robin - Hot-reload: daemon detects config file changes every 5s and adds/removes workspaces without restart - Remove `--workspace-id` flag from daemon (workspace selection is now purely config-driven via `multica workspace watch`) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b9d2b88852
commit
4210fe69f4
6 changed files with 332 additions and 81 deletions
|
|
@ -10,11 +10,40 @@ import (
|
|||
|
||||
const defaultCLIConfigPath = ".multica/config.json"
|
||||
|
||||
// WatchedWorkspace represents a workspace the daemon should monitor for tasks.
|
||||
type WatchedWorkspace struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// CLIConfig holds persistent CLI settings.
|
||||
type CLIConfig struct {
|
||||
ServerURL string `json:"server_url,omitempty"`
|
||||
WorkspaceID string `json:"workspace_id,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
ServerURL string `json:"server_url,omitempty"`
|
||||
WorkspaceID string `json:"workspace_id,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
WatchedWorkspaces []WatchedWorkspace `json:"watched_workspaces,omitempty"`
|
||||
}
|
||||
|
||||
// AddWatchedWorkspace adds a workspace to the watch list. Returns true if added.
|
||||
func (c *CLIConfig) AddWatchedWorkspace(id, name string) bool {
|
||||
for _, w := range c.WatchedWorkspaces {
|
||||
if w.ID == id {
|
||||
return false
|
||||
}
|
||||
}
|
||||
c.WatchedWorkspaces = append(c.WatchedWorkspaces, WatchedWorkspace{ID: id, Name: name})
|
||||
return true
|
||||
}
|
||||
|
||||
// RemoveWatchedWorkspace removes a workspace from the watch list. Returns true if found.
|
||||
func (c *CLIConfig) RemoveWatchedWorkspace(id string) bool {
|
||||
for i, w := range c.WatchedWorkspaces {
|
||||
if w.ID == id {
|
||||
c.WatchedWorkspaces = append(c.WatchedWorkspaces[:i], c.WatchedWorkspaces[i+1:]...)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// CLIConfigPath returns the default path for the CLI config file.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue