Skip to content
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Check Formatting (Spotless)
run: mvn spotless:check

- name: Build and Verify (Tests + Coverage)
run: mvn clean verify

- name: Upload Coverage Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: target/site/jacoco/
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target/
*.class
.idea/
*.iml
.vscode/
*.log
.DS_Store
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to MemU Java SDK

Thank you for your interest in contributing to the MemU Java SDK! We welcome contributions from the community.

## Development Setup

1. **Java Version**: Ensure you have Java 21 installed.
2. **Maven**: This project uses Maven for dependency management and building.

## Coding Style

We use **Google Java Format** to maintain code consistency. This is enforced via the [Spotless Maven Plugin](https://github.com/diffplug/spotless).

Before committing your changes, please run the following command to automatically format your code:

```bash
mvn spotless:apply
```

If you do not run this, the CI build will fail during the formatting check.

## Running Tests

To run the unit and integration tests, use the standard Maven test command:

```bash
mvn test
```

To run the full verification suite (tests + code coverage + formatting check), run:

```bash
mvn clean verify
```

## Pull Requests

1. Fork the repository.
2. Create a feature branch (`git checkout -b feature/amazing-feature`).
3. Commit your changes.
4. Run `mvn spotless:apply` and `mvn verify` to ensure everything is correct.
5. Push to the branch (`git push origin feature/amazing-feature`).
6. Open a Pull Request.

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
# memU-sdk-java
# MemU Java SDK

![Build Status](https://github.com/nevamind-ai/memu-sdk-java/actions/workflows/ci.yml/badge.svg)
![Version](https://img.shields.io/badge/version-0.1.0--SNAPSHOT-blue)
![License](https://img.shields.io/badge/license-MIT-green)

The official Java SDK for MemU, an advanced memory storage and retrieval API for AI applications.

## Installation

Add the following dependency to your `pom.xml`:

```xml
<dependency>
<groupId>com.nevamind.ai</groupId>
<artifactId>memu-sdk-java</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
```

## Quick Start

Here is a complete example of how to initialize the client, create a memory, and search for it.

```java
import com.nevamind.memu.MemUClient;
import com.nevamind.memu.model.*;
import java.util.List;

public class MemUExample {
public static void main(String[] args) {
// 1. Initialize the client
String baseUrl = "https://api.memu.ai";
String apiKey = System.getenv("MEMU_API_KEY");

MemUClient client = new MemUClient(baseUrl, apiKey);

// 2. Create a Memory
MemoryItem memory = MemoryItem.builder()
.summary("The user prefers dark mode in their IDE.")
.memoryType(MemoryType.preference)
.build();

try {
boolean success = client.createMemory(memory);
System.out.println("Memory created: " + success);
} catch (Exception e) {
System.err.println("Failed to create memory: " + e.getMessage());
}

// 3. Search for Memories
SearchRequest request = SearchRequest.builder()
.queries(List.of("What IDE theme does the user like?"))
.limit(3)
.build();

try {
SearchResponse response = client.search(request);
response.getResults().forEach(result -> {
System.out.println("Found: " + result.getContent() + " (Score: " + result.getScore() + ")");
});
} catch (Exception e) {
System.err.println("Search failed: " + e.getMessage());
}
}
}
```

## Configuration

The `MemUClient` constructor requires two parameters:

| Parameter | Description | Example |
|-----------|-------------|---------|
| `baseUrl` | The URL of your MemU API instance. | `https://api.memu.ai` |
| `apiKey` | Your authentication token. | `mem_12345abcde` |

We recommend storing your API key in an environment variable (e.g., `MEMU_API_KEY`) rather than hardcoding it.

## Building from Source

To build the SDK and run tests locally, ensure you have **Java 21** and **Maven** installed.

```bash
# Clone the repository
git clone https://github.com/nevamind-ai/memu-sdk-java.git
cd memu-sdk-java

# Build and run integrity checks (Tests + Formatting + Coverage)
mvn clean verify
```

## Requirements

* Java 21 or higher
* Maven 3.6+
2 changes: 2 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
Empty file added null
Empty file.
136 changes: 136 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.nevamind.ai</groupId>
<artifactId>memu-sdk-java</artifactId>
<version>0.1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- HTTP Client -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>

<!-- JSON Processing -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.16.1</version>
</dependency>

<!-- Boilerplate Reduction -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.41.1</version>
<configuration>
<java>
<googleJavaFormat>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>${java.version}</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading