claude-flow 3.58.1 → 3.59.1
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/.claude/proven-config.json +1 -1
- package/README.md +2 -0
- package/package.json +2 -1
- package/v3/@claude-flow/cli/README.md +2 -0
- package/v3/@claude-flow/cli/bin/cli.js +19 -1
- package/v3/@claude-flow/cli/catalog-manifest.json +3 -3
- package/v3/@claude-flow/cli/dist/src/commands/harness.d.ts +40 -0
- package/v3/@claude-flow/cli/dist/src/commands/harness.js +142 -0
- package/v3/@claude-flow/cli/dist/src/commands/index.js +1 -0
- package/v3/@claude-flow/cli/dist/src/commands/init.js +116 -0
- package/v3/@claude-flow/cli/dist/src/commands/memory.js +6 -1
- package/v3/@claude-flow/cli/dist/src/commands/status.js +2 -2
- package/v3/@claude-flow/cli/dist/src/commands/tui.js +9 -4
- package/v3/@claude-flow/cli/dist/src/index.d.ts +3 -0
- package/v3/@claude-flow/cli/dist/src/index.js +12 -2
- package/v3/@claude-flow/cli/dist/src/init/grok-generator.d.ts +96 -0
- package/v3/@claude-flow/cli/dist/src/init/grok-generator.js +371 -0
- package/v3/@claude-flow/cli/dist/src/init/grok-templates.d.ts +11 -0
- package/v3/@claude-flow/cli/dist/src/init/grok-templates.js +28 -0
- package/v3/@claude-flow/cli/dist/src/init/index.d.ts +2 -0
- package/v3/@claude-flow/cli/dist/src/init/index.js +2 -0
- package/v3/@claude-flow/cli/dist/src/mcp-client.js +4 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-execute-core.js +59 -12
- package/v3/@claude-flow/cli/dist/src/mcp-tools/capability-brain.d.ts +1 -1
- package/v3/@claude-flow/cli/dist/src/mcp-tools/capability-brain.js +5 -3
- package/v3/@claude-flow/cli/dist/src/mcp-tools/embeddings-tools.js +11 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/index.d.ts +1 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/index.js +2 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +42 -4
- package/v3/@claude-flow/cli/dist/src/mcp-tools/task-tools.js +7 -3
- package/v3/@claude-flow/cli/dist/src/mcp-tools/team-tools.d.ts +15 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/team-tools.js +244 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +19 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +163 -3
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +4 -0
- package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +70 -37
- package/v3/@claude-flow/cli/dist/src/memory/rabitq-index.d.ts +19 -0
- package/v3/@claude-flow/cli/dist/src/memory/rabitq-index.js +117 -1
- package/v3/@claude-flow/cli/dist/src/missions/schemas.d.ts +113 -113
- package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +193 -193
- package/v3/@claude-flow/cli/dist/src/services/live-harness.d.ts +111 -0
- package/v3/@claude-flow/cli/dist/src/services/live-harness.js +427 -0
- package/v3/@claude-flow/cli/package.json +4 -3
- package/v3/@claude-flow/cli/templates/grok/agents/ruflo-architect.md +35 -0
- package/v3/@claude-flow/cli/templates/grok/agents/ruflo-coder.md +34 -0
- package/v3/@claude-flow/cli/templates/grok/agents/ruflo-reviewer.md +30 -0
- package/v3/@claude-flow/cli/templates/grok/agents/ruflo-tester.md +26 -0
- package/v3/@claude-flow/cli/templates/grok/config.toml +63 -0
- package/v3/@claude-flow/cli/templates/grok/docs/README.md +186 -0
- package/v3/@claude-flow/cli/templates/grok/hooks/subagent-stop-team.json +15 -0
- package/v3/@claude-flow/cli/templates/grok/rules/ruflo-grok.md +132 -0
- package/v3/@claude-flow/cli/templates/grok/scripts/grok-subagent-stop-hook.mjs +90 -0
- package/v3/@claude-flow/cli/templates/grok/scripts/grok-team-bus.mjs +525 -0
- package/v3/@claude-flow/cli/templates/grok/scripts/grok-team-store.mjs +287 -0
- package/v3/@claude-flow/cli/templates/grok/scripts/host-statusline.mjs +281 -0
- package/v3/@claude-flow/cli/templates/grok/skills/agent-teams-grok/SKILL.md +98 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ruflo-tester
|
|
3
|
+
description: >
|
|
4
|
+
Ruflo tester for Grok. Writes and runs tests from implementation handoffs.
|
|
5
|
+
Use worktree isolation when modifying the tree. Reports to reviewer via team bus.
|
|
6
|
+
prompt_mode: full
|
|
7
|
+
agents_md: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You are the **tester** on a Ruflo Agent Team under **Grok Build**.
|
|
11
|
+
|
|
12
|
+
This file is a session profile (`grok --agent-profile ruflo-tester` or `/agents`). On Grok Build 1.0.41, `spawn_subagent` does not select it. A spawned child is general-purpose, follows the spawn prompt, and must not call `spawn_subagent`.
|
|
13
|
+
|
|
14
|
+
## Comms protocol
|
|
15
|
+
|
|
16
|
+
- Inbox: `node scripts/grok-team-bus.mjs inbox --team <TEAM> --agent tester`
|
|
17
|
+
- After tests:
|
|
18
|
+
`node scripts/grok-team-bus.mjs send --team <TEAM> --to reviewer --from tester --summary "tests-ready" --message "<commands, pass/fail, coverage gaps>"`
|
|
19
|
+
- `node scripts/grok-team-bus.mjs on-stop --team <TEAM> --agent tester`
|
|
20
|
+
|
|
21
|
+
## Deliverable
|
|
22
|
+
|
|
23
|
+
- Test plan + implemented tests
|
|
24
|
+
- Exact commands to run
|
|
25
|
+
- Failures with file:line
|
|
26
|
+
- Gaps you did not cover
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Ruflo on Grok Build — project-scoped host config
|
|
2
|
+
# Loaded by Grok when this folder is trusted (see ~/.grok/trusted_folders.toml).
|
|
3
|
+
#
|
|
4
|
+
# Goal: full harness (MCP + hooks + skills + agent teams path), not a thin CLI wrapper.
|
|
5
|
+
# See: .grok/rules/ruflo-grok.md and v3/docs/adr/ADR-402-host-agnostic-agent-teams.md
|
|
6
|
+
#
|
|
7
|
+
# After editing: restart Grok (or reload MCPs) so tool lists refresh.
|
|
8
|
+
|
|
9
|
+
# ---------------------------------------------------------------------------
|
|
10
|
+
# Ruflo MCP — orchestrator / ledger (memory, swarm, hooks, team bus, neural)
|
|
11
|
+
# `ruflo init --grok` pins this to the Ruflo version that ran it, because the
|
|
12
|
+
# team_* tools ship in that same release (an older @latest may lack them).
|
|
13
|
+
# From a source checkout it points at that checkout's bin/cli.js instead.
|
|
14
|
+
# Cold npx can exceed 30s; keep timeouts high.
|
|
15
|
+
# ---------------------------------------------------------------------------
|
|
16
|
+
[mcp_servers.ruflo]
|
|
17
|
+
command = {{RUFLO_MCP_COMMAND}}
|
|
18
|
+
args = {{RUFLO_MCP_ARGS}}
|
|
19
|
+
enabled = true
|
|
20
|
+
startup_timeout_sec = 120
|
|
21
|
+
tool_timeout_sec = 180
|
|
22
|
+
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
# Optional: RuvNet Brain grounding (search_ruvnet over embedded rUv source)
|
|
25
|
+
# Install: npx ruvnet-brain@latest → kb under ~/.cache/ruvnet-brain/kb
|
|
26
|
+
#
|
|
27
|
+
# forge-mcp-all defaults KB_DIR to process.cwd(). When Grok spawns MCP from the
|
|
28
|
+
# project root, search fails with "passages sidecar not found: ./agentdb…".
|
|
29
|
+
# Always set env.KB_DIR to the absolute kb path. tool_timeout_sec high for cold
|
|
30
|
+
# BGE model download (first big search can take minutes).
|
|
31
|
+
# init --grok fills in your home directory for the {{HOME}} paths below.
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
# [mcp_servers.ruvnet-brain]
|
|
34
|
+
# command = "node"
|
|
35
|
+
# args = ["{{HOME}}/.cache/ruvnet-brain/kb/forge-mcp-all.mjs"]
|
|
36
|
+
# env = { KB_DIR = "{{HOME}}/.cache/ruvnet-brain/kb" }
|
|
37
|
+
# enabled = true
|
|
38
|
+
# startup_timeout_sec = 90
|
|
39
|
+
# tool_timeout_sec = 600
|
|
40
|
+
|
|
41
|
+
# ---------------------------------------------------------------------------
|
|
42
|
+
# Permissions — allow Ruflo CLI + helpers without re-prompting every turn
|
|
43
|
+
# (deny still wins over allow; PreToolUse hooks can still block)
|
|
44
|
+
# ---------------------------------------------------------------------------
|
|
45
|
+
[permission]
|
|
46
|
+
allow = [
|
|
47
|
+
"Bash(npx ruflo*)",
|
|
48
|
+
"Bash(npx @claude-flow*)",
|
|
49
|
+
"Bash(npx claude-flow*)",
|
|
50
|
+
"Bash(node .claude/*)",
|
|
51
|
+
"Bash(npx -y ruflo*)",
|
|
52
|
+
"Bash(node scripts/grok-team-bus.mjs*)",
|
|
53
|
+
"MCPTool(ruflo__*)",
|
|
54
|
+
"MCPTool(ruvnet-brain__*)",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
# ---------------------------------------------------------------------------
|
|
58
|
+
# Subagent defaults are user-level on Grok Build 1.0.41.
|
|
59
|
+
# Project .grok/config.toml contributes only [mcp_servers], [plugins],
|
|
60
|
+
# [permission], and [mcp].max_output_bytes. A [subagents] table here is ignored.
|
|
61
|
+
# Put role defaults in ~/.grok/config.toml if you need them.
|
|
62
|
+
# Team children: pass host.grok.spawn from team_spawn (see docs/grok/README.md).
|
|
63
|
+
# ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Ruflo on Grok Build
|
|
2
|
+
|
|
3
|
+
How to run Ruflo inside [Grok Build](https://x.ai/) after `npx ruflo init --grok`.
|
|
4
|
+
|
|
5
|
+
**Host contract checked against Grok Build 1.0.41** (`grok 1.0.41`, macOS, 2026-09-27) and the user guide shipped with that binary (`~/.grok/docs/user-guide/`). Newer Grok builds change spawn arguments and which keys a project config may set. Run the check in [When Grok updates](#when-grok-updates) before treating this page as current.
|
|
6
|
+
|
|
7
|
+
Ruflo is the ledger: memory, swarm records, the team bus, hooks. Grok is the executor: it edits files, runs the shell, and calls `spawn_subagent`. After `team_create` or `swarm_init`, keep working. Those calls record coordination. They do not write the feature.
|
|
8
|
+
|
|
9
|
+
## What `init --grok` writes
|
|
10
|
+
|
|
11
|
+
| Path | Purpose |
|
|
12
|
+
|------|---------|
|
|
13
|
+
| `.grok/config.toml` | Project MCP server `ruflo` and permission allows |
|
|
14
|
+
| `.grok/rules/ruflo-grok.md` | Host doctrine loaded as a project rule |
|
|
15
|
+
| `.grok/agents/` | Session profiles (`ruflo-architect`, `ruflo-coder`, `ruflo-tester`, `ruflo-reviewer`) |
|
|
16
|
+
| `.grok/skills/agent-teams-grok/` | Skill the lead follows to spawn a pipeline |
|
|
17
|
+
| `.grok/hooks/subagent-stop-team.json` | `SubagentStop` → team bus idle-assign |
|
|
18
|
+
| `scripts/grok-team-bus.mjs`, `scripts/grok-team-store.mjs` | Team bus CLI (same store as the MCP `team_*` tools) |
|
|
19
|
+
| `scripts/grok-subagent-stop-hook.mjs` | Hook script: advances the plan when a teammate stops |
|
|
20
|
+
| `scripts/host-statusline.mjs` | The "what is loaded" line (see Loaded status) |
|
|
21
|
+
| `docs/grok/README.md` | This guide |
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
From the app you want Grok to work in (any repo, not only the Ruflo monorepo):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx -y ruflo@latest init --grok
|
|
29
|
+
# see what it would write, write nothing:
|
|
30
|
+
# npx -y ruflo@latest init --grok --dry-run
|
|
31
|
+
# overwrite an earlier scaffold:
|
|
32
|
+
# npx -y ruflo@latest init --grok --force
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`init --grok` writes only inside this project, and prints every path it wrote. It pins `[mcp_servers.ruflo]` to the Ruflo version that ran it (for example `ruflo@3.48.0`), because the `team_*` tools ship in that same release and an older `@latest` from a stale npx cache would lack them. Run from a Ruflo source checkout, it points the server at that checkout's `bin/cli.js` instead; re-run it from a published release before you commit `.grok/config.toml`.
|
|
36
|
+
|
|
37
|
+
Then:
|
|
38
|
+
|
|
39
|
+
1. Trust the folder. `/hooks-trust`, or launch with `grok --trust`. On 1.0.41 one grant covers project MCP, hooks, skills, and project rules together. The decision is stored in `~/.grok/trusted_folders.toml`.
|
|
40
|
+
2. Restart Grok with this folder as the workspace so `.grok/config.toml` loads.
|
|
41
|
+
3. Confirm the server:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
grok mcp list # ruflo (project)
|
|
45
|
+
grok mcp doctor ruflo # handshake ok; team_create present once this build is the server
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`init` writes the MCP block itself. To register by hand, scope it to the project. The default scope is your user config (`~/.grok/config.toml`), which would install Ruflo for every repo:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
grok mcp add ruflo --scope project -- npx -y ruflo@<version> mcp start
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Use a version that ships `team_*` (the one `init --grok` pinned). `-s project` is the same flag. Cold `npx` often exceeds the 30s default startup timeout; the scaffold sets `startup_timeout_sec = 120`.
|
|
55
|
+
|
|
56
|
+
## Use it in a session
|
|
57
|
+
|
|
58
|
+
Grok does not put each Ruflo tool on the model as its own function. The model has `search_tool` and `use_tool`.
|
|
59
|
+
|
|
60
|
+
1. `search_tool` with a keyword (`team_create`, `memory_search`, `swarm_init`).
|
|
61
|
+
2. `use_tool` with the catalog key: `ruflo__team_create`, `ruflo__memory_search`.
|
|
62
|
+
3. Stay on a small subset. A full Ruflo server exposes hundreds of tools; keyword search is how the model reaches them.
|
|
63
|
+
|
|
64
|
+
MCP parameter names on the team tools are `team` and `agent`.
|
|
65
|
+
|
|
66
|
+
### Agent teams
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
team_create → team_plan → team_spawn → spawn_subagent → team_send / team_inbox → team_on_stop → team_shutdown
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`team_spawn` returns a plan. The lead calls `spawn_subagent` with the top-level `prompt` and **only** `host.grok.spawn`:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
spawn_subagent({
|
|
76
|
+
prompt: spawnPlan.prompt,
|
|
77
|
+
description: spawnPlan.host.grok.spawn.description,
|
|
78
|
+
background: spawnPlan.host.grok.spawn.background,
|
|
79
|
+
isolation: spawnPlan.host.grok.spawn.isolation
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`host.grok.advisory.capability_mode` and `subagent_type` describe the role. They are not arguments of `spawn_subagent` on 1.0.41. Passing them fails the call. The child is `general-purpose`. The prompt states the read-only constraint. `isolation: "worktree"` is the setting Grok enforces, and it is how writers avoid editing the lead's tree.
|
|
84
|
+
|
|
85
|
+
Only the lead spawns. A child that calls `spawn_subagent` hits the depth limit (1).
|
|
86
|
+
|
|
87
|
+
Pass `description` through unchanged. It is `<role>:<agent>@<team>`, and the `SubagentStop` hook parses it to mark that agent idle and advance that team's plan. If a description has no `@team`, the hook uses the one active team that lists the agent; when several do, it advances nothing and says so on stderr.
|
|
88
|
+
|
|
89
|
+
How the bus behaves:
|
|
90
|
+
|
|
91
|
+
- State and mail live in `.claude-flow/teams/<team>/` (`team.json`, `mailbox/<agent>/`). Mail is per team: `team_inbox` needs `team` and `agent`, and `team_status` counts only that team's mail.
|
|
92
|
+
- `team.json` changes take a lock and are written to a temp file and renamed, so parallel spawns and hooks do not drop updates.
|
|
93
|
+
- `team_spawn` refuses once the team has `maxAgents` members (re-spawning an existing member is fine).
|
|
94
|
+
- `team_shutdown` closes the team: spawn, send, broadcast, plan, and on-stop refuse afterwards. `team_inbox` and `team_status` still work so remaining mail can be drained. `team_create --force` reopens the name.
|
|
95
|
+
- A broadcast (`to: "*"`) goes to current members and is refused while the team has none.
|
|
96
|
+
- `priority` is an integer 0-999; lower is read first.
|
|
97
|
+
- Several teams can be active at once; every call names its team.
|
|
98
|
+
|
|
99
|
+
`.grok/agents/ruflo-coder.md` and the other profiles apply when you start Grok as that agent (`grok --agent-profile ruflo-coder` or `/agents`). Spawn does not select them.
|
|
100
|
+
|
|
101
|
+
CLI bus, same plan shape, no MCP required:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
node scripts/grok-team-bus.mjs create --name feature-x --topology hierarchical
|
|
105
|
+
node scripts/grok-team-bus.mjs plan --team feature-x \
|
|
106
|
+
--steps '["architect","developer","tester","reviewer"]'
|
|
107
|
+
node scripts/grok-team-bus.mjs spawn --team feature-x --agent architect --role architect \
|
|
108
|
+
--prompt "Design the feature." --next developer
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Map the printed `spawnPlan.host.grok.spawn` the same way. Skill: `agent-teams-grok`.
|
|
112
|
+
|
|
113
|
+
### What the project config loads
|
|
114
|
+
|
|
115
|
+
On 1.0.41, `.grok/config.toml` contributes:
|
|
116
|
+
|
|
117
|
+
- `[mcp_servers]`
|
|
118
|
+
- `[plugins]`
|
|
119
|
+
- `[permission]`
|
|
120
|
+
- `[mcp].max_output_bytes`
|
|
121
|
+
|
|
122
|
+
Other tables, including `[subagents]`, are read from `~/.grok/config.toml` only. The scaffold used to write `[subagents] enabled = true` into the project file. That key does nothing there. Subagents are on by default.
|
|
123
|
+
|
|
124
|
+
Permission allows in the scaffold use Grok's native forms, `Bash(...)` and `MCPTool(ruflo__*)`. Deny still beats allow.
|
|
125
|
+
|
|
126
|
+
### Hooks
|
|
127
|
+
|
|
128
|
+
`.grok/hooks/subagent-stop-team.json` runs on `SubagentStop` and calls `scripts/grok-subagent-stop-hook.mjs`. It runs only after the folder is trusted. `$CLAUDE_PROJECT_DIR` is set (alias of `GROK_WORKSPACE_ROOT`).
|
|
129
|
+
|
|
130
|
+
`UserPromptSubmit` hooks that allow the prompt do not inject stdout into the model on 1.0.41. If a route hook seems to vanish, read `.swarm/route-latest.md` or call the route tool. That is a host limit, not a missing Ruflo file.
|
|
131
|
+
|
|
132
|
+
## Loaded status
|
|
133
|
+
|
|
134
|
+
`scripts/host-statusline.mjs` is the shared "what loaded" line: `RuFlo loaded │ ruflo │ rules │ 4 agents │ skill │ hook │ trusted`, or the names of what is missing. Claude shows its own richer `statusLine`. Codex has no status row; `node scripts/host-statusline.mjs --host codex` prints the same facts.
|
|
135
|
+
|
|
136
|
+
Grok reads `[ui.status_line]` only from your user file, `~/.grok/config.toml`; a project config cannot set it. `init --grok` does not touch that file unless you ask. It prints the snippet to add, or with `--grok-statusline` it:
|
|
137
|
+
|
|
138
|
+
- copies the script to `~/.grok/ruflo/host-statusline.mjs`, and
|
|
139
|
+
- merges this into `~/.grok/config.toml` (parsed with a TOML parser; an existing `ui.status_line` in any form is left alone, and a file it cannot merge safely is not changed — you get the snippet instead):
|
|
140
|
+
|
|
141
|
+
```toml
|
|
142
|
+
[ui.status_line]
|
|
143
|
+
type = "command"
|
|
144
|
+
command = 'node "/home/you/.grok/ruflo/host-statusline.mjs"'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The command is an absolute path to your own copy, so no repo can substitute a script of its own. It reports on whichever folder Grok is in. Restart Grok after the user file changes.
|
|
148
|
+
|
|
149
|
+
## Prove it
|
|
150
|
+
|
|
151
|
+
From a Ruflo checkout (this script is not copied by `init --grok`; run `init --grok` in the checkout first):
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
node scripts/probe-host-live.mjs --host grok
|
|
155
|
+
node scripts/probe-host-live.mjs --host all --no-execute
|
|
156
|
+
node scripts/probe-host-live.mjs --host grok --live
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
One contract (discover, connect, SessionStart receipt, optional memory round trip) with a Grok, Claude, or Codex adapter. A check that CLI cannot answer is a skip, not a pass.
|
|
160
|
+
|
|
161
|
+
## When Grok updates
|
|
162
|
+
|
|
163
|
+
The July 2026 host work assumed Grok 1.0.34 and a spawn schema that accepted `subagent_type` and `capability_mode`. 1.0.41 dropped both from the model-facing tool and stopped applying `[subagents]` from project config. The same class of drift will happen again.
|
|
164
|
+
|
|
165
|
+
After `grok --version` changes:
|
|
166
|
+
|
|
167
|
+
1. Open `~/.grok/docs/user-guide/16-subagents.md` and read **Spawning Subagents**. The parameter table is the contract. Forward a key only if it is listed.
|
|
168
|
+
2. Open `26-config-reference.md` and confirm which sections a project `.grok/config.toml` may set (1.0.41: mcp servers, plugins, permission, mcp output cap).
|
|
169
|
+
3. Open `07-mcp-servers.md` and confirm `grok mcp add --scope` still defaults to `user`, and that tools are still `search_tool` / `use_tool` with `server__tool` names.
|
|
170
|
+
4. Open `10-hooks.md` and confirm `SubagentStop`, folder trust, and `$CLAUDE_PROJECT_DIR`.
|
|
171
|
+
5. Open `22-permissions-and-safety.md` and confirm `MCPTool(server__tool)` and `Bash(...)` still match the allows in `.grok/config.toml`.
|
|
172
|
+
6. Spawn once with `host.grok.spawn` only. If the tool rejects `background`, the user guide's name for that flag is `run_in_background` — use the name the live schema accepts.
|
|
173
|
+
7. Update the `contract` string in `team_spawn` / `scripts/grok-team-bus.mjs` and this page to the version you just checked.
|
|
174
|
+
|
|
175
|
+
`grok inspect` shows which rules, skills, and MCP servers the trusted folder actually loaded.
|
|
176
|
+
|
|
177
|
+
## Optional
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npx -y ruflo@latest daemon start
|
|
181
|
+
npx -y ruflo@latest doctor
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
RuvNet Brain is off in the scaffold. Uncomment `[mcp_servers.ruvnet-brain]` in `.grok/config.toml` after `npx ruvnet-brain@latest`, and set `env.KB_DIR` to the absolute `~/.cache/ruvnet-brain/kb` path. `init --grok` fills in your home directory for those paths when it creates the file.
|
|
185
|
+
|
|
186
|
+
Architecture: ADR-402 (Host-Agnostic Agent Teams), in the Ruflo repo at `v3/docs/adr/ADR-402-host-agnostic-agent-teams.md`.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Ruflo on Grok — host doctrine
|
|
2
|
+
|
|
3
|
+
You are running **inside Grok Build**, not Claude Code. Ruflo is the harness (orchestrator/ledger). **You** execute.
|
|
4
|
+
|
|
5
|
+
## Division of labor
|
|
6
|
+
|
|
7
|
+
| Layer | Role |
|
|
8
|
+
|-------|------|
|
|
9
|
+
| **Grok** | Executor — edit files, shell, tests, `spawn_subagent`, synthesize |
|
|
10
|
+
| **Ruflo MCP/CLI** | Orchestrator — memory, swarm records, team bus, learning, security hooks |
|
|
11
|
+
|
|
12
|
+
After any `swarm_init` / `team_create` / `agent_spawn` / MCP coordination call: **immediately continue working**. Never wait for Ruflo to “build the feature.” It does not execute code.
|
|
13
|
+
|
|
14
|
+
## Tool map (Claude / CLAUDE.md → Grok)
|
|
15
|
+
|
|
16
|
+
| Claude / CLAUDE.md | Grok |
|
|
17
|
+
|--------------------|------|
|
|
18
|
+
| `Task(...)` / Agent Teams spawn | `spawn_subagent` (`background: true` for parallel) |
|
|
19
|
+
| `SendMessage` | Ruflo MCP `team_send` / `team_inbox` (host-agnostic bus) — until available: AgentDB memory namespace `team:{id}` or `collaboration` |
|
|
20
|
+
| `TodoWrite` | `todo_write` |
|
|
21
|
+
| `Bash` | `run_terminal_command` |
|
|
22
|
+
| `Read` / `Grep` / `Glob` | `read_file` / `grep` / `list_dir` |
|
|
23
|
+
| `Write` / `Edit` / `MultiEdit` | `write` / `search_replace` |
|
|
24
|
+
| `claude -p` workers | `spawn_subagent` or `grok -p` |
|
|
25
|
+
| `mcp__claude-flow__*` / `mcp__ruflo__*` | `search_tool` then `use_tool` with `ruflo__*` names |
|
|
26
|
+
| Haiku / Sonnet / Opus routing | Ignore Anthropic tiers; use Grok models / subagent `model` only when needed |
|
|
27
|
+
|
|
28
|
+
## MCP usage
|
|
29
|
+
|
|
30
|
+
1. Discover: `search_tool` with keywords (`memory_search`, `swarm_init`, `team_`, `hooks`).
|
|
31
|
+
2. Call: `use_tool` with the fully-qualified name (e.g. `ruflo__memory_search`).
|
|
32
|
+
3. Prefer memory + team/swarm subset over flooding with all 300+ tools.
|
|
33
|
+
|
|
34
|
+
## Before complex work (mandatory)
|
|
35
|
+
|
|
36
|
+
1. `memory_search` (namespace `patterns` when available) for similar past solutions.
|
|
37
|
+
2. If RuvNet Brain / `search_ruvnet` is available: ground stack choices in real rUv source **before** recommending Pinecone, pgvector, LangChain, or other training-prior defaults.
|
|
38
|
+
3. For multi-file / multi-role work: open a **named team** pipeline (see Agent Teams below).
|
|
39
|
+
|
|
40
|
+
## After success (mandatory)
|
|
41
|
+
|
|
42
|
+
Store what worked via `memory_store` (namespace `patterns`): approach, files, gotchas, commands.
|
|
43
|
+
|
|
44
|
+
## Agent Teams on Grok (comms-first)
|
|
45
|
+
|
|
46
|
+
Named agents coordinate via the **Ruflo team bus** (MCP), not proprietary Claude `SendMessage`.
|
|
47
|
+
|
|
48
|
+
### Preferred pipeline
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
lead (you)
|
|
52
|
+
→ spawn named subagents in ONE turn (background: true)
|
|
53
|
+
→ each agent handoff via team_send / memory key
|
|
54
|
+
→ SubagentStop / you assign next step
|
|
55
|
+
→ lead synthesizes
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Spawn contract (Grok Build 1.0.41)
|
|
59
|
+
|
|
60
|
+
`spawn_subagent` takes `prompt`, `description`, `background`, `isolation`, and optionally `cwd`, `resume_from`, and `model`. It does not take `subagent_type` or `capability_mode`. An omitted type is `general-purpose`. Nesting depth is 1, so only the lead spawns.
|
|
61
|
+
|
|
62
|
+
`team_spawn` returns `host.grok.spawn` for those arguments and `host.grok.advisory` for the role constraint. Pass `spawn` plus `prompt`. The prompt tells a read-only role not to edit. `isolation: "worktree"` is what Grok enforces for writers.
|
|
63
|
+
|
|
64
|
+
`.grok/agents/ruflo-*` are session profiles (`grok --agent-profile` or `/agents`). They are not spawn types.
|
|
65
|
+
|
|
66
|
+
Project `.grok/config.toml` contributes `[mcp_servers]`, `[plugins]`, `[permission]`, and `[mcp].max_output_bytes`. A `[subagents]` table in that file is ignored. Subagent defaults belong in `~/.grok/config.toml`.
|
|
67
|
+
|
|
68
|
+
Operator guide: `docs/grok/README.md`. If `grok --version` moves past 1.0.41, re-check `~/.grok/docs/user-guide/16-subagents.md` and `26-config-reference.md` before forwarding new spawn keys.
|
|
69
|
+
|
|
70
|
+
### Defaults
|
|
71
|
+
|
|
72
|
+
| Role | Prompt constraint | `isolation` |
|
|
73
|
+
|------|-------------------|-------------|
|
|
74
|
+
| researcher / architect / reviewer | read-only | `none` |
|
|
75
|
+
| coder / implementer | full tools | **`worktree`** |
|
|
76
|
+
| tester | full tools | **`worktree`** when writing tests |
|
|
77
|
+
|
|
78
|
+
- Always pass a clear **name/role** in the prompt (“You are architect on team feature-x”).
|
|
79
|
+
- Tell each agent **who to message next** and **what artifact to produce**.
|
|
80
|
+
- Prefer short cycles with verification gates over one giant agent.
|
|
81
|
+
- Hierarchical topology for coding swarms; max ~6–8 concurrent workers.
|
|
82
|
+
|
|
83
|
+
### Spawn pattern (all in one message)
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
spawn_subagent({ prompt, description, background: true, isolation: "none" })
|
|
87
|
+
architect → team_send to developer
|
|
88
|
+
spawn_subagent({ ..., isolation: "worktree" })
|
|
89
|
+
developer → tester → reviewer (reviewer isolation "none")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Use MCP team tools or memory handoffs. There is no `SendMessage` tool.
|
|
93
|
+
|
|
94
|
+
## Skills
|
|
95
|
+
|
|
96
|
+
- Prefer project skills under `.agents/skills/` and `.claude/skills/`.
|
|
97
|
+
- High-value first: swarm-orchestration, memory-management, sparc-methodology, security-audit, github-automation, hive-mind.
|
|
98
|
+
- Load a skill when the task matches its description; don’t dump all 100+ into context.
|
|
99
|
+
|
|
100
|
+
## Hooks (already in `.claude/settings.json`)
|
|
101
|
+
|
|
102
|
+
Grok loads Claude-compatible hooks when the folder is trusted. Expect:
|
|
103
|
+
|
|
104
|
+
- SessionStart: session restore + memory import
|
|
105
|
+
- UserPromptSubmit: route / intelligence context
|
|
106
|
+
- PreToolUse Bash: pre-bash safety
|
|
107
|
+
- PostToolUse edits: post-edit learning
|
|
108
|
+
- SubagentStop: post-task / idle assign
|
|
109
|
+
|
|
110
|
+
If route context does not appear in the transcript, call `hooks route` via CLI/MCP or read `.swarm/route-latest.md` when present.
|
|
111
|
+
|
|
112
|
+
## CLI fallback
|
|
113
|
+
|
|
114
|
+
When MCP is down:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npx -y ruflo@latest memory search --query "…"
|
|
118
|
+
npx -y ruflo@latest memory store --key "…" --value "…" --namespace patterns
|
|
119
|
+
npx -y ruflo@latest swarm init --topology hierarchical --max-agents 8
|
|
120
|
+
npx -y ruflo@latest doctor
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Team calls have their own fallback that needs no npx: `node scripts/grok-team-bus.mjs <command> --team <team> …` (same store as the `team_*` tools).
|
|
124
|
+
|
|
125
|
+
## Anti-patterns
|
|
126
|
+
|
|
127
|
+
- Waiting after `swarm start` for code to appear
|
|
128
|
+
- Calling Claude-only tools (`SendMessage`, Claude `Task` agent types as host APIs)
|
|
129
|
+
- Shared-tree parallel coders without worktrees (file races)
|
|
130
|
+
- Skipping memory_search / grounding on stack decisions
|
|
131
|
+
- Creating docs in repo root or committing secrets
|
|
132
|
+
)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Grok SubagentStop → team bus on-stop (ADR-402).
|
|
4
|
+
*
|
|
5
|
+
* Reads the hook JSON from stdin (Grok / Claude compatible fields) and marks
|
|
6
|
+
* the stopped teammate idle, advancing its team's plan.
|
|
7
|
+
*
|
|
8
|
+
* Which teammate: team_spawn sets the spawn description to
|
|
9
|
+
* `<role>:<agent>@<team>`. The hook parses that; TEAM_NAME / SUBAGENT_NAME
|
|
10
|
+
* env vars or explicit `team` / `agentName` fields override it.
|
|
11
|
+
*
|
|
12
|
+
* Which team, when the description has no @team: the one active team that
|
|
13
|
+
* lists the agent as a member. Several matches are reported as ambiguous and
|
|
14
|
+
* nothing is advanced.
|
|
15
|
+
*
|
|
16
|
+
* Exit codes: 0 done, or the subagent is not a team member (nothing to do);
|
|
17
|
+
* 1 a team subagent could not be recorded (reason on stderr, non-blocking).
|
|
18
|
+
*/
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
21
|
+
|
|
22
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const bus = await import(pathToFileURL(join(here, 'grok-team-bus.mjs')).href);
|
|
24
|
+
|
|
25
|
+
const projectRoot = process.env.CLAUDE_PROJECT_DIR || process.env.GROK_WORKSPACE_ROOT || process.cwd();
|
|
26
|
+
|
|
27
|
+
function readStdin() {
|
|
28
|
+
if (process.stdin.isTTY) return Promise.resolve('');
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
let data = '';
|
|
31
|
+
const t = setTimeout(() => resolve(data), 1000);
|
|
32
|
+
process.stdin.setEncoding('utf8');
|
|
33
|
+
process.stdin.on('data', (c) => { data += c; });
|
|
34
|
+
process.stdin.on('end', () => { clearTimeout(t); resolve(data); });
|
|
35
|
+
process.stdin.on('error', () => { clearTimeout(t); resolve(data); });
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fail(reason) {
|
|
40
|
+
process.stderr.write(`ruflo team hook: ${reason}\n`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let input = {};
|
|
45
|
+
const raw = await readStdin();
|
|
46
|
+
try {
|
|
47
|
+
input = raw.trim() ? JSON.parse(raw) : {};
|
|
48
|
+
} catch {
|
|
49
|
+
input = {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const description = input.description ?? input.toolInput?.description ?? input.tool_input?.description;
|
|
53
|
+
const parsed = bus.parseSpawnDescription(description) || {};
|
|
54
|
+
const agent =
|
|
55
|
+
process.env.SUBAGENT_NAME
|
|
56
|
+
|| input.subagentName
|
|
57
|
+
|| input.agentName
|
|
58
|
+
|| input.agent
|
|
59
|
+
|| parsed.agent;
|
|
60
|
+
const explicitTeam = process.env.TEAM_NAME || input.teamName || input.team || parsed.team;
|
|
61
|
+
|
|
62
|
+
if (!agent) {
|
|
63
|
+
// Not a team spawn (no description in <role>:<agent>@<team> form).
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let team = explicitTeam;
|
|
68
|
+
if (!team) {
|
|
69
|
+
let matches;
|
|
70
|
+
try {
|
|
71
|
+
matches = bus.teamsWithMember(projectRoot, String(agent));
|
|
72
|
+
} catch (err) {
|
|
73
|
+
fail(err.message);
|
|
74
|
+
}
|
|
75
|
+
if (matches.length === 0) process.exit(0);
|
|
76
|
+
if (matches.length > 1) {
|
|
77
|
+
fail(`agent "${agent}" is on several active teams (${matches.join(', ')}); spawn with the description from team_spawn (<role>:<agent>@<team>) or set TEAM_NAME`);
|
|
78
|
+
}
|
|
79
|
+
team = matches[0];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
const r = await bus.onStop(projectRoot, { team: String(team), agent: String(agent) });
|
|
84
|
+
if (!r.member && !r.advanced) {
|
|
85
|
+
fail(`agent "${agent}" is not a member of team "${team}" and is not its current plan step`);
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
fail(err.message || String(err));
|
|
89
|
+
}
|
|
90
|
+
process.exit(0);
|