heimdall-agent 1.1.0 → 1.4.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.
Files changed (60) hide show
  1. package/README.md +101 -31
  2. package/README.pt-BR.md +124 -40
  3. package/agents/code-sentinel.md +7 -1
  4. package/agents/frontend-designer.md +6 -1
  5. package/agents/modernizer.md +8 -3
  6. package/agents/orchestrator.md +22 -8
  7. package/agents/reviewer.md +3 -1
  8. package/config/agents.json +177 -5
  9. package/config/mcp.json +1 -1
  10. package/config/mcp.resolved.json +74 -0
  11. package/config/mcp.template.json +85 -0
  12. package/config/models.json +70 -0
  13. package/config/profiles.json +4 -3
  14. package/config/skills.json +321 -93
  15. package/docs/SKILLS.md +158 -75
  16. package/docs/designs/old/2026-11-16 upstream-skill-sync-and-provenance-links.md +60 -0
  17. package/docs/runs/skill-audit/2026-11-12-compare-report.json +1028 -0
  18. package/docs/runs/skill-audit/2026-11-12-upstream-audit.json +275 -0
  19. package/doctrine/AGENTS.md +7 -4
  20. package/hooks/heimdall-hook.cjs +16 -1
  21. package/hooks/hooks.json +11 -0
  22. package/lib/catalog-sync.cjs +8 -3
  23. package/lib/model-context.cjs +50 -1
  24. package/lib/model-router.cjs +294 -0
  25. package/package.json +1 -1
  26. package/playbooks/01-interactive-grilling-gate.md +14 -10
  27. package/playbooks/03-adversarial-code-review.md +12 -4
  28. package/playbooks/05-canonical-plan-template.md +8 -13
  29. package/playbooks/06-model-registry-matrix.md +27 -19
  30. package/readme.html +1006 -0
  31. package/setup.mjs +317 -206
  32. package/skills/antislop-copywriting/SKILL.md +36 -1
  33. package/skills/brainstorming/SKILL.md +60 -38
  34. package/skills/codebase-design/DEEPENING.md +37 -0
  35. package/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  36. package/skills/codebase-design/SKILL.md +114 -0
  37. package/skills/communication-doctrine/SKILL.md +2 -2
  38. package/skills/domain-modeling/ADR-FORMAT.md +47 -0
  39. package/skills/domain-modeling/GLOSSARY-FORMAT.md +60 -0
  40. package/skills/domain-modeling/SKILL.md +74 -0
  41. package/skills/executing-plans/SKILL.md +6 -4
  42. package/skills/grill-me/SKILL.md +65 -0
  43. package/skills/handoff/SKILL.md +77 -0
  44. package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  45. package/skills/improve-codebase-architecture/SKILL.md +71 -0
  46. package/skills/mcp-cleanup/SKILL.md +61 -0
  47. package/skills/mcp-sync/SKILL.md +58 -0
  48. package/skills/modern-web-guidance/SKILL.md +90 -0
  49. package/skills/owasp-security/reference/config-and-supply-chain.md +346 -344
  50. package/skills/owasp-security/reference/languages.md +378 -372
  51. package/skills/owasp-security/reference/owasp-report.md +1144 -1140
  52. package/skills/owasp-security/reference/review-checklist.md +134 -132
  53. package/skills/ruminate/SKILL.md +140 -0
  54. package/skills/subagent-driven-development/SKILL.md +7 -4
  55. package/skills/taste-skill/SKILL.md +367 -534
  56. package/skills/to-spec/SKILL.md +75 -0
  57. package/skills/to-tickets/SKILL.md +105 -0
  58. package/skills/upstream-skill-sync/SKILL.md +46 -0
  59. package/skills/wayfinder/SKILL.md +128 -0
  60. package/skills/writing-plans/SKILL.md +1 -1
