Sandbox
@amazinglvxw/enso-os

Shell hooks for Claude Code and Gemini CLI

Enso is a discipline plugin that sits around an existing agent instead of replacing it. It captures tool errors, turns them into lessons, injects that memory into later sessions, and uses PAC to ask about patterns you have not raised yourself. The system is local and works through shell hooks and template files under `~/.enso/`.

88 starsβ€’5 forksβ€’Shellβ€’Updated 4mo ago
Who it's for

Builders who use Claude Code, Gemini CLI, or another agent with lifecycle hooks and want consistent learning between sessions.

What it delivers

You can stop re-explaining past mistakes and get a session that remembers lessons, forgets stale ones, and calls out recurring blind spots.

What it does

Error capture and lesson distillation

Hooks record tool failures, distill them into lessons, and inject them in the next session.

Active forgetting

Stale lessons are pruned with decay, LRU eviction, trace rotation, and archive handling.

PAC challenges

The PAC layer watches logs and memory, then writes Socratic challenges when it sees self-limiting patterns.

Self-protection and safety checks

Pre-tool hooks block unsafe memory writes, secret leaks, and self-modification of core rules where supported.

Weekly knowledge lint

`enso-lint.sh` checks for orphaned, duplicate, weak, or oversized memory entries.

How to get it

  1. 1That's it. Start a new session. Enso is active
    Session 1:  You hit an error -> Enso captures it automatically
                Session ends -> Enso distills 1-3 lessons from the error
    
    Session 2:  Enso injects the lessons -> Agent avoids the same mistake
                You didn't do anything. The system learned by itself.

README

Enso

MIT License v0.7.0 12 Shell Hooks bash + python3 PAC Mechanism

Quickstart β€’ PAC πŸͺž β€’ What Enso Adds β€’ Works With β€’ How It Works β€’ δΈ­ζ–‡


Enso is the first AI plugin that speaks first.

Every LLM product today β€” ChatGPT, Claude, Gemini, Perplexity β€” is built on the same anti-pattern: AI responds, AI never initiates. It observes your mistakes and stays silent. It sees your self-limiting patterns and waits for you to ask.

Enso breaks that silence. It is a discipline plugin that adds three things no mainstream AI product has by default:

  1. Code-enforced learning β€” errors become hooks, not prompts. No third strike.
  2. Active forgetting β€” stale knowledge is pruned. Not all memory is worth keeping.
  3. πŸͺž PAC (Proactive Accountability Challenge) β€” AI that raises the issue you haven't asked about.

Install in 30 seconds. Just bash + python3 (pre-installed on macOS/Linux). Wraps around Claude Code, Hermes, OpenClaw, Gemini CLI. Your data stays local.

Enso: Session 1 error -> Session 2 learned

Quickstart

# Claude Code (default)
git clone https://github.com/amazinglvxw/enso-os.git
cd enso-os && bash install.sh

# Gemini CLI
bash install.sh --target gemini-cli

# Hermes Agent
bash install.sh --target hermes

# OpenClaw
bash install.sh --target openclaw

# Any agent with lifecycle hooks
bash install.sh --target generic

That's it. Start a new session. Enso is active:

Session 1:  You hit an error -> Enso captures it automatically
            Session ends -> Enso distills 1-3 lessons from the error

Session 2:  Enso injects the lessons -> Agent avoids the same mistake
            You didn't do anything. The system learned by itself.

PAC β€” Proactive Accountability Challenge (New in v0.7.0)

"PAC is not a judge. It's a mirror."

Every mainstream LLM is query-response. You ask, AI answers. If you don't ask about the blindspot, AI doesn't raise it. This is polite. It is also β€” for serious users β€” expensive.

PAC adds the missing half: observation-initiated dialogue. Enso watches your session logs, memory files, and decision patterns. When it detects self-limiting behavior that you haven't asked about, it writes a Socratic challenge and delivers it at the start of your next session.

The Five Patterns PAC Detects

#PatternExample Trigger
1Repetition β€” Starting new while old is incomplete5 new business lines in 30 days, each lasting 4 days
2Claim-Action Conflict β€” Stated focus β‰  executed focusMEMORY says "focus on X", logs show 70% on Y
3Capability-Task Mismatch β€” Strategy delegated to executorsSupply-chain risk handed to an ops person with past failures
4Sunk Cost β€” Long-running zero-growth with tactical churn47 days, 17 days zero growth, pricing changed twice, core assumption never questioned
5Critical Decision Node β€” Irreversible action about to ship"about to sign" on a $50k contract

