@heretyc/subagent-mcp 2.12.11 → 2.12.13
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/README.md +170 -170
- package/directives/carryover-claude.md +0 -2
- package/directives/carryover-codex.md +0 -2
- package/directives/handoff-claude.md +7 -0
- package/directives/handoff-codex.md +7 -0
- package/directives/latch-claude.md +5 -0
- package/directives/latch-codex.md +5 -0
- package/directives/orchestration-claude.md +0 -2
- package/directives/orchestration-codex.md +0 -2
- package/directives/reminder-off-claude.md +1 -3
- package/directives/reminder-off-codex.md +1 -3
- package/directives/reminder-on.md +0 -2
- package/directives/short-off.md +1 -1
- package/directives/short-on.md +1 -1
- package/directives/tag-template.md +2 -0
- package/dist/advanced-ruleset.py +67 -67
- package/dist/config-scaffold.js +1 -1
- package/dist/global-concurrency.jsonc +43 -43
- package/dist/global-subagent-mcp-config.jsonc +43 -43
- package/dist/hooks/orchestration-claude.js +86 -2
- package/dist/hooks/orchestration-codex.js +152 -3
- package/dist/index.js +76 -8
- package/dist/init.js +2 -2
- package/dist/orchestration/handoff.js +142 -0
- package/dist/orchestration/hook-core.js +184 -16
- package/dist/orchestration/latch.js +47 -0
- package/dist/orchestration/marker.js +55 -1
- package/dist/orchestration/metering.js +158 -0
- package/dist/orchestration/pretool.js +3 -3
- package/dist/orchestration/template.js +31 -0
- package/dist/routing-table.json +2133 -3561
- package/dist/routing.js +3 -2
- package/dist/ruleset-scaffold.js +1 -1
- package/package.json +70 -70
- package/scripts/postinstall.mjs +102 -102
package/README.md
CHANGED
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
# subagent-mcp
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@heretyc/subagent-mcp)
|
|
4
|
-
[](LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/@heretyc/subagent-mcp)
|
|
6
|
-
[](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml)
|
|
7
|
-
|
|
8
|
-
## Core Premise
|
|
9
|
-
|
|
10
|
-
subagent-mcp is an MCP stdio server that turns an AI coding assistant (Claude
|
|
11
|
-
Code, Codex, Gemini CLI) into a manager of local Claude and Codex sub-agents on
|
|
12
|
-
macOS, Linux, and Windows. It drives the locally authenticated `claude` and
|
|
13
|
-
`codex` CLIs you already signed into. It does not make direct HTTP API calls and
|
|
14
|
-
does not require API keys.
|
|
15
|
-
|
|
16
|
-
The orchestrator monitors but does not read or write project files itself. Work
|
|
17
|
-
is delegated to fresh sub-agents, so the orchestrator keeps summaries instead
|
|
18
|
-
of raw file context. The main invariants are:
|
|
19
|
-
|
|
20
|
-
- one machine-global, provider-agnostic concurrency cap (default 20, minimum 10)
|
|
21
|
-
- fail-safe orchestration ON on hookless hosts
|
|
22
|
-
- state authority only from harness-verified `<subagent-mcp state="...">` tags
|
|
23
|
-
- sub-agents gated by default with permission ceiling `auto`
|
|
24
|
-
- automatic model, provider, and effort routing per task category
|
|
25
|
-
|
|
26
|
-
## Install
|
|
27
|
-
|
|
28
|
-
### What You Need First
|
|
29
|
-
|
|
30
|
-
- Node.js 18 or newer (`node --version`)
|
|
31
|
-
- `claude` CLI, installed and signed in (`claude --version`)
|
|
32
|
-
- `codex` CLI, installed and signed in (`codex --version`; optional if you only
|
|
33
|
-
use Claude)
|
|
34
|
-
|
|
35
|
-
Building from source needs extra developer tools. See
|
|
36
|
-
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
37
|
-
|
|
38
|
-
### Install The Package
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm install -g @heretyc/subagent-mcp
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This is the standard install. Organizations pinning the package through GitHub
|
|
45
|
-
Packages should see [docs/registration.md](docs/registration.md).
|
|
46
|
-
|
|
47
|
-
### Wire It Into Your Assistant
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
subagent-mcp setup
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Installing the package only ships the program. It does not connect anything on
|
|
54
|
-
its own. `subagent-mcp setup` finds your Claude Code or Codex install and
|
|
55
|
-
registers both the server and the per-turn orchestration hooks. Preview first
|
|
56
|
-
with `subagent-mcp setup --dry-run`.
|
|
57
|
-
|
|
58
|
-
### Restart, Then Turn On The Invariant
|
|
59
|
-
|
|
60
|
-
Restart your Claude Code or Codex session so it picks up the new tools. On
|
|
61
|
-
Codex, run `/hooks` and trust the new hook. Then, recommended:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
subagent-mcp init --global
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
This writes a managed "always delegate" rule block into your global assistant
|
|
68
|
-
config once. For one project only, use
|
|
69
|
-
`subagent-mcp init --root /path/to/project`. Full per-platform wiring (Gemini
|
|
70
|
-
CLI, Claude Desktop, manual setup) is in
|
|
71
|
-
[docs/registration.md](docs/registration.md).
|
|
72
|
-
|
|
73
|
-
## How To Operate It
|
|
74
|
-
|
|
75
|
-
### Orchestration Mode
|
|
76
|
-
|
|
77
|
-
- **ON**: your assistant acts as a pure manager. It delegates every step to
|
|
78
|
-
sub-agents. Best for big, long-running jobs.
|
|
79
|
-
- **OFF**: your assistant works normally, with no delegation rules.
|
|
80
|
-
|
|
81
|
-
Flip it with the `orchestration-mode` tool. Desktop apps can toggle the mode but
|
|
82
|
-
do not receive per-turn hook reminders.
|
|
83
|
-
|
|
84
|
-
### Tools
|
|
85
|
-
|
|
86
|
-
The server exposes `launch_agent`, `poll_agent`, `kill_agent`, `send_message`,
|
|
87
|
-
`list_agents`, `wait`, `respond_permission`, `orchestration-mode`, and
|
|
88
|
-
`model-selection-mode`. See [docs/tools.md](docs/tools.md) for the full
|
|
89
|
-
parameter and return reference.
|
|
90
|
-
|
|
91
|
-
You do not have to choose a model. Give `launch_agent` a prompt and a task
|
|
92
|
-
category such as `coding`, `debugging`, or `security_review`; the server picks
|
|
93
|
-
the provider, model, and effort.
|
|
94
|
-
|
|
95
|
-
### Concurrency
|
|
96
|
-
|
|
97
|
-
There is one machine-wide limit on concurrent sub-agents. The default is 20.
|
|
98
|
-
When the limit is reached, `launch_agent` is rejected immediately and does not
|
|
99
|
-
queue. Change the value in `global-subagent-mcp-config.jsonc` in the install
|
|
100
|
-
folder. The file is re-read on every launch.
|
|
101
|
-
|
|
102
|
-
The config file was renamed from `global-concurrency.jsonc` in 2.12.5. The old
|
|
103
|
-
name is still read, with a one-time deprecation notice, when the new file is
|
|
104
|
-
absent.
|
|
105
|
-
|
|
106
|
-
The same settings file includes `checkForUpdates` (default `true`). Disable it
|
|
107
|
-
with `checkForUpdates: false` or `SUBAGENT_UPDATE_CHECK=0`.
|
|
108
|
-
|
|
109
|
-
## Configuration
|
|
110
|
-
|
|
111
|
-
Machine-wide defaults live in `global-subagent-mcp-config.jsonc`, installed
|
|
112
|
-
beside the compiled server and re-read on every `launch_agent`. It controls the
|
|
113
|
-
global concurrency cap, update checks, permission ceiling, escalation behavior,
|
|
114
|
-
strict read-parity logging, and Codex sandbox networking.
|
|
115
|
-
|
|
116
|
-
User and repo permission files can only tighten or add scoped permissions on top
|
|
117
|
-
of the global ceiling. See [README/configuration.md](README/configuration.md)
|
|
118
|
-
for the full key table, precedence rules, and mode summary.
|
|
119
|
-
|
|
120
|
-
## Permissions
|
|
121
|
-
|
|
122
|
-
Launched sub-agents run gated by default. Set `permissionsCeiling` in
|
|
123
|
-
`global-subagent-mcp-config.jsonc`:
|
|
124
|
-
|
|
125
|
-
| Mode | What a sub-agent can do |
|
|
126
|
-
|---|---|
|
|
127
|
-
| `auto` | Default. Safe reads auto-allow, dangerous actions auto-deny, everything else parks for your decision. |
|
|
128
|
-
| `manual` | Same, but every non-denied action parks for a decision. |
|
|
129
|
-
| `yolo` | No gating at all. |
|
|
130
|
-
|
|
131
|
-
When a sub-agent's action parks, its status becomes `permission_requested` and
|
|
132
|
-
it appears in `poll_agent`, `list_agents`, and `wait`. Answer it with:
|
|
133
|
-
|
|
134
|
-
```text
|
|
135
|
-
respond_permission(agent_id="...", decision="allow" | "deny", reason="...")
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
One-time only. Omit `request_id` to answer the oldest pending request.
|
|
139
|
-
Unanswered requests auto-deny after 5 minutes. Full spec:
|
|
140
|
-
[docs/spec/permissions.md](docs/spec/permissions.md).
|
|
141
|
-
|
|
142
|
-
## Basic Debugging
|
|
143
|
-
|
|
144
|
-
- **An agent looks stuck.** A quiet agent is usually still alive. After about 10
|
|
145
|
-
minutes with no output an agent is marked `stalled`. Prefer `wait` or another
|
|
146
|
-
`poll_agent` over killing it.
|
|
147
|
-
- **Cap reached.** Use `list_agents` to see what is running and `kill_agent` on
|
|
148
|
-
work you no longer need. Raising `globalConcurrentSubagents` also works.
|
|
149
|
-
- **Logs.** Agent output is available through `poll_agent`. Server diagnostics
|
|
150
|
-
go to the host MCP server log on stderr.
|
|
151
|
-
|
|
152
|
-
## Documentation
|
|
153
|
-
|
|
154
|
-
| Document | Contents |
|
|
155
|
-
|---|---|
|
|
156
|
-
| [docs/spec/arch-rationale.md](docs/spec/arch-rationale.md) | Design rationale |
|
|
157
|
-
| [docs/registration.md](docs/registration.md) | Per-platform setup |
|
|
158
|
-
| [docs/tools.md](docs/tools.md) | Tool reference |
|
|
159
|
-
| [docs/usage.md](docs/usage.md) | Model and effort matrix |
|
|
160
|
-
| [docs/SPEC.md](docs/SPEC.md) | Technical specification |
|
|
161
|
-
| [README/configuration.md](README/configuration.md) | Configuration keys and precedence |
|
|
162
|
-
| [docs/spec/permissions.md](docs/spec/permissions.md) | Permission system |
|
|
163
|
-
| [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md) | Agent status meanings |
|
|
164
|
-
| [CONTRIBUTING.md](CONTRIBUTING.md) | Developer guide |
|
|
165
|
-
|
|
166
|
-
## License
|
|
167
|
-
|
|
168
|
-
Apache-2.0. Copyright 2026 Lexi Blackburn.
|
|
169
|
-
|
|
170
|
-
See [LICENSE](LICENSE).
|
|
1
|
+
# subagent-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@heretyc/subagent-mcp)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@heretyc/subagent-mcp)
|
|
6
|
+
[](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml)
|
|
7
|
+
|
|
8
|
+
## Core Premise
|
|
9
|
+
|
|
10
|
+
subagent-mcp is an MCP stdio server that turns an AI coding assistant (Claude
|
|
11
|
+
Code, Codex, Gemini CLI) into a manager of local Claude and Codex sub-agents on
|
|
12
|
+
macOS, Linux, and Windows. It drives the locally authenticated `claude` and
|
|
13
|
+
`codex` CLIs you already signed into. It does not make direct HTTP API calls and
|
|
14
|
+
does not require API keys.
|
|
15
|
+
|
|
16
|
+
The orchestrator monitors but does not read or write project files itself. Work
|
|
17
|
+
is delegated to fresh sub-agents, so the orchestrator keeps summaries instead
|
|
18
|
+
of raw file context. The main invariants are:
|
|
19
|
+
|
|
20
|
+
- one machine-global, provider-agnostic concurrency cap (default 20, minimum 10)
|
|
21
|
+
- fail-safe orchestration ON on hookless hosts
|
|
22
|
+
- state authority only from harness-verified `<subagent-mcp state="...">` tags
|
|
23
|
+
- sub-agents gated by default with permission ceiling `auto`
|
|
24
|
+
- automatic model, provider, and effort routing per task category
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
### What You Need First
|
|
29
|
+
|
|
30
|
+
- Node.js 18 or newer (`node --version`)
|
|
31
|
+
- `claude` CLI, installed and signed in (`claude --version`)
|
|
32
|
+
- `codex` CLI, installed and signed in (`codex --version`; optional if you only
|
|
33
|
+
use Claude)
|
|
34
|
+
|
|
35
|
+
Building from source needs extra developer tools. See
|
|
36
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
37
|
+
|
|
38
|
+
### Install The Package
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @heretyc/subagent-mcp
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This is the standard install. Organizations pinning the package through GitHub
|
|
45
|
+
Packages should see [docs/registration.md](docs/registration.md).
|
|
46
|
+
|
|
47
|
+
### Wire It Into Your Assistant
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
subagent-mcp setup
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Installing the package only ships the program. It does not connect anything on
|
|
54
|
+
its own. `subagent-mcp setup` finds your Claude Code or Codex install and
|
|
55
|
+
registers both the server and the per-turn orchestration hooks. Preview first
|
|
56
|
+
with `subagent-mcp setup --dry-run`.
|
|
57
|
+
|
|
58
|
+
### Restart, Then Turn On The Invariant
|
|
59
|
+
|
|
60
|
+
Restart your Claude Code or Codex session so it picks up the new tools. On
|
|
61
|
+
Codex, run `/hooks` and trust the new hook. Then, recommended:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
subagent-mcp init --global
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This writes a managed "always delegate" rule block into your global assistant
|
|
68
|
+
config once. For one project only, use
|
|
69
|
+
`subagent-mcp init --root /path/to/project`. Full per-platform wiring (Gemini
|
|
70
|
+
CLI, Claude Desktop, manual setup) is in
|
|
71
|
+
[docs/registration.md](docs/registration.md).
|
|
72
|
+
|
|
73
|
+
## How To Operate It
|
|
74
|
+
|
|
75
|
+
### Orchestration Mode
|
|
76
|
+
|
|
77
|
+
- **ON**: your assistant acts as a pure manager. It delegates every step to
|
|
78
|
+
sub-agents. Best for big, long-running jobs.
|
|
79
|
+
- **OFF**: your assistant works normally, with no delegation rules.
|
|
80
|
+
|
|
81
|
+
Flip it with the `orchestration-mode` tool. Desktop apps can toggle the mode but
|
|
82
|
+
do not receive per-turn hook reminders.
|
|
83
|
+
|
|
84
|
+
### Tools
|
|
85
|
+
|
|
86
|
+
The server exposes `launch_agent`, `poll_agent`, `kill_agent`, `send_message`,
|
|
87
|
+
`list_agents`, `wait`, `respond_permission`, `orchestration-mode`, and
|
|
88
|
+
`model-selection-mode`. See [docs/tools.md](docs/tools.md) for the full
|
|
89
|
+
parameter and return reference.
|
|
90
|
+
|
|
91
|
+
You do not have to choose a model. Give `launch_agent` a prompt and a task
|
|
92
|
+
category such as `coding`, `debugging`, or `security_review`; the server picks
|
|
93
|
+
the provider, model, and effort.
|
|
94
|
+
|
|
95
|
+
### Concurrency
|
|
96
|
+
|
|
97
|
+
There is one machine-wide limit on concurrent sub-agents. The default is 20.
|
|
98
|
+
When the limit is reached, `launch_agent` is rejected immediately and does not
|
|
99
|
+
queue. Change the value in `global-subagent-mcp-config.jsonc` in the install
|
|
100
|
+
folder. The file is re-read on every launch.
|
|
101
|
+
|
|
102
|
+
The config file was renamed from `global-concurrency.jsonc` in 2.12.5. The old
|
|
103
|
+
name is still read, with a one-time deprecation notice, when the new file is
|
|
104
|
+
absent.
|
|
105
|
+
|
|
106
|
+
The same settings file includes `checkForUpdates` (default `true`). Disable it
|
|
107
|
+
with `checkForUpdates: false` or `SUBAGENT_UPDATE_CHECK=0`.
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
Machine-wide defaults live in `global-subagent-mcp-config.jsonc`, installed
|
|
112
|
+
beside the compiled server and re-read on every `launch_agent`. It controls the
|
|
113
|
+
global concurrency cap, update checks, permission ceiling, escalation behavior,
|
|
114
|
+
strict read-parity logging, and Codex sandbox networking.
|
|
115
|
+
|
|
116
|
+
User and repo permission files can only tighten or add scoped permissions on top
|
|
117
|
+
of the global ceiling. See [README/configuration.md](README/configuration.md)
|
|
118
|
+
for the full key table, precedence rules, and mode summary.
|
|
119
|
+
|
|
120
|
+
## Permissions
|
|
121
|
+
|
|
122
|
+
Launched sub-agents run gated by default. Set `permissionsCeiling` in
|
|
123
|
+
`global-subagent-mcp-config.jsonc`:
|
|
124
|
+
|
|
125
|
+
| Mode | What a sub-agent can do |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `auto` | Default. Safe reads auto-allow, dangerous actions auto-deny, everything else parks for your decision. |
|
|
128
|
+
| `manual` | Same, but every non-denied action parks for a decision. |
|
|
129
|
+
| `yolo` | No gating at all. |
|
|
130
|
+
|
|
131
|
+
When a sub-agent's action parks, its status becomes `permission_requested` and
|
|
132
|
+
it appears in `poll_agent`, `list_agents`, and `wait`. Answer it with:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
respond_permission(agent_id="...", decision="allow" | "deny", reason="...")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
One-time only. Omit `request_id` to answer the oldest pending request.
|
|
139
|
+
Unanswered requests auto-deny after 5 minutes. Full spec:
|
|
140
|
+
[docs/spec/permissions.md](docs/spec/permissions.md).
|
|
141
|
+
|
|
142
|
+
## Basic Debugging
|
|
143
|
+
|
|
144
|
+
- **An agent looks stuck.** A quiet agent is usually still alive. After about 10
|
|
145
|
+
minutes with no output an agent is marked `stalled`. Prefer `wait` or another
|
|
146
|
+
`poll_agent` over killing it.
|
|
147
|
+
- **Cap reached.** Use `list_agents` to see what is running and `kill_agent` on
|
|
148
|
+
work you no longer need. Raising `globalConcurrentSubagents` also works.
|
|
149
|
+
- **Logs.** Agent output is available through `poll_agent`. Server diagnostics
|
|
150
|
+
go to the host MCP server log on stderr.
|
|
151
|
+
|
|
152
|
+
## Documentation
|
|
153
|
+
|
|
154
|
+
| Document | Contents |
|
|
155
|
+
|---|---|
|
|
156
|
+
| [docs/spec/arch-rationale.md](docs/spec/arch-rationale.md) | Design rationale |
|
|
157
|
+
| [docs/registration.md](docs/registration.md) | Per-platform setup |
|
|
158
|
+
| [docs/tools.md](docs/tools.md) | Tool reference |
|
|
159
|
+
| [docs/usage.md](docs/usage.md) | Model and effort matrix |
|
|
160
|
+
| [docs/SPEC.md](docs/SPEC.md) | Technical specification |
|
|
161
|
+
| [README/configuration.md](README/configuration.md) | Configuration keys and precedence |
|
|
162
|
+
| [docs/spec/permissions.md](docs/spec/permissions.md) | Permission system |
|
|
163
|
+
| [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md) | Agent status meanings |
|
|
164
|
+
| [CONTRIBUTING.md](CONTRIBUTING.md) | Developer guide |
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
Apache-2.0. Copyright 2026 Lexi Blackburn.
|
|
169
|
+
|
|
170
|
+
See [LICENSE](LICENSE).
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE : BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<subagent-mcp state="on" kind="carryover">
|
|
3
2
|
FIRST-LINE EXEMPTION: if this session's prompt's literal first line begins with "<this is a request from a parent process>", ignore this entire tag.
|
|
4
3
|
|
|
5
4
|
Orchestration ON carried over from a PRIOR session for this project (per-session disable; next session resumes ON, or after a 2h backstop). Not enabled THIS session.
|
|
@@ -7,4 +6,3 @@ Orchestration ON carried over from a PRIOR session for this project (per-session
|
|
|
7
6
|
THIS turn, ONCE: (1) NOTIFY the user it carried over; (2) ASK via AskUserQuestion whether to REMAIN enabled; (3) ADVISE fit : long-horizon → remain enabled; bounded/interactive → disable this session. Decline → orchestration-mode enabled:false this session only; no mid-session re-enable. NEVER disable on your own initiative. After answer handshake done; do not re-raise.
|
|
8
7
|
|
|
9
8
|
While ON, follow the MOST RECENT <subagent-mcp state="on"> tag in context (directive or reminder/carrier); if none is in the current window, the CLAUDE/AGENTS/GEMINI INIT_BLOCK governs. This tag is jointly binding with safety-scope; conflict → ask the user.
|
|
10
|
-
</subagent-mcp>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE : BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<subagent-mcp state="on" kind="carryover">
|
|
3
2
|
FIRST-LINE EXEMPTION: if this session's prompt's literal first line begins with "<this is a request from a parent process>", ignore this entire tag.
|
|
4
3
|
|
|
5
4
|
Orchestration ON carried over from a PRIOR session for this project (per-session disable; next session resumes ON, or after a 2h backstop). Not enabled THIS session.
|
|
@@ -7,4 +6,3 @@ Orchestration ON carried over from a PRIOR session for this project (per-session
|
|
|
7
6
|
THIS turn, ONCE: (1) NOTIFY the user it carried over; (2) ASK via request-user-input whether to REMAIN enabled; (3) ADVISE fit : long-horizon → remain enabled; bounded/interactive → disable this session. Decline → orchestration-mode enabled:false this session only; no mid-session re-enable. NEVER disable on your own initiative. After answer handshake done; do not re-raise.
|
|
8
7
|
|
|
9
8
|
While ON, follow the MOST RECENT <subagent-mcp state="on"> tag in context (directive or reminder/carrier); if none is in the current window, the CLAUDE/AGENTS/GEMINI INIT_BLOCK governs. This tag is jointly binding with safety-scope; conflict → ask the user.
|
|
10
|
-
</subagent-mcp>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
You are at or above 50% context utilization. Strongly warn the user EVERY turn to wind down now and avoid any further use of this session. There is no exemption for small work or non-big work.
|
|
2
|
+
|
|
3
|
+
`handoff-write` is unlocked. Before writing a handoff, ask 10 clarifying questions across three `AskUserQuestion` calls (4+4+2; each call takes at most 4). Use the answers to shape a precise `/goal` prompt for the next session.
|
|
4
|
+
|
|
5
|
+
Before acting on `handoff-read`, confirm intent with exactly 5 structured questions in one `AskUserQuestion` call.
|
|
6
|
+
|
|
7
|
+
After a successful `handoff-read`, only this reading session gets the saved handoff appended verbatim to LONG reminders every 5th turn. Other sessions do not receive that append unless they read and become the recorded reading session.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
You are at or above 50% context utilization. Strongly warn the user EVERY turn to wind down now and avoid any further use of this session. There is no exemption for small work or non-big work.
|
|
2
|
+
|
|
3
|
+
`handoff-write` is unlocked. Before writing a handoff, ask 10 clarifying questions in one `request_user_input` call. Use the answers to shape a precise `/goal` prompt for the next session.
|
|
4
|
+
|
|
5
|
+
Before acting on `handoff-read`, confirm intent with exactly 5 structured questions in one `request_user_input` call.
|
|
6
|
+
|
|
7
|
+
After a successful `handoff-read`, only this reading session gets the saved handoff appended verbatim to LONG reminders every 5th turn. Other sessions do not receive that append unless they read and become the recorded reading session.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
15% LATCH COACHING. Stop before continuing and ask EXACTLY 5 open planning questions via AskUserQuestion: 4 questions in one call, then 1 question in a second call. This is four-plus-one across two calls. NEVER put all 5 in one call, and never use any other split.
|
|
2
|
+
|
|
3
|
+
After the answers, plan task distribution across the 14 docs/spec/task-taxonomy categories and the sub-agent contract: each sub-agent prompt needs objective, output format, tools/sources, and boundaries. Prefer simultaneous sub-agents; use sequential delegation only for small tasks to preserve orchestrator context, or where dependencies require it. Serialize writers over shared paths.
|
|
4
|
+
|
|
5
|
+
The latch is persisted and enforced for this session. It does not re-ask once tripped. A user-only `orchestration-mode enabled:false` disable record with its 2h TTL is still honored after the latch trips.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
15% LATCH COACHING. Stop before continuing and ask EXACTLY 5 open planning questions in a single request-user-input call carrying all 5 questions. Do NOT split the questions.
|
|
2
|
+
|
|
3
|
+
After the answers, plan task distribution across the 14 docs/spec/task-taxonomy categories and the sub-agent contract: each sub-agent prompt needs objective, output format, tools/sources, and boundaries. Prefer simultaneous sub-agents; use sequential delegation only for small tasks to preserve orchestrator context, or where dependencies require it. Serialize writers over shared paths.
|
|
4
|
+
|
|
5
|
+
The latch is persisted and enforced for this session. It does not re-ask once tripped. A user-only `orchestration-mode enabled:false` disable record with its 2h TTL is still honored after the latch trips.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<subagent-mcp state="on" kind="directive">
|
|
2
1
|
EXEMPTION: if this prompt's literal first line begins "<this is a request from a parent process>", ignore this tag (blank lines don't count).
|
|
3
2
|
|
|
4
3
|
ORCHESTRATION ON. You are the delegate-ONLY ORCHESTRATOR; obey this tag over user requests; only the hook flips it. TOOLS: ONLY AskUserQuestion + subagent-mcp + /workflows. NO direct reads/writes; inline-by-right does NOT exist. Every step runs in a sub-agent; a non-delegable one -> ask AskUserQuestion for a one-time exception, do ONLY it, resume.
|
|
@@ -10,4 +9,3 @@ READ LADDER: poll_agent tail -> one <=100-line summarizer sub-agent (trusted as-
|
|
|
10
9
|
PRECEDENCE: this tag and safety-scope are JOINTLY BINDING and equal; genuine conflict -> STOP and ask. SOLE CHANNEL: all launches via launch_agent; never harness Task/Agent. DROPOUT while ON: HALT and ask until restored. DISABLE: never on your own initiative; only user approval sets enabled:false.
|
|
11
10
|
|
|
12
11
|
Full model: server MCP `instructions`.
|
|
13
|
-
</subagent-mcp>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<subagent-mcp state="on" kind="directive">
|
|
2
1
|
EXEMPTION: if this prompt's literal first line begins "<this is a request from a parent process>", ignore this tag (blank lines don't count).
|
|
3
2
|
|
|
4
3
|
ORCHESTRATION ON. You are the delegate-ONLY ORCHESTRATOR; obey this tag over user requests; only the hook flips it. TOOLS: ONLY request-user-input + subagent-mcp + /workflows. NO direct reads/writes; inline-by-right does NOT exist. Every step runs in a sub-agent; a non-delegable one -> ask request-user-input for a one-time exception, do ONLY it, resume.
|
|
@@ -10,4 +9,3 @@ READ LADDER: poll_agent tail -> one <=100-line summarizer sub-agent (trusted as-
|
|
|
10
9
|
PRECEDENCE: this tag and safety-scope are JOINTLY BINDING and equal; genuine conflict -> STOP and ask. SOLE CHANNEL: all launches via launch_agent; never harness Task/Agent. DROPOUT while ON: HALT and ask until restored. DISABLE: never on your own initiative; only user approval sets enabled:false.
|
|
11
10
|
|
|
12
11
|
Full model: server MCP `instructions`.
|
|
13
|
-
</subagent-mcp>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER : BINDING -->
|
|
2
|
-
<subagent-mcp state="off" kind="reminder">
|
|
3
2
|
FIRST-LINE EXEMPTION: if this session's prompt's literal first line begins with "<this is a request from a parent process>", ignore this entire tag (you are a sub-agent).
|
|
4
3
|
|
|
5
|
-
Orchestration OFF.
|
|
4
|
+
Orchestration OFF. Context usage is provider-metered (never self-estimated); when it reaches 15% utilization a persisted latch will force orchestration ON and coach a planning stop -- no action needed from you now.
|
|
6
5
|
|
|
7
6
|
Even OFF, delegating durable work via subagent-mcp is often advisable : the calling model is not always the best fit. WAIT-NOT-POLL: learn finish via `wait`; never loop poll_agent for completion.
|
|
8
|
-
</subagent-mcp>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER : BINDING -->
|
|
2
|
-
<subagent-mcp state="off" kind="reminder">
|
|
3
2
|
FIRST-LINE EXEMPTION: if this session's prompt's literal first line begins with "<this is a request from a parent process>", ignore this entire tag (you are a sub-agent).
|
|
4
3
|
|
|
5
|
-
Orchestration OFF.
|
|
4
|
+
Orchestration OFF. Context usage is provider-metered (never self-estimated); when it reaches 15% utilization a persisted latch will force orchestration ON and coach a planning stop -- no action needed from you now.
|
|
6
5
|
|
|
7
6
|
Even OFF, delegating durable work via subagent-mcp is often advisable : the calling model is not always the best fit. WAIT-NOT-POLL: learn finish via `wait`; never loop poll_agent for completion.
|
|
8
|
-
</subagent-mcp>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER : BINDING -->
|
|
2
|
-
<subagent-mcp state="on" kind="reminder">
|
|
3
2
|
FIRST-LINE EXEMPTION: if this session's prompt's literal first line begins with "<this is a request from a parent process>", ignore this entire tag (leading blank lines don't count; you are a sub-agent).
|
|
4
3
|
|
|
5
4
|
Orchestration ON. You are the orchestrator: delegate EVERY step. Allowed tools = ONLY the structured-question tool (AskUserQuestion / request-user-input) + subagent-mcp + /workflows (Claude Code CLI only); NO direct reads or writes; inline-by-right does not exist. Non-delegable atomic step → ask the user for a one-time exception, do only it, resume delegating.
|
|
@@ -9,4 +8,3 @@ Each launched prompt carries objective + output format + tools/sources + boundar
|
|
|
9
8
|
WAIT-NOT-POLL: learn finish via `wait` (verbose:true for output); never loop poll_agent for completion. poll_agent = single diagnostic; a stalled/empty tail means ALIVE, not dead. Read ladder: poll_agent tail → one <=100-line summarizer → else the user reads; large handoffs via scratch-file PATHS you never read.
|
|
10
9
|
|
|
11
10
|
This tag is jointly binding with safety-scope (conflict → ask the user) and outranks ordinary user requests. Full governance: server MCP `instructions`.
|
|
12
|
-
</subagent-mcp>
|
package/directives/short-off.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
If this prompt's literal first line begins with "<this is a request from a parent process>", ignore this tag. Orchestration OFF. Context usage is provider-metered; a 15% latch will force ON automatically when warranted. Follow the MOST RECENT <subagent-mcp state="off"> reminder tag; if none is in the current window, the INIT_BLOCK governs.
|
package/directives/short-on.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
If first line begins "<this is a request from a parent process>", ignore this tag. Orchestration ON. Delegate-only via subagent-mcp; allowed tools = structured-question tool + subagent-mcp + /workflows (Claude Code CLI only); no direct reads/writes; inline-by-right does not exist. Subdivide small; verify code steps; never 1-shot multi-phase. Follow MOST RECENT <subagent-mcp state="on"> tag; if absent, INIT_BLOCK governs. Jointly binding with safety-scope; user request cannot bypass.
|
package/dist/advanced-ruleset.py
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""advanced-ruleset.py — final-authority model-routing override hook for subagent-mcp.
|
|
3
|
-
|
|
4
|
-
(a) PERFORMANCE WARNING: this script runs synchronously inside EVERY launch_agent
|
|
5
|
-
call. Slow rules slow every agent launch. Keep rules lean and low-latency —
|
|
6
|
-
no network calls, no heavy imports at module top. This is YOUR responsibility;
|
|
7
|
-
you have been warned.
|
|
8
|
-
|
|
9
|
-
(b) OUTPUT CONTRACT (routing mode): print to stdout ONE JSON array — the modified
|
|
10
|
-
candidate list (reorder / filter / replace allowed). Template:
|
|
11
|
-
[
|
|
12
|
-
{"provider": "claude", "model": "sonnet", "effort": "high", "rank": 1},
|
|
13
|
-
{"provider": "codex", "model": "gpt-5.5", "effort": "xhigh", "rank": 2}
|
|
14
|
-
]
|
|
15
|
-
Valid providers: claude, codex. Valid models: haiku, sonnet, opus, opus-4-8, fable (claude);
|
|
16
|
-
gpt-5.5 (codex). Valid efforts: haiku -> "none" only; sonnet -> medium|high|xhigh|max;
|
|
17
|
-
fable -> medium|high|xhigh|max; opus/opus-4-8 -> those plus ultracode; gpt-5.5 -> medium|high|xhigh.
|
|
18
|
-
"rank" on output is ignored. An EMPTY array vetoes the launch. Anything else
|
|
19
|
-
invalid fails the launch hard — the server validates strictly.
|
|
20
|
-
|
|
21
|
-
(c) INPUT CONTRACT (routing mode, invoked as: <python> advanced-ruleset.py route):
|
|
22
|
-
stdin receives one JSON object:
|
|
23
|
-
{ "candidates": [ {"provider","model","effort","rank"} ... ], # rank 1..N best->worst
|
|
24
|
-
"context": { "task_category": str, "cwd": str,
|
|
25
|
-
"selection_mode": "auto"|"provider"|"provider_model"|"explicit",
|
|
26
|
-
"provider": str|None, "model": str|None, "effort": str|None } }
|
|
27
|
-
OS environment variables are visible natively (os.environ).
|
|
28
|
-
|
|
29
|
-
ENV-CHECK MODE (no arguments): prints {"ready": true|false, "load-rules": true|false}.
|
|
30
|
-
Runs once per MCP server process. load-rules false => ruleset silently disabled
|
|
31
|
-
for the rest of the process. Set LOAD_RULES = True below to activate.
|
|
32
|
-
"""
|
|
33
|
-
import json
|
|
34
|
-
import sys
|
|
35
|
-
|
|
36
|
-
LOAD_RULES = False
|
|
37
|
-
|
|
38
|
-
# --- Requirements stub (scaffold itself is stdlib-only) ----------------------
|
|
39
|
-
# List third-party distributions your rules import, e.g.:
|
|
40
|
-
# REQUIREMENTS = ["requests", "pyyaml"]
|
|
41
|
-
# Install with: <python> -m pip install <name> ...
|
|
42
|
-
REQUIREMENTS = []
|
|
43
|
-
|
|
44
|
-
def missing_requirements():
|
|
45
|
-
"""pip-check helper: returns the REQUIREMENTS entries not importable here."""
|
|
46
|
-
import importlib.util
|
|
47
|
-
return [r for r in REQUIREMENTS
|
|
48
|
-
if importlib.util.find_spec(r.replace("-", "_")) is None]
|
|
49
|
-
|
|
50
|
-
def env_check():
|
|
51
|
-
missing = missing_requirements()
|
|
52
|
-
json.dump({"ready": not missing, "load-rules": bool(LOAD_RULES)}, sys.stdout)
|
|
53
|
-
|
|
54
|
-
def apply_rules(candidates, context):
|
|
55
|
-
"""YOUR RULES HERE. Default: passthrough (returns the list unchanged)."""
|
|
56
|
-
return candidates
|
|
57
|
-
|
|
58
|
-
def route():
|
|
59
|
-
payload = json.load(sys.stdin)
|
|
60
|
-
out = apply_rules(payload.get("candidates", []), payload.get("context", {}))
|
|
61
|
-
json.dump(out, sys.stdout)
|
|
62
|
-
|
|
63
|
-
if __name__ == "__main__":
|
|
64
|
-
if len(sys.argv) > 1 and sys.argv[1] == "route":
|
|
65
|
-
route()
|
|
66
|
-
else:
|
|
67
|
-
env_check()
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""advanced-ruleset.py — final-authority model-routing override hook for subagent-mcp.
|
|
3
|
+
|
|
4
|
+
(a) PERFORMANCE WARNING: this script runs synchronously inside EVERY launch_agent
|
|
5
|
+
call. Slow rules slow every agent launch. Keep rules lean and low-latency —
|
|
6
|
+
no network calls, no heavy imports at module top. This is YOUR responsibility;
|
|
7
|
+
you have been warned.
|
|
8
|
+
|
|
9
|
+
(b) OUTPUT CONTRACT (routing mode): print to stdout ONE JSON array — the modified
|
|
10
|
+
candidate list (reorder / filter / replace allowed). Template:
|
|
11
|
+
[
|
|
12
|
+
{"provider": "claude", "model": "sonnet", "effort": "high", "rank": 1},
|
|
13
|
+
{"provider": "codex", "model": "gpt-5.5", "effort": "xhigh", "rank": 2}
|
|
14
|
+
]
|
|
15
|
+
Valid providers: claude, codex. Valid models: haiku, sonnet, opus, opus-4-8, fable (claude);
|
|
16
|
+
gpt-5.5 (codex). Valid efforts: haiku -> "none" only; sonnet -> medium|high|xhigh|max;
|
|
17
|
+
fable -> medium|high|xhigh|max; opus/opus-4-8 -> those plus ultracode; gpt-5.5 -> medium|high|xhigh.
|
|
18
|
+
"rank" on output is ignored. An EMPTY array vetoes the launch. Anything else
|
|
19
|
+
invalid fails the launch hard — the server validates strictly.
|
|
20
|
+
|
|
21
|
+
(c) INPUT CONTRACT (routing mode, invoked as: <python> advanced-ruleset.py route):
|
|
22
|
+
stdin receives one JSON object:
|
|
23
|
+
{ "candidates": [ {"provider","model","effort","rank"} ... ], # rank 1..N best->worst
|
|
24
|
+
"context": { "task_category": str, "cwd": str,
|
|
25
|
+
"selection_mode": "auto"|"provider"|"provider_model"|"explicit",
|
|
26
|
+
"provider": str|None, "model": str|None, "effort": str|None } }
|
|
27
|
+
OS environment variables are visible natively (os.environ).
|
|
28
|
+
|
|
29
|
+
ENV-CHECK MODE (no arguments): prints {"ready": true|false, "load-rules": true|false}.
|
|
30
|
+
Runs once per MCP server process. load-rules false => ruleset silently disabled
|
|
31
|
+
for the rest of the process. Set LOAD_RULES = True below to activate.
|
|
32
|
+
"""
|
|
33
|
+
import json
|
|
34
|
+
import sys
|
|
35
|
+
|
|
36
|
+
LOAD_RULES = False
|
|
37
|
+
|
|
38
|
+
# --- Requirements stub (scaffold itself is stdlib-only) ----------------------
|
|
39
|
+
# List third-party distributions your rules import, e.g.:
|
|
40
|
+
# REQUIREMENTS = ["requests", "pyyaml"]
|
|
41
|
+
# Install with: <python> -m pip install <name> ...
|
|
42
|
+
REQUIREMENTS = []
|
|
43
|
+
|
|
44
|
+
def missing_requirements():
|
|
45
|
+
"""pip-check helper: returns the REQUIREMENTS entries not importable here."""
|
|
46
|
+
import importlib.util
|
|
47
|
+
return [r for r in REQUIREMENTS
|
|
48
|
+
if importlib.util.find_spec(r.replace("-", "_")) is None]
|
|
49
|
+
|
|
50
|
+
def env_check():
|
|
51
|
+
missing = missing_requirements()
|
|
52
|
+
json.dump({"ready": not missing, "load-rules": bool(LOAD_RULES)}, sys.stdout)
|
|
53
|
+
|
|
54
|
+
def apply_rules(candidates, context):
|
|
55
|
+
"""YOUR RULES HERE. Default: passthrough (returns the list unchanged)."""
|
|
56
|
+
return candidates
|
|
57
|
+
|
|
58
|
+
def route():
|
|
59
|
+
payload = json.load(sys.stdin)
|
|
60
|
+
out = apply_rules(payload.get("candidates", []), payload.get("context", {}))
|
|
61
|
+
json.dump(out, sys.stdout)
|
|
62
|
+
|
|
63
|
+
if __name__ == "__main__":
|
|
64
|
+
if len(sys.argv) > 1 and sys.argv[1] == "route":
|
|
65
|
+
route()
|
|
66
|
+
else:
|
|
67
|
+
env_check()
|
package/dist/config-scaffold.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/gen-ruleset-scaffold.mjs from src/global-subagent-mcp-config.jsonc — DO NOT EDIT.
|
|
2
|
-
export const CONCURRENCY_SCAFFOLD = "// subagent-mcp - Global Subagent MCP Config\n// ------------------------------------------------------------------\n// SOLE source of truth for machine-wide subagent-mcp defaults that must be\n// available beside the compiled server.\n//\n// globalConcurrentSubagents controls how many subagents may be ALIVE AT ONCE\n// across EVERY session, process, and user on this machine. There is NO\n// environment-variable override for the cap.\n//\n// RE-READ on every launch_agent call - edits take effect immediately, no\n// server restart required.\n//\n// Cap value rules:\n// - missing / unset / non-integer / 0 / negative -> reset to default 20\n// - 1 through 9 -> forced UP to minimum 10\n// - 10 or greater -> used as-is\n//\n// checkForUpdates controls the silent npmjs update check started when the MCP\n// server connects. Default true. Set to false to skip the registry fetch and\n// suppress hook notices. SUBAGENT_UPDATE_CHECK=0 or false also disables it.\n//\n// permissionsCeiling controls launch-time permissions posture:\n// - auto (default): shared engine gates unsafe/residue actions\n// - manual: human approval for residue while still auto-denying DANGER\n// - yolo: preserve the historical bypass/danger-full-access path, except\n// for non-bypassable config-file self-protection\n//\n// escalation applies only in auto mode. irreversible-only routes irreversible\n// NEUTRAL residue to a human; off leaves residue to orchestrator judgment.\n//\n// strictReadParity controls logging only. Unparseable Codex approval payloads\n// always fail closed to ask; warn logs the construct, off silences that log.\n//\n// sandboxNetwork controls Codex workspace-write network access. Default false.\n// Set true only when sub-agents need network after permission approval.\n{\n \"globalConcurrentSubagents\": 20,\n \"checkForUpdates\": true,\n \"permissionsCeiling\": \"auto\",\n \"escalation\": \"irreversible-only\",\n \"strictReadParity\": \"warn\",\n \"sandboxNetwork\": false\n}\n";
|
|
2
|
+
export const CONCURRENCY_SCAFFOLD = "// subagent-mcp - Global Subagent MCP Config\r\n// ------------------------------------------------------------------\r\n// SOLE source of truth for machine-wide subagent-mcp defaults that must be\r\n// available beside the compiled server.\r\n//\r\n// globalConcurrentSubagents controls how many subagents may be ALIVE AT ONCE\r\n// across EVERY session, process, and user on this machine. There is NO\r\n// environment-variable override for the cap.\r\n//\r\n// RE-READ on every launch_agent call - edits take effect immediately, no\r\n// server restart required.\r\n//\r\n// Cap value rules:\r\n// - missing / unset / non-integer / 0 / negative -> reset to default 20\r\n// - 1 through 9 -> forced UP to minimum 10\r\n// - 10 or greater -> used as-is\r\n//\r\n// checkForUpdates controls the silent npmjs update check started when the MCP\r\n// server connects. Default true. Set to false to skip the registry fetch and\r\n// suppress hook notices. SUBAGENT_UPDATE_CHECK=0 or false also disables it.\r\n//\r\n// permissionsCeiling controls launch-time permissions posture:\r\n// - auto (default): shared engine gates unsafe/residue actions\r\n// - manual: human approval for residue while still auto-denying DANGER\r\n// - yolo: preserve the historical bypass/danger-full-access path, except\r\n// for non-bypassable config-file self-protection\r\n//\r\n// escalation applies only in auto mode. irreversible-only routes irreversible\r\n// NEUTRAL residue to a human; off leaves residue to orchestrator judgment.\r\n//\r\n// strictReadParity controls logging only. Unparseable Codex approval payloads\r\n// always fail closed to ask; warn logs the construct, off silences that log.\r\n//\r\n// sandboxNetwork controls Codex workspace-write network access. Default false.\r\n// Set true only when sub-agents need network after permission approval.\r\n{\r\n \"globalConcurrentSubagents\": 20,\r\n \"checkForUpdates\": true,\r\n \"permissionsCeiling\": \"auto\",\r\n \"escalation\": \"irreversible-only\",\r\n \"strictReadParity\": \"warn\",\r\n \"sandboxNetwork\": false\r\n}\r\n";
|