heimdall-agent 1.2.0 → 1.5.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/README.md +108 -30
- package/README.pt-BR.md +109 -31
- package/agents/frontend-designer.md +6 -1
- package/agents/modernizer.md +4 -1
- package/agents/orchestrator.md +2 -1
- package/agents/reviewer.md +1 -1
- package/config/agents.json +166 -4
- package/config/mcp.resolved.json +74 -0
- package/config/mcp.template.json +85 -0
- package/config/models.json +70 -0
- package/config/profiles.json +4 -3
- package/config/skills.json +911 -762
- package/docs/SKILLS.md +82 -21
- package/docs/designs/old/2026-11-16 upstream-skill-sync-and-provenance-links.md +60 -0
- package/doctrine/AGENTS.md +3 -3
- package/hooks/heimdall-hook.cjs +16 -1
- package/hooks/hooks.json +11 -0
- package/lib/hud-sync.cjs +187 -0
- package/lib/model-context.cjs +50 -1
- package/lib/model-router.cjs +294 -0
- package/package.json +1 -1
- package/playbooks/05-canonical-plan-template.md +5 -12
- package/playbooks/06-model-registry-matrix.md +27 -19
- package/readme.html +1006 -0
- package/setup.mjs +583 -220
- package/skills/communication-doctrine/SKILL.md +2 -2
- package/skills/handoff/SKILL.md +13 -0
- package/skills/mcp-cleanup/SKILL.md +61 -0
- package/skills/mcp-sync/SKILL.md +58 -0
- package/skills/modern-web-guidance/SKILL.md +90 -0
- package/skills/ruminate/SKILL.md +140 -0
- package/skills/taste-skill/SKILL.md +367 -534
- package/skills/upstream-skill-sync/SKILL.md +46 -0
- package/skills/writing-plans/SKILL.md +1 -1
- package/tools/heimdall-hud.mjs +283 -0
package/docs/SKILLS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Heimdall Canonical Skills & Suites Directory
|
|
2
2
|
|
|
3
|
-
This directory serves as the
|
|
3
|
+
This directory serves as the reference manual for Heimdall's **30 Primary Toolkits & Suites (69 modular capabilities)**.
|
|
4
4
|
|
|
5
5
|
> **Architecture & Execution**: Each skill module is an isolated directory containing a YAML-frontmattered `SKILL.md`. AI agent harnesses (Google Antigravity, Claude Code, OpenAI Codex CLI) parse frontmatter on startup and dynamically activate instructions via progressive disclosure.
|
|
6
6
|
|
|
@@ -46,6 +46,10 @@ heimdall update-skill all
|
|
|
46
46
|
- [⚡ Herdr Coding Agent Multiplexer & Orchestrator](#herdr)
|
|
47
47
|
- [⚡ Thermo Architectural & Maintainability Audit](#thermo)
|
|
48
48
|
- [⚡ PStack Engineering Discipline](#pstack-discipline)
|
|
49
|
+
- [⚡ Google Chrome Modern Web Guidance](#modern-web-guidance)
|
|
50
|
+
- [⚡ MCP Orphan Process Cleanup](#mcp-cleanup)
|
|
51
|
+
- [⚡ MCP Template Resolver & Sync](#mcp-sync)
|
|
52
|
+
- [⚡ Upstream Skill Sync & Triage](#upstream-skill-sync)
|
|
49
53
|
|
|
50
54
|
---
|
|
51
55
|
|
|
@@ -68,7 +72,7 @@ heimdall update-skill all
|
|
|
68
72
|
* **`systematic-debugging`**: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes ([Contract File](../skills/systematic-debugging/SKILL.md))
|
|
69
73
|
* **`verification-before-completion`**: Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always ([Contract File](../skills/verification-before-completion/SKILL.md))
|
|
70
74
|
* **`finishing-a-development-branch`**: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work ([Contract File](../skills/finishing-a-development-branch/SKILL.md))
|
|
71
|
-
* **`using-git-worktrees`**: Use when starting feature work that needs isolation from current workspace or before executing implementation plans -
|
|
75
|
+
* **`using-git-worktrees`**: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - verifies or creates an isolated workspace via native tools or git worktree fallback ([Contract File](../skills/using-git-worktrees/SKILL.md))
|
|
72
76
|
* **`requesting-code-review`**: Use when completing tasks, implementing major features, or before merging to verify work meets requirements ([Contract File](../skills/requesting-code-review/SKILL.md))
|
|
73
77
|
* **`receiving-code-review`**: Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation ([Contract File](../skills/receiving-code-review/SKILL.md))
|
|
74
78
|
* **`using-superpowers`**: Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions ([Contract File](../skills/using-superpowers/SKILL.md))
|
|
@@ -155,25 +159,25 @@ heimdall update-skill all
|
|
|
155
159
|
|
|
156
160
|
## Standalone Power Toolkits
|
|
157
161
|
|
|
158
|
-
<a id="mattpocock-suite"></a>
|
|
159
|
-
### 📦 Matt Pocock Real Engineering Suite (8 modules)
|
|
160
|
-
|
|
161
|
-
- **Upstream Source**: [https://github.com/mattpocock/skills](https://github.com/mattpocock/skills)
|
|
162
|
-
- **Suite Type**: Multi-Skill Suite
|
|
163
|
-
|
|
164
|
-
#### Included Modules:
|
|
165
|
-
|
|
166
|
-
* **`codebase-design`**: Design deep modules (small interfaces hiding large implementations), apply the deletion test, and enforce legitimate seams based on John Ousterhout's *Philosophy of Software Design*. ([Contract File](../skills/codebase-design/SKILL.md))
|
|
167
|
-
* **`domain-modeling`**: Extract ubiquitous language, domain models, and record Architecture Decision Records (ADRs) to eliminate terminology drift and document architectural choices. ([Contract File](../skills/domain-modeling/SKILL.md))
|
|
168
|
-
* **`improve-codebase-architecture`**: Audit codebase structure, detect circular dependencies, evaluate module coupling, and generate dependency matrix reports. ([Contract File](../skills/improve-codebase-architecture/SKILL.md))
|
|
169
|
-
* **`to-spec`**: Formalize requirements and interview outcomes into precise specifications with invariants, error matrices, and user journeys. ([Contract File](../skills/to-spec/SKILL.md))
|
|
170
|
-
* **`to-tickets`**: Decompose formal specifications into atomic, dependency-ordered task tickets formatted for subagent task queues. ([Contract File](../skills/to-tickets/SKILL.md))
|
|
171
|
-
* **`wayfinder`**: Map problem frontiers across large codebases, separating settled decisions from active frontier tickets and unexplored fog. ([Contract File](../skills/wayfinder/SKILL.md))
|
|
172
|
-
* **`grill-me`**: Relentless interview protocol using the Design Tree Frontier, autonomous fact-finding, and Yes-to-Approve recommendation format before implementation begins. ([Contract File](../skills/grill-me/SKILL.md))
|
|
173
|
-
* **`handoff`**: Compact session context into pointer-first handoff documents saved to $env:TEMP with mandatory Suggested Skills contracts to eliminate context drift and skill blindness. ([Contract File](../skills/handoff/SKILL.md))
|
|
174
|
-
|
|
175
|
-
[↑ Back to top](#toc)
|
|
176
|
-
|
|
162
|
+
<a id="mattpocock-suite"></a>
|
|
163
|
+
### 📦 Matt Pocock Real Engineering Suite (8 modules)
|
|
164
|
+
|
|
165
|
+
- **Upstream Source**: [https://github.com/mattpocock/skills](https://github.com/mattpocock/skills)
|
|
166
|
+
- **Suite Type**: Multi-Skill Suite
|
|
167
|
+
|
|
168
|
+
#### Included Modules:
|
|
169
|
+
|
|
170
|
+
* **`codebase-design`**: Design deep modules (small interfaces hiding large implementations), apply the deletion test, and enforce legitimate seams based on John Ousterhout's *Philosophy of Software Design*. ([Contract File](../skills/codebase-design/SKILL.md))
|
|
171
|
+
* **`domain-modeling`**: Extract ubiquitous language, domain models, and record Architecture Decision Records (ADRs) to eliminate terminology drift and document architectural choices. ([Contract File](../skills/domain-modeling/SKILL.md))
|
|
172
|
+
* **`improve-codebase-architecture`**: Audit codebase structure, detect circular dependencies, evaluate module coupling, and generate dependency matrix reports. ([Contract File](../skills/improve-codebase-architecture/SKILL.md))
|
|
173
|
+
* **`to-spec`**: Formalize requirements and interview outcomes into precise specifications with invariants, error matrices, and user journeys. ([Contract File](../skills/to-spec/SKILL.md))
|
|
174
|
+
* **`to-tickets`**: Decompose formal specifications into atomic, dependency-ordered task tickets formatted for subagent task queues. ([Contract File](../skills/to-tickets/SKILL.md))
|
|
175
|
+
* **`wayfinder`**: Map problem frontiers across large codebases, separating settled decisions from active frontier tickets and unexplored fog. ([Contract File](../skills/wayfinder/SKILL.md))
|
|
176
|
+
* **`grill-me`**: Relentless interview protocol using the Design Tree Frontier, autonomous fact-finding, and Yes-to-Approve recommendation format before implementation begins. ([Contract File](../skills/grill-me/SKILL.md))
|
|
177
|
+
* **`handoff`**: Compact session context into pointer-first handoff documents saved to $env:TEMP with mandatory Suggested Skills contracts to eliminate context drift and skill blindness. ([Contract File](../skills/handoff/SKILL.md))
|
|
178
|
+
|
|
179
|
+
[↑ Back to top](#toc)
|
|
180
|
+
|
|
177
181
|
---
|
|
178
182
|
|
|
179
183
|
<a id="ponytail"></a>
|
|
@@ -398,3 +402,60 @@ heimdall update-skill all
|
|
|
398
402
|
[↑ Back to top](#toc)
|
|
399
403
|
|
|
400
404
|
---
|
|
405
|
+
|
|
406
|
+
<a id="ruminate"></a>
|
|
407
|
+
### ⚡ Ruminate Session Transcript Mining
|
|
408
|
+
|
|
409
|
+
- **Module Name**: `ruminate`
|
|
410
|
+
- **Description**: Mine historical Claude and Gemini session transcripts for correction patterns, repeated preferences, skill trigger failures, agent selection accuracy, doctrine violations, and cross-agent consistency drift. Writes findings as memory files or skill amendments. Use when bootstrapping a brain from existing conversation history or running periodic deep audits.
|
|
411
|
+
- **Upstream Inspiration**: [https://github.com/poteto/brainmaxxing](https://github.com/poteto/brainmaxxing)
|
|
412
|
+
- **Contract File**: [`skills/ruminate/SKILL.md`](../skills/ruminate/SKILL.md)
|
|
413
|
+
|
|
414
|
+
[↑ Back to top](#toc)
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
<a id="modern-web-guidance"></a>
|
|
419
|
+
### ⚡ Google Chrome Modern Web Guidance
|
|
420
|
+
|
|
421
|
+
- **Module Name**: `modern-web-guidance`
|
|
422
|
+
- **Description**: Search and retrieve Google Chrome Modern Web Guidance (Baseline-safe native HTML/CSS/JS APIs, Core Web Vitals, accessibility, and `legacy-scan` frontend modernization).
|
|
423
|
+
- **Upstream Source**: [https://github.com/GoogleChrome/modern-web-guidance](https://github.com/GoogleChrome/modern-web-guidance)
|
|
424
|
+
- **Contract File**: [`skills/modern-web-guidance/SKILL.md`](../skills/modern-web-guidance/SKILL.md)
|
|
425
|
+
|
|
426
|
+
[↑ Back to top](#toc)
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
<a id="mcp-cleanup"></a>
|
|
431
|
+
### ⚡ MCP Orphan Process Cleanup
|
|
432
|
+
|
|
433
|
+
- **Module Name**: `mcp-cleanup`
|
|
434
|
+
- **Description**: Kill orphaned MCP server processes left behind by crashed or closed agent sessions.
|
|
435
|
+
- **Contract File**: [`skills/mcp-cleanup/SKILL.md`](../skills/mcp-cleanup/SKILL.md)
|
|
436
|
+
|
|
437
|
+
[↑ Back to top](#toc)
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
<a id="mcp-sync"></a>
|
|
442
|
+
### ⚡ MCP Template Resolver & Sync
|
|
443
|
+
|
|
444
|
+
- **Module Name**: `mcp-sync`
|
|
445
|
+
- **Description**: Resolve Heimdall MCP template to local paths and sync to agent harness configs.
|
|
446
|
+
- **Contract File**: [`skills/mcp-sync/SKILL.md`](../skills/mcp-sync/SKILL.md)
|
|
447
|
+
|
|
448
|
+
[↑ Back to top](#toc)
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
<a id="upstream-skill-sync"></a>
|
|
453
|
+
### ⚡ Upstream Skill Sync & Triage
|
|
454
|
+
|
|
455
|
+
- **Module Name**: `upstream-skill-sync`
|
|
456
|
+
- **Description**: Audit upstream skill repositories in `config/skills.json` and classify updates via the 3-tier triage rubric (Safe 1:1, Defer/Selective Merge, Reject).
|
|
457
|
+
- **Contract File**: [`skills/upstream-skill-sync/SKILL.md`](../skills/upstream-skill-sync/SKILL.md)
|
|
458
|
+
|
|
459
|
+
[↑ Back to top](#toc)
|
|
460
|
+
|
|
461
|
+
---
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Plan: Upstream Skill Provenance Links & `upstream-skill-sync` Triage Skill
|
|
2
|
+
|
|
3
|
+
### Plan BLUF
|
|
4
|
+
- **Goal**: Add clickable upstream links to `readme.html` and `README*.md`, classify all 68+ skills by `integrationMode` in `config/skills.json`, and create `skills/upstream-skill-sync/SKILL.md` with a 3-tier update rubric.
|
|
5
|
+
- **Architectural Approach**: Approach A — enrich `config/skills.json` with `integrationMode` (`mirror` | `adapted` | `native`), bind a new `upstream-skill-sync` skill to `orchestrator` and `modernizer`, and surface `upstream` URLs across `readme.html`, `README.md`, and `README.pt-BR.md`.
|
|
6
|
+
- **Risk & Blast Radius**: Low — additive documentation, registry metadata, and one new skill (`68` → `69` modules, `29` → `30` toolkits); verified by `test/catalog-integrity.test.mjs` and `npm test`.
|
|
7
|
+
- **Human Approval Gate**: Required before modifying repository source/config files.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Goal Description
|
|
12
|
+
|
|
13
|
+
Every skill in `config/skills.json` already records an `upstream` repository URL, and `heimdall update-skill <name|all>` prints those URLs. However:
|
|
14
|
+
1. `readme.html` and `README.md` / `README.pt-BR.md` do not link individual skills or toolkits directly to their original upstream sources.
|
|
15
|
+
2. Users have no standardized skill or decision rubric to instruct an AI harness to audit upstream repositories and classify changes into **Safe (1:1)**, **Defer / Selective Merge**, or **Not Recommended (Reject)** without overwriting Heimdall-specific customizations (such as `/ruminate` additions in `handoff` and `writing-plans`, BLUF/ASD-STE100 rules, or the Zero Dev-Server Policy).
|
|
16
|
+
|
|
17
|
+
This plan implements **Approach A** (Skill-Driven + Registry Metadata).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Proposed Changes
|
|
22
|
+
|
|
23
|
+
### 1. Registry Metadata & Triage Rubric (`config/skills.json`)
|
|
24
|
+
|
|
25
|
+
- Add `integrationMode` to every skill entry in `skills`:
|
|
26
|
+
- `"mirror"`: Clean 1:1 upstream skill (safe for direct diffing and 1:1 updates after security scan).
|
|
27
|
+
- `"adapted"`: Upstream skill with Heimdall-specific additions or overrides (e.g., `handoff`, `writing-plans`, `modern-web-guidance`, `ruminate`). Requires selective delta incorporation.
|
|
28
|
+
- `"native"`: Authored inside `heimdall-agent` (e.g., `communication-doctrine`, `mcp-sync`, `mcp-cleanup`, `claude-collaborator`, `gemini-collaborator`, `codex-collaborator`, `upstream-skill-sync`).
|
|
29
|
+
- Register the new `upstream-skill-sync` standalone suite & skill entry (`totalSuites`: `30`, `totalModules`: `69`).
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### 2. Upstream Sync Skill & Agent Bindings
|
|
34
|
+
|
|
35
|
+
- Create `skills/upstream-skill-sync/SKILL.md` with frontmatter triggers (`"update skills"`, `"sync upstream skills"`, `"check skill updates"`, `"audit upstream"`).
|
|
36
|
+
- Define the 5-step execution workflow in ASD-STE100 syntax:
|
|
37
|
+
1. **Read Registry**: Load `config/skills.json` and filter by target skill, suite, or `all`.
|
|
38
|
+
2. **Check Upstream**: Run `git ls-remote <upstream>` or inspect upstream `SKILL.md` / release notes.
|
|
39
|
+
3. **Security Gate**: Run `snyk-agent-scan` heuristics on fetched upstream diffs to block prompt injection or credential harvesting.
|
|
40
|
+
4. **Classify via 3-Tier Triage Rubric**:
|
|
41
|
+
- **Tier 1 — Safe (1:1 Replace / Fast-Forward)**: Applies to `"mirror"` skills when upstream adds bugfixes, clearer examples, or new Baseline rules without violating Heimdall doctrine.
|
|
42
|
+
- **Tier 2 — Defer / Selective Merge**: Applies to `"adapted"` skills (or upstream skills overlapping existing Heimdall agents/doctrine). Extract only non-conflicting improvements; preserve `/ruminate` rules, BLUF/STE headers, and Goldfish isolation.
|
|
43
|
+
- **Tier 3 — Not Recommended (Reject / Skip)**: Reject upstream changes that introduce dev-server commands, chatbot closers, vague qualifiers (`ensure`, `properly`), bloated wrappers, or vendor lock-in.
|
|
44
|
+
5. **Report & Verify**: Output a `Review Verdict` BLUF summary listing each skill's tier, source revision, and `npm test` status.
|
|
45
|
+
- Bind `upstream-skill-sync` in `agents/orchestrator.md` and `agents/modernizer.md`.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### 3. Upstream Provenance Links & Documentation Sync
|
|
50
|
+
|
|
51
|
+
- Update `readme.html`: add an `Upstream ↗` link and `mirror` / `adapted` / `native` badge to every skill card, add `upstream-skill-sync`, and update counters (`69` skills, `30` toolkits).
|
|
52
|
+
- Update `README.md` and `README.pt-BR.md`: add clickable upstream links to suite headings and standalone toolkit bullets, add `upstream-skill-sync` to the Standalone Toolkits list and `orchestrator` / `modernizer` rows.
|
|
53
|
+
- Update `docs/SKILLS.md` and run `syncCatalogCounts`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Verification Plan
|
|
58
|
+
|
|
59
|
+
1. Run `npm test` (`node --test test/*.test.mjs`) to verify `Catalog and Documentation Count Integrity Sentinel` and `Communication Doctrine (BLUF & STE) Invariants` pass with `69` modules and `30` suites.
|
|
60
|
+
2. Verify every skill card in `readme.html` has a valid `href="https://..."` upstream link and zero AI-slop buzzwords.
|
package/doctrine/AGENTS.md
CHANGED
|
@@ -22,8 +22,8 @@ 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
|
-
-
|
|
26
|
-
- COMMUNICATION DISCIPLINE (BLUF & STE):
|
|
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>
|
|
@@ -39,7 +39,7 @@ Universal directives for Google Antigravity, Claude Code, and OpenAI Codex CLI a
|
|
|
39
39
|
- Generate an authoritative plan strictly following `05-canonical-plan-template.md` (resolved via `playbooks/`, `../playbooks/`, or `../heimdall-agent/playbooks/`).
|
|
40
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`.
|
|
41
41
|
- The plan MUST specify:
|
|
42
|
-
a) Multi-Agent Orchestration & Model Allocation Matrix (allocating tasks across
|
|
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).
|
|
43
43
|
b) Symmetric Cross-Model Validation Loop (`herdr agent prompt`) and Non-Interactive Verification Harness.
|
|
44
44
|
c) Orchestrator Heartbeat (cadence for monitoring task progress and liveness).
|
|
45
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).
|
package/hooks/heimdall-hook.cjs
CHANGED
|
@@ -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.
|
|
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",
|
package/lib/hud-sync.cjs
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const os = require('node:os');
|
|
4
|
+
|
|
5
|
+
const CODEX_STATUS_LINE_ITEMS = [
|
|
6
|
+
'model-with-reasoning',
|
|
7
|
+
'current-dir',
|
|
8
|
+
'git-branch',
|
|
9
|
+
'context-used',
|
|
10
|
+
'context-window-size',
|
|
11
|
+
'five-hour-limit',
|
|
12
|
+
'weekly-limit'
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
function formatHudCommand(hudScriptPath) {
|
|
16
|
+
const normalized = String(hudScriptPath).replace(/\\/g, '/');
|
|
17
|
+
return `node "${normalized}"`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Configures Claude Code's ~/.claude/settings.json statusLine command.
|
|
22
|
+
*/
|
|
23
|
+
function configureClaudeStatusLine(hudScriptPath, dryRun = false, homeDir = os.homedir()) {
|
|
24
|
+
const settingsPath = path.join(homeDir, '.claude', 'settings.json');
|
|
25
|
+
if (!fs.existsSync(settingsPath)) return false;
|
|
26
|
+
try {
|
|
27
|
+
const cfg = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
28
|
+
const desiredCmd = formatHudCommand(hudScriptPath);
|
|
29
|
+
if (cfg.statusLine?.command === desiredCmd && cfg.statusLine?.type === 'command') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
cfg.statusLine = { type: 'command', command: desiredCmd };
|
|
33
|
+
if (!dryRun) {
|
|
34
|
+
fs.writeFileSync(settingsPath, JSON.stringify(cfg, null, 2) + '\n');
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Configures Antigravity CLI's ~/.gemini/antigravity-cli/settings.json statusLine command.
|
|
44
|
+
*/
|
|
45
|
+
function configureAntigravityStatusLine(hudScriptPath, dryRun = false, homeDir = os.homedir()) {
|
|
46
|
+
const settingsPath = path.join(homeDir, '.gemini', 'antigravity-cli', 'settings.json');
|
|
47
|
+
if (!fs.existsSync(settingsPath)) return false;
|
|
48
|
+
try {
|
|
49
|
+
const cfg = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
50
|
+
const desiredCmd = formatHudCommand(hudScriptPath);
|
|
51
|
+
if (cfg.statusLine?.command === desiredCmd && cfg.statusLine?.enabled === true) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
cfg.statusLine = {
|
|
55
|
+
type: 'command',
|
|
56
|
+
command: desiredCmd,
|
|
57
|
+
enabled: true,
|
|
58
|
+
padding: 0,
|
|
59
|
+
stack_with_default: false
|
|
60
|
+
};
|
|
61
|
+
if (!dryRun) {
|
|
62
|
+
fs.writeFileSync(settingsPath, JSON.stringify(cfg, null, 2) + '\n');
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ensures Codex CLI's ~/.codex/config.toml [tui] table includes status_line items.
|
|
72
|
+
*/
|
|
73
|
+
function configureCodexStatusLine(dryRun = false, homeDir = os.homedir()) {
|
|
74
|
+
const configPath = path.join(homeDir, '.codex', 'config.toml');
|
|
75
|
+
if (!fs.existsSync(configPath)) return false;
|
|
76
|
+
try {
|
|
77
|
+
let content = fs.readFileSync(configPath, 'utf8');
|
|
78
|
+
if (/^\s*status_line\s*=/m.test(content)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const itemsLiteral = CODEX_STATUS_LINE_ITEMS.map(item => `"${item}"`).join(', ');
|
|
82
|
+
const snippet = `status_line = [${itemsLiteral}]`;
|
|
83
|
+
|
|
84
|
+
if (/^\[tui\]/m.test(content)) {
|
|
85
|
+
content = content.replace(/^(\[tui\]\s*\r?\n)/m, `$1${snippet}\n`);
|
|
86
|
+
} else {
|
|
87
|
+
content = content.trimEnd() + `\n\n[tui]\n${snippet}\n`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!dryRun) {
|
|
91
|
+
fs.writeFileSync(configPath, content);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Removes statusLine from Claude Code's ~/.claude/settings.json.
|
|
101
|
+
*/
|
|
102
|
+
function disableClaudeStatusLine(dryRun = false, homeDir = os.homedir()) {
|
|
103
|
+
const settingsPath = path.join(homeDir, '.claude', 'settings.json');
|
|
104
|
+
if (!fs.existsSync(settingsPath)) return false;
|
|
105
|
+
try {
|
|
106
|
+
const cfg = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
107
|
+
if (!cfg.statusLine) return false;
|
|
108
|
+
delete cfg.statusLine;
|
|
109
|
+
if (!dryRun) {
|
|
110
|
+
fs.writeFileSync(settingsPath, JSON.stringify(cfg, null, 2) + '\n');
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
} catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Removes statusLine from Antigravity CLI's ~/.gemini/antigravity-cli/settings.json.
|
|
120
|
+
*/
|
|
121
|
+
function disableAntigravityStatusLine(dryRun = false, homeDir = os.homedir()) {
|
|
122
|
+
const settingsPath = path.join(homeDir, '.gemini', 'antigravity-cli', 'settings.json');
|
|
123
|
+
if (!fs.existsSync(settingsPath)) return false;
|
|
124
|
+
try {
|
|
125
|
+
const cfg = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
126
|
+
if (!cfg.statusLine) return false;
|
|
127
|
+
delete cfg.statusLine;
|
|
128
|
+
if (!dryRun) {
|
|
129
|
+
fs.writeFileSync(settingsPath, JSON.stringify(cfg, null, 2) + '\n');
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Removes status_line and status_line_use_colors from Codex CLI's ~/.codex/config.toml.
|
|
139
|
+
*/
|
|
140
|
+
function disableCodexStatusLine(dryRun = false, homeDir = os.homedir()) {
|
|
141
|
+
const configPath = path.join(homeDir, '.codex', 'config.toml');
|
|
142
|
+
if (!fs.existsSync(configPath)) return false;
|
|
143
|
+
try {
|
|
144
|
+
const original = fs.readFileSync(configPath, 'utf8');
|
|
145
|
+
const updated = original
|
|
146
|
+
.replace(/^\s*status_line\s*=.*\r?\n?/gm, '')
|
|
147
|
+
.replace(/^\s*status_line_use_colors\s*=.*\r?\n?/gm, '');
|
|
148
|
+
if (updated === original) return false;
|
|
149
|
+
if (!dryRun) {
|
|
150
|
+
fs.writeFileSync(configPath, updated);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Persists user HUD theme and line-count preferences to ~/.heimdall-hud.json.
|
|
160
|
+
*/
|
|
161
|
+
function writeHudConfig({ theme, lines }, dryRun = false, homeDir = os.homedir()) {
|
|
162
|
+
const cfgPath = path.join(homeDir, '.heimdall-hud.json');
|
|
163
|
+
let existing = {};
|
|
164
|
+
if (fs.existsSync(cfgPath)) {
|
|
165
|
+
try { existing = JSON.parse(fs.readFileSync(cfgPath, 'utf8')); } catch {}
|
|
166
|
+
}
|
|
167
|
+
const next = {
|
|
168
|
+
...existing,
|
|
169
|
+
...(theme ? { theme } : {}),
|
|
170
|
+
...(lines ? { lines: Number(lines) === 1 ? 1 : 2 } : {})
|
|
171
|
+
};
|
|
172
|
+
if (!dryRun) {
|
|
173
|
+
fs.writeFileSync(cfgPath, JSON.stringify(next, null, 2) + '\n');
|
|
174
|
+
}
|
|
175
|
+
return next;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
module.exports = {
|
|
179
|
+
CODEX_STATUS_LINE_ITEMS,
|
|
180
|
+
configureClaudeStatusLine,
|
|
181
|
+
configureAntigravityStatusLine,
|
|
182
|
+
configureCodexStatusLine,
|
|
183
|
+
disableClaudeStatusLine,
|
|
184
|
+
disableAntigravityStatusLine,
|
|
185
|
+
disableCodexStatusLine,
|
|
186
|
+
writeHudConfig
|
|
187
|
+
};
|
package/lib/model-context.cjs
CHANGED
|
@@ -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
|
};
|