Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle
.idea
.kotlin
build
build
**/.claude/settings.local.json
96 changes: 96 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This repository contains the Koan Agents framework, a Kotlin multiplatform library for building AI agents. The framework enables creating intelligent agents that interact with tools, handle complex workflows, and maintain context across conversations.

## Building and Testing

### Basic Commands

```bash
# Build the project
./gradlew assemble

# Compile test classes
./gradlew jvmTestClasses jsTestClasses

# Run all JVM tests
./gradlew jvmTest

# Run all JS tests
./gradlew jsTest

# Run a specific test class
./gradlew jvmTest --tests "fully.qualified.TestClassName"
# Example:
./gradlew jvmTest --tests "ai.grazie.code.agents.test.SimpleAgentIntegrationTest"

# Run a specific test method
./gradlew jvmTest --tests "fully.qualified.TestClassName.testMethodName"
# Example:
./gradlew jvmTest --tests "ai.grazie.code.agents.test.SimpleAgentIntegrationTest.simpleChatAgent should call default tools"
```

## Architecture

### Key Modules

1. **agents-core**: Core abstractions and interfaces
- AIAgent, AIAgentStrategy, event handling system

2. **agents-core-tools**: Tool infrastructure
- Tool, ToolRegistry, ToolDescriptor

3. **agents-local**: Local execution implementation
- KotlinAIAgent, execution strategies, session management

4. **agents-local-features**: Extensible agent capabilities
- Memory, tracing, and other features

5. **prompt**: LLM interaction layer
- LLM executors, prompt construction, structured data processing

### Core Concepts

- **Agents**: State-machine graphs with nodes that process inputs and produce outputs
- **Tools**: Encapsulated actions with standardized interfaces
- **Strategies**: Define agent behavior and execution flow
- **Features**: Installable extensions that enhance agent capabilities
- **Event Handling**: System for intercepting and processing agent lifecycle events

### Implementation Pattern

1. Define tools that agents can use
2. Register tools in the ToolRegistry
3. Configure agent with strategy
4. Set up communication (if integrating with external systems)

## Testing

The project has extensive testing support:

- **Mocking LLM responses**:
```kotlin
val mockLLMApi = getMockExecutor(toolRegistry, eventHandler) {
mockLLMAnswer("Hello!") onRequestContains "Hello"
mockLLMToolCall(CreateTool, CreateTool.Args("solve")) onRequestEquals "Solve task"
}
```

- **Mocking tool calls**:
```kotlin
mockTool(PositiveToneTool) alwaysReturns "The text has a positive tone."
```

- **Testing agent graph structure**:
```kotlin
testGraph {
assertStagesOrder("first", "second")
// ...
}
```

For detailed testing guidelines, refer to `agents/TESTING.md`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import ai.grazie.gradle.publish.maven.publishToGraziePublicMaven

group = "${rootProject.group}.prompt"
version = rootProject.version

plugins {
id("ai.kotlin.multiplatform")
alias(libs.plugins.kotlin.serialization)
}

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":agents:agents-core-tools"))
implementation(project(":prompt:prompt-executor:prompt-executor-clients"))
implementation(project(":prompt:prompt-llm"))
implementation(project(":prompt:prompt-model"))
implementation(libs.ai.grazie.utils.common)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
}
}

jvmMain {
dependencies {
implementation(libs.ktor.client.cio)
}
}

commonTest {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
}
}

jvmTest {
dependencies {
implementation(kotlin("test-junit5"))
}
}
}
}

publishToGraziePublicMaven()
Loading
Loading