@heretyc/subagent-mcp 2.7.1 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +5 -5
- package/README.md +130 -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 +14 -21
- package/directives/orchestration-codex.md +15 -22
- package/directives/reminder-off-claude.md +12 -0
- package/directives/reminder-off-codex.md +12 -0
- package/directives/reminder-on.md +15 -0
- package/dist/advanced-ruleset.py +67 -67
- package/dist/hooks/orchestration-claude.js +4 -2
- package/dist/hooks/orchestration-codex.js +14 -23
- package/dist/index.js +1 -1
- package/dist/orchestration/hook-core.js +85 -37
- package/dist/orchestration/marker.js +6 -0
- package/dist/orchestration/reminder.js +72 -0
- package/dist/routing-table.json +4149 -3821
- package/dist/routing.js +6 -2
- package/dist/ruleset-scaffold.js +1 -1
- package/dist/setup.js +3 -0
- package/package.json +51 -51
- package/scripts/postinstall.mjs +102 -102
package/README.md
CHANGED
|
@@ -1,124 +1,130 @@
|
|
|
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
|
-
| `
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
| `prompt_engineering` | designed/optimized prompt or prompt-system steering an LLM/agent (composite-inferred) |
|
|
73
|
+
| `vulnerability_research` | discovery + PoC of a novel vulnerability (composite-inferred) |
|
|
74
|
+
| `molecular_biology` | reasoned molecular/computational-biology result over sequences, structures, or -omics data (composite-inferred) |
|
|
75
|
+
| `ml_accelerator_design` | hardware/software design for ML acceleration — dataflow, kernel, roofline (composite-inferred) |
|
|
76
|
+
| `fallback_default` | no category matches with confidence; prefer splitting work instead |
|
|
77
|
+
|
|
78
|
+
The last four are **composite-inferred**: they carry no dedicated benchmark and their routing competency is composed from parent categories rather than measured directly.
|
|
79
|
+
|
|
80
|
+
**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.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Tools
|
|
85
|
+
|
|
86
|
+
Six tools are exposed over the stdio MCP transport:
|
|
87
|
+
|
|
88
|
+
| Tool | Purpose |
|
|
89
|
+
|------|---------|
|
|
90
|
+
| `launch_agent` | Spawn a new `claude`/`codex` sub-agent process |
|
|
91
|
+
| `poll_agent` | Get status + output tail of one agent |
|
|
92
|
+
| `kill_agent` | Immediately force-kill any live agent |
|
|
93
|
+
| `send_message` | Write to a live agent's stdin |
|
|
94
|
+
| `list_agents` | List all agents with token-efficient core metrics |
|
|
95
|
+
| `wait` | Block until one or more agents finish, or 15-minute timeout |
|
|
96
|
+
|
|
97
|
+
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).
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Agent Lifecycle
|
|
102
|
+
|
|
103
|
+
Each agent transitions through these states:
|
|
104
|
+
|
|
105
|
+
| Status | Meaning |
|
|
106
|
+
|--------|---------|
|
|
107
|
+
| `processing` | Process alive with a visible provider-stream heartbeat in the last 10 minutes -- actively working. Launch time counts as the initial heartbeat |
|
|
108
|
+
| `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 |
|
|
109
|
+
| `finished` | Process exited with code 0, or Codex emitted `turn.completed` event |
|
|
110
|
+
| `errored` | Process exited with non-zero code |
|
|
111
|
+
| `stopped` | Terminated by `kill_agent` |
|
|
112
|
+
|
|
113
|
+
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).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Documentation
|
|
118
|
+
|
|
119
|
+
- [docs/registration.md](docs/registration.md) -- per-platform registration (Claude Code, Codex, Gemini), prerequisites, install, config paths.
|
|
120
|
+
- [docs/tools.md](docs/tools.md) -- full Tool Reference for all six tools, including `alive` / `idle_seconds` / `hint` fields.
|
|
121
|
+
- [docs/usage.md](docs/usage.md) -- model & effort matrix, ultracode mechanism, underlying CLI invocations, usage examples.
|
|
122
|
+
- [docs/SPEC.md](docs/SPEC.md) -- full technical specification (architecture, schemas, status lifecycle, error catalogue).
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0 -- Copyright 2026 Lexi Blackburn
|
|
129
|
+
|
|
130
|
+
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
|
-
|
|
1
|
+
Follow the directives in the last <ORCHESTRATION-REMINDER-INVARIANT> block; if none has appeared yet this session, await it — do not infer its content.
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
<!-- INJECTED PRE-PROMPT DIRECTIVE
|
|
2
|
-
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
ORCHESTRATION MODE ON: ORCHESTRATOR; default=DELEGATE.
|
|
4
|
+
|
|
5
|
+
INLINE BY RIGHT only for main-session-only capability: user interaction/consent, agent control, tiny audits, final git/PR, irreducible verify loops. State which+why. Direct tool calls spend main context; keep to that set.
|
|
6
|
+
|
|
7
|
+
Clarification/consent: subagents surface questions to orchestrator. Orchestrator asks with AskUserQuestion, sends answer back. Question/gate/audit duty does not justify adjacent discovery or edits inline.
|
|
8
|
+
|
|
9
|
+
MUST DELEGATE/OFFLOAD: pure compute; implementation/integration edits; mixed tasks split. One MCP-bound step never makes all inline. Payload >50KB or >200 lines -> scratch path (%TEMP% or /tmp), hand off PATH. Orchestrator audits diffs/results before commit.
|
|
10
|
+
|
|
11
|
+
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default. Tool-pin repartitions work, does not suspend mode. IPC=temp scratch files only. Full model/governance: server MCP instructions.
|
|
12
|
+
|
|
13
|
+
DISABLE: never on own initiative. Propose via AskUserQuestion only; disable only after explicit user permission.
|
|
14
|
+
</SUB-AGENT-INVARIANT>
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
<SUB-AGENT-INVARIANT priority="CRITICAL" override="NONE">
|
|
2
|
+
SCOPE: if prompt begins "<this is a request from a parent process>", skip rest.
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION MODE ON: ORCHESTRATOR; default=DELEGATE.
|
|
5
|
+
|
|
6
|
+
INLINE BY RIGHT only for main-session-only capability: user interaction/consent, agent control, tiny audits, final git/PR, irreducible verify loops. State which+why. Direct calls spend main context; keep to that set.
|
|
7
|
+
|
|
8
|
+
Clarification/consent: subagents surface questions to orchestrator. Orchestrator asks with request-user-input, sends answer back. Question/gate/audit duty does not justify adjacent discovery or edits inline.
|
|
9
|
+
|
|
10
|
+
MUST DELEGATE/OFFLOAD: pure compute; implementation/integration edits; mixed tasks split. One MCP-bound step never makes all inline. Payload >50KB or >200 lines -> scratch path (%TEMP% or /tmp), hand off PATH. Orchestrator audits diffs/results before commit.
|
|
11
|
+
|
|
12
|
+
CONFLICT ORDER: safety-scope > user instruction this turn > delegate-default. Tool-pin repartitions work, does not suspend mode. IPC=temp scratch files only. Full governance: server MCP instructions.
|
|
13
|
+
|
|
14
|
+
DISABLE: never on own initiative. Propose via request-user-input only; disable only after explicit permission.
|
|
15
|
+
</SUB-AGENT-INVARIANT>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
+
<ORCHESTRATION-REMINDER-INVARIANT>
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION OFF. 5-CALL RULE: if the request likely needs >5 tool calls, OR
|
|
5
|
+
your 5th call completes with work remaining — STOP, ask via AskUserQuestion
|
|
6
|
+
whether to switch orchestration mode ON. Even while OFF, delegating via
|
|
7
|
+
subagent-mcp full-auto routing (per-category, latest benchmark data) is
|
|
8
|
+
advisable for well-rounded, durable results — do not assume the calling model
|
|
9
|
+
is always the best fit. Why this exists: agents grind through large work
|
|
10
|
+
without ever considering orchestration. Sub-agent sessions: ignore this block.
|
|
11
|
+
|
|
12
|
+
</ORCHESTRATION-REMINDER-INVARIANT>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
+
<ORCHESTRATION-REMINDER-INVARIANT>
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION OFF. 5-CALL RULE: if the request likely needs >5 tool calls, OR
|
|
5
|
+
your 5th call completes with work remaining — STOP, ask via request-user-input
|
|
6
|
+
whether to switch orchestration mode ON. Even while OFF, delegating via
|
|
7
|
+
subagent-mcp full-auto routing (per-category, latest benchmark data) is
|
|
8
|
+
advisable for well-rounded, durable results — do not assume the calling model
|
|
9
|
+
is always the best fit. Why this exists: agents grind through large work
|
|
10
|
+
without ever considering orchestration. Sub-agent sessions: ignore this block.
|
|
11
|
+
|
|
12
|
+
</ORCHESTRATION-REMINDER-INVARIANT>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- INJECTED PER-PROMPT REMINDER — BINDING -->
|
|
2
|
+
<ORCHESTRATION-REMINDER-INVARIANT>
|
|
3
|
+
|
|
4
|
+
ORCHESTRATION ON. Delegate-default: decompose; delegate; keep orchestrator
|
|
5
|
+
context lean. The 5-CALL RULE is satisfied by delegation.
|
|
6
|
+
Subagents may ask for clarification/consent through the orchestrator; answers
|
|
7
|
+
return to subagents. Questions, gates, and audits do not justify adjacent
|
|
8
|
+
inline discovery/edits. Orchestrator tool use is limited to user interaction,
|
|
9
|
+
agent control, tiny audits, final git/PR actions, and irreducible verify loops.
|
|
10
|
+
Implementation/integration edits remain delegated by default; audit before
|
|
11
|
+
commit.
|
|
12
|
+
<SUB-AGENT-INVARIANT> governance applies — full model: server MCP instructions.
|
|
13
|
+
Sub-agent sessions: ignore this block.
|
|
14
|
+
|
|
15
|
+
</ORCHESTRATION-REMINDER-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()
|
|
@@ -36,14 +36,16 @@ export const claudeAdapter = {
|
|
|
36
36
|
// Count JSONL lines in the transcript whose parsed object.type === 'user'.
|
|
37
37
|
// Delegates to the bounded counter (reads at most the trailing window so a
|
|
38
38
|
// huge/attacker-supplied transcript can't stall the inline host turn).
|
|
39
|
-
// Unreadable/missing transcript -> 0
|
|
40
|
-
//
|
|
39
|
+
// Unreadable/missing transcript -> 0 (fail-safe: the claim baseline stamps
|
|
40
|
+
// at 0; cadence is counter-driven and unaffected). Read on claim turns only.
|
|
41
41
|
currentTurn(transcriptPath) {
|
|
42
42
|
return countJsonlType(transcriptPath, "user");
|
|
43
43
|
},
|
|
44
44
|
fullDirectiveFile: "orchestration-claude.md",
|
|
45
45
|
offTurnFile: "off-turn-reminder.md",
|
|
46
46
|
carryoverDirectiveFile: "carryover-claude.md",
|
|
47
|
+
reminderOnFile: "reminder-on.md",
|
|
48
|
+
reminderOffFile: "reminder-off-claude.md",
|
|
47
49
|
};
|
|
48
50
|
function readStdin() {
|
|
49
51
|
return new Promise((resolve) => {
|