Skip to content

feat: pre-chat hook for deterministic boot context injection #82

@dimakis

Description

@dimakis

Problem

Mitzo currently relies on a static systemPrompt.append string that tells the model to read CLAUDE.md and .cursor/rules/ for project context.

That is weaker than Claude Code's startup path in mgmt, where a SessionStart hook runs a generator and injects the resulting boot context directly as additionalContext.

Current Mitzo behavior means:

  • project context is only loaded if the model decides to read the right files
  • startup context quality varies by session
  • generated boot bundles like mgmt/.cursor/rules/boot-context.mdc are only consumed indirectly
  • Mitzo remains behind Cursor / Claude Code for deterministic startup behavior

Current Reference

In mgmt, Claude Code startup runs:

  • .claude/hooks/inject-boot-context.sh
  • which calls python3 scripts/build_boot_context.py --json
  • which emits deterministic startup context from canonical source files

Mitzo currently does this instead in server/chat.ts:

  • append a static instruction to read CLAUDE.md and .cursor/rules/

Proposal

Add a pre-chat startup hook / prompt assembly step in Mitzo that can:

  1. detect a repo-local context generator or boot hook
  2. execute it before query()
  3. inject the returned context directly into systemPrompt.append (or equivalent startup prompt layer)
  4. fall back to the current "read CLAUDE.md and .cursor/rules/" instruction when no generator exists

For mgmt, that would mean calling something like:

  • python3 scripts/build_boot_context.py --json

Why This Is Better

  • deterministic startup context across sessions
  • parity with Claude Code behavior
  • no dependence on the model remembering to read the right files
  • allows repo-specific compiled boot context without hardcoding mgmt logic into Mitzo
  • good stepping stone toward a fuller context-assembler later

Constraints

  • Must stay repo-agnostic: not every repo will have scripts/build_boot_context.py
  • Must fail soft: if the hook/generator errors, Mitzo should still start the chat
  • Should avoid double-loading context by injecting generated boot content and also telling the model to re-read the same files unnecessarily
  • Keep existing concise Mitzo mobile-specific instructions

Acceptance Criteria

  • Mitzo supports an optional pre-chat context hook/generator call before query()
  • For repos that expose a generator/hook, the returned context is injected automatically
  • For repos without one, Mitzo preserves current behavior
  • Failure to run the generator does not block chat startup
  • Add one integration path for mgmt as the first concrete consumer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions