tx

tx memory

Headless search over markdown directories — index, search, tag, and navigate your knowledge graph

Purpose

Memory provides filesystem-backed document search over markdown directories. Unlike learnings (which are structured records stored in SQLite), memory indexes your existing .md files — project notes, design docs, meeting notes, wikis — and makes them searchable via BM25 keyword search, vector similarity, and graph expansion through wikilinks and frontmatter relationships.

Documents are regular .md files with YAML frontmatter. tx indexes them; it does not own them. Your files stay where they are.

At A Glance

Memory Pipeline

Rendering diagram…
Register a markdown source once, index it into a searchable graph, then query that graph without moving your files into tx.

Search Mode

Rendering diagram…
Keep the search stack simple: start with BM25, add semantic matching for fuzzy recall, then add graph expansion when related docs matter.

Memory vs Learnings

Durable knowledge

tx memory

  • Long-form notes, runbooks, design docs, and linked markdown.
  • Searchable by BM25, semantic recall, and graph expansion.
  • Best when backlinks, wikilinks, and document structure matter.

Reusable insight

tx learning

  • Short patterns, pitfalls, reminders, and operator heuristics.
  • Surfaces directly in learning search and task context.
  • Best when the agent needs a concise hint, not a full document.
Distill a durable doc into a short learning when that knowledge also needs to surface intx contextand learning search.
Use memory for durable markdown docs. Use learnings for short reusable insights. Distill across both when task context and long-form retrieval both matter.

Commands

Source Management

CommandDescription
tx memory source add <dir>Register a directory for indexing
tx memory source rm <dir>Unregister a directory
tx memory source listShow registered directories

Document Management

CommandDescription
tx memory add <title>Create a new .md file
tx memory show <id>Display a document
tx memory listList indexed documents

Search & Indexing

CommandDescription
tx memory search <query>Search documents (BM25, vector, graph)
tx memory indexIndex all registered sources

Metadata

CommandDescription
tx memory tag <id> <tags...>Add tags to frontmatter
tx memory untag <id> <tags...>Remove tags from frontmatter
tx memory set <id> <key> <value>Set a frontmatter property
tx memory unset <id> <key>Remove a frontmatter property
tx memory props <id>Show all properties
tx memory relate <id> <target>Add to frontmatter.related

Graph Navigation

CommandDescription
tx memory links <id>Outgoing wikilinks + explicit edges
tx memory backlinks <id>Incoming links
tx memory link <source-id> <target-ref>Create an explicit edge

Key Concepts

Memory IDs

Every indexed document gets a deterministic ID in the format mem-<12 hex chars>, derived from SHA256(relativePath + rootDir). The same file always produces the same ID.

Memory supports three types of links between documents:

TypeSourceExample
wikilink[[page-name]] in document bodyAuto-detected during indexing
frontmatterrelated: array in YAML frontmatterManaged via tx memory relate
explicittx memory link commandManual graph edges

Reserved Frontmatter Keys

KeyManaged ByNotes
tagstx memory tag / tx memory untagArray of string tags
relatedtx memory relateArray of related document references
createdAuto-set on creationISO 8601 timestamp

All other frontmatter keys are user-defined and can be managed via tx memory set / tx memory unset.


Source Management

tx memory source add

Register a directory of markdown files for indexing.

tx memory source add <dir> [options]

Options:

OptionDescription
--label <name>Human-readable label for this source
--jsonOutput as JSON

Examples:

# Register a notes directory
tx memory source add ~/notes

# Register with a label
tx memory source add ./docs --label "Project Docs"

# Register and output JSON
tx memory source add ~/wiki --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

// Register a directory
const source = await tx.memory.sourceAdd('/Users/me/notes')
// Returns: { id, rootDir, label, createdAt }

// Register with a label
const docs = await tx.memory.sourceAdd('./docs', 'Project Docs')
console.log(`Registered: ${docs.rootDir} (${docs.label})`)
{
  "tool": "tx_memory_source_add",
  "arguments": {
    "dir": "/Users/me/notes",
    "label": "Project Notes"
  }
}

