@heretyc/subagent-mcp 2.8.6 → 2.8.7
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/LICENSE +201 -201
- package/NOTICE +5 -5
- package/README.md +136 -136
- package/directives/carryover-claude.md +6 -9
- package/directives/carryover-codex.md +6 -9
- package/directives/orchestration-claude.md +8 -16
- package/directives/orchestration-codex.md +8 -16
- package/directives/reminder-off-claude.md +5 -5
- package/directives/reminder-off-codex.md +5 -5
- package/directives/reminder-on.md +8 -4
- package/directives/short-off.md +1 -1
- package/directives/short-on.md +1 -1
- package/dist/advanced-ruleset.py +67 -67
- package/dist/effort.js +6 -3
- package/dist/hooks/orchestration-claude.js +0 -4
- package/dist/index.js +11 -6
- package/dist/init.js +59 -28
- package/dist/launch-prompt.js +29 -0
- package/dist/orchestration/hook-core.js +1 -1
- package/dist/orchestration/pretool.js +10 -66
- package/dist/routing-table.json +3561 -4149
- package/dist/routing.js +1 -1
- package/dist/ruleset-scaffold.js +1 -1
- package/package.json +53 -53
- package/scripts/postinstall.mjs +102 -102
package/README.md
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
# subagent-mcp
|
|
2
|
-
|
|
3
|
-
MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions. Runs on **macOS, Linux, and Windows**.
|
|
4
|
-
|
|
5
|
-
**No direct API calls.** subagent-mcp does NOT use the Anthropic or OpenAI HTTP APIs and has no plans to. Claude sessions use the Claude Agent SDK against your local Claude Code executable; Codex sessions use your local `codex app-server`. No API keys.
|
|
6
|
-
|
|
7
|
-
**License:** Apache-2.0 | **Author:** Lexi Blackburn | **Repo:** https://github.com/Heretyc/subagent-mcp
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- Start Claude or Codex interactive sessions as managed sub-agents from any MCP host
|
|
14
|
-
- Poll status, stream stdout/stderr tails, and enqueue follow-up messages to live sessions
|
|
15
|
-
- Concurrency caps: 5 concurrent Claude agents + 5 concurrent Codex agents (counts only actively-streaming `processing` agents, to limit API rate-limit pressure; quiet `stalled` agents don't reserve a slot)
|
|
16
|
-
- Liveness tracking via the visible provider stream (Claude SDK events, Codex app-server JSONL): agents with no parsed visible provider stream item for 10 minutes enter `stalled` state (still alive, just quiet -- thinking or awaiting a temp-file handoff), and recover to `processing` if the visible stream resumes
|
|
17
|
-
- Ultracode mode for Opus 4.8 -- headless activation via `--settings {"ultracode":true}` (see [docs/usage.md](docs/usage.md))
|
|
18
|
-
- Cross-platform exe resolution (Windows: npm-prefix .exe paths; macOS/Linux: PATH + Homebrew/usr-local fallbacks); immediate `taskkill /t /f` (Windows) / `SIGKILL` (POSIX) force-kill; no graceful shutdown period
|
|
19
|
-
- stdio MCP transport; built with `@modelcontextprotocol/sdk` + `zod`
|
|
20
|
-
- `orchestration-mode` tool — toggles orchestrator directives injected by bundled Claude Code / Codex hooks; Claude also gets a deterministic `PreToolUse` gate (Desktop hosts toggle but do not inject); see [docs/spec/orchestration-mode/_INDEX.md](docs/spec/orchestration-mode/_INDEX.md)
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Quick Start
|
|
25
|
-
|
|
26
|
-
**Prerequisites:** Node.js >= 18, plus the `claude` and/or `codex` CLIs installed globally and authenticated.
|
|
27
|
-
|
|
28
|
-
Installed via [GitHub Packages](https://github.com/Heretyc/subagent-mcp/pkgs/npm/subagent-mcp). One-time `.npmrc` setup required (GitHub Packages requires auth even for public packages):
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# 1. Configure registry for @heretyc scope (once per machine)
|
|
32
|
-
echo "@heretyc:registry=https://npm.pkg.github.com" >> ~/.npmrc
|
|
33
|
-
|
|
34
|
-
# 2. Authenticate — use a classic PAT with read:packages scope
|
|
35
|
-
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc
|
|
36
|
-
|
|
37
|
-
# 3. Install and wire
|
|
38
|
-
npm install -g @heretyc/subagent-mcp
|
|
39
|
-
subagent-mcp setup
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
`setup` detects which vendors are present, registers the MCP server, and writes orchestration-mode hooks. Idempotent — safe to re-run after updates. Pass `--dry-run` to preview.
|
|
43
|
-
|
|
44
|
-
For consumer projects, run `subagent-mcp init --root /path/to/project` to upsert
|
|
45
|
-
the managed invariant block into `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`.
|
|
46
|
-
Use `--dry-run` to preview, `--remove` to uninstall the block, and `--force`
|
|
47
|
-
only if you intentionally run inside this source repo.
|
|
48
|
-
|
|
49
|
-
After setup, restart your Claude Code or Codex session. On Codex, run `/hooks` and trust the new hook.
|
|
50
|
-
|
|
51
|
-
**Updating:** `subagent-mcp update && subagent-mcp setup`
|
|
52
|
-
|
|
53
|
-
For manual wiring, developer install from source, Gemini CLI, and Claude Desktop, see [docs/registration.md](docs/registration.md).
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Auto Mode
|
|
58
|
-
|
|
59
|
-
`launch_agent` supports **auto mode**: pass `prompt` + `task_category` and the server picks the best provider/model/effort for that category from its routing table, silently falling back to the next-best candidate on any launch-time failure.
|
|
60
|
-
|
|
61
|
-
`provider`, `model`, and `effort` are optional overrides — omit them to get auto-selected best combination. Rules: passing `model` requires `provider`; passing `effort` requires both `provider` and `model`.
|
|
62
|
-
|
|
63
|
-
**task_category** (required) — pick one:
|
|
64
|
-
|
|
65
|
-
| Category | What it is |
|
|
66
|
-
|---|---|
|
|
67
|
-
| `math_proof` | deliverable is a proof/derivation/formally-checkable result |
|
|
68
|
-
| `security_review` | security verdict, threat assessment, or demonstrated exploit |
|
|
69
|
-
| `debugging` | verified fix/root-cause; requires an observed failure as precondition |
|
|
70
|
-
| `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
|
|
71
|
-
| `architecture` | cross-module design/plan, no code, no execution loop |
|
|
72
|
-
| `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
|
|
73
|
-
| `data_analysis` | empirical finding about structured dataset (query, stat, model) |
|
|
74
|
-
| `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
|
|
75
|
-
| `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
|
|
76
|
-
| `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
|
|
77
|
-
| `prompt_engineering` | designed/optimized prompt or prompt-system steering an LLM/agent (composite-inferred) |
|
|
78
|
-
| `vulnerability_research` | discovery + PoC of a novel vulnerability (composite-inferred) |
|
|
79
|
-
| `molecular_biology` | reasoned molecular/computational-biology result over sequences, structures, or -omics data (composite-inferred) |
|
|
80
|
-
| `ml_accelerator_design` | hardware/software design for ML acceleration — dataflow, kernel, roofline (composite-inferred) |
|
|
81
|
-
| `fallback_default` | no category matches with confidence; prefer splitting work instead |
|
|
82
|
-
|
|
83
|
-
The last four are **composite-inferred**: they carry no dedicated benchmark and their routing competency is composed from parent categories rather than measured directly.
|
|
84
|
-
|
|
85
|
-
**Atomic-split guidance:** if you are unsure which category fits, do NOT submit one large amorphous task. Break the work into smaller atomic steps each mapping to a single category and launch one agent per step.
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Tools
|
|
90
|
-
|
|
91
|
-
Six tools are exposed over the stdio MCP transport:
|
|
92
|
-
|
|
93
|
-
| Tool | Purpose |
|
|
94
|
-
|------|---------|
|
|
95
|
-
| `launch_agent` | Start a new `claude`/`codex` sub-agent session |
|
|
96
|
-
| `poll_agent` | Get status + output tail of one agent |
|
|
97
|
-
| `kill_agent` | Immediately force-kill any live agent |
|
|
98
|
-
| `send_message` | Enqueue a user message on a live session |
|
|
99
|
-
| `list_agents` | List all agents with token-efficient core metrics |
|
|
100
|
-
| `wait` | Block until one or more agents finish, or 15-minute timeout |
|
|
101
|
-
|
|
102
|
-
Full parameters, return shapes, the `alive` / `idle_seconds` / `hint` / `recent_stream` fields, and `poll_agent`'s last-3 visible-stream items are in [docs/tools.md](docs/tools.md).
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## Agent Lifecycle
|
|
107
|
-
|
|
108
|
-
Each agent transitions through these states:
|
|
109
|
-
|
|
110
|
-
| Status | Meaning |
|
|
111
|
-
|--------|---------|
|
|
112
|
-
| `processing` | Driver alive with a visible provider-stream heartbeat in the last 10 minutes -- actively working. Launch time counts as the initial heartbeat |
|
|
113
|
-
| `stalled` | Driver STILL ALIVE but no parsed visible provider stream item for >= 10 minutes -- working, thinking, or awaiting a temp-file handoff (not a failure). Recovers to `processing` if the visible stream resumes |
|
|
114
|
-
| `finished` | Current turn completed, or driver exited with code 0 |
|
|
115
|
-
| `errored` | Process exited with non-zero code |
|
|
116
|
-
| `stopped` | Terminated by `kill_agent` |
|
|
117
|
-
|
|
118
|
-
`processing` and `stalled` are live. `finished` is reportable for `wait`; if `alive` is still true, `send_message` can start the next turn on the same session. A health monitor runs every 10 seconds, and `poll_agent`/`list_agents` additionally reconcile driver exit synchronously. `wait` does not return just because an agent is `stalled`. `stalled` agents recover to `processing` if the visible stream resumes and are never auto-killed -- prefer `wait`/re-poll over `kill_agent`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## Documentation
|
|
123
|
-
|
|
124
|
-
- [docs/registration.md](docs/registration.md) -- per-platform registration (Claude Code, Codex, Gemini), prerequisites, install, config paths.
|
|
125
|
-
- [docs/tools.md](docs/tools.md) -- full Tool Reference for all six tools, including `alive` / `idle_seconds` / `hint` fields.
|
|
126
|
-
- [docs/usage.md](docs/usage.md) -- model & effort matrix, ultracode mechanism, underlying CLI invocations, usage examples.
|
|
127
|
-
- [docs/SPEC.md](docs/SPEC.md) -- full technical specification (architecture, schemas, status lifecycle, error catalogue).
|
|
128
|
-
- [docs/spec/interactive-drivers.md](docs/spec/interactive-drivers.md) -- always-interactive Claude/Codex driver model.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## License
|
|
133
|
-
|
|
134
|
-
Apache-2.0 -- Copyright 2026 Lexi Blackburn
|
|
135
|
-
|
|
136
|
-
See [docs/SPEC.md](docs/SPEC.md) for the full technical specification.
|
|
1
|
+
# subagent-mcp
|
|
2
|
+
|
|
3
|
+
MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions. Runs on **macOS, Linux, and Windows**.
|
|
4
|
+
|
|
5
|
+
**No direct API calls.** subagent-mcp does NOT use the Anthropic or OpenAI HTTP APIs and has no plans to. Claude sessions use the Claude Agent SDK against your local Claude Code executable; Codex sessions use your local `codex app-server`. No API keys.
|
|
6
|
+
|
|
7
|
+
**License:** Apache-2.0 | **Author:** Lexi Blackburn | **Repo:** https://github.com/Heretyc/subagent-mcp
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Start Claude or Codex interactive sessions as managed sub-agents from any MCP host
|
|
14
|
+
- Poll status, stream stdout/stderr tails, and enqueue follow-up messages to live sessions
|
|
15
|
+
- Concurrency caps: 5 concurrent Claude agents + 5 concurrent Codex agents (counts only actively-streaming `processing` agents, to limit API rate-limit pressure; quiet `stalled` agents don't reserve a slot)
|
|
16
|
+
- Liveness tracking via the visible provider stream (Claude SDK events, Codex app-server JSONL): agents with no parsed visible provider stream item for 10 minutes enter `stalled` state (still alive, just quiet -- thinking or awaiting a temp-file handoff), and recover to `processing` if the visible stream resumes
|
|
17
|
+
- Ultracode mode for Opus 4.8 -- headless activation via `--settings {"ultracode":true}` (see [docs/usage.md](docs/usage.md))
|
|
18
|
+
- Cross-platform exe resolution (Windows: npm-prefix .exe paths; macOS/Linux: PATH + Homebrew/usr-local fallbacks); immediate `taskkill /t /f` (Windows) / `SIGKILL` (POSIX) force-kill; no graceful shutdown period
|
|
19
|
+
- stdio MCP transport; built with `@modelcontextprotocol/sdk` + `zod`
|
|
20
|
+
- `orchestration-mode` tool — toggles orchestrator directives injected by bundled Claude Code / Codex hooks; Claude also gets a deterministic `PreToolUse` gate (Desktop hosts toggle but do not inject); see [docs/spec/orchestration-mode/_INDEX.md](docs/spec/orchestration-mode/_INDEX.md)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
**Prerequisites:** Node.js >= 18, plus the `claude` and/or `codex` CLIs installed globally and authenticated.
|
|
27
|
+
|
|
28
|
+
Installed via [GitHub Packages](https://github.com/Heretyc/subagent-mcp/pkgs/npm/subagent-mcp). One-time `.npmrc` setup required (GitHub Packages requires auth even for public packages):
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. Configure registry for @heretyc scope (once per machine)
|
|
32
|
+
echo "@heretyc:registry=https://npm.pkg.github.com" >> ~/.npmrc
|
|
33
|
+
|
|
34
|
+
# 2. Authenticate — use a classic PAT with read:packages scope
|
|
35
|
+
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc
|
|
36
|
+
|
|
37
|
+
# 3. Install and wire
|
|
38
|
+
npm install -g @heretyc/subagent-mcp
|
|
39
|
+
subagent-mcp setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`setup` detects which vendors are present, registers the MCP server, and writes orchestration-mode hooks. Idempotent — safe to re-run after updates. Pass `--dry-run` to preview.
|
|
43
|
+
|
|
44
|
+
For consumer projects, run `subagent-mcp init --root /path/to/project` to upsert
|
|
45
|
+
the managed invariant block into `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`.
|
|
46
|
+
Use `--dry-run` to preview, `--remove` to uninstall the block, and `--force`
|
|
47
|
+
only if you intentionally run inside this source repo.
|
|
48
|
+
|
|
49
|
+
After setup, restart your Claude Code or Codex session. On Codex, run `/hooks` and trust the new hook.
|
|
50
|
+
|
|
51
|
+
**Updating:** `subagent-mcp update && subagent-mcp setup`
|
|
52
|
+
|
|
53
|
+
For manual wiring, developer install from source, Gemini CLI, and Claude Desktop, see [docs/registration.md](docs/registration.md).
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Auto Mode
|
|
58
|
+
|
|
59
|
+
`launch_agent` supports **auto mode**: pass `prompt` + `task_category` and the server picks the best provider/model/effort for that category from its routing table, silently falling back to the next-best candidate on any launch-time failure.
|
|
60
|
+
|
|
61
|
+
`provider`, `model`, and `effort` are optional overrides — omit them to get auto-selected best combination. Rules: passing `model` requires `provider`; passing `effort` requires both `provider` and `model`.
|
|
62
|
+
|
|
63
|
+
**task_category** (required) — pick one:
|
|
64
|
+
|
|
65
|
+
| Category | What it is |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `math_proof` | deliverable is a proof/derivation/formally-checkable result |
|
|
68
|
+
| `security_review` | security verdict, threat assessment, or demonstrated exploit |
|
|
69
|
+
| `debugging` | verified fix/root-cause; requires an observed failure as precondition |
|
|
70
|
+
| `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
|
|
71
|
+
| `architecture` | cross-module design/plan, no code, no execution loop |
|
|
72
|
+
| `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
|
|
73
|
+
| `data_analysis` | empirical finding about structured dataset (query, stat, model) |
|
|
74
|
+
| `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
|
|
75
|
+
| `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
|
|
76
|
+
| `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
|
|
77
|
+
| `prompt_engineering` | designed/optimized prompt or prompt-system steering an LLM/agent (composite-inferred) |
|
|
78
|
+
| `vulnerability_research` | discovery + PoC of a novel vulnerability (composite-inferred) |
|
|
79
|
+
| `molecular_biology` | reasoned molecular/computational-biology result over sequences, structures, or -omics data (composite-inferred) |
|
|
80
|
+
| `ml_accelerator_design` | hardware/software design for ML acceleration — dataflow, kernel, roofline (composite-inferred) |
|
|
81
|
+
| `fallback_default` | no category matches with confidence; prefer splitting work instead |
|
|
82
|
+
|
|
83
|
+
The last four are **composite-inferred**: they carry no dedicated benchmark and their routing competency is composed from parent categories rather than measured directly.
|
|
84
|
+
|
|
85
|
+
**Atomic-split guidance:** if you are unsure which category fits, do NOT submit one large amorphous task. Break the work into smaller atomic steps each mapping to a single category and launch one agent per step.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Tools
|
|
90
|
+
|
|
91
|
+
Six tools are exposed over the stdio MCP transport:
|
|
92
|
+
|
|
93
|
+
| Tool | Purpose |
|
|
94
|
+
|------|---------|
|
|
95
|
+
| `launch_agent` | Start a new `claude`/`codex` sub-agent session |
|
|
96
|
+
| `poll_agent` | Get status + output tail of one agent |
|
|
97
|
+
| `kill_agent` | Immediately force-kill any live agent |
|
|
98
|
+
| `send_message` | Enqueue a user message on a live session |
|
|
99
|
+
| `list_agents` | List all agents with token-efficient core metrics |
|
|
100
|
+
| `wait` | Block until one or more agents finish, or 15-minute timeout |
|
|
101
|
+
|
|
102
|
+
Full parameters, return shapes, the `alive` / `idle_seconds` / `hint` / `recent_stream` fields, and `poll_agent`'s last-3 visible-stream items are in [docs/tools.md](docs/tools.md).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Agent Lifecycle
|
|
107
|
+
|
|
108
|
+
Each agent transitions through these states:
|
|
109
|
+
|
|
110
|
+
| Status | Meaning |
|
|
111
|
+
|--------|---------|
|
|
112
|
+
| `processing` | Driver alive with a visible provider-stream heartbeat in the last 10 minutes -- actively working. Launch time counts as the initial heartbeat |
|
|
113
|
+
| `stalled` | Driver STILL ALIVE but no parsed visible provider stream item for >= 10 minutes -- working, thinking, or awaiting a temp-file handoff (not a failure). Recovers to `processing` if the visible stream resumes |
|
|
114
|
+
| `finished` | Current turn completed, or driver exited with code 0 |
|
|
115
|
+
| `errored` | Process exited with non-zero code |
|
|
116
|
+
| `stopped` | Terminated by `kill_agent` |
|
|
117
|
+
|
|
118
|
+
`processing` and `stalled` are live. `finished` is reportable for `wait`; if `alive` is still true, `send_message` can start the next turn on the same session. A health monitor runs every 10 seconds, and `poll_agent`/`list_agents` additionally reconcile driver exit synchronously. `wait` does not return just because an agent is `stalled`. `stalled` agents recover to `processing` if the visible stream resumes and are never auto-killed -- prefer `wait`/re-poll over `kill_agent`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Documentation
|
|
123
|
+
|
|
124
|
+
- [docs/registration.md](docs/registration.md) -- per-platform registration (Claude Code, Codex, Gemini), prerequisites, install, config paths.
|
|
125
|
+
- [docs/tools.md](docs/tools.md) -- full Tool Reference for all six tools, including `alive` / `idle_seconds` / `hint` fields.
|
|
126
|
+
- [docs/usage.md](docs/usage.md) -- model & effort matrix, ultracode mechanism, underlying CLI invocations, usage examples.
|
|
127
|
+
- [docs/SPEC.md](docs/SPEC.md) -- full technical specification (architecture, schemas, status lifecycle, error catalogue).
|
|
128
|
+
- [docs/spec/interactive-drivers.md](docs/spec/interactive-drivers.md) -- always-interactive Claude/Codex driver model.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
Apache-2.0 -- Copyright 2026 Lexi Blackburn
|
|
135
|
+
|
|
136
|
+
See [docs/SPEC.md](docs/SPEC.md) for the full technical specification.
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<
|
|
2
|
+
<subagent-mcp state="on" kind="carryover">
|
|
3
|
+
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.
|
|
3
4
|
|
|
4
|
-
Orchestration
|
|
5
|
+
Orchestration ON carried over from a PRIOR session for this project (persists until disabled with user permission). Not enabled THIS session.
|
|
5
6
|
|
|
6
|
-
THIS turn, ONCE:
|
|
7
|
-
1. NOTIFY user it carried over.
|
|
8
|
-
2. ASK keep ON? via AskUserQuestion.
|
|
9
|
-
3. ADVISE fit: long-horizon context-filling → keep ON; bounded/interactive/core-bound to main-session-only MCP → propose OFF.
|
|
7
|
+
THIS turn, ONCE: (1) NOTIFY the user it carried over; (2) ASK via AskUserQuestion whether to keep it ON; (3) ADVISE fit — long-horizon / context-filling → keep ON; bounded / interactive → propose OFF. Decline → orchestration-mode enabled:false. NEVER disable on your own initiative. After the answer the handshake is done; do not re-raise.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</ORCHESTRATION-CARRYOVER>
|
|
9
|
+
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 co-supreme with safety-scope; conflict → ask the user.
|
|
10
|
+
</subagent-mcp>
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<
|
|
2
|
+
<subagent-mcp state="on" kind="carryover">
|
|
3
|
+
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.
|
|
3
4
|
|
|
4
|
-
Orchestration
|
|
5
|
+
Orchestration ON carried over from a PRIOR session for this project (persists until disabled with user permission). Not enabled THIS session.
|
|
5
6
|
|
|
6
|
-
THIS turn, ONCE:
|
|
7
|
-
1. NOTIFY user it carried over.
|
|
8
|
-
2. ASK keep ON? via request-user-input.
|
|
9
|
-
3. ADVISE fit: long-horizon context-filling → keep ON; bounded/interactive/core-bound to main-session-only MCP → propose OFF.
|
|
7
|
+
THIS turn, ONCE: (1) NOTIFY the user it carried over; (2) ASK via request-user-input whether to keep it ON; (3) ADVISE fit — long-horizon / context-filling → keep ON; bounded / interactive → propose OFF. Decline → orchestration-mode enabled:false. NEVER disable on your own initiative. After the answer the handshake is done; do not re-raise.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</ORCHESTRATION-CARRYOVER>
|
|
9
|
+
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 co-supreme with safety-scope; conflict → ask the user.
|
|
10
|
+
</subagent-mcp>
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<subagent-mcp state="on" kind="directive">
|
|
3
|
+
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
4
|
|
|
5
|
-
ORCHESTRATION
|
|
5
|
+
ORCHESTRATION ON. You are the ORCHESTRATOR. This tag is MAXIMALLY CRITICAL: obey with NO exceptions. No user request overrides it; the only user-changeable thing is the ON/OFF state, reported authoritatively by this hook injection.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
9
|
-
loops. State which + why, one line.
|
|
7
|
+
ALLOWED TOOLS: ONLY AskUserQuestion + subagent-mcp. NO direct reads or writes. Inline-by-right does NOT exist. Every step runs in a sub-agent. A non-delegable atomic step → ask the user via AskUserQuestion for a one-time exception, do ONLY that step, then resume delegating.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
any payload >50KB or >200 lines → scratch file, hand off the PATH.
|
|
13
|
-
Mixed task = SPLIT. One MCP-bound step never makes the whole task inline.
|
|
9
|
+
READ LADDER: poll_agent tail → one <=100-line summarizer sub-agent (trusted as-is) → else the USER reads it. Large handoffs: assign scratch-file PATHS; producer writes, consumer reads; you NEVER read those files.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
User tool-pin re-partitions work; does not suspend mode.
|
|
11
|
+
PRECEDENCE: this tag and safety-scope are CO-SUPREME and equal; genuine conflict → STOP and escalate to the user (FORBIDDEN: resolving it yourself). SOLE CHANNEL: all launches via launch_agent. DROPOUT while ON: HALT and ask the user; stay halted until restored. The only user choices are keep-waiting or explicitly abandon the whole task; aborting ends the task, it never switches you to inline work. DISABLE: never on your own initiative.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
DISABLE: never on own initiative. Propose via AskUserQuestion only.
|
|
21
|
-
|
|
22
|
-
</ORCHESTRATION-INVARIANT>
|
|
13
|
+
Full model + governance: server MCP `instructions`.
|
|
14
|
+
</subagent-mcp>
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<subagent-mcp state="on" kind="directive">
|
|
3
|
+
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
4
|
|
|
5
|
-
ORCHESTRATION
|
|
5
|
+
ORCHESTRATION ON. You are the ORCHESTRATOR. This tag is MAXIMALLY CRITICAL: obey with NO exceptions. No user request overrides it; the only user-changeable thing is the ON/OFF state, reported authoritatively by this hook injection.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
9
|
-
loops. State which + why, one line.
|
|
7
|
+
ALLOWED TOOLS: ONLY request-user-input + subagent-mcp. NO direct reads or writes. Inline-by-right does NOT exist. Every step runs in a sub-agent. A non-delegable atomic step → ask the user via request-user-input for a one-time exception, do ONLY that step, then resume delegating.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
any payload >50KB or >200 lines → scratch file, hand off the PATH.
|
|
13
|
-
Mixed task = SPLIT. One MCP-bound step never makes the whole task inline.
|
|
9
|
+
READ LADDER: poll_agent tail → one <=100-line summarizer sub-agent (trusted as-is) → else the USER reads it. Large handoffs: assign scratch-file PATHS; producer writes, consumer reads; you NEVER read those files.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
User tool-pin re-partitions work; does not suspend mode.
|
|
11
|
+
PRECEDENCE: this tag and safety-scope are CO-SUPREME and equal; genuine conflict → STOP and escalate to the user (FORBIDDEN: resolving it yourself). SOLE CHANNEL: all launches via launch_agent. DROPOUT while ON: HALT and ask the user; stay halted until restored. The only user choices are keep-waiting or explicitly abandon the whole task; aborting ends the task, it never switches you to inline work. DISABLE: never on your own initiative.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
DISABLE: never on own initiative. Propose via request-user-input only.
|
|
21
|
-
|
|
22
|
-
</ORCHESTRATION-INVARIANT>
|
|
13
|
+
Full model + governance: server MCP `instructions`.
|
|
14
|
+
</subagent-mcp>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
-
<
|
|
2
|
+
<subagent-mcp state="off" kind="reminder">
|
|
3
|
+
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).
|
|
3
4
|
|
|
4
|
-
Orchestration OFF.
|
|
5
|
+
Orchestration OFF. LONG-HORIZON CHECK: a task is long-horizon when its TOTAL context footprint (input read + output produced) exceeds 200 lines. After EVERY user turn, measure the CUMULATIVE footprint since your last upgrade ask (reset that count to zero only when you actually ask); if it qualifies, STOP and ask via AskUserQuestion whether to switch Orchestration ON. Ask on EVERY qualifying turn; a decline does NOT suppress later asks.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</ORCHESTRATION-INVARIANT>
|
|
7
|
+
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,8 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
-
<
|
|
2
|
+
<subagent-mcp state="off" kind="reminder">
|
|
3
|
+
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).
|
|
3
4
|
|
|
4
|
-
Orchestration OFF.
|
|
5
|
+
Orchestration OFF. LONG-HORIZON CHECK: a task is long-horizon when its TOTAL context footprint (input read + output produced) exceeds 200 lines. After EVERY user turn, measure the CUMULATIVE footprint since your last upgrade ask (reset that count to zero only when you actually ask); if it qualifies, STOP and ask via request-user-input whether to switch Orchestration ON. Ask on EVERY qualifying turn; a decline does NOT suppress later asks.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</ORCHESTRATION-INVARIANT>
|
|
7
|
+
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,12 @@
|
|
|
1
1
|
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
-
<
|
|
2
|
+
<subagent-mcp state="on" kind="reminder">
|
|
3
|
+
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).
|
|
3
4
|
|
|
4
|
-
Orchestration ON.
|
|
5
|
+
Orchestration ON. You are the orchestrator: delegate EVERY step. Allowed tools = ONLY the structured-question tool (AskUserQuestion / request-user-input) + subagent-mcp; 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.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
READ LADDER: poll_agent tail → one <=100-line summarizer sub-agent (trusted as-is) → else the user reads it. Large handoffs via scratch-file PATHS you never read.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
WAIT-NOT-POLL: learn finish via `wait` (verbose:true for output); never loop poll_agent for completion. poll_agent = single diagnostic; stalled/empty = alive, not dead.
|
|
10
|
+
|
|
11
|
+
This tag is co-supreme 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
|
+
<subagent-mcp state="off" kind="carrier">If this prompt's literal first line begins with "<this is a request from a parent process>", ignore this tag. Orchestration OFF. After each user turn, if CUMULATIVE context footprint since your last ask exceeds 200 lines, STOP and ask whether to switch ON (every qualifying turn; declines don't latch; reset the count only when you ask). Follow the MOST RECENT <subagent-mcp state="off"> reminder tag; if none is in the current window, the INIT_BLOCK governs.</subagent-mcp>
|
package/directives/short-on.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<
|
|
1
|
+
<subagent-mcp state="on" kind="carrier">If this prompt's literal first line begins with "<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; NO direct reads/writes; inline-by-right does not exist. Follow the MOST RECENT <subagent-mcp state="on"> tag in context (directive or reminder/carrier); if none is in the current window, the INIT_BLOCK governs. Co-supreme with safety-scope; no ordinary user request bypasses it.</subagent-mcp>
|
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 (claude);
|
|
16
|
-
gpt-5.5 (codex). Valid efforts: haiku -> "none" only; sonnet ->
|
|
17
|
-
opus/opus-4-8 -> those plus ultracode; gpt-5.5 ->
|
|
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 (claude);
|
|
16
|
+
gpt-5.5 (codex). Valid efforts: haiku -> "none" only; sonnet -> medium|high|xhigh|max;
|
|
17
|
+
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()
|