KAE System Pack · 19 July 2026
Tool Audit
A complete inventory of every script, hook, monitor, and reusable tool across all 9 operational layers of the Kujenga Autonomy Engine. Includes location, purpose, invocation trigger, complexity, and cost profile.
87
Total tools
9
Layers
28
Hooks
26
Clients
19
Guardians
4
High-cost layers
Cost key
Negligible Pure JS/SQL logic — no I/O
Low Reads a few files or writes SQLite
Medium Reads many files, runs git, or sends small data
High Chromium, LLM API calls, or network file transfer
System Structure Overview
Directory Layout
| Systems/ | All business content — clients, guardians, playbooks, library |
| KAE/ | Kujenga Autonomy Engine — Node.js daemon, PM2-managed |
| .claude/ | Claude Code harness — hooks, settings, skills |
| Knowledge/ | LEGBA knowledge ingest working set (searchable extracted text) |
| KAE-Visualizations/ | Architecture diagrams and visual docs |
Systems/ at a Glance
| 26 client folders | Brand, campaigns, finance, legal, OGUN config per client |
| 19 guardian folders | Each owns Instructions/, Data/, Logs/ |
| 10 playbook folders | Methodology repos — LEZA, NOMMO, HEPHAESTUS, HERMES, etc. |
| 2 libraries | OGUN (shared tools) + LEGBA (MCP gateway) |
| 50+ handoff docs | Cross-session context records, June–July 2026 |
Layer 1 — Hooks
hooks 28 files · .claude/hooks/Every file save passes through up to 11 pre-checks + 1 post-router dispatching to 15 sub-handlers. A single Write call can touch up to 28 hook code paths.
Session-Start — fires once per session open
| Tool | Purpose | Lines | Freq | Cost |
|---|---|---|---|---|
mandatory-reads.js |
Injects OS-critical files into every session from mandatory-reads.json |
57 | session open | Low |
kae-status.js |
Builds situational awareness — MEMORY.md, tasks, last session log, git status, PM2 status (1h cooldown) | 131 | 1h cooldown | Medium |
UserPromptSubmit — fires on every prompt
| Tool | Purpose | Lines | Freq | Cost |
|---|---|---|---|---|
session-brief.js |
Injects KAE SESSION BRIEF — overdue tasks + due content (1h cooldown) | 165 | hourly | Medium |
context-bridge.js |
Saves/restores session state across compaction. WRITE at 600KB; INJECT when context shrinks below 60% of write-size | 281 | every prompt | Medium |
PreToolUse Write/Edit — fires before every file save (11 gates)
| Tool | Purpose | Lines | Blocking | Cost |
|---|---|---|---|---|
kae-guard.js |
Counts writes to Systems/ in 10-min window; stops KAE at 3+ to prevent runaway API spend | 90 | Stops KAE | Low |
contract-threshold-gate.js |
MAAT: blocks delivery/finance writes when no signed contract is on file for the client | 134 | Hard block | Low |
process-registration-gate.js |
DEMETER: new tools/hooks must appear in the registry before they land | 104 | Warn | Low |
brand-foundation-gate.js |
Hard-blocks design-surface files (HTML/CSS) when client has no ogun-config.json or brand reference | 169 | Hard block (design) | Low |
brief-prerequisite-gate.js |
DEMETER: no campaign assets without a LEZA brief/audit on file | 117 | Warn | Low |
spec-first-gate.js |
HEPHAESTUS: complex client builds must have a .spec.md before code starts | 177 | Warn | Low |
kdacm-phase-foundation-gate.js |
Blocks digital builds when Phase 1 narrative foundation (story, messaging, content matrix) is absent | 269 | Hard block | Low–Med |
research-freshness-gate.js |
MINERVA: time-sensitive research must carry a freshness marker before supporting a public claim | 106 | Warn | Low |
content-payload-completeness-gate.js |
HERMES: blocks content reviews when the post body is missing or too thin | 143 | Hard block | Low |
design-smell-gate.js |
Hard-blocks banned CSS/color patterns (dark blue, neon, glassmorphism, non-Kujenga hex values) before they hit disk | 85 | Hard block | Negligible |
image-gen-preflight.js (Bash) |
Fires before every Bash call; injects IMAGE-GEN-IMPROVEMENTS.md creative rules when the command references image-gen | 113 | Injects only | Low |
PostToolUse Write/Edit — 1 router + 15 sub-handlers
| Tool | Purpose | Lines | Cost |
|---|---|---|---|
post-write-router.js |
Router — replaced 15 separate processes with 1. All sub-handlers run in the same Node process after every Write/Edit | 74 | Low–Med |
tasks-data-gate.js | tasks.json/projects.json completeness — owner gaps, open work without date windows | 230 | Low |
team-profile-gate.js | YEMOJA: team profile structural completeness | 124 | Low |
campaign-quality-gate.js | Merged: readiness, proof claim, review clearance, opportunity discipline in campaign files | 188 | Low |
finance-state-gate.js | OYA: payment status, commission ownership, rate visibility in finance files | 140 | Low |
hades-resolution-date-gate.js | HADES: every review record must have a next-check date | 127 | Low |
offer-viability-gate.js | Service/offer files must name resources, delivery system, and commercial proof | 141 | Low |
documentation-gate.js | Enforces file header blocks, function doc-comments, Status+Owner metadata in markdown files | 167 | Low |
client-lifecycle-gate.js | ESHU/ELEUTHIA: clients need intake records and a visible lifecycle stage | 159 | Low |
owner-assignment-gate.js | YEMOJA: no task without a named owner traceable to a real Team profile | 141 | Low |
poseidon-flag-response-gate.js | POSEIDON: every flag must have a response within 24 hours | 124 | Low |
review-clearance-gate.js | HERMES: no live-bound content without explicit approval markers | 102 | Low |
proof-claim-gate.js | SANGO/AETHER: public claims must point at evidence in truth-ledger.md | 118 | Low |
task-completeness-gate.js | Tasks must have dates, scope, state, action plan, and success criteria | 183 | Low |
amendment-validate.js | Validates GAIA amendment files against schema at authoring time | 70 | Negligible |
opportunity-discipline-gate.js | OSHOSI: opportunities need a champion; closed deals need autopsy; conversion assets need a next step | 114 | Low |
SessionEnd — fires on every session close
| Tool | Purpose | Lines | Cost |
|---|---|---|---|
gaia-pack-sync.js |
Thin wrapper — triggers the GAIA pack sync script; writes live-system-changes.md/html | 55 | Medium |
session-close.js |
Restarts KAE if build-stop guard parked it; injects session-close checklist into Claude | 147 | Low |
Layer 2 — KAE Scripts
scripts 26 files · KAE/scripts/| Tool | Purpose | Lines | Schedule / Trigger | Cost |
|---|---|---|---|---|
morning-brief.js | Scans all client posts + tasks; emails overdue list; writes HADES/content-alert.md; takes day snapshot for evening diff | 278 | 05:30 SAST daily | Medium |
evening-brief.js | Diffs live state against morning snapshot; emails Tasks/Content/Executive digest | 313 | 18:00 SAST daily | Medium |
poseidon-data-feed.js | Scans client post folders; writes POSEIDON intake form for operator to fill | 266 | Sat + Sun 09:00 | Medium |
context-bridge.js | Saves/restores session state across compaction (see Hooks — Layer 1) | 281 | every prompt | Medium |
session-brief.js | KAE SESSION BRIEF injection (see Hooks — Layer 1) | 165 | hourly | Medium |
tasks-check.js | Reads tasks.json; writes HADES task alerts + POSEIDON project registry | 194 | tasks.json edits | Low |
gaia-field-intel-archive.js | Trims Field Intelligence sections from guardian instruction files; deduplicates; archives to APOLLO | 254 | 03:00 SAST daily | Medium |
guardian-state-archive.js | Moves guardian-state.md entries older than 7 days to APOLLO archive. Run before reading guardian-state.md | 188 | manual | Low |
validate-models.js | Tests each guardian after a model change — calls LLM per guardian; records pass/fail in APOLLO Logs | 180 | KAE restart | High (LLM) |
push-post-to-buffer.js | FTP-stages images; schedules post via Buffer GraphQL API. Requires .env credentials | 92 | manual per post | High (FTP + API) |
generate-linkedin-preview-pdf.js | Headless browser PDF preview of LinkedIn post content for client review | 171 | manual | High (browser) |
generate-proposals-pdf.js | Headless browser PDF from proposal markdown | 135 | manual | High (browser) |
amendments.js | CLI for the human evolution-amendment review loop: list / approve / withdraw / show | 171 | manual | Low |
assemble-ghn-patterns.js | Merges all 17 guardian patterns.json files into the master GHN seed file | 95 | manual | Low |
deploy-ftp.js | Mirrors a local build folder to a remote FTP target with hash verification | 127 | manual per deploy | High (FTP) |
repair-pattern-confidence.js | Restores GHN routing confidence eroded by API outages. Run after fixing the underlying cause | 53 | emergency | Low |
requeue-failed.js | Resets failed SQLite queue rows back to pending after an outage is resolved | 41 | emergency | Negligible |
scaffold-clients.js | Retro-scaffolds active client folders to DEMETER gate standard (idempotent) | 139 | onboarding | Low |
validate-manifests.js | Whole-chain coherence: guardian folder → registry.js → ghn-patterns.json consistency | 67 | manual | Low |
ogun-usage.js | Reads usage-log.jsonl; writes frequency report to suggest configs for new clients | 123 | onboarding | Low |
codebase-roster-close.js | Writes batch-tracked SQLite roster from git status at session close | 104 | session close | Low |
extract-archive.py | Extracts .docx/.pdf/.xlsx into Knowledge/ for LEGBA search | ~120 | manual | Low–Med |
restart.js | KAE restart utility | 48 | manual | Low |
platform-detect.js | Detects OS platform for cross-platform scripts (imported as library) | 22 | — | Negligible |
verify-skill-tables.js | Verifies SQLite skill tables exist — safe to run while KAE is live | 31 | diagnostic | Negligible |
register-*.ps1 ×2 | Registers morning-brief + poseidon-data-feed as Windows scheduled tasks (one-time per machine) | ~30 each | one-time setup | Low |
Layer 3 — KAE Monitors
monitors 12 files · KAE/monitors/ · started by index.js on boot| Monitor | Purpose | Lines | Schedule | Cost |
|---|---|---|---|---|
health-check.js | Checks SQLite pattern count, queue depth, error rates; writes GAIA/Health/ report | 124 | boot + cron | Low |
backup.js | SQLite VACUUM INTO backup + .env + state JSONs to KujengaDepot/Backups/ (14-day retention) | 84 | 02:30 SAST | Low–Med |
content-alert.js | Scans all client posts + tasks; writes HADES/content-alert.md; emails on action-needed days | 237 | 05:30 SAST | Medium |
project-gate.js | Reads tasks.json; flags projects with no date window or no owner | 27 | 06:00 SAST | Low |
project-closeout.js | Flags projects needing closeout attention (HOLD/WARN status) | 25 | 06:15 SAST | Low |
amendment-review.js | Scans pending amendments; writes GAIA/Amendments/REVIEW-QUEUE.md for human review | 90 | daily | Low |
field-intel-archive.js | Thin cron wrapper — triggers gaia-field-intel-archive.js daily to keep instruction files lean | 31 | 03:00 SAST | Medium |
quality-scorer.js | 7-day guardian run report (total runs, success rate, duration, errors); writes GAIA/QualityReports/ | 93 | weekly | Low |
json-export.js | Dumps all SQLite stores to KAE/state/backup/ as human-readable JSON (inspection/recovery material) | 49 | nightly | Low |
poseidon-monitor.js | Reads all client overviews; generates POSEIDON pipeline intelligence via LLM call | 195 | weekly | High (LLM) |
client-monitors.js | ELEUTHIA stall check (Mon 07:15 SAST): scans client stage maps for stalls across active roster | 166 | Mon 07:15 | Medium |
demeter-check.js | Aggregates all gate violation JSON files into one DEMETER violations report | 23 | every 12h | Low |
Layer 4 — GHN / Routing
routing 5 files · KAE/ghn/ · fires on every file-change event| Tool | Purpose | Lines | Freq | Cost |
|---|---|---|---|---|
router.js | Main event router — receives file events, calls findRoute(), runs plane sequencing, dispatches guardians, feeds learning loop | 138 | every file event | Low–High |
core.js | Pattern store API (SQLite). findRoute() with specificity tie-breaker, updatePatternUse(). 28 seeded patterns + learned patterns | 252 | every file event | Low |
plane-check.js | Ubuntu World Pantheon sequencing validator — co-dispatches ESHU/MAAT when capability/runtime guardians fire without them | 107 | every file event | Negligible |
learning-loop.js | Pattern learning — accumulates observations in SQLite; promotes to routing patterns at 80% success over 3 occurrences | 186 | every routed event | Low |
plane-manifest.json | Authoritative 8-plane Ubuntu World Pantheon membership (sovereign, memory, state, access, enforcement, capability, channel, runtime). Read once at boot | — | boot | Negligible |
Layer 5 — Evolution Engine
evolution 10 files · KAE/evolution/ · highest-cost layerThe self-learning layer. Extracts field intelligence from guardian outputs via LLM, accumulates evidence, and proposes instruction amendments when patterns repeat. Every tool here that calls the Anthropic API is a direct cost event.
| Tool | Purpose | Lines | Trigger | Cost |
|---|---|---|---|---|
batch-submitter.js | Submits pending guardian outputs to the Anthropic Batch API hourly | 81 | hourly | High (Batch API) |
batch-poller.js | Polls Batch API for completed jobs; calls outcome-extractor on each result | 124 | periodic | High (Batch API) |
outcome-extractor.js | LLM call to distill field intelligence from each guardian output. FIELD_INTEL_BLOCKED regex suppresses infra-error spam | 106 | per guardian output | High (LLM) |
amendment-proposer.js | Drafts instruction amendments via LLM when evidence threshold reached (3 obs, 80% confidence). BLOCKED_TOPICS regex prevents infra-noise becoming methodology | 107 | per threshold hit | High (LLM) |
amendment-writer.js | Applies human-approved amendments to instruction files. Appends to the correct section; moves applied files to applied/ | 127 | per approval | Low–Med |
evidence-store.js | Accumulates field observations in SQLite; triggers proposer when threshold is met | 100 | per extraction | Low |
evolution-queue.js | SQLite queue — enqueue/read/mark-processed for guardian outputs awaiting extraction | 75 | per guardian run | Low |
field-writer.js | Appends field intelligence to ## Field Intelligence sections in guardian instruction files | 46 | per observation | Low |
resolve-instruction-path.js | Repairs model-returned paths that drop the Instructions/ segment — prevents silent field intel loss | 63 | per extraction | Negligible |
amendment-schema.js | Canonical schema + validator for amendment files. Imported by both hook and writer to prevent format drift | 96 | imported | Negligible |
Layer 6 — OGUN Library Tools
ogun 13 tools · Systems/Library/OGUN/Tools/Scripts/| Tool | Language | Purpose | Lines | Trigger | Cost |
|---|---|---|---|---|---|
image-gen/generate.js | Node.js | LinkedIn social cards from HTML templates + brand config via Puppeteer. 7 templates, 5 styles, 3 sizes | 250 | manual per image | High (Chromium) |
html-to-pdf/html-to-pdf.js | Node.js | A4 HTML → print-ready PDF. Preserves @page CSS, gradients, backgrounds. --portrait flag for portrait layout | 148 | manual per doc | High (Chromium) |
gaia-pack-sync/gaia-pack-sync.js | Node.js | Generates live-system-changes.md/html from the git working tree. Largest tool script in the repo | 478 | session close | Medium |
enforcement-audit/enforcement-audit.js | Node.js | Audits which Kujenga doctrine rules are code-enforced vs prose-only. Exit 2 when critical rules are still prose | 156 | manual | Low |
send-email/send-email.js | Node.js | SMTP email with optional attachment via Kujenga Digital mail server (mail.kujengadigital.co.za:465) | 40 | manual per email | High (SMTP) |
screenshot-url/screenshot-url.js | Node.js | Headless Chrome screenshot of any URL — local dev servers or public sites | 68 | manual per QA | High (Chromium) |
nightly-push/nightly-push.ps1 | PowerShell | Auto-discovers all git repos under Span/ and laragon/www/; pushes committed-but-unpushed code at 01:00 | 69 | 01:00 nightly | Medium |
image-bank-organise/image-bank-organise.js | Node.js | Renames and copies campaign images using bg-[context].ext convention; writes manifest. No npm deps | 214 | manual per campaign | Low–Med |
vecteezy/search.js | Node.js | Vecteezy REST API — search royalty-free photos/vectors/video. Requires .env credentials | 88 | manual | Medium |
vecteezy/download.js | Node.js | Vecteezy REST API — download by resource ID with optional --dest and --name flags | 91 | manual | Medium |
vecteezy/account.js | Node.js | Vecteezy REST API — check quotas and license usage | 61 | manual | Low |
backfill-post-metadata.js | Node.js | One-time utility: backfills HERMES metadata headers into legacy post markdown files | 153 | migration only | Low |
pptx/ (4 modules) | Python | Reusable PPTX layout + component library (layout.py, components.py, theme_aem.py, theme_smooth.py). Imported by client build scripts | ~200 | imported | Negligible |
Layer 7 — LEGBA Gateway
legba 8 files · Systems/Library/LEGBA/Server/| Tool | Purpose | Lines | Trigger | Cost |
|---|---|---|---|---|
legba-mcp.js | MCP gateway over stdio — the local door for Claude Code on this machine | 38 | every MCP call | Low |
legba-http.js | Remote MCP gateway at legba.kujengadigital.co.za — handles remote seats (staff phones, Codex, claude.ai). 755 lines — largest file in the gateway | 755 | every remote call | Low (network) |
lib/tools.js | All 15 LEGBA tool implementations: read_doc, list_clients, tasks_list, get_client, get_guardian_status, invoke_minerva, kuji_render, perplexity_search, oxylabs_search, etc. 868 lines — largest file in the system | 868 | called by rpc-core.js | Low–High per tool |
rpc-core.js | Shared JSON-RPC dispatcher used by both stdio and HTTP transports. Enforces role-based tool allowlists | 81 | imported | Negligible |
legba-seat.js | Creates/lists/revokes access tokens for the HTTP gateway. One seat = one named person (YEMOJA rule) | 82 | staff changes | Negligible |
check-health.js (VPS) | Checks LEGBA uptime every 5 minutes; writes uptime log to disk | 129 | every 5 min (VPS) | Low |
backup-state.js (VPS) | Nightly LEGBA state backup on VPS — seats, activity log, PM2 dump | 104 | 02:25 SAST (VPS) | Low |
deploy-public-surfaces.js (VPS) | Copies domain surfaces to public folders; syncs favicon/manifest family | 103 | manual per deploy | Low |
Layer 8 — Internal Engines
engines 6 files · KAE/ogun/ · KAE/loop/ · KAE/sync/| Tool | Purpose | Lines | Trigger | Cost |
|---|---|---|---|---|
ogun/skill-engine.js | OGUN Skill Engine — loads skill steps from SQLite per request, keeping SKILL.md files as lightweight manifests. Most complex internal engine. CLI: --skill, --step, --list, --import, --export, --seed | 653 | per skill step | Low (SQLite) |
loop/discovery.js | GAIA loop Phase 1 — scores tasks + post backlog + evolution alerts against strategic goals; writes ranked discovery backlog to GAIA/Discovery/ | 277 | cron / manual | Medium |
loop/goal-store.js | SQLite CRUD for the human-set strategic goals that discovery.js scores candidates against | 110 | imported | Negligible |
loop/seed-gaia-loop.js | Seeds initial GAIA loop config + goals + discovery schedule into SQLite (one-time setup or reset) | 193 | one-time | Low |
loop/seed-goals.js | Seeds the canonical strategic goal set into the SQLite goal store | 104 | one-time | Negligible |
sync/systems-sync.js | Synchronises Systems/ state with KAE — used during VPS migration and multi-machine setup | 50 | migration | Low–Med |
Layer 9 — Client-Specific Build Scripts
client 5 scripts · Systems/Clients/ and Systems/Playbooks/These use OGUN tools as libraries but are kept in client folders because they contain client-specific content or credentials.
| Script | Client | Language | Purpose |
|---|---|---|---|
generate-orientation.js | ANANSI / Playbooks | Node.js | Role-specific staff onboarding orientation generator |
build-pptx-report.py | DBIA | Python | PPTX report template using python-pptx — copy and rename per project |
md-to-html-dbia.js | DBIA | Node.js | Converts DBIA markdown documents to branded HTML |
send-email.ps1 | DBIA | PowerShell | DBIA-specific email sender with hardcoded DBIA SMTP credentials |
build-aem-brief.py | DBIA / AEM | Python | 6-slide PPTX brief using OGUN pptx/ library |
Invocation Frequency Summary
| Frequency | Tools |
|---|---|
| every prompt | context-bridge.js |
| every Write/Edit | kae-guard.js · contract-threshold-gate.js · process-registration-gate.js · brand-foundation-gate.js · brief-prerequisite-gate.js · spec-first-gate.js · kdacm-phase-foundation-gate.js · research-freshness-gate.js · content-payload-completeness-gate.js · design-smell-gate.js · post-write-router.js + 15 sub-handlers |
| every file event | router.js · core.js · plane-check.js · learning-loop.js |
| session open | mandatory-reads.js · kae-status.js |
| hourly | session-brief.js · batch-submitter.js · batch-poller.js |
| session close | gaia-pack-sync.js · session-close.js |
| KAE boot | validate-models.js (detached) · health-check.js · backup.js · content-alert.js · project-gate.js · project-closeout.js · demeter-check.js |
| 03:00 SAST | field-intel-archive.js |
| 05:30 SAST | morning-brief.js · content-alert.js monitor |
| 06:00–06:15 SAST | project-gate.js · project-closeout.js |
| 18:00 SAST | evening-brief.js |
| every 12h | demeter-check.js |
| nightly 01:00 | nightly-push.ps1 |
| nightly 02:25 | backup-state.js (VPS) |
| nightly 02:30 | backup.js |
| every 5 min (VPS) | check-health.js |
| Sat + Sun 09:00 | poseidon-data-feed.js |
| weekly | quality-scorer.js · poseidon-monitor.js · client-monitors.js |
| manual only | amendments.js · requeue-failed.js · repair-pattern-confidence.js · scaffold-clients.js · deploy-ftp.js · push-post-to-buffer.js · assemble-ghn-patterns.js · validate-manifests.js · extract-archive.py · legba-seat.js · deploy-public-surfaces.js · all OGUN build tools |
Cost Profile by Layer
| Layer | Highest-cost tools | Cost driver | Profile |
|---|---|---|---|
| L5 — Evolution | batch-submitter · batch-poller · outcome-extractor · amendment-proposer |
Direct Anthropic API spend — fires per guardian run, hourly | Highest |
| L3 — Monitors | poseidon-monitor |
One LLM call per weekly run | High |
| L2 — Scripts | validate-models · generate-*-pdf · push-post-to-buffer |
LLM calls on every KAE restart; Chromium per PDF; FTP per post | High (per run) |
| L6 — OGUN | image-gen · html-to-pdf · screenshot-url |
Chromium per invocation | High (per run) |
| L7 — LEGBA | perplexity_search · oxylabs_search · invoke_minerva |
External API call per invocation | High (per call) |
| L1 — Hook lattice | None individually high | Very high frequency — fires on every file write; low per-hook but significant in aggregate | Medium (aggregate) |
| L4 — GHN Routing | None | SQLite only — negligible per event | Negligible |
| L8 — Engines | None (skill-engine is SQLite) | SQLite reads only | Negligible |