A TypeScript-based conversational agent that walks users through the Field Diagnostic Protocol from the Lichen Protocol system.
The Field Diagnostic Protocol helps surface the invisible field currently shaping your behavior, decisions, and emotional stance. This agent guides you through 6 themes to identify the systemic pressures and patterns you're living inside—so you can see clearly what is holding you, rather than mistaking it for personal failure or strength.
-
ENTRY Mode: Provides orientation
- Presents protocol purpose, why it matters, when to use it, and expected outcomes
- Ends with an invitation to walk the protocol step by step
- No theme-level content
-
WALK Mode: Steps through themes one at a time
- Guides through 6 themes with one question per turn
- Mirrors back user responses with Stone-aligned clarity
- Tracks completion and advances themes
-
CLOSE Mode: Field diagnosis
- Synthesizes answers across all themes
- Generates pattern-level field name (e.g., "Velocity Over Depth")
- Checks alignment with coherence or collapse
- Offers summary of the walk
- Intent Classifier (
src/classifier.ts): AI-powered intent detection that classifies user messages before retrieval - Protocol Parser (
src/protocol/parser.ts): Parses markdown protocol files with YAML frontmatter into structured chunks - Retrieval Registry (
src/tools/registry.ts): Retrieves appropriate chunks (ENTRY or WALK) based on mode - Composer (
src/composer/): Generates responses using Claude API with mode-specific system prompts - Agent Orchestrator (
src/agent.ts): Main state management and workflow coordination - CLI Interface (
src/index.ts): Interactive readline-based command-line interface
# Install dependencies
npm install
# Build TypeScript
npm run buildCreate a .env file:
ANTHROPIC_API_KEY=your_anthropic_api_key_herenpm run devnpm run server
# Server runs on http://localhost:3000For frontend integration, see INTEGRATION.md
Prometheus-compatible metrics are available at /metrics:
curl http://localhost:3000/metricsAvailable metrics include:
audit_events_total- Total audit events by type and operationaudit_ledger_height- Current ledger height (Merkle tree size)audit_signature_duration_ms- Cryptographic signature timingaudit_merkle_append_duration_ms- Merkle tree append timingaudit_verification_duration_ms- Receipt verification timingaudit_verification_failures_total- Failed verification countaudit_file_lock_wait_duration_ms- File lock wait timeaudit_file_lock_contention_total- Lock retry countaudit_key_age_days- Current signing key ageaudit_jwks_fetch_requests_total- JWKS endpoint requestsaudit_crash_recovery_temp_files_removed_total- Crash recovery events
See docs/specs/metrics.md for detailed metrics documentation and Grafana dashboard examples.
- exit or quit: End the session
- reset: Start over from the beginning
- state: View current session state (for debugging)
- help: Show help information
> What field am I in?
[Agent provides ENTRY orientation]
Would you like to walk that protocol step by step?
> Yes, walk me through it
[Agent enters WALK mode, Theme 1: Surface Behaviors]
What language am I using most often right now?
> I use language about shipping fast, hitting deadlines...
[Agent mirrors back, then advances]
> continue
[Agent moves to Theme 2: Felt Experience]
...
Run the test scenarios:
npm run testThe test suite includes:
- Greeting Test
- ENTRY Mode Test
- WALK Transition Test
- Continuity Test
- Full Walk Test (all 6 themes → CLOSE)
field-diagnostic-agent/
├── package.json
├── tsconfig.json
├── .env.example
├── README.md
├── API.md # API documentation
├── INTEGRATION.md # Frontend integration guide
├── test-frontend.html # Simple test interface
├── src/
│ ├── index.ts # CLI entry point
│ ├── server.ts # Express API server ✨ NEW
│ ├── agent.ts # Main orchestrator
│ ├── classifier.ts # Intent detection
│ ├── validator.ts # Response validation
│ ├── types.ts # Shared types
│ ├── protocol/
│ │ ├── parser.ts # Markdown → chunks
│ │ └── types.ts # Protocol types
│ ├── tools/
│ │ └── registry.ts # Retrieval tool
│ └── composer/
│ ├── prompts.ts # System prompts
│ ├── client.ts # Claude API integration
│ └── index.ts # Composer orchestrator
├── protocols/
│ └── field_diagnostic.md # Protocol file
└── test/
└── scenarios.ts # Test suite
- Surface Behaviors - Name visible habits and language patterns
- Felt Experience - Attend to how the body and emotions register the field
- Rewards and Punishments - Identify what the field rewards and punishes
- Source Stories - Uncover narratives and myths the field is built on
- Pressure Points - Examine how the field behaves under stress
- Naming the Field - Gather evidence and explicitly name the field
The agent voice is shaped by three Lichen Stones:
- Stone 4: Clarity Over Cleverness - Simple, not shallow
- Stone 5: Presence Is Productivity - Stillness is part of the work
- Stone 8: Integrity Is the Growth Strategy - Grow through alignment
- Never mix ENTRY and WALK chunks in one retrieval
- One question per turn in WALK mode
- Deterministic mode transitions after classifier
- Pattern-level field naming (not "The [X] Field" format)
- Stone-aligned voice throughout
- In-memory state only (no persistence)
- Fallback to ENTRY on ambiguity
Session state is tracked in-memory:
interface SessionState {
active_protocol: string | null;
mode: 'ENTRY' | 'WALK' | 'CLOSE';
theme_index: number | null;
last_completion_confirmed: boolean;
resume_hint: 'awaiting_theme_completion' | 'ready_to_advance' | 'none';
last_answer_summary: string;
last_chunk_refs: string[];
}
Invariant — Memory enriches but never controls.
turn_counter: number;
emotion_last?: string;
field_diagnosed?: string;
updated_at: string;
}Before retrieval, user messages are classified into intents:
- discover: Wants orientation (e.g., "What field am I in?")
- walk: Begin/continue stepping through (e.g., "Walk me through it")
- memory: Continue from prior context (e.g., "continue", "next")
- none: Greeting/off-topic (e.g., "Hello")
Fallback rules ensure safe defaults when confidence is low.
The CLOSE mode generates pattern-level field names by abstracting user language:
- "ship or die" → Velocity Over Depth
- "always on" → Constant Availability
- "prove daily" → Continuous Proving
- "care invisible" → Invisible Labor
- "everything urgent" → Manufactured Urgency
This project is implementing the Lichen Protocol Memory Layer in phases, tracked via the Master Roadmap issue.
- Phase 0: ✅ Foundations and scaffolding (Completed)
- Phase 1.0: ✅ Cryptographic audit system with Ed25519 + Merkle + JWKS (Completed)
- Phase 1.1: 🔄 Governance & audit hardening (In Progress)
- CI validation gates, key rotation, metrics instrumentation
- Phase 2: 📋 Differential privacy & consent management (Planned)
- Phase 3: 📋 Federated learning integration (Planned)
- Phase 4: 📋 Constitutional governance (Planned)
- Phase 5: 📋 Public auditing & transparency reports (Planned)
- Memory enriches but never controls - Core invariant
- Cryptographic audit trails for all operations
- Consent-driven privacy with differential privacy guarantees
- Constitutional governance with human oversight
See the Master Roadmap issue (tracked in repository variables) for:
- Live progress tracking across all phases
- Child issue status (planned, in-progress, blocked, done)
- Recently completed items (last 7 days)
- Detailed phase breakdowns and checklists
The roadmap is automatically synced when issues are opened, closed, or labeled.
See CONTRIBUTING.md for:
- How to create child issues for phases/themes
- Label conventions and workflow
- Issue templates and PR process
- Development workflow and testing requirements
Related Documentation:
- CHANGELOG.md - Version history and changes
- docs/adr/ - Architecture Decision Records
- docs/specs/ - Specifications and feature docs
- docs/runbooks/ - Operational procedures
ISC
This is an experimental protocol agent implementing the Lichen Protocol Memory Layer.
For detailed contribution guidelines, roadmap workflow, and development setup, see CONTRIBUTING.md.
Feedback and improvements welcome!