Constraint vs Self-Limitation β€” The Critical Distinction

A naive challenger burns out the user. PAC's core innovation is classification:

  • 🟒 Constraint-optimal (DO NOT challenge) β€” User chose X because of real-world limits they can't change (no runway, family obligations, health). Affirm the choice.
  • πŸ”΄ Self-limiting (MUST challenge) β€” User has the capability and keeps tripping on the same pattern. Challenge firmly.

When uncertain, PAC biases toward not challenging. Silence is the safe default.

Quality Standards

Every PAC challenge must pass five checks before it ever reaches you:

#RuleBadGood
1Based on observation, not wisdom"You should focus more""execution-log shows 9 active lines in 30 days"
2Point to structure, not instance"Why did you do X?""Why do you always do X-type things?"
3Challenge premise, not options"A or B?""Why do you need this at all?"
4Time dimension"This is wrong""In Q1 you did X, Q2 also X β€” why?"
5No answer given"You should do Y""If you only had 3 options, what would they be?"

Anti-Fatigue by Design

  • Max 1 challenge per 24 hours (hard limit)
  • Max 3 challenges per week (hard limit)
  • 7-day silence period after any challenge on the same pattern
  • 1-month cooldown after 3 consecutive user rejections
  • PAC_ENABLED=false to disable entirely

Example Output

<enso-pac-challenge confidence="0.85" pattern="claim_action_conflict">
  <observation>
    You told me 3 weeks ago to focus on the survival layer.
    execution-log shows 60% of your actual actions on the ambition layer
    and 25% on the remote layer. Survival layer: 15%.
  </observation>
  <challenges>
    <q id="1">Is the stated priority still true?</q>
    <q id="2">If it is, what's the structural force pulling you elsewhere?</q>
    <q id="3">If it isn't, why hasn't the stated priority been updated?</q>
  </challenges>
  <no-answer>These questions are for you to sit with.</no-answer>
</enso-pac-challenge>

The Philosophy

道德经: ηŸ₯δΊΊθ€…ζ™ΊοΌŒθ‡ͺηŸ₯θ€…ζ˜Žγ€‚ Knowing others is intelligence. Knowing yourself is enlightenment.

PAC is the mirror for θ‡ͺηŸ₯ (self-knowing). Its goal is not to manage you. It is to help you see yourself clearly. Once a month, PAC should ask a question that makes you pause, silent for 30 seconds, unable to immediately answer.

That 30 seconds of silence is where growth begins.

Full spec: docs/PAC_SPEC.md


What Enso Adds

Enso is a plugin, not a platform. It adds discipline to your existing agent without replacing anything.

What Enso addsWhat your host agent handles
Code-enforced error learningContext management
Active forgetting (stale decay, LRU)Multi-model orchestration
Immutable self-protection (3 hooks)Platform integrations
Knowledge quality checks (weekly lint)Tool execution
πŸͺž PAC β€” AI that initiates, not just respondsQuery-response dialogue
What Enso enforces (blocks violations)What Enso audits (logs + warns)
Self-protection: agent can't modify its own hooksWrite verification: tracks unverified writes
Safety scan: blocks secrets/injection in memory filesMemory budget: warns when MEMORY.md is too large

Enso doesn't replace your agent. It makes it more disciplined. Like SELinux for your AI β€” invisible when things go right, invaluable when they go wrong. Your agent keeps doing what it does best (context, tools, models). Enso adds the layer it's missing: learning from failure, forgetting what's stale, and protecting its own rules from itself.

Works With

CapabilityClaude CodeGemini CLIHermesOpenClawGeneric
Error capture + distillationβœ…βœ…βœ…βœ…βœ…
Lesson injection (SessionStart)βœ…βœ…βœ…βœ…βœ…
Tool call tracingβœ…βœ…βœ…βœ…βœ…
Active forgetting + maintenanceβœ…βœ…βœ…βœ…βœ…
Self-protection (core-readonly)βœ…βœ…β€”β€”β€”
Memory safety scanβœ…βœ…β€”β€”β€”
Memory budget guardβœ…βœ…β€”β€”β€”
Write verification auditβœ…βœ…β€”β€”β€”