@@ -0,0 +1,275 @@
1
+ [
2
+ {
3
+ "upstream": "https://github.com/miqdadbadjuber/anti-slop",
4
+ "skills": [
5
+ "antislop",
6
+ "antislop-code",
7
+ "antislop-copywriting",
8
+ "antislop-human",
9
+ "antislop-layoutmobile",
10
+ "antislop-ui"
11
+ ],
12
+ "current": [
13
+ "941b153"
14
+ ],
15
+ "latest": "4520786d3dff09eb295a2c563c7fab50063f00fb",
16
+ "status": "NEEDS_AUDIT",
17
+ "message": "Remote HEAD: 4520786d3d"
18
+ },
19
+ {
20
+ "upstream": "https://github.com/obra/superpowers",
21
+ "skills": [
22
+ "brainstorming",
23
+ "diagnosing-superpowers",
24
+ "dispatching-parallel-agents",
25
+ "executing-plans",
26
+ "finishing-a-development-branch",
27
+ "receiving-code-review",
28
+ "requesting-code-review",
29
+ "subagent-driven-development",
30
+ "systematic-debugging",
31
+ "test-driven-development",
32
+ "using-git-worktrees",
33
+ "using-superpowers",
34
+ "verification-before-completion",
35
+ "writing-plans",
36
+ "writing-skills"
37
+ ],
38
+ "current": [
39
+ "2ce8aa1"
40
+ ],
41
+ "latest": "22f0b463e7a5e579904dd6211a520321035526f7",
42
+ "status": "NEEDS_AUDIT",
43
+ "message": "Remote HEAD: 22f0b463e7"
44
+ },
45
+ {
46
+ "upstream": "https://github.com/Leonxlnx/taste-skill",
47
+ "skills": [
48
+ "brandkit",
49
+ "image-to-code-skill",
50
+ "imagegen-frontend-mobile",
51
+ "imagegen-frontend-web",
52
+ "output-skill",
53
+ "taste-skill"
54
+ ],
55
+ "current": [
56
+ "12af471"
57
+ ],
58
+ "latest": "f6b76575f949707b4e3c37cd86cb44b0b98643e8",
59
+ "status": "NEEDS_AUDIT",
60
+ "message": "Remote HEAD: f6b76575f9"
61
+ },
62
+ {
63
+ "upstream": "https://github.com/Leonxlnx/taste-skill-classics",
64
+ "skills": [
65
+ "brutalist-skill",
66
+ "minimalist-skill",
67
+ "redesign-skill",
68
+ "soft-skill",
69
+ "stitch-skill"
70
+ ],
71
+ "current": [
72
+ "5e08c93"
73
+ ],
74
+ "latest": "5e08c9383dc4ad7fc0df70e1ac8cfa09ec356305",
75
+ "status": "UP_TO_DATE",
76
+ "message": "Remote HEAD: 5e08c9383d"
77
+ },
78
+ {
79
+ "upstream": "https://github.com/JuliusBrussee/caveman",
80
+ "skills": [
81
+ "caveman"
82
+ ],
83
+ "current": [
84
+ "2e068f7"
85
+ ],
86
+ "latest": "3dc497a7f858c774d6e15b25e8c6120ef3a0eda8",
87
+ "status": "NEEDS_AUDIT",
88
+ "message": "Remote HEAD: 3dc497a7f8"
89
+ },
90
+ {
91
+ "upstream": "https://github.com/bepaldes/heimdall-agent",
92
+ "skills": [
93
+ "claude-collaborator",
94
+ "gemini-collaborator",
95
+ "project-hygiene",
96
+ "codex-collaborator",
97
+ "progressive-disclosure",
98
+ "communication-doctrine",
99
+ "threat-modeling",
100
+ "mcp-engineering"
101
+ ],
102
+ "current": [
103
+ "v1.0.0"
104
+ ],
105
+ "latest": "first-party (local)",
106
+ "status": "UP_TO_DATE",
107
+ "message": "Local first-party skill"
108
+ },
109
+ {
110
+ "upstream": "https://github.com/cloudflare/security-audit-skill",
111
+ "skills": [
112
+ "cloudflare-security-audit"
113
+ ],
114
+ "current": [
115
+ "c1c8a8c"
116
+ ],
117
+ "latest": "c1c8a8c1471069fb0e188eeaff69b8e8db6564a8",
118
+ "status": "UP_TO_DATE",
119
+ "message": "Remote HEAD: c1c8a8c147"
120
+ },
121
+ {
122
+ "upstream": "https://github.com/multica-ai/andrej-karpathy-skills",
123
+ "skills": [
124
+ "karpathy-guidelines"
125
+ ],
126
+ "current": [
127
+ "2c60614"
128
+ ],
129
+ "latest": "2c606141936f1eeef17fa3043a72095b4765b9c2",
130
+ "status": "UP_TO_DATE",
131
+ "message": "Remote HEAD: 2c60614193"
132
+ },
133
+ {
134
+ "upstream": "https://github.com/agamm/claude-code-owasp",
135
+ "skills": [
136
+ "owasp-security"
137
+ ],
138
+ "current": [
139
+ "8ac7965"
140
+ ],
141
+ "latest": "1ae29cb22518560e3625d77f2ae64f61647d9201",
142
+ "status": "NEEDS_AUDIT",
143
+ "message": "Remote HEAD: 1ae29cb225"
144
+ },
145
+ {
146
+ "upstream": "https://github.com/DietrichGebert/ponytail",
147
+ "skills": [
148
+ "ponytail"
149
+ ],
150
+ "current": [
151
+ "96608e0"
152
+ ],
153
+ "latest": "96608e078b2d5ea607c5c3b8b5a54d1c1fba6846",
154
+ "status": "UP_TO_DATE",
155
+ "message": "Remote HEAD: 96608e078b"
156
+ },
157
+ {
158
+ "upstream": "https://github.com/neondatabase/postgres-skills",
159
+ "skills": [
160
+ "postgres-best-practices"
161
+ ],
162
+ "current": [
163
+ "27fe45e"
164
+ ],
165
+ "latest": "27fe45e0f71ea89a6eaf9ea4d2e4068957c81c26",
166
+ "status": "UP_TO_DATE",
167
+ "message": "Remote HEAD: 27fe45e0f7"
168
+ },
169
+ {
170
+ "upstream": "https://github.com/blencorp/security-sweep",
171
+ "skills": [
172
+ "security-audit-sweep"
173
+ ],
174
+ "current": [
175
+ "v1.0.0"
176
+ ],
177
+ "latest": "75526136b29d55083ce58bd37cec13eb076c9cb7",
178
+ "status": "NEEDS_AUDIT",
179
+ "message": "Remote HEAD: 75526136b2"
180
+ },
181
+ {
182
+ "upstream": "https://github.com/snyk/agent-scan",
183
+ "skills": [
184
+ "snyk-agent-scan"
185
+ ],
186
+ "current": [
187
+ "a69e1c3"
188
+ ],
189
+ "latest": "59def8c624f9d7bef4d49992a4da5e68f83f4e75",
190
+ "status": "NEEDS_AUDIT",
191
+ "message": "Remote HEAD: 59def8c624"
192
+ },
193
+ {
194
+ "upstream": "https://github.com/usestrix/strix",
195
+ "skills": [
196
+ "strix-security"
197
+ ],
198
+ "current": [
199
+ "6b7ae2e"
200
+ ],
201
+ "latest": "01119158f8f50027591cbae73f37cf0a2fea644d",
202
+ "status": "NEEDS_AUDIT",
203
+ "message": "Remote HEAD: 01119158f8"
204
+ },
205
+ {
206
+ "upstream": "https://github.com/trailofbits/skills",
207
+ "skills": [
208
+ "trailofbits-audit-context",
209
+ "trailofbits-insecure-defaults",
210
+ "trailofbits-triage-brocards"
211
+ ],
212
+ "current": [
213
+ "2be6433"
214
+ ],
215
+ "latest": "e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff",
216
+ "status": "NEEDS_AUDIT",
217
+ "message": "Remote HEAD: e4dd0bb5b1"
218
+ },
219
+ {
220
+ "upstream": "https://github.com/unclebob/ub-mode",
221
+ "skills": [
222
+ "clean-code"
223
+ ],
224
+ "current": [
225
+ "57a8bdd"
226
+ ],
227
+ "latest": "3da62bf3fcfd2034de41f30d920d2739e566171f",
228
+ "status": "NEEDS_AUDIT",
229
+ "message": "Remote HEAD: 3da62bf3fc"
230
+ },
231
+ {
232
+ "upstream": "https://herdr.dev",
233
+ "skills": [
234
+ "herdr"
235
+ ],
236
+ "current": [
237
+ "v0.1.0"
238
+ ],
239
+ "latest": "UNKNOWN",
240
+ "status": "ERROR",
241
+ "message": "fatal: https://herdr.dev/info/refs not valid: is this a git repository?"
242
+ },
243
+ {
244
+ "upstream": "https://github.com/cursor/plugins",
245
+ "skills": [
246
+ "thermo",
247
+ "pstack-discipline"
248
+ ],
249
+ "current": [
250
+ "main"
251
+ ],
252
+ "latest": "a5539b15a3d56e04992565aafee2b37051329ce3",
253
+ "status": "NEEDS_AUDIT",
254
+ "message": "Remote HEAD: a5539b15a3"
255
+ },
256
+ {
257
+ "upstream": "https://github.com/mattpocock/skills",
258
+ "skills": [
259
+ "codebase-design",
260
+ "domain-modeling",
261
+ "improve-codebase-architecture",
262
+ "to-spec",
263
+ "to-tickets",
264
+ "wayfinder",
265
+ "grill-me",
266
+ "handoff"
267
+ ],
268
+ "current": [
269
+ "main"
270
+ ],
271
+ "latest": "5863806dd4e15c63174bee4e7515a4256792ecfa",
272
+ "status": "NEEDS_AUDIT",
273
+ "message": "Remote HEAD: 5863806dd4"
274
+ }
275
+ ]
@@ -22,21 +22,24 @@ Universal directives for Google Antigravity, Claude Code, and OpenAI Codex CLI a
22
22
  1. Persona: Identity, core expertise, and voice traits.
23
23
  2. Chronological Rules: Ordered lifecycle steps from initialization to handoff.
24
24
  3. Unmistakable Guardrails: Explicit negative constraints and non-negotiable "If X, do Y" boundaries.
25
- - CANONICAL MODEL NAMES: Anthropic models are strictly 'claude-opus-5-5' (Opus 5.5) and 'claude-sonnet-5' (Sonnet 5). There is NO 'sonnet-5-5' or 'sonnet 5.5' (hallucination trap). Never emit, invoke, or allocate 'claude-sonnet-5-5'.
26
- - COMMUNICATION DISCIPLINE (BLUF & STE): Communication must prioritize zero-latency triage and testable clarity (skills/communication-doctrine). All status reports, review verdicts, and plan overviews must lead with Bottom Line Up Front (BLUF). All procedural execution steps must follow Simplified Technical English (STE): active imperative verbs, <= 20 words per step, zero banned vague qualifiers ('ensure', 'properly', 'appropriately', 'as needed').
25
+ - DYNAMIC MODEL REGISTRY: Resolve authorized model IDs, context limits, and specializations dynamically from `config/models.json` and `playbooks/06-model-registry-matrix.md` (refreshed via `heimdall sync` / `heimdall sync-models`). Never invent unlisted model IDs; route tasks by capability tier across any live registered model family (Anthropic, Google, OpenAI, Zhipu/GLM, Tencent/Hunyuan, Xiaomi/MiMo, etc.).
26
+ - COMMUNICATION DISCIPLINE (BLUF & STE): Apply `skills/communication-doctrine` on EVERY response, status report, review verdict, and plan. Lead with Bottom Line Up Front (BLUF) in the first 1-2 sentences. Write all procedural execution steps in ASD-STE100 Simplified Technical English (STE): active imperative verbs, <= 20 words per step, zero banned vague qualifiers ('ensure', 'properly', 'appropriately', 'gracefully', 'as needed', 'etc.').
27
27
  </core_discipline>
28
28
 
29
29
  <planning_protocol>
30
30
  When receiving an EXPLICIT planning or interview command (/plan or /grill-me):
31
31
  1. TURN 1 INTERACTIVE GRILLING:
32
- - Interrogate assumptions: Ask 2-3 probing questions on limits, failure modes, and edge cases.
32
+ - Autonomous fact-finding first: inspect the codebase; never ask questions the files answer.
33
+ - Focus strictly on the active decision frontier (unsettled decisions whose prerequisites are met).
34
+ - Ask 2-3 probing questions in the "Yes-to-Approve" format (❓ Question + ➡️ Recommended answer).
33
35
  - Propose 2 distinct concrete approaches with explicit architectural trade-offs.
36
+ - For architectural scope, record settled choices in ADRs (`docs/adr/`).
34
37
  - Render Scope, Questions, and Alternatives clearly in chat markdown, then pause for user approval.
35
38
  2. TURN 2+ MULTI-MODEL PLAN GENERATION:
36
39
  - Generate an authoritative plan strictly following `05-canonical-plan-template.md` (resolved via `playbooks/`, `../playbooks/`, or `../heimdall-agent/playbooks/`).
37
40
  - PLAN STORAGE & LIFECYCLE: All plans MUST be created in `docs/designs/YYYY-MM-DD <plan name>.md`. Once implemented, verified, and confirmed working, the plan is moved to `docs/designs/old/YYYY-MM-DD <plan name>.md`.
38
41
  - The plan MUST specify:
39
- a) Multi-Agent Orchestration & Model Allocation Matrix (allocating tasks across Claude, Gemini, and Codex from `06-model-registry-matrix.md` in the same playbooks directory).
42
+ a) Multi-Agent Orchestration & Model Allocation Matrix (allocating tasks by capability tier across available model families in `06-model-registry-matrix.md` / `config/models.json` — including Claude, Gemini, Codex/GPT, GLM, Hunyuan, MiMo, and newly synced GhostCLI models).
40
43
  b) Symmetric Cross-Model Validation Loop (`herdr agent prompt`) and Non-Interactive Verification Harness.
41
44
  c) Orchestrator Heartbeat (cadence for monitoring task progress and liveness).
42
45
  d) Verification Harness (Non-interactive terminating test suites, static builds, and linters. Playwright E2E strictly against pre-existing human-managed servers or static build previews. NEVER include steps to start a dev server).
@@ -10,6 +10,7 @@ const { execSync } = require('child_process');
10
10
  const os = require('os');
11
11
  const fs = require('fs');
12
12
  const path = require('path');
13
+ const { lookupModelContextFromCatalog } = require('../lib/model-context.cjs');
13
14
 
14
15
  const MAX_STDIN = 1024 * 1024; // 1 MiB
15
16
 
@@ -47,6 +48,15 @@ function getActiveContextLimit() {
47
48
  const parsed = parseInt(process.env.HEIMDALL_ACTIVE_CONTEXT_LIMIT, 10);
48
49
  if (parsed > 0) return parsed;
49
50
  }
51
+ const activeModel =
52
+ process.env.HEIMDALL_ACTIVE_MODEL ||
53
+ process.env.ANTHROPIC_MODEL ||
54
+ process.env.OPENAI_MODEL ||
55
+ process.env.GEMINI_MODEL;
56
+ if (activeModel) {
57
+ const resolved = lookupModelContextFromCatalog(activeModel, path.join(__dirname, '..'));
58
+ if (resolved && resolved.tokens > 0) return resolved.tokens;
59
+ }
50
60
  return 1000000; // 1M default maximum
51
61
  }
52
62
 
@@ -211,9 +221,14 @@ async function main() {
211
221
  break;
212
222
  }
213
223
 
224
+ case 'user-prompt': {
225
+ process.stdout.write('[Heimdall Communication Doctrine] Lead with BLUF (conclusion in first 1-2 sentences). Use ASD-STE100 for procedural steps: active imperative verb first, <=20 words/step, zero banned words (ensure, properly, appropriately, gracefully, as needed, etc.).\n');
226
+ break;
227
+ }
228
+
214
229
  case 'pre-compact': {
215
230
  clearSessionState();
216
- process.stderr.write('[Heimdall Lifecycle Sentinel] Context compaction occurring. Ensure active tasks, rulings, and pending ledger items are preserved on disk.\n');
231
+ process.stderr.write('[Heimdall Lifecycle Sentinel] Context compaction occurring. Verify active tasks, rulings, and pending ledger items are preserved on disk.\n');
217
232
  break;
218
233
  }
219
234
 
package/hooks/hooks.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "description": "Heimdall Sentinel Lifecycle Hooks for Claude Code and AI Harnesses",
3
3
  "hooks": {
4
+ "UserPromptSubmit": [
5
+ {
6
+ "matcher": ".*",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "node \"{{HOOKS_DIR}}/heimdall-hook.cjs\" user-prompt"
11
+ }
12
+ ]
13
+ }
14
+ ],
4
15
  "PreToolUse": [
5
16
  {
6
17
  "matcher": "Bash|PowerShell",
@@ -23,7 +23,10 @@ function syncCatalogCounts(rootDir, dryRun = false) {
23
23
  const catalog = JSON.parse(rawCatalog);
24
24
  const skillCount = Object.keys(catalog.skills || {}).length;
25
25
  const suiteCount = Object.keys(catalog.suites || {}).length;
26
- const standaloneCount = suiteCount - 5; // 5 Core Suites + remainder Standalone
26
+ const multiSuites = Object.values(catalog.suites || {}).filter(s => s.type === 'Multi-Skill Suite');
27
+ const multiSuiteCount = multiSuites.length;
28
+ const multiModuleCount = multiSuites.reduce((acc, s) => acc + (s.modules ? s.modules.length : 1), 0);
29
+ const standaloneCount = suiteCount - multiSuiteCount;
27
30
  const agentsDir = path.join(rootDir, 'agents');
28
31
  const agentCount = fs.existsSync(agentsDir)
29
32
  ? fs.readdirSync(agentsDir).filter(f => f.endsWith('.md')).length
@@ -94,7 +97,8 @@ function syncCatalogCounts(rootDir, dryRun = false) {
94
97
  content = content.replace(/synchronizes \*\*\d+ specialized agent personas\*\*/g, `synchronizes **${agentCount} specialized agent personas**`);
95
98
  content = content.replace(/\* \*\*Specialized Agent Personas\*\*:\s*\d+\s*predefined roles/g, `* **Specialized Agent Personas**: ${agentCount} predefined roles`);
96
99
  content = content.replace(/(\|\s*`agents\/`\s*\|\s*`~\/\.<tool>\/agents\/`\s*\|\s*)\d+(\s*specialized agent persona)/g, `$1${agentCount}$2`);
97
- content = content.replace(/(Heimdall organizes capabilities into \*\*5 Core Multi-Skill Suites \(37 modules\)\*\* and \*\*)\d+(\s*Standalone Toolkits \()\d+(\s*modules\)\*\*)/g, `$1${standaloneCount}$2${standaloneCount}$3`);
100
+ content = content.replace(/(Heimdall organizes capabilities into \*\*)\d+(\s*Core Multi-Skill Suites \()\d+(\s*modules\)\*\* and \*\*)\d+(\s*Standalone Toolkits \()\d+(\s*modules\)\*\*)/g, `$1${multiSuiteCount}$2${multiModuleCount}$3${standaloneCount}$4${standaloneCount}$5`);
101
+ content = content.replace(/(#### Core Multi-Skill Suites \()\d+(\s*Suites \/ \s*)\d+(\s*Modules\))/g, `$1${multiSuiteCount}$2${multiModuleCount}$3`);
98
102
  content = content.replace(/(#### Standalone Toolkits \()\d+(\s*Curated Toolkits \/ \s*)\d+(\s*Modules\))/g, `$1${standaloneCount}$2${standaloneCount}$3`);
99
103
 
100
104
  if (content !== orig) {
@@ -126,7 +130,8 @@ function syncCatalogCounts(rootDir, dryRun = false) {
126
130
  content = content.replace(/sincroniza \*\*\d+ personas de agentes especializados\*\*/g, `sincroniza **${agentCount} personas de agentes especializados**`);
127
131
  content = content.replace(/\* \*\*Personas de Agentes Especializados\*\*:\s*\d+\s*papéis predefinidos/g, `* **Personas de Agentes Especializados**: ${agentCount} papéis predefinidos`);
128
132
  content = content.replace(/(\|\s*`agents\/`\s*\|\s*`~\/\.<ferramenta>\/agents\/`\s*\|\s*)\d+(\s*definições de personas)/g, `$1${agentCount}$2`);
129
- content = content.replace(/(O Heimdall organiza as capacidades em \*\*5 Suítes Multi-Skill Principais \(37 módulos\)\*\* e \*\*)\d+(\s*Toolkits Independentes \()\d+(\s*módulos\)\*\*)/g, `$1${standaloneCount}$2${standaloneCount}$3`);
133
+ content = content.replace(/(O Heimdall organiza as capacidades em \*\*)\d+(\s*Suítes Multi-Skill Principais \()\d+(\s*módulos\)\*\* e \*\*)\d+(\s*Toolkits Independentes \()\d+(\s*módulos\)\*\*)/g, `$1${multiSuiteCount}$2${multiModuleCount}$3${standaloneCount}$4${standaloneCount}$5`);
134
+ content = content.replace(/(#### Suítes Multi-Skill Principais \()\d+(\s*Suítes \/ \s*)\d+(\s*Módulos\))/g, `$1${multiSuiteCount}$2${multiModuleCount}$3`);
130
135
  content = content.replace(/(#### Toolkits Independentes \()\d+(\s*Toolkits Curados \/ \s*)\d+(\s*Módulos\))/g, `$1${standaloneCount}$2${standaloneCount}$3`);
131
136
 
132
137
  if (content !== orig) {
@@ -1,5 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+
3
6
  /**
4
7
  * Authoritative Canonical Context Mappings (Max Capacity)
5
8
  * Derived from playbooks/06-model-registry-matrix.md
@@ -15,9 +18,19 @@ const CANONICAL_MODEL_CONTEXTS = {
15
18
  // GhostCLI / Custom Proxies (Max extended capacity)
16
19
  'claude-opus-5-5': 1000000,
17
20
  'claude-sonnet-5': 1000000,
21
+ 'claude-sonnet-5-5': 1000000,
18
22
  'claude-fable-5.1': 1000000,
23
+ 'claude-fable-5.2': 1000000,
19
24
  'z-ai/glm-5.3': 1000000,
20
25
  'glm-5.3': 1000000,
26
+ 'z-ai/glm-5.3-flash': 1000000,
27
+ 'glm-5.3-flash': 1000000,
28
+ 'tencent/Hy4-preview': 1000000,
29
+ 'tencent/hy4-preview': 1000000,
30
+ 'hy4-preview': 1000000,
31
+ 'XiaomiMiMo/MiMo-V2.6-Pro': 1000000,
32
+ 'xiaomimimo/mimo-v2.6-pro': 1000000,
33
+ 'mimo-v2.6-pro': 1000000,
21
34
  'gpt-6-astra': 1000000,
22
35
  'astra': 1000000
23
36
  };
@@ -115,9 +128,45 @@ function resolveCustomModelsEndpoint(endpoints = {}) {
115
128
  return null;
116
129
  }
117
130
 
131
+ /**
132
+ * Looks up a model's maximum context window from config/models.json first,
133
+ * falling back to CANONICAL_MODEL_CONTEXTS and the safe 128K default.
134
+ */
135
+ function lookupModelContextFromCatalog(modelId, rootDir) {
136
+ if (!modelId || typeof modelId !== 'string') {
137
+ return normalizeContextTokens(131072);
138
+ }
139
+ const cleanId = modelId.toLowerCase().trim().replace(/\[1m\]$/i, '');
140
+ const shortId = cleanId.split('/').pop();
141
+
142
+ if (rootDir) {
143
+ try {
144
+ const modelsPath = path.join(rootDir, 'config', 'models.json');
145
+ if (fs.existsSync(modelsPath)) {
146
+ const catalog = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
147
+ const all = [
148
+ ...(catalog.google || []),
149
+ ...(catalog.ghostcli || []),
150
+ ...(catalog.custom_proxies || [])
151
+ ];
152
+ const match = all.find(m => {
153
+ const mId = (m.id || '').toLowerCase().trim();
154
+ return mId === cleanId || mId.split('/').pop() === shortId;
155
+ });
156
+ if (match) {
157
+ return resolveModelMaxContext(match, { prioritizeMax: true });
158
+ }
159
+ }
160
+ } catch {}
161
+ }
162
+
163
+ return resolveModelMaxContext(cleanId, { prioritizeMax: true });
164
+ }
165
+
118
166
  module.exports = {
119
167
  CANONICAL_MODEL_CONTEXTS,
120
168
  normalizeContextTokens,
121
169
  resolveModelMaxContext,
122
- resolveCustomModelsEndpoint
170
+ resolveCustomModelsEndpoint,
171
+ lookupModelContextFromCatalog
123
172
  };