@heretyc/subagent-mcp 2.12.12 → 2.12.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -170
- package/directives/carryover-claude.md +0 -2
- package/directives/carryover-codex.md +0 -2
- package/directives/handoff-claude.md +7 -0
- package/directives/handoff-codex.md +7 -0
- package/directives/latch-claude.md +5 -0
- package/directives/latch-codex.md +5 -0
- package/directives/orchestration-claude.md +0 -2
- package/directives/orchestration-codex.md +0 -2
- package/directives/reminder-off-claude.md +1 -3
- package/directives/reminder-off-codex.md +1 -3
- package/directives/reminder-on.md +0 -2
- package/directives/short-off.md +1 -1
- package/directives/short-on.md +1 -1
- package/directives/tag-template.md +2 -0
- package/dist/advanced-ruleset.py +67 -67
- package/dist/config-scaffold.js +1 -1
- package/dist/global-concurrency.jsonc +43 -43
- package/dist/global-subagent-mcp-config.jsonc +43 -43
- package/dist/hooks/orchestration-claude.js +86 -2
- package/dist/hooks/orchestration-codex.js +152 -3
- package/dist/index.js +76 -8
- package/dist/init.js +2 -2
- package/dist/orchestration/handoff.js +142 -0
- package/dist/orchestration/hook-core.js +184 -16
- package/dist/orchestration/latch.js +47 -0
- package/dist/orchestration/marker.js +55 -1
- package/dist/orchestration/metering.js +158 -0
- package/dist/orchestration/pretool.js +3 -3
- package/dist/orchestration/template.js +31 -0
- package/dist/routing-table.json +2133 -2133
- package/dist/ruleset-scaffold.js +1 -1
- package/package.json +70 -70
- package/scripts/postinstall.mjs +102 -102
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const TAG_TEMPLATE = '<subagent-mcp state="{{state}}" kind="{{kind}}" phase="{{phase}}" utilization="{{utilization}}">';
|
|
2
|
+
export const FOOTER_TEMPLATE = "Remaining Context={{remaining}}%";
|
|
3
|
+
const PLACEHOLDER = /\{\{([a-zA-Z0-9_]+)\}\}/g;
|
|
4
|
+
const UNRESOLVED_PLACEHOLDER = /\{\{[a-zA-Z0-9_]+\}\}/;
|
|
5
|
+
export function renderTemplate(template, vars) {
|
|
6
|
+
const rendered = template.replace(PLACEHOLDER, (token, name) => {
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(vars, name)) {
|
|
8
|
+
throw new Error(`Missing template variable: ${name}`);
|
|
9
|
+
}
|
|
10
|
+
return vars[name] ?? "";
|
|
11
|
+
});
|
|
12
|
+
if (UNRESOLVED_PLACEHOLDER.test(rendered)) {
|
|
13
|
+
throw new Error("Rendered template contains unresolved placeholder");
|
|
14
|
+
}
|
|
15
|
+
return rendered;
|
|
16
|
+
}
|
|
17
|
+
export function composeTag(vars) {
|
|
18
|
+
// Test-only seam: SUBAGENT_MCP_TEST_TAG_TEMPLATE overrides the tag template so a malformed value forces a throw (mission item 5 fail-safe: any template error => inject nothing). Unset in production.
|
|
19
|
+
const template = process.env.SUBAGENT_MCP_TEST_TAG_TEMPLATE ?? TAG_TEMPLATE;
|
|
20
|
+
return renderTemplate(template, vars);
|
|
21
|
+
}
|
|
22
|
+
export function composeFooter(remainingPct) {
|
|
23
|
+
if (remainingPct === null)
|
|
24
|
+
return "";
|
|
25
|
+
if (!Number.isFinite(remainingPct)) {
|
|
26
|
+
throw new Error("Invalid remaining context percentage");
|
|
27
|
+
}
|
|
28
|
+
return renderTemplate(FOOTER_TEMPLATE, {
|
|
29
|
+
remaining: String(Math.round(remainingPct)),
|
|
30
|
+
});
|
|
31
|
+
}
|