Pre-tool-use hooks (self-protection, safety scan, budget guard, write verification) require the framework to support a "before tool execution" lifecycle event. Hermes, OpenClaw, and generic targets get the full learning + forgetting loop but not the guard layer.

Your Agent (Claude Code / Hermes / OpenClaw / Gemini CLI / ...)
       ↕ every tool call passes through
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Enso Discipline Layer        β”‚
β”‚  πŸ”’ Can't skip  🧠 Learns  πŸ—‘οΈ Forgets β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How It Works

Enso Architecture

12 hooks, 5 layers. The agent can't skip what code enforces.

LayerHooksWhat they do
Immutable3Write must verify. Can't modify own rules. Session-end audit.
Learning3Log every tool call. Capture errors. Distill lessons via LLM.
Memory1Inject lessons + knowledge + wisdom into next session.
Guard3Memory budget cap. Block secrets/injection. Auto-maintenance.
πŸͺž PAC2Scan for self-limiting patterns. Inject pending challenges.

The two loops:

Error loop:     Error -> Capture -> Distill -> Store -> Inject -> Avoid (reactive)
PAC loop:       Pattern -> Classify -> Challenge -> Silence -> Observe answer (proactive)

Forgetting

Most memory systems only grow. Enso actively forgets β€” because not forgetting is more dangerous.

MechanismWhat it does
Stale decayLessons unused >37 days deleted
LRU evictionOver 50 lessons, oldest evicted
MEMORY.md downsinkCompleted items archived
Trace rotation>14 days deleted (daily cron)
Recovery safety netDeleted lesson reappears as error, flagged

Health Check

enso-lint.sh runs weekly β€” like CI for your knowledge base:

CheckWhat it finds
OrphansLessons never used (hits:0, >7 days)
Duplicates>60% keyword overlap between lessons
Weak lessonsNo actionable verb β€” not useful
BudgetMEMORY.md capacity status

Every distillation auto-rebuilds lessons/INDEX.md for fast routing.

Architecture

~/.enso/
β”œβ”€β”€ core/                          # Shared modules
β”‚   β”œβ”€β”€ env.sh                     # Paths, enso_parse(), enso_find_memory_file()
β”‚   β”œβ”€β”€ parse-hook-input.py        # JSON parser for all hooks
β”‚   β”œβ”€β”€ dikw-utils.py              # DIKW operations (7 subcommands)
β”‚   β”œβ”€β”€ enso-lint.sh               # Weekly health check
β”‚   β”œβ”€β”€ rebuild-index.py           # Auto-rebuild INDEX.md
β”‚   β”œβ”€β”€ deleted-lessons-tracker.py # Recovery safety net
β”‚   β”œβ”€β”€ pac-analyzer.py            # πŸͺž 5-pattern self-limiting detection
β”‚   └── pac-question-generator.py  # πŸͺž Socratic challenge generation
β”œβ”€β”€ hooks/                         # 12 lifecycle hooks
β”‚   β”œβ”€β”€ pre-tool-use/              # core-readonly, budget-guard, safety-scan
β”‚   β”œβ”€β”€ post-tool-use/             # physical-verification, trace-emission
β”‚   β”œβ”€β”€ post-tool-use-failure/     # error-seed-capture
β”‚   β”œβ”€β”€ stop/                      # audit, distill, maintenance, pac-challenge
β”‚   └── session-start/             # load-lessons, pac-pending-check
β”œβ”€β”€ dikw/                          # DIKW distillation (Info -> Knowledge -> Wisdom)
β”œβ”€β”€ pac/                           # πŸͺž Pending challenges + history + rate state
β”œβ”€β”€ traces/                        # Tool call logs + lint reports
└── lessons/                       # active.md + INDEX.md
Philosophy: "Constraints are the foundation of flexibility"

Like biological evolution: DNA provides immutable constraints (protein folding physics), but within those constraints, life finds infinite creative solutions.

  • 3 immutable hooks = the foundation (never changes)
  • Everything else = free to evolve
  • Active forgetting = prevents calcification

Built from 100+ papers analyzed over 5 months:

