How codexhaven/codex-developer works
1. What this repository is
- This is not an application product; it is a project-building orchestration tool (“Codex Developer v12.6”) installed as a Hermes skill.
- Its job is to take a natural-language request, research the target domain, generate or modify a project, validate it, optionally deploy it, and push it to GitHub.
2. Primary runtime and interfaces
- The repo is mostly Bash orchestration scripts with a few Python utilities.
- The main entry point is listen.sh, which runs in a Linux/macOS/Termux shell environment and depends on Git, Python 3.10+, and external tools like hermes, plus optional GitHub and Vercel credentials.
3. Request intake and mode routing
- listen.sh is the front door: it classifies the user request into modes such as NEW, GENERATE, EXISTING, REVIEW, CONTINUATION, CHECK, DEPLOY, and DIRECT.
- That mode decision determines whether the repo performs a full build, a targeted patch, a review-only scan, a continuation from queue state, or a deploy path.
4. Build engine and phase-gated execution
- runcycle.sh is the central build engine.
- It runs a phase-gated loop with retry limits, orchestrates build steps in order, and coordinates post-generation validation and push/deploy actions.
- The README describes this as the core “factory” loop, with a maximum cycle count and phase progression enforced by the orchestrator.
5. Research and architecture planning
- The sandbox/recon.sh and sandbox/architect.sh scripts form the research/planning boundary.
- recon.sh performs domain-aware analysis and generates a project brain / contract plan; architect.sh enforces phase gates and validates that the generated plan matches expected build contracts.
6. Hardening and code-shape enforcement
- sandbox/strengthen.sh is the hardening pass that re-checks generated files, import relationships, and structure.
- Supporting utilities like modules/enforce_path.py, modules/scan_deps.py, modules/map_project.py, and modules/import-check.sh help ensure generated code stays within allowed paths and has consistent dependency wiring.
7. Validation, contracts, and smoke checks
- Validation is a separate subsystem, not just a final test.
- Scripts such as modules/contract-import-check.sh, modules/symbol-check.sh, modules/failure-check.sh, modules/smoke-tester.sh, and modules/self-test.sh verify that generated code matches expected function/import contracts and is actually runnable.
- This is a key architectural boundary: generation is followed by structural checks before any deploy/push.
8. Self-healing loop
- modules/healer.sh coordinates failure recovery through healer_trace.sh, healer_analyze.sh, healer_fix.sh, and healer_reset.sh.
- The pipeline captures failure context, diagnoses likely root cause, applies a targeted repair, and resets state if needed.
- This subsystem is triggered when builds repeatedly fail, so recovery is part of the normal architecture rather than an exception path.
9. Stack-specific adapters for generated projects
- The repository includes stack plugins for different target project types: modules/vibestack, modules/flaskstack, and modules/vanillastack, each with an apply.sh.
- These act as specialization layers so the factory can generate different kinds of projects without changing the core orchestration flow.
- The README also mentions auto-detection and method adaptation, which means stack choice is a first-class routing concern.
10. External services and delivery
- GitHub integration is handled by scripts like modules/github-push.sh, and deployment support is provided by modules/vercel-deploy.sh.
- The repo expects credentials via environment variables such as GITHUB_TOKEN, GITHUB_USER, VERCEL_TOKEN, and OPENROUTER_KEY.
- These services materially affect the architecture because the factory can automatically push and optionally deploy generated work.
11. State, queues, and recovery boundaries
- Build state is persisted in .codex/ files such as the build queue and completion markers, with lock handling via /tmp files.
- This means the system is stateful across invocations: listen.sh can resume work via CONTINUATION, and recovery often starts by clearing queue/lock state.
- The repo also includes self-update.sh and related maintenance scripts, showing that the factory can manage its own lifecycle.
12. Knowledge assets and analysis helpers
- Files like global-knowledge.jsonl, patterns.json, failure-patterns.json, project-templates.json, and domain notes such as domain_knowledge_healthcare_ehr.txt provide prompt and pattern intelligence.
- Python analyzers like lesson-analyzer.py and opportunity-analyzer.py process prior runs and failure lessons to improve future builds.
- These are not app data stores; they are the factory’s “experience layer.”
13. Testing and verification
- The repository includes a small test suite under tests/, including mocks and tests/test_calc.py, which likely exercises a simple utility path and verifies the tooling itself.
- This supports the repo’s own reliability claims: the factory validates its core scripts before being trusted to generate or modify other projects.
14. How the pieces fit together
- The high-level flow is: request intake → mode selection → research/plan → phase-gated build → hardening/validation → self-heal if needed → push/deploy.
- The architectural boundary to emphasize is that this repo is a meta-build system: its outputs are external projects, while its own source tree is a coordinated orchestration and validation platform.
Main entry points: runcycle.sh Run Cycle · healer.sh Healer · strengthen.sh Strengthen · listen.sh Listen
Components 26
Orchestration
Front door and build-cycle control for the factory runtime.
Planning
Research, architecture, and project-shaping stages before generation.
Validation
Hardening, contract checks, smoke tests, and self-healing.
- Strengthen · Re-checks generated files, imports, and structure.
sandbox/strengthen.sh - Contract Check · Checks generated code against expected import/function contracts.
modules/contract-import-check.sh - Symbol Check · Verifies exported symbols and structural expectations.
modules/symbol-check.sh - Smoke Test · Runs basic execution checks against the generated project.
modules/smoke-tester.sh - Self Test · Validates the factory's own scripts and support paths.
modules/self-test.sh - Healer · Coordinates failure tracing, diagnosis, repair, and reset.
modules/healer.sh - Trace · Captures failure context for recovery analysis.
modules/healer_trace.sh - Analyze · Infers likely causes from failure traces and run history.
modules/healer_analyze.sh - Fix · Applies focused repairs to failing generated work.
modules/healer_fix.sh - Reset · Clears or rewinds state after repeated failure.
modules/healer_reset.sh
Adapters
Stack-specific specialization layers for generated projects.
- Vibe Stack · Specialized adapter for one target project style.
modules/vibestack/apply.sh - Flask Stack · Specialized adapter for Flask-style target projects.
modules/flaskstack/apply.sh - Vanilla Stack · Specialized adapter for minimal or framework-light projects.
modules/vanillastack/apply.sh
Delivery & State
External push/deploy integrations, persistent state, and knowledge assets.
- GitHub Push · Pushes generated work to GitHub.
modules/github-push.sh - Vercel Deploy · Deploys eligible generated projects to Vercel.
modules/vercel-deploy.sh - Review Queue · Moves review output into queued continuation state.
modules/review-to-queue.sh - Codex State · Queue, completion markers, and resume state under .codex/.
.codex - Knowledge · Patterns, lessons, templates, and domain notes used to guide future runs.
global-knowledge.jsonl - Lessons · Extracts lessons from prior runs and failures.
lesson-analyzer.py - Opportunities · Finds improvement opportunities from run history.
opportunity-analyzer.py
Connections 25
- Listen → Run Cycle: route mode · Request intake selects the build path and hands control to the cycle engine.
- Listen → Review Queue: continuation · Continuation and review modes can enqueue work for later execution.
- Run Cycle → Recon: plan · The build cycle begins with research and project shaping when needed.
- Run Cycle → Architect: gate · Plans are checked against phase and contract rules before generation proceeds.
- Run Cycle → Strengthen: harden · Generated output is re-scanned for path and shape issues.
- Run Cycle → Healer: recover · Repeated failures trigger recovery instead of immediate termination.
- Recon → Knowledge: consult · Research uses repository knowledge, patterns, and domain notes.
- Architect → Knowledge: validate against · Architecture decisions are compared with templates and known contracts.
- Strengthen → Contract Check: verify · Hardening runs contract-level checks on generated files.
- Strengthen → Symbol Check: verify · Hardening also checks symbol and structure expectations.
- Strengthen → Smoke Test: exercise · Runnable smoke tests confirm the project can execute.
- Self Test → Listen: trust · Factory self-tests validate the core orchestration scripts.
- Healer → Trace: capture · Recovery starts by collecting failure context.
- Healer → Analyze: diagnose · Captured traces are analyzed for likely root cause.
- Healer → Fix: repair · Targeted fixes are applied after diagnosis.
- Healer → Reset: reset · State is cleared or rewound when recovery needs a fresh start.
- Run Cycle → Vibe Stack: specialize · Stack detection can route generation through a Vibestack adapter.
- Run Cycle → Flask Stack: specialize · Stack detection can route generation through a Flask adapter.
- Run Cycle → Vanilla Stack: specialize · Stack detection can route generation through a Vanilla adapter.
- Run Cycle → GitHub Push: push · Successful builds can be published to GitHub.
- Run Cycle → Vercel Deploy: deploy · Deployable targets can be sent to Vercel.
- Review Queue → Codex State: persist · Queue state and resume markers are stored in .codex/.
- Listen → Codex State: resume · The front door can resume work from persisted state.
- Lessons → Knowledge: update · Lessons extracted from runs feed the experience layer.
- Opportunities → Knowledge: update · Opportunity analysis informs future build decisions.