Parameters

ParameterRequiredDescription
dirYesAbsolute path to directory to register
labelNoHuman-readable label for this source
POST /api/memory/sources
Content-Type: application/json

{
  "dir": "/Users/me/notes",
  "label": "Project Notes"
}

Example

curl -X POST http://localhost:3456/api/memory/sources \
  -H "Content-Type: application/json" \
  -d '{"dir": "/Users/me/notes", "label": "Project Notes"}'

tx memory source rm

Unregister a directory. This removes the source from the index but does not delete any files.

tx memory source rm <dir> [options]

Options:

OptionDescription
--jsonOutput as JSON

Examples:

# Remove a source
tx memory source rm ~/old-notes

# Remove with JSON output
tx memory source rm ./archive --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.sourceRemove('/Users/me/old-notes')
{
  "tool": "tx_memory_source_rm",
  "arguments": {
    "dir": "/Users/me/old-notes"
  }
}

Parameters

ParameterRequiredDescription
dirYesDirectory path to unregister
DELETE /api/memory/sources
Content-Type: application/json

{
  "dir": "/Users/me/old-notes"
}

Example

curl -X DELETE http://localhost:3456/api/memory/sources \
  -H "Content-Type: application/json" \
  -d '{"dir": "/Users/me/old-notes"}'

tx memory source list

Show all registered source directories.

tx memory source list [options]

Options:

OptionDescription
--jsonOutput as JSON

Examples:

# List all sources
tx memory source list

# JSON output
tx memory source list --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const sources = await tx.memory.sourceList()
// Returns: Array<{ id, rootDir, label, createdAt }>

for (const src of sources) {
  console.log(`${src.rootDir} (${src.label ?? 'no label'})`)
}
{
  "tool": "tx_memory_source_list",
  "arguments": {}
}
GET /api/memory/sources

Example

curl http://localhost:3456/api/memory/sources

Document Management

tx memory add

Create a new .md file in a registered source directory.

tx memory add <title> [options]

Options:

OptionDescription
-c, --content <text>Initial document body content
-t, --tags <tags...>Tags to add to frontmatter
--prop <key=value>Set a frontmatter property (repeatable)
-d, --dir <path>Target source directory (defaults to first registered source)
--jsonOutput as JSON

Examples:

# Create a simple document
tx memory add "Meeting Notes 2024-01-15"

# Create with content and tags
tx memory add "Auth Architecture" \
  -c "## Overview\nJWT-based authentication with refresh tokens." \
  -t architecture auth

# Create with properties and target directory
tx memory add "Sprint Retro" \
  --prop sprint=42 --prop team=backend \
  -d ~/notes/retros

# Create and output JSON
tx memory add "API Design" -t api design --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const doc = await tx.memory.add({
  title: 'Auth Architecture',
  content: '## Overview\nJWT-based authentication with refresh tokens.',
  tags: ['architecture', 'auth'],
  properties: { status: 'draft', sprint: '42' },
  dir: '/Users/me/notes',
})
// Returns: { id, filePath, rootDir, title, content, tags, ... }

console.log(`Created: ${doc.id} at ${doc.filePath}`)
{
  "tool": "tx_memory_add",
  "arguments": {
    "title": "Auth Architecture",
    "content": "## Overview\nJWT-based authentication with refresh tokens.",
    "tags": ["architecture", "auth"],
    "properties": { "status": "draft" },
    "dir": "/Users/me/notes"
  }
}

Parameters

ParameterRequiredDescription
titleYesDocument title (used to generate filename)
contentNoInitial body content
tagsNoFrontmatter tags
propertiesNoKey-value properties for frontmatter
dirNoTarget directory (default: first registered source)
POST /api/memory/documents
Content-Type: application/json

{
  "title": "Auth Architecture",
  "content": "## Overview\nJWT-based authentication with refresh tokens.",
  "tags": ["architecture", "auth"],
  "properties": { "status": "draft" }
}

Example

curl -X POST http://localhost:3456/api/memory/documents \
  -H "Content-Type: application/json" \
  -d '{"title": "Auth Architecture", "tags": ["architecture", "auth"]}'

tx memory show

Display a document's content and metadata.

tx memory show <id> [options]

Options:

OptionDescription
--jsonOutput as JSON

Examples:

# Show a document
tx memory show mem-a1b2c3d4e5f6

# Show as JSON
tx memory show mem-a1b2c3d4e5f6 --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const doc = await tx.memory.show('mem-a1b2c3d4e5f6')
// Returns: { id, filePath, rootDir, title, content, tags, frontmatter, ... }

console.log(doc.title)
console.log(doc.content)
{
  "tool": "tx_memory_show",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID (e.g. mem-abc123def456)
GET /api/memory/documents/:id

Example

curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6

tx memory list

List indexed documents with optional filtering.

tx memory list [options]

Options:

OptionDescription
--source <dir>Filter by source directory
-t, --tags <tags...>Filter by tags
--jsonOutput as JSON

Examples:

# List all documents
tx memory list

# Filter by source
tx memory list --source ~/notes

# Filter by tags
tx memory list -t architecture design

# Combined filters with JSON
tx memory list --source ./docs -t api --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

// List all documents
const docs = await tx.memory.list()

// Filter by source and tags
const filtered = await tx.memory.list({
  source: '/Users/me/notes',
  tags: ['architecture'],
})
// Returns: Array<{ id, filePath, rootDir, title, content, tags, ... }>

for (const doc of filtered) {
  console.log(`${doc.id}: ${doc.title}`)
}
{
  "tool": "tx_memory_list",
  "arguments": {
    "source": "/Users/me/notes",
    "tags": ["architecture"]
  }
}

Parameters

ParameterRequiredDescription
sourceNoFilter by source directory path
tagsNoFilter by tags (documents must have all specified tags)
GET /api/memory/documents?source=/Users/me/notes&tags=architecture,auth

Example

# List all documents
curl http://localhost:3456/api/memory/documents

# Filter by source and tags
curl "http://localhost:3456/api/memory/documents?source=/Users/me/notes&tags=architecture"

Search & Indexing

Search documents using BM25 keyword search, vector similarity, or a combination with graph expansion. This is the primary command for querying the memory graph.

tx memory search <query> [options]

Options:

OptionDescription
-s, --semanticUse vector similarity search (requires embeddings)
-e, --expandExpand results via wikilinks and frontmatter.related
-t, --tags <tags...>Filter by tags
--prop <key=value>Filter by frontmatter property (repeatable)
-n, --limit <n>Maximum results (default: 10)
--min-score <n>Minimum relevance score 0-1
--jsonOutput as JSON

Search Modes:

ModeFlagHow it works
Keyword (BM25)(default)Full-text search with term frequency scoring
Semantic--semanticCosine similarity on embedding vectors
Expanded--expandFollow wikilinks and related edges from initial results
Combined--semantic --expandRRF (Reciprocal Rank Fusion) across all signals

Examples:

# Basic keyword search
tx memory search "authentication flow"

# Semantic similarity search
tx memory search "how does login work" --semantic

# Keyword search with graph expansion
tx memory search "database schema" --expand

# Combined: keyword + semantic + graph expansion
tx memory search "error handling patterns" --semantic --expand

# Filter by tags and properties
tx memory search "deployment" -t devops --prop env=production

# Limit results and set minimum score
tx memory search "react hooks" -n 5 --min-score 0.5

# JSON output for scripting
tx memory search "API design" --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

// Basic keyword search
const results = await tx.memory.search({ query: 'authentication flow' })

// Combined: semantic + graph expansion with filters
const expanded = await tx.memory.search({
  query: 'error handling patterns',
  semantic: true,
  expand: true,
  limit: 5,
  minScore: 0.3,
  tags: ['backend'],
  props: { env: 'production' },
})
// Returns: Array<{ id, title, content, relevanceScore, bm25Score, vectorScore, ... }>

for (const doc of expanded) {
  console.log(`[${doc.relevanceScore.toFixed(2)}] ${doc.title}`)
}
{
  "tool": "tx_memory_search",
  "arguments": {
    "query": "authentication flow",
    "semantic": true,
    "expand": true,
    "limit": 5,
    "tags": ["backend"]
  }
}

Parameters

ParameterRequiredDescription
queryYesSearch query text
limitNoMaximum results (default: 100)
minScoreNoMinimum relevance score 0-1
semanticNoEnable vector similarity search
expandNoEnable graph expansion via wikilinks
tagsNoFilter results by tags
propsNoFilter by properties (format: key=value or key)
GET /api/memory/search?query=authentication+flow&semantic=true&expand=true&limit=5

Example

# Basic keyword search
curl "http://localhost:3456/api/memory/search?query=authentication+flow"

# Combined search with filters
curl "http://localhost:3456/api/memory/search?query=error+handling&semantic=true&expand=true&limit=5&tags=backend"

Output

Search results for "authentication flow":

  1. [0.92] auth-architecture.md
     Tags: architecture, auth | Source: ~/notes
     JWT-based authentication with refresh token rotation...

  2. [0.78] login-flow.md
     Tags: auth, frontend | Source: ~/notes
     User enters credentials → API validates → issues token pair...

  3. [0.61] security-review.md
     Tags: security | Source: ~/docs
     OAuth2 PKCE flow recommended for SPA clients...

tx memory index

Index all registered source directories. Scans for .md files, parses frontmatter, extracts wikilinks, and updates the search index.

tx memory index [options]

Options:

OptionDescription
-i, --incrementalOnly re-index files that changed since last index (based on file hash)
--statusShow indexing status (file counts, coverage) without re-indexing
--jsonOutput as JSON

Examples:

# Full re-index
tx memory index

# Incremental index (skip unchanged files)
tx memory index --incremental

# Check indexing status
tx memory index --status

# Incremental with JSON output
tx memory index -i --json
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

// Full re-index
const result = await tx.memory.index()
// Returns: { indexed, skipped, removed }

console.log(`Indexed: ${result.indexed}, Skipped: ${result.skipped}`)

// Incremental index (only changed files)
const incremental = await tx.memory.index({ incremental: true })

// Check indexing status
const status = await tx.memory.indexStatus()
// Returns: { totalFiles, indexed, stale, embedded, links, sources }
{
  "tool": "tx_memory_index",
  "arguments": {
    "incremental": true
  }
}

Parameters

ParameterRequiredDescription
incrementalNoIf true, only re-index changed files

For index status, use:

{
  "tool": "tx_memory_index_status",
  "arguments": {}
}
POST /api/memory/index
Content-Type: application/json

{
  "incremental": true
}

Examples

# Full re-index
curl -X POST http://localhost:3456/api/memory/index

# Incremental index
curl -X POST http://localhost:3456/api/memory/index \
  -H "Content-Type: application/json" \
  -d '{"incremental": true}'

# Check indexing status
curl http://localhost:3456/api/memory/index/status

Metadata

tx memory tag

Add tags to a document's YAML frontmatter.

tx memory tag <id> <tags...>

Examples:

# Add a single tag
tx memory tag mem-a1b2c3d4e5f6 architecture

# Add multiple tags
tx memory tag mem-a1b2c3d4e5f6 backend api v2
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.tag('mem-a1b2c3d4e5f6', ['backend', 'api', 'v2'])
{
  "tool": "tx_memory_tag",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6",
    "tags": ["backend", "api", "v2"]
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
tagsYesTags to add
POST /api/memory/documents/:id/tags
Content-Type: application/json

{
  "tags": ["backend", "api", "v2"]
}

Example

curl -X POST http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/tags \
  -H "Content-Type: application/json" \
  -d '{"tags": ["backend", "api", "v2"]}'

tx memory untag

Remove tags from a document's YAML frontmatter.

tx memory untag <id> <tags...>

Examples:

# Remove a single tag
tx memory untag mem-a1b2c3d4e5f6 draft

# Remove multiple tags
tx memory untag mem-a1b2c3d4e5f6 wip experimental
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.untag('mem-a1b2c3d4e5f6', ['wip', 'experimental'])
{
  "tool": "tx_memory_untag",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6",
    "tags": ["wip", "experimental"]
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
tagsYesTags to remove
DELETE /api/memory/documents/:id/tags
Content-Type: application/json

{
  "tags": ["wip", "experimental"]
}

Example

curl -X DELETE http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/tags \
  -H "Content-Type: application/json" \
  -d '{"tags": ["wip", "experimental"]}'

tx memory set

Set a frontmatter property on a document. Writes to both the YAML frontmatter in the .md file and the database index.

tx memory set <id> <key> <value>

Examples:

# Set a string property
tx memory set mem-a1b2c3d4e5f6 status "reviewed"

# Set a numeric property
tx memory set mem-a1b2c3d4e5f6 priority 1

# Set a custom property
tx memory set mem-a1b2c3d4e5f6 owner "team-backend"
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.set('mem-a1b2c3d4e5f6', 'status', 'reviewed')
await tx.memory.set('mem-a1b2c3d4e5f6', 'owner', 'team-backend')
{
  "tool": "tx_memory_set",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6",
    "key": "status",
    "value": "reviewed"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
keyYesProperty key
valueYesProperty value
PUT /api/memory/documents/:id/props/:key
Content-Type: application/json

{
  "value": "reviewed"
}

Example

curl -X PUT http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/props/status \
  -H "Content-Type: application/json" \
  -d '{"value": "reviewed"}'

tx memory unset

Remove a frontmatter property from a document.

tx memory unset <id> <key>

Examples:

# Remove a property
tx memory unset mem-a1b2c3d4e5f6 status

# Remove a custom property
tx memory unset mem-a1b2c3d4e5f6 owner
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.unset('mem-a1b2c3d4e5f6', 'status')
{
  "tool": "tx_memory_unset",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6",
    "key": "status"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
keyYesProperty key to remove
DELETE /api/memory/documents/:id/props/:key

Example

curl -X DELETE http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/props/status

tx memory props

Show all frontmatter properties for a document.

tx memory props <id>

Examples:

tx memory props mem-a1b2c3d4e5f6

Output

Properties for mem-a1b2c3d4e5f6 (auth-architecture.md):

  tags:     architecture, auth
  created:  2024-01-15T10:30:00Z
  status:   reviewed
  owner:    team-backend
  related:  login-flow.md, token-refresh.md
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const props = await tx.memory.props('mem-a1b2c3d4e5f6')
// Returns: Record<string, string>

for (const [key, value] of Object.entries(props)) {
  console.log(`${key}: ${value}`)
}
{
  "tool": "tx_memory_props",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
GET /api/memory/documents/:id/props

Example

curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/props

tx memory relate

Add a target document to a document's frontmatter.related array. This creates a frontmatter link type in the graph.

tx memory relate <id> <target>

Examples:

# Relate two documents
tx memory relate mem-a1b2c3d4e5f6 mem-f6e5d4c3b2a1

# Relate by filename
tx memory relate mem-a1b2c3d4e5f6 login-flow.md
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.relate('mem-a1b2c3d4e5f6', 'mem-f6e5d4c3b2a1')

// Or relate by filename
await tx.memory.relate('mem-a1b2c3d4e5f6', 'login-flow.md')
{
  "tool": "tx_memory_relate",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6",
    "target": "login-flow.md"
  }
}

Parameters

ParameterRequiredDescription
idYesSource memory document ID
targetYesTarget reference (document ID, title, or filename)
POST /api/memory/documents/:id/relate
Content-Type: application/json

{
  "target": "login-flow.md"
}

Example

curl -X POST http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/relate \
  -H "Content-Type: application/json" \
  -d '{"target": "login-flow.md"}'

Graph Navigation

Show outgoing links from a document, including wikilinks parsed from the body and explicit edges.

tx memory links <id>

Examples:

tx memory links mem-a1b2c3d4e5f6

Output

Outgoing links from auth-architecture.md:

  [wikilink]    → login-flow.md
  [wikilink]    → token-refresh.md
  [frontmatter] → security-review.md
  [explicit]    → oauth2-spec.md
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const links = await tx.memory.links('mem-a1b2c3d4e5f6')
// Returns: Array<{ id, sourceDocId, targetDocId, targetRef, linkType, createdAt }>

for (const link of links) {
  console.log(`[${link.linkType}] → ${link.targetRef}`)
}
{
  "tool": "tx_memory_links",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
GET /api/memory/documents/:id/links

Example

curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/links

Show incoming links to a document from other documents.

tx memory backlinks <id>

Examples:

tx memory backlinks mem-a1b2c3d4e5f6

Output

Incoming links to auth-architecture.md:

  [wikilink]    ← api-design.md
  [frontmatter] ← security-overview.md
  [explicit]    ← onboarding-guide.md
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

const backlinks = await tx.memory.backlinks('mem-a1b2c3d4e5f6')
// Returns: Array<{ id, sourceDocId, targetDocId, targetRef, linkType, createdAt }>

for (const link of backlinks) {
  console.log(`[${link.linkType}] <- ${link.sourceDocId}`)
}
{
  "tool": "tx_memory_backlinks",
  "arguments": {
    "id": "mem-a1b2c3d4e5f6"
  }
}

Parameters

ParameterRequiredDescription
idYesMemory document ID
GET /api/memory/documents/:id/backlinks

Example

curl http://localhost:3456/api/memory/documents/mem-a1b2c3d4e5f6/backlinks

Create an explicit edge between two documents. This is a manual graph connection that persists independently of document content.

tx memory link <source-id> <target-ref>

Examples:

# Link by memory ID
tx memory link mem-a1b2c3d4e5f6 mem-f6e5d4c3b2a1

# Link by filename reference
tx memory link mem-a1b2c3d4e5f6 deployment-guide.md
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

await tx.memory.link('mem-a1b2c3d4e5f6', 'mem-f6e5d4c3b2a1')

// Or link by filename
await tx.memory.link('mem-a1b2c3d4e5f6', 'deployment-guide.md')
{
  "tool": "tx_memory_link",
  "arguments": {
    "sourceId": "mem-a1b2c3d4e5f6",
    "targetRef": "deployment-guide.md"
  }
}

Parameters

ParameterRequiredDescription
sourceIdYesSource memory document ID
targetRefYesTarget reference (document ID, title, or filename)
POST /api/memory/links
Content-Type: application/json

{
  "sourceId": "mem-a1b2c3d4e5f6",
  "targetRef": "deployment-guide.md"
}

Example

curl -X POST http://localhost:3456/api/memory/links \
  -H "Content-Type: application/json" \
  -d '{"sourceId": "mem-a1b2c3d4e5f6", "targetRef": "deployment-guide.md"}'

Agent Workflow

#!/bin/bash
# Agent uses memory to find relevant context before starting a task

TASK=$(tx ready --json --limit 1 | jq -r '.[0].id')
TITLE=$(tx show "$TASK" --json | jq -r '.title')

# Search memory for relevant documents
CONTEXT=$(tx memory search "$TITLE" --semantic --expand --json)

# Feed context into the agent prompt
claude --print "
Task: $TASK$TITLE
Relevant docs: $CONTEXT
Read CLAUDE.md, implement the task, then run tx done $TASK
"

# After completing the task, create a memory document with findings
tx memory add "Implementation Notes: $TITLE" \
  -c "## Approach\n...\n## Decisions\n..." \
  -t implementation "$(echo "$TITLE" | tr ' ' '-')"

Memory vs Learnings

Featuretx memorytx learning
StorageFilesystem (.md files)SQLite database
OwnershipYour files, tx indexes themtx owns the records
StructureYAML frontmatter + markdown bodyFlat text with category
NavigationGraph (wikilinks, related, edges)Flat list
SearchBM25 + vector + graph expansionBM25 + vector + recency
Best forProject docs, notes, wikisShort insights, patterns, mistakes

Use memory for rich, structured documents with relationships. Use learnings for quick insights that should surface in tx context.

On this page