SourceKey Insight
OpenAI Harness EngineeringRules in code, not prompts
Agent Lightning (Microsoft)Trace/Span + Hook/Emission dual layer
fireworks-skill-memory200 lines of hooks > 800 lines of prompt
SWE-agent (NeurIPS 2024)Constrained interfaces reduce errors
The Survival Experiment

This project's GitHub metrics are its evolutionary fitness signal:

  • Stars = survival ("this is useful")
  • Forks = reproduction ("I'm building on this")
  • Issues = selection pressure ("improve this")

The agent maintaining this repo monitors these signals. If the system works, it thrives. If not, it dies.

FAQ

Q: What agents does this work with? Five targets out of the box: Claude Code (default, fully tested), Gemini CLI, Hermes Agent, OpenClaw, and a generic target for any agent with lifecycle hooks.

Q: Does Enso compete with Mem0, Hermes memory, or OpenClaw Dreaming? No. Those are memory systems β€” they store facts and context. Enso is a discipline system β€” it enforces error learning, active forgetting, and self-protection. They are complementary.

Q: Can I use Hermes memory + Enso together? Yes, that's exactly the point. Hermes handles context and skill creation. Enso adds code-enforced error capture, stale decay, and immutable self-protection on top. Same with Claude Code's Auto Memory or OpenClaw's Dreaming.

Q: Where is my data stored? 100% local. ~/.enso/ on your machine. No cloud, no Docker, no database.

Q: What are the prerequisites? bash and python3 (3.6+). Both are pre-installed on macOS and most Linux distros. No pip install, no npm, no Docker.

Q: Do I need to configure anything after install? No. bash install.sh registers all hooks. Next session, it starts learning.

Q: Why not just use my agent's built-in memory? Built-in memory stores facts. Enso adds what's missing: code-enforced error learning, active forgetting with quality checks, and immutable self-protection hooks that the agent cannot bypass.

Q: Is PAC just another nagging notification system? No. PAC has five anti-fatigue layers: max 1/day, max 3/week, 7-day same-topic silence, 1-month cooldown after 3 rejections, and a confidence threshold that defaults to 0.70. Most sessions trigger zero PAC challenges. When one does trigger, it's because five independent checks all agreed.

Q: What if PAC challenges something I already thought through? PAC distinguishes constraint-optimal choices (don't challenge) from self-limiting ones (must challenge). When uncertain, it stays silent. If it ever misfires, you can dismiss and it enters cooldown on that pattern for 30 days.

Q: Does PAC send my data anywhere? No. Everything is local in ~/.enso/pac/. Pattern detection runs in Python on your machine. The Socratic question generator uses your existing LLM adapter chain (claude β†’ llm β†’ openai CLI). No telemetry.

Q: How do I disable PAC? export PAC_ENABLED=false in your shell rc. Or delete the two PAC hooks from ~/.claude/settings.json. The rest of Enso keeps working.

Contributing

See CONTRIBUTING.md. Most impactful:

  • Bug reports with repro steps
  • New hook ideas
  • Compatibility testing with other agents
  • DIKW pipeline improvements

License

MIT. See LICENSE.


The enso is drawn in a single stroke β€” imperfect, incomplete, beautiful.
This system will never be perfect. But it will always be evolving.

Files in the repo

Repository payloadβ€’13 top-level entries
  • .github
  • docs
  • examples
  • harness
  • memory
  • tests
  • .gitignore
  • CHANGELOG.md
  • CONTRIBUTING.md
  • install.sh
  • LICENSE
  • README.md
  • README.zh-CN.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More hooks

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

80k

Warcraft III Peon voice notifications (+ more!) for Claude Code, Codex, IDEs, and any AI agent. Stop babysitting your terminal. Employ a Peon today.

5k
bahni-m/
code-with-quran

Read the Qur'an while Claude Code works. Start a session with 'claude --cwq' and a reader beside it walks forward through the Qur'an one ayah per prompt, resuming where you left off β€” in a terminal pane or a browser tab. Zero dependencies, fully offline.

48
zachahn/
vomit

Clean up Claude's token vomit with a separate LLM. Save your tokens, Opus is hopeless

193

A pre-execution guard for AI coding agents. It blocks destructive Git and file system commands, plus common attempts to access sensitive files, before a tool call runs. Supports Amp Code, Antigravity CLI, Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, Grok Build, Hermes Agent, Kimi Code, OpenClaw, OpenCode, and Pi.

1.5k