@heretyc/subagent-mcp 2.6.0
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 -0
- package/NOTICE +5 -0
- package/README.md +124 -0
- package/directives/carryover-claude.md +17 -0
- package/directives/carryover-codex.md +17 -0
- package/directives/off-turn-reminder.md +1 -0
- package/directives/orchestration-claude.md +21 -0
- package/directives/orchestration-codex.md +22 -0
- package/dist/advanced-ruleset.py +67 -0
- package/dist/deadlock.js +8 -0
- package/dist/doctor.js +32 -0
- package/dist/effort.js +78 -0
- package/dist/hooks/orchestration-claude.js +88 -0
- package/dist/hooks/orchestration-codex.js +152 -0
- package/dist/index.js +908 -0
- package/dist/orchestration/hook-core.js +208 -0
- package/dist/orchestration/marker.js +139 -0
- package/dist/output-helpers.js +128 -0
- package/dist/platform.js +59 -0
- package/dist/routing-table.json +3821 -0
- package/dist/routing.js +260 -0
- package/dist/ruleset-scaffold.js +2 -0
- package/dist/ruleset.js +319 -0
- package/dist/setup.js +507 -0
- package/dist/status-helpers.js +56 -0
- package/dist/stream-helpers.js +182 -0
- package/dist/wait-helpers.js +21 -0
- package/package.json +51 -0
- package/scripts/postinstall.mjs +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined in Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or Object
|
|
36
|
+
form, made available under the License, as indicated by a copyright
|
|
37
|
+
notice that is included in or attached to the work (an example is
|
|
38
|
+
provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original Work and any Derivative Works thereof, and any modifications
|
|
50
|
+
and enhancements to those works or Derivative Works thereof, that is
|
|
51
|
+
intentionally submitted to Licensor for inclusion in the Work by the
|
|
52
|
+
copyright owner or by an individual or Legal Entity authorized to submit
|
|
53
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
54
|
+
"submitted" means any form of electronic, verbal, or written communication
|
|
55
|
+
sent to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
63
|
+
whom a Contribution has been received by Licensor and subsequently
|
|
64
|
+
incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file, then any
|
|
107
|
+
Derivative Works that You distribute must include a readable
|
|
108
|
+
copy of the attribution notices contained within such NOTICE
|
|
109
|
+
file, excluding those notices that do not pertain to any part
|
|
110
|
+
of the Derivative Works, in at least one of the following
|
|
111
|
+
places: within a NOTICE text file distributed as part of the
|
|
112
|
+
Derivative Works; within the Source form or documentation,
|
|
113
|
+
if provided along with the Derivative Works; or, within a
|
|
114
|
+
display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE from the Work, provided that
|
|
120
|
+
such additional attribution notices cannot be construed as
|
|
121
|
+
modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions of this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work by
|
|
132
|
+
You to Licensor shall be under the terms and conditions of this License,
|
|
133
|
+
without any additional terms or conditions. Notwithstanding the above,
|
|
134
|
+
nothing herein shall supersede or modify the terms of any separate
|
|
135
|
+
license agreement you may have executed with Licensor regarding such
|
|
136
|
+
Contribution.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file type. You may also add a brief
|
|
185
|
+
description of what the file does on the same "printed page" as
|
|
186
|
+
the copyright notice for easier identification within third-party
|
|
187
|
+
archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Lexi Blackburn
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +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.
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Reminder: <SUB-AGENT-INVARIANT> and <sanity-rules> apply. HALT if unknown.
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +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()
|
package/dist/deadlock.js
ADDED
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `subagent-mcp doctor` — read-only health check for the installed addon.
|
|
3
|
+
//
|
|
4
|
+
// Diagnoses without touching any file: install completeness, vendor presence,
|
|
5
|
+
// and whether each vendor's wiring (MCP server + hooks) points at THIS install.
|
|
6
|
+
// The fixer is always `subagent-mcp setup` (idempotent, self-repairing); doctor
|
|
7
|
+
// just tells you whether you need it and what exactly is wrong.
|
|
8
|
+
//
|
|
9
|
+
// Exit code: 0 = everything healthy, 1 = at least one check failed.
|
|
10
|
+
import { verifyWiring } from "./setup.js";
|
|
11
|
+
export async function runDoctor() {
|
|
12
|
+
console.log("subagent-mcp doctor (read-only — changes nothing)\n");
|
|
13
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
14
|
+
console.log(` ${major >= 18 ? "PASS" : "FAIL"} node version — ${process.versions.node}` +
|
|
15
|
+
(major >= 18 ? "" : " (Node >= 18 required)"));
|
|
16
|
+
let failed = major < 18 ? 1 : 0;
|
|
17
|
+
for (const r of verifyWiring()) {
|
|
18
|
+
console.log(` ${r.ok ? "PASS" : "FAIL"} ${r.label} — ${r.detail}`);
|
|
19
|
+
if (!r.ok)
|
|
20
|
+
failed++;
|
|
21
|
+
}
|
|
22
|
+
if (failed === 0) {
|
|
23
|
+
console.log("\nAll checks passed. If tools still don't appear in a session:\n" +
|
|
24
|
+
" - Claude Code: restart the session, run /mcp\n" +
|
|
25
|
+
" - Codex CLI: restart the session, run /hooks (the hook must be TRUSTED)");
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
console.log(`\n${failed} check(s) failed. Fix automatically with: subagent-mcp setup\n` +
|
|
29
|
+
"(setup is idempotent: it repairs stale paths and re-adds missing wiring,\n" +
|
|
30
|
+
" backing up each config file before its first edit.)");
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
package/dist/effort.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { writeFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { tmpdir } from "os";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
export function mapModel(provider, model) {
|
|
6
|
+
if (provider === "claude") {
|
|
7
|
+
if (model === "opus" || model === "opus-4-8")
|
|
8
|
+
return "claude-opus-4-8";
|
|
9
|
+
return model; // haiku, sonnet as-is
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return model; // gpt-5.5
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function resolveEffort(provider, model, effort) {
|
|
16
|
+
const isOpus48 = provider === "claude" && (model === "opus" || model === "opus-4-8");
|
|
17
|
+
if (effort === "ultracode") {
|
|
18
|
+
if (!isOpus48) {
|
|
19
|
+
throw new Error(`ultracode effort is only available on Opus 4.8+ (got ${provider}/${model}). Use xhigh for other models.`);
|
|
20
|
+
}
|
|
21
|
+
return { kind: "settings" };
|
|
22
|
+
}
|
|
23
|
+
if (provider === "claude" && model === "haiku") {
|
|
24
|
+
return { kind: "none" };
|
|
25
|
+
}
|
|
26
|
+
if (provider === "claude" && ["sonnet", "opus", "opus-4-8"].includes(model)) {
|
|
27
|
+
if (["low", "medium", "high", "xhigh", "max"].includes(effort)) {
|
|
28
|
+
return { kind: "flag", value: effort };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (provider === "codex") {
|
|
32
|
+
if (effort === "max") {
|
|
33
|
+
throw new Error(`max effort is not valid for gpt-5.5 (Codex). Valid: low, medium, high, xhigh.`);
|
|
34
|
+
}
|
|
35
|
+
if (["low", "medium", "high", "xhigh"].includes(effort)) {
|
|
36
|
+
return { kind: "flag", value: effort };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { kind: "flag", value: "high" };
|
|
40
|
+
}
|
|
41
|
+
export function buildCommand(provider, model, effort, prompt, cwd) {
|
|
42
|
+
const mapped = mapModel(provider, model);
|
|
43
|
+
const er = resolveEffort(provider, model, effort);
|
|
44
|
+
if (provider === "claude") {
|
|
45
|
+
const args = ["-p", "--model", mapped];
|
|
46
|
+
if (er.kind === "flag") {
|
|
47
|
+
args.push("--effort", er.value);
|
|
48
|
+
}
|
|
49
|
+
else if (er.kind === "settings") {
|
|
50
|
+
const ucSettingsPath = join(tmpdir(), `subagent-uc-${randomUUID()}.json`);
|
|
51
|
+
writeFileSync(ucSettingsPath, '{"ultracode":true}');
|
|
52
|
+
args.push("--settings", ucSettingsPath);
|
|
53
|
+
args.push("--permission-mode", "bypassPermissions", "--tools", "default", "--max-turns", "50", "--output-format", "stream-json", "--verbose");
|
|
54
|
+
return { args, ucSettingsPath };
|
|
55
|
+
}
|
|
56
|
+
args.push("--permission-mode", "bypassPermissions", "--tools", "default", "--max-turns", "50", "--output-format", "stream-json", "--verbose");
|
|
57
|
+
return { args };
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// codex
|
|
61
|
+
const effortValue = er.value;
|
|
62
|
+
return {
|
|
63
|
+
args: [
|
|
64
|
+
"exec",
|
|
65
|
+
"-C",
|
|
66
|
+
cwd,
|
|
67
|
+
"-m",
|
|
68
|
+
"gpt-5.5",
|
|
69
|
+
"-c",
|
|
70
|
+
`model_reasoning_effort="${effortValue}"`,
|
|
71
|
+
"--dangerously-bypass-approvals-and-sandbox",
|
|
72
|
+
"--skip-git-repo-check",
|
|
73
|
+
"--json",
|
|
74
|
+
prompt,
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|