@heretyc/subagent-mcp 2.6.0 → 2.6.2
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 +124 -124
- package/directives/carryover-claude.md +17 -17
- package/directives/carryover-codex.md +17 -17
- package/directives/off-turn-reminder.md +1 -1
- package/directives/orchestration-claude.md +21 -21
- package/directives/orchestration-codex.md +22 -22
- package/dist/advanced-ruleset.py +67 -67
- package/dist/doctor.js +6 -6
- package/dist/routing-table.json +3821 -3821
- package/dist/ruleset-scaffold.js +1 -1
- package/dist/setup.js +118 -36
- package/package.json +51 -51
- package/scripts/postinstall.mjs +102 -102
package/README.md
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
# subagent-mcp
|
|
2
|
-
|
|
3
|
-
MCP server that launches and manages locally installed `claude` and `codex` CLI binaries as child sub-agent processes. 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. It invokes your locally installed and authenticated `claude` (Claude Code) and `codex` CLIs. No API keys, no SDKs beyond the CLIs themselves.
|
|
6
|
-
|
|
7
|
-
**License:** Apache-2.0 | **Author:** Lexi Blackburn | **Repo:** https://github.com/Heretyc/subagent-mcp
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- Spawn `claude` or `codex` CLI processes as managed sub-agents from any MCP host
|
|
14
|
-
- Poll status, stream stdout/stderr tails, and send stdin messages to live agents
|
|
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 `stream-json`, Codex `--json` 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 an orchestrator-only directive that the bundled Claude Code / Codex plugin injects every turn via its `UserPromptSubmit` hook (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 the `UserPromptSubmit` hook for orchestration-mode injection. Idempotent — safe to re-run after updates. Pass `--dry-run` to preview.
|
|
43
|
-
|
|
44
|
-
After setup, restart your Claude Code or Codex session. On Codex, run `/hooks` and trust the new hook.
|
|
45
|
-
|
|
46
|
-
**Updating:** `npm install -g @heretyc/subagent-mcp && subagent-mcp setup`
|
|
47
|
-
|
|
48
|
-
For manual wiring, developer install from source, Gemini CLI, and Claude Desktop, see [docs/registration.md](docs/registration.md).
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Auto Mode
|
|
53
|
-
|
|
54
|
-
`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.
|
|
55
|
-
|
|
56
|
-
`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`.
|
|
57
|
-
|
|
58
|
-
**task_category** (required) — pick one:
|
|
59
|
-
|
|
60
|
-
| Category | What it is |
|
|
61
|
-
|---|---|
|
|
62
|
-
| `math_proof` | deliverable is a proof/derivation/formally-checkable result |
|
|
63
|
-
| `security_review` | security verdict, threat assessment, or demonstrated exploit |
|
|
64
|
-
| `debugging` | verified fix/root-cause; requires an observed failure as precondition |
|
|
65
|
-
| `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
|
|
66
|
-
| `architecture` | cross-module design/plan, no code, no execution loop |
|
|
67
|
-
| `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
|
|
68
|
-
| `data_analysis` | empirical finding about structured dataset (query, stat, model) |
|
|
69
|
-
| `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
|
|
70
|
-
| `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
|
|
71
|
-
| `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
|
|
72
|
-
| `fallback_default` | no category matches with confidence; prefer splitting work instead |
|
|
73
|
-
|
|
74
|
-
**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.
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## Tools
|
|
79
|
-
|
|
80
|
-
Six tools are exposed over the stdio MCP transport:
|
|
81
|
-
|
|
82
|
-
| Tool | Purpose |
|
|
83
|
-
|------|---------|
|
|
84
|
-
| `launch_agent` | Spawn a new `claude`/`codex` sub-agent process |
|
|
85
|
-
| `poll_agent` | Get status + output tail of one agent |
|
|
86
|
-
| `kill_agent` | Immediately force-kill any live agent |
|
|
87
|
-
| `send_message` | Write to a live agent's stdin |
|
|
88
|
-
| `list_agents` | List all agents with token-efficient core metrics |
|
|
89
|
-
| `wait` | Block until one or more agents finish, or 15-minute timeout |
|
|
90
|
-
|
|
91
|
-
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).
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## Agent Lifecycle
|
|
96
|
-
|
|
97
|
-
Each agent transitions through these states:
|
|
98
|
-
|
|
99
|
-
| Status | Meaning |
|
|
100
|
-
|--------|---------|
|
|
101
|
-
| `processing` | Process alive with a visible provider-stream heartbeat in the last 10 minutes -- actively working. Launch time counts as the initial heartbeat |
|
|
102
|
-
| `stalled` | Process 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 |
|
|
103
|
-
| `finished` | Process exited with code 0, or Codex emitted `turn.completed` event |
|
|
104
|
-
| `errored` | Process exited with non-zero code |
|
|
105
|
-
| `stopped` | Terminated by `kill_agent` |
|
|
106
|
-
|
|
107
|
-
Only `finished`, `errored`, and `stopped` are terminal; `processing` and `stalled` are live. A health monitor runs every 10 seconds, and `poll_agent`/`list_agents` additionally reconcile exit synchronously so an exited process is reported immediately. `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 (or checking the agent's temp output) over `kill_agent`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Documentation
|
|
112
|
-
|
|
113
|
-
- [docs/registration.md](docs/registration.md) -- per-platform registration (Claude Code, Codex, Gemini), prerequisites, install, config paths.
|
|
114
|
-
- [docs/tools.md](docs/tools.md) -- full Tool Reference for all six tools, including `alive` / `idle_seconds` / `hint` fields.
|
|
115
|
-
- [docs/usage.md](docs/usage.md) -- model & effort matrix, ultracode mechanism, underlying CLI invocations, usage examples.
|
|
116
|
-
- [docs/SPEC.md](docs/SPEC.md) -- full technical specification (architecture, schemas, status lifecycle, error catalogue).
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## License
|
|
121
|
-
|
|
122
|
-
Apache-2.0 -- Copyright 2026 Lexi Blackburn
|
|
123
|
-
|
|
124
|
-
See [docs/SPEC.md](docs/SPEC.md) for the full technical specification.
|
|
1
|
+
# subagent-mcp
|
|
2
|
+
|
|
3
|
+
MCP server that launches and manages locally installed `claude` and `codex` CLI binaries as child sub-agent processes. 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. It invokes your locally installed and authenticated `claude` (Claude Code) and `codex` CLIs. No API keys, no SDKs beyond the CLIs themselves.
|
|
6
|
+
|
|
7
|
+
**License:** Apache-2.0 | **Author:** Lexi Blackburn | **Repo:** https://github.com/Heretyc/subagent-mcp
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Spawn `claude` or `codex` CLI processes as managed sub-agents from any MCP host
|
|
14
|
+
- Poll status, stream stdout/stderr tails, and send stdin messages to live agents
|
|
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 `stream-json`, Codex `--json` 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 an orchestrator-only directive that the bundled Claude Code / Codex plugin injects every turn via its `UserPromptSubmit` hook (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 the `UserPromptSubmit` hook for orchestration-mode injection. Idempotent — safe to re-run after updates. Pass `--dry-run` to preview.
|
|
43
|
+
|
|
44
|
+
After setup, restart your Claude Code or Codex session. On Codex, run `/hooks` and trust the new hook.
|
|
45
|
+
|
|
46
|
+
**Updating:** `npm install -g @heretyc/subagent-mcp && subagent-mcp setup`
|
|
47
|
+
|
|
48
|
+
For manual wiring, developer install from source, Gemini CLI, and Claude Desktop, see [docs/registration.md](docs/registration.md).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Auto Mode
|
|
53
|
+
|
|
54
|
+
`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.
|
|
55
|
+
|
|
56
|
+
`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`.
|
|
57
|
+
|
|
58
|
+
**task_category** (required) — pick one:
|
|
59
|
+
|
|
60
|
+
| Category | What it is |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `math_proof` | deliverable is a proof/derivation/formally-checkable result |
|
|
63
|
+
| `security_review` | security verdict, threat assessment, or demonstrated exploit |
|
|
64
|
+
| `debugging` | verified fix/root-cause; requires an observed failure as precondition |
|
|
65
|
+
| `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
|
|
66
|
+
| `architecture` | cross-module design/plan, no code, no execution loop |
|
|
67
|
+
| `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
|
|
68
|
+
| `data_analysis` | empirical finding about structured dataset (query, stat, model) |
|
|
69
|
+
| `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
|
|
70
|
+
| `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
|
|
71
|
+
| `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
|
|
72
|
+
| `fallback_default` | no category matches with confidence; prefer splitting work instead |
|
|
73
|
+
|
|
74
|
+
**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.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Tools
|
|
79
|
+
|
|
80
|
+
Six tools are exposed over the stdio MCP transport:
|
|
81
|
+
|
|
82
|
+
| Tool | Purpose |
|
|
83
|
+
|------|---------|
|
|
84
|
+
| `launch_agent` | Spawn a new `claude`/`codex` sub-agent process |
|
|
85
|
+
| `poll_agent` | Get status + output tail of one agent |
|
|
86
|
+
| `kill_agent` | Immediately force-kill any live agent |
|
|
87
|
+
| `send_message` | Write to a live agent's stdin |
|
|
88
|
+
| `list_agents` | List all agents with token-efficient core metrics |
|
|
89
|
+
| `wait` | Block until one or more agents finish, or 15-minute timeout |
|
|
90
|
+
|
|
91
|
+
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).
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Agent Lifecycle
|
|
96
|
+
|
|
97
|
+
Each agent transitions through these states:
|
|
98
|
+
|
|
99
|
+
| Status | Meaning |
|
|
100
|
+
|--------|---------|
|
|
101
|
+
| `processing` | Process alive with a visible provider-stream heartbeat in the last 10 minutes -- actively working. Launch time counts as the initial heartbeat |
|
|
102
|
+
| `stalled` | Process 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 |
|
|
103
|
+
| `finished` | Process exited with code 0, or Codex emitted `turn.completed` event |
|
|
104
|
+
| `errored` | Process exited with non-zero code |
|
|
105
|
+
| `stopped` | Terminated by `kill_agent` |
|
|
106
|
+
|
|
107
|
+
Only `finished`, `errored`, and `stopped` are terminal; `processing` and `stalled` are live. A health monitor runs every 10 seconds, and `poll_agent`/`list_agents` additionally reconcile exit synchronously so an exited process is reported immediately. `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 (or checking the agent's temp output) over `kill_agent`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Documentation
|
|
112
|
+
|
|
113
|
+
- [docs/registration.md](docs/registration.md) -- per-platform registration (Claude Code, Codex, Gemini), prerequisites, install, config paths.
|
|
114
|
+
- [docs/tools.md](docs/tools.md) -- full Tool Reference for all six tools, including `alive` / `idle_seconds` / `hint` fields.
|
|
115
|
+
- [docs/usage.md](docs/usage.md) -- model & effort matrix, ultracode mechanism, underlying CLI invocations, usage examples.
|
|
116
|
+
- [docs/SPEC.md](docs/SPEC.md) -- full technical specification (architecture, schemas, status lifecycle, error catalogue).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
Apache-2.0 -- Copyright 2026 Lexi Blackburn
|
|
123
|
+
|
|
124
|
+
See [docs/SPEC.md](docs/SPEC.md) for the full technical specification.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<ORCHESTRATION-CARRYOVER priority="CRITICAL" override="NONE">
|
|
3
|
-
|
|
4
|
-
ORCHESTRATION MODE was ON at session start — carried over from a PRIOR session
|
|
5
|
-
for this project (persists until disabled with permission). Not enabled in THIS
|
|
6
|
-
session.
|
|
7
|
-
|
|
8
|
-
THIS turn, ONCE:
|
|
9
|
-
1. NOTIFY user it carried over.
|
|
10
|
-
2. ASK keep ON? via AskUserQuestion.
|
|
11
|
-
3. ADVISE fit: long-horizon context-filling → keep ON; bounded, interactive, or
|
|
12
|
-
core-bound to main-session-only MCP → propose OFF.
|
|
13
|
-
|
|
14
|
-
Declines → orchestration-mode enabled:false. NEVER disable on own initiative.
|
|
15
|
-
After answer: handshake done — do not re-raise.
|
|
16
|
-
|
|
17
|
-
</ORCHESTRATION-CARRYOVER>
|
|
1
|
+
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
+
<ORCHESTRATION-CARRYOVER priority="CRITICAL" override="NONE">
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION MODE was ON at session start — carried over from a PRIOR session
|
|
5
|
+
for this project (persists until disabled with permission). Not enabled in THIS
|
|
6
|
+
session.
|
|
7
|
+
|
|
8
|
+
THIS turn, ONCE:
|
|
9
|
+
1. NOTIFY user it carried over.
|
|
10
|
+
2. ASK keep ON? via AskUserQuestion.
|
|
11
|
+
3. ADVISE fit: long-horizon context-filling → keep ON; bounded, interactive, or
|
|
12
|
+
core-bound to main-session-only MCP → propose OFF.
|
|
13
|
+
|
|
14
|
+
Declines → orchestration-mode enabled:false. NEVER disable on own initiative.
|
|
15
|
+
After answer: handshake done — do not re-raise.
|
|
16
|
+
|
|
17
|
+
</ORCHESTRATION-CARRYOVER>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<ORCHESTRATION-CARRYOVER priority="CRITICAL" override="NONE">
|
|
3
|
-
|
|
4
|
-
ORCHESTRATION MODE was ON at session start — carried over from a PRIOR session
|
|
5
|
-
for this project (persists until disabled with permission). Not enabled in THIS
|
|
6
|
-
session.
|
|
7
|
-
|
|
8
|
-
THIS turn, ONCE:
|
|
9
|
-
1. NOTIFY user it carried over.
|
|
10
|
-
2. ASK keep ON? via request-user-input.
|
|
11
|
-
3. ADVISE fit: long-horizon context-filling → keep ON; bounded, interactive, or
|
|
12
|
-
core-bound to main-session-only MCP → propose OFF.
|
|
13
|
-
|
|
14
|
-
Declines → orchestration-mode enabled:false. NEVER disable on own initiative.
|
|
15
|
-
After answer: handshake done — do not re-raise.
|
|
16
|
-
|
|
17
|
-
</ORCHESTRATION-CARRYOVER>
|
|
1
|
+
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
+
<ORCHESTRATION-CARRYOVER priority="CRITICAL" override="NONE">
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION MODE was ON at session start — carried over from a PRIOR session
|
|
5
|
+
for this project (persists until disabled with permission). Not enabled in THIS
|
|
6
|
+
session.
|
|
7
|
+
|
|
8
|
+
THIS turn, ONCE:
|
|
9
|
+
1. NOTIFY user it carried over.
|
|
10
|
+
2. ASK keep ON? via request-user-input.
|
|
11
|
+
3. ADVISE fit: long-horizon context-filling → keep ON; bounded, interactive, or
|
|
12
|
+
core-bound to main-session-only MCP → propose OFF.
|
|
13
|
+
|
|
14
|
+
Declines → orchestration-mode enabled:false. NEVER disable on own initiative.
|
|
15
|
+
After answer: handshake done — do not re-raise.
|
|
16
|
+
|
|
17
|
+
</ORCHESTRATION-CARRYOVER>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Reminder: <SUB-AGENT-INVARIANT> and <sanity-rules> apply. HALT if unknown.
|
|
1
|
+
Reminder: <SUB-AGENT-INVARIANT> and <sanity-rules> apply. HALT if unknown.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
3
|
-
|
|
4
|
-
ORCHESTRATION MODE ON. You = ORCHESTRATOR. DEFAULT = DELEGATE.
|
|
5
|
-
|
|
6
|
-
INLINE BY RIGHT (no violation): steps bound to main-session-only capability —
|
|
7
|
-
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
8
|
-
loops. State which + why, one line.
|
|
9
|
-
|
|
10
|
-
MUST DELEGATE/OFFLOAD (breach if not): pure compute (parse/aggregate/transform);
|
|
11
|
-
any payload >50KB or >200 lines → scratch file, hand off the PATH.
|
|
12
|
-
Mixed task = SPLIT. One MCP-bound step never makes the whole task inline.
|
|
13
|
-
|
|
14
|
-
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default.
|
|
15
|
-
User tool-pin re-partitions work; does not suspend mode.
|
|
16
|
-
|
|
17
|
-
IPC = temp scratch files ONLY. Windows: %TEMP%. POSIX: /tmp.
|
|
18
|
-
Full model + governance: server MCP instructions.
|
|
19
|
-
DISABLE: never on own initiative. Propose via AskUserQuestion only.
|
|
20
|
-
|
|
21
|
-
</SUB-AGENT-INVARIANT>
|
|
1
|
+
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
+
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION MODE ON. You = ORCHESTRATOR. DEFAULT = DELEGATE.
|
|
5
|
+
|
|
6
|
+
INLINE BY RIGHT (no violation): steps bound to main-session-only capability —
|
|
7
|
+
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
8
|
+
loops. State which + why, one line.
|
|
9
|
+
|
|
10
|
+
MUST DELEGATE/OFFLOAD (breach if not): pure compute (parse/aggregate/transform);
|
|
11
|
+
any payload >50KB or >200 lines → scratch file, hand off the PATH.
|
|
12
|
+
Mixed task = SPLIT. One MCP-bound step never makes the whole task inline.
|
|
13
|
+
|
|
14
|
+
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default.
|
|
15
|
+
User tool-pin re-partitions work; does not suspend mode.
|
|
16
|
+
|
|
17
|
+
IPC = temp scratch files ONLY. Windows: %TEMP%. POSIX: /tmp.
|
|
18
|
+
Full model + governance: server MCP instructions.
|
|
19
|
+
DISABLE: never on own initiative. Propose via AskUserQuestion only.
|
|
20
|
+
|
|
21
|
+
</SUB-AGENT-INVARIANT>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
-
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
3
|
-
SCOPE: If this session's prompt begins with "<this is a request from a parent process>", SUB-AGENT-INVARIANT does NOT apply to this session, SKIP the remainder of this directive.
|
|
4
|
-
|
|
5
|
-
ORCHESTRATION MODE ON. You = ORCHESTRATOR. DEFAULT = DELEGATE.
|
|
6
|
-
|
|
7
|
-
INLINE BY RIGHT (no violation): steps bound to main-session-only capability —
|
|
8
|
-
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
9
|
-
loops. State which + why, one line.
|
|
10
|
-
|
|
11
|
-
MUST DELEGATE/OFFLOAD (breach if not): pure compute (parse/aggregate/transform);
|
|
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.
|
|
14
|
-
|
|
15
|
-
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default.
|
|
16
|
-
User tool-pin re-partitions work; does not suspend mode.
|
|
17
|
-
|
|
18
|
-
IPC = temp scratch files ONLY. Windows: %TEMP%. POSIX: /tmp.
|
|
19
|
-
Full model + governance: server MCP instructions.
|
|
20
|
-
DISABLE: never on own initiative. Propose via request-user-input only.
|
|
21
|
-
|
|
22
|
-
</SUB-AGENT-INVARIANT>
|
|
1
|
+
<!-- INJECTED PRE-PROMPT DIRECTIVE — BINDING, NON-NEGOTIABLE -->
|
|
2
|
+
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
3
|
+
SCOPE: If this session's prompt begins with "<this is a request from a parent process>", SUB-AGENT-INVARIANT does NOT apply to this session, SKIP the remainder of this directive.
|
|
4
|
+
|
|
5
|
+
ORCHESTRATION MODE ON. You = ORCHESTRATOR. DEFAULT = DELEGATE.
|
|
6
|
+
|
|
7
|
+
INLINE BY RIGHT (no violation): steps bound to main-session-only capability —
|
|
8
|
+
MCP tools sub-agents can't inherit, interactive/consent tools, tight verify
|
|
9
|
+
loops. State which + why, one line.
|
|
10
|
+
|
|
11
|
+
MUST DELEGATE/OFFLOAD (breach if not): pure compute (parse/aggregate/transform);
|
|
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.
|
|
14
|
+
|
|
15
|
+
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default.
|
|
16
|
+
User tool-pin re-partitions work; does not suspend mode.
|
|
17
|
+
|
|
18
|
+
IPC = temp scratch files ONLY. Windows: %TEMP%. POSIX: /tmp.
|
|
19
|
+
Full model + governance: server MCP instructions.
|
|
20
|
+
DISABLE: never on own initiative. Propose via request-user-input only.
|
|
21
|
+
|
|
22
|
+
</SUB-AGENT-INVARIANT>
|
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 -> low|medium|high|xhigh|max;
|
|
17
|
-
opus/opus-4-8 -> those plus ultracode; gpt-5.5 -> low|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 (claude);
|
|
16
|
+
gpt-5.5 (codex). Valid efforts: haiku -> "none" only; sonnet -> low|medium|high|xhigh|max;
|
|
17
|
+
opus/opus-4-8 -> those plus ultracode; gpt-5.5 -> low|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/doctor.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `subagent-mcp doctor` — read-only health check for the installed addon.
|
|
3
3
|
//
|
|
4
|
-
// Diagnoses
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Diagnoses install completeness, vendor presence, and whether each vendor's
|
|
5
|
+
// wiring (MCP server + hooks) points at THIS install. Doctor self-repairs
|
|
6
|
+
// missing MCP registrations via vendor CLIs; use `subagent-mcp setup` for
|
|
7
|
+
// config-file and hook repairs.
|
|
8
8
|
//
|
|
9
9
|
// Exit code: 0 = everything healthy, 1 = at least one check failed.
|
|
10
10
|
import { verifyWiring } from "./setup.js";
|
|
11
11
|
export async function runDoctor() {
|
|
12
|
-
console.log("subagent-mcp doctor (
|
|
12
|
+
console.log("subagent-mcp doctor (checks wiring; repairs missing MCP registrations via vendor CLIs)\n");
|
|
13
13
|
const major = Number(process.versions.node.split(".")[0]);
|
|
14
14
|
console.log(` ${major >= 18 ? "PASS" : "FAIL"} node version — ${process.versions.node}` +
|
|
15
15
|
(major >= 18 ? "" : " (Node >= 18 required)"));
|
|
16
16
|
let failed = major < 18 ? 1 : 0;
|
|
17
|
-
for (const r of verifyWiring()) {
|
|
17
|
+
for (const r of verifyWiring(undefined, true)) {
|
|
18
18
|
console.log(` ${r.ok ? "PASS" : "FAIL"} ${r.label} — ${r.detail}`);
|
|
19
19
|
if (!r.ok)
|
|
20
20
|
failed++;
|