AI & Agentslow risk

metagit-sharing-state

Configure shared coordination state (objectives, handoffs, approvals, events) across multiple agents and machines via METAGIT_STATE_URL and the ops HTTP backend. Use when Hermes subagents, CI runners, or humans must see the same objective queue without Syncthing JSON files.

metagit-ai/metagit-cli·skills/metagit-sharing-state/SKILL.md
85/ 100品質分

匯入這個 Skill

選擇你的 coding agent,複製專案級或個人級安裝指令。

固定至平台收錄的 commit
匯入目前專案.agents/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a codex -y
匯入個人環境~/.agents/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a codex -g -y
手動放置目錄.agents/skills/metagit-sharing-stateOfficial docs ↗
匯入目前專案.claude/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a claude-code -y
匯入個人環境~/.claude/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a claude-code -g -y
手動放置目錄.claude/skills/metagit-sharing-stateOfficial docs ↗
匯入目前專案.agents/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a github-copilot -y
匯入個人環境~/.copilot/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a github-copilot -g -y
手動放置目錄.agents/skills/metagit-sharing-stateOfficial docs ↗
匯入目前專案.agents/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a cursor -y
匯入個人環境~/.cursor/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a cursor -g -y
手動放置目錄.agents/skills/metagit-sharing-stateOfficial docs ↗
匯入目前專案.agents/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a gemini-cli -y
匯入個人環境~/.gemini/skills/metagit-sharing-state
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/skills/metagit-sharing-state -a gemini-cli -g -y
Native Gemini CLIgemini skills install https://github.com/metagit-ai/metagit-cli.git --scope workspace --path skills/metagit-sharing-state
手動放置目錄.agents/skills/metagit-sharing-stateOfficial docs ↗
⚠ 安裝指令使用開源 skills CLI。執行前請檢查來源、腳本與權限。
# Metagit shared coordination state

Use when **more than one agent or machine** must read/write the same objectives,
handoffs, approvals, and event feed — without syncing `.metagit/sessions/*.json`
via Syncthing.

Full reference: [docs/reference/sharing-state.md](../../../../docs/reference/sharing-state.md)

## When to use

- Hermes controller + subagents on different hosts
- Human on Metagit Web + agents on MCP/CLI
- CI runner updating objectives while developers use Cursor MCP

Prefer **remote state** over Syncthing for coordination JSON when agents run on
separate machines. Keep Syncthing (or git) for `.metagit.yml` catalog edits only.

## Coordinator setup

On one host with the workspace manifest:

```bash
metagit web serve --host 127.0.0.1 --port 8787
# production: TLS reverse proxy + bearer token in front
```

Persistence stays on that host under `.metagit/sessions/` and `.metagit/approvals/`.

## Client setup (CLI, MCP, every agent host)

App config (`~/.config/metagit/config.yml`):

```yaml
config:
  state:
    backend: http
    url: https://coordinator.example.com:8787
    token: your-bearer-token
    conflict_retries: 1
```

Or environment (overrides file — **must be set on the MCP server process**):

```bash
export METAGIT_AGENT_MODE=true
export METAGIT_STATE_URL=https://coordinator.example.com:8787
export METAGIT_STATE_TOKEN='…'
```

Restart MCP after changing env (`metagit mcp serve` inherits the shell env).

## Verify backend (MCP)

```text
resources/read → metagit://gate/status
```

Check `state_backend`:

| Field | Meaning |
|-------|---------|
| `backend` | `local` or `http` (effective) |
| `url` | Remote ops base when `http` |
| `token_configured` | Bearer token present (not the secret) |
| `env_overrides` | Which `METAGIT_STATE_*` vars are set |

If `backend` is `local` but you expected remote, the MCP host is missing env/config.

## MCP tools (unchanged names — remote-aware)

| Coordination | MCP tool | Resource |
|--------------|----------|----------|
| Objectives | `metagit_objective_list`, `metagit_objective_upsert`, `metagit_objective_edit` | `metagit://objectives` |
| Approvals | `metagit_approval_request`, `metagit_approval_list`, `metagit_approval_resolve` | `metagit://approvals/pending` |
| Handoffs | `metagit_handoff_list`, `metagit_handoff_create`, `metagit_handoff_claim`, `metagit_handoff_complete` | `metagit://handoffs/open` |
| Events poll | `metagit_events` | `metagit://events/recent?since=` |

All use `resolve_backend()` — no separate remote MCP tools.

## CLI parity

```bash
metagit context objective list --json
metagit context handoff list --json
metagit context approval list --json
```

## Anti-patterns

- Mixed backends (some agents local, some remote) — objectives diverge silently
- Syncthing `.metagit/sessions/objectives.json` **and** remote state on the same fleet
- Forgetting to export `METAGIT_STATE_*` in the MCP launcher JSON (Cursor/Claude Desktop)

## Related skills

- `metagit-context-pack` — session bootstrap + objective/approval CLI/MCP table
- `metagit-mcp-resources` — resource read ladder including events poll
- `metagit-control-center` — ongoing multi-repo coordination
- `metagit-agent-coordination` — git isolation (branches/leases/worktrees); orthogonal to shared state JSON