> For the complete documentation index, see [llms.txt](https://evo-5.gitbook.io/evo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://evo-5.gitbook.io/evo/api-reference/service-api.md).

# Service API

The Cordis plugin registers `ctx.evo` as a service for programmatic access within DeepSeek Harness.

## Core Methods

### remember

Stores a memory item.

```ts
await ctx.evo.remember({
  scope: { type: 'project', id: '/workspace/app' },
  kind: 'constraint',
  title: 'Verification',
  content: 'Run the full check command before reporting completion.',
  tags: ['workflow', 'ci']
})
```

### recall

Retrieves memories matching criteria.

```ts
const items = await ctx.evo.recall({
  scopes: [
    { type: 'global' },
    { type: 'project', id: '/workspace/app' }
  ],
  text: 'verification',
  kinds: ['constraint', 'procedure'],
  limit: 20
})
```

### consolidate

Merges and cleans up memories in a scope.

```ts
const result = await ctx.evo.consolidate({
  type: 'project',
  id: '/workspace/app'
})

console.log(`Consolidated: ${result.before} → ${result.after} items`)
```

### importWorkspace

Imports workspace files into project memory.

```ts
await ctx.evo.importWorkspace('/workspace/app', { force: true })
```

## Interfaces

The core exports these interfaces for custom implementations:

### MemoryStore

```ts
interface MemoryStore {
  list(query: MemoryQuery): Promise<MemoryItem[]>
  get(id: string): Promise<MemoryItem | null>
  put(item: MemoryItem): Promise<void>
  delete(id: string): Promise<void>
  replace(scope: MemoryScope, items: MemoryItem[]): Promise<void>
}
```

### ModelRunner

```ts
interface ModelRunner {
  stream(prompt: string, options?: StreamOptions): AsyncIterable<string>
}
```

### MemoryMaterializer

```ts
interface MemoryMaterializer {
  materialize(items: MemoryItem[], target: string): Promise<void>
}
```

### MemoryEventSink

```ts
interface MemoryEventSink {
  emit(event: MemoryEvent): void
}
```

## Type Definitions

### MemoryScope

```ts
type MemoryScopeType = 'global' | 'user' | 'project' | 'session' | 'conversation'

interface MemoryScope {
  type: MemoryScopeType
  id?: string
}
```

### MemoryItem

```ts
interface MemoryItem {
  id: string
  scope: MemoryScope
  kind: 'fact' | 'constraint' | 'procedure' | 'skill'
  title: string
  content: string
  tags: string[]
  source: MemorySource
  createdAt: Date
  updatedAt: Date
  uses: number
}
```

### MemoryQuery

```ts
interface MemoryQuery {
  scopes?: MemoryScope[]
  kinds?: string[]
  text?: string
  tags?: string[]
  limit?: number
}
```

## Provider-Neutral Design

The domain model depends only on these interfaces. SQLite and DeepSeek Harness are implementations, not dependencies:

* `SQLiteMemoryStore` implements `MemoryStore`
* Harness adapter implements `ModelRunner` via `ctx.llm.stream()`

This allows replacing storage or model backend without changing the core memory logic.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://evo-5.gitbook.io/evo/api-reference/service-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
