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
20 changes: 20 additions & 0 deletions .agents/plugins/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "tdai-memory-local",
"interface": {
"displayName": "TencentDB Agent Memory Local"
},
"plugins": [
{
"name": "tdai-memory",
"source": {
"source": "local",
"path": "./plugins/tdai-memory"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_INSTALL"
},
"category": "Productivity"
}
]
}
20 changes: 20 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
"name": "tdai-memory-local",
"description": "Local TencentDB Agent Memory plugins for Claude Code.",
"owner": {
"name": "TencentDB Agent Memory"
},
"plugins": [
{
"name": "tdai-memory-claude-code",
"description": "Connect Claude Code to TencentDB Agent Memory through MCP lookup tools and agent hooks.",
"author": {
"name": "TencentDB Agent Memory"
},
"category": "productivity",
"source": "./plugins/tdai-memory-claude-code",
"homepage": "https://github.com/TencentDB/TencentDB-Agent-Memory"
}
]
}
6 changes: 6 additions & 0 deletions packages/tdai-memory-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__/
.pytest_cache/
.venv/
*.egg-info/
*.pyc
*.log
63 changes: 63 additions & 0 deletions packages/tdai-memory-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# TencentDB Agent Memory Hook CLI

This project is the hook-facing CLI adapter for TencentDB Agent Memory Gateway.
It is intentionally separate from the MCP server project and from Codex
workspace installation logic.
It assumes Gateway is already running and does not start, stop, supervise, or
watch the Gateway process.

Commands:

```bash
tdai-memory prefetch --query "..." --session-key "..."
tdai-memory sync-turn --user-content "..." --assistant-content "..." --session-key "..."
tdai-memory end-session --session-key "..."
tdai-memory session-start
```

Hook wrapper commands read hook event JSON from stdin and call the commands above:

```bash
tdai-memory-hook prefetch
tdai-memory-hook sync-turn
tdai-memory-hook end-session
tdai-memory-hook session-start
```

See `examples/hooks.json`, `examples/codex/hooks.json`, and
`examples/claude-code/hooks.json` for command-hook configuration templates.
Hook failures are non-blocking by default; set `TDAI_HOOK_STRICT=1` to return
non-zero on Gateway or parsing failures.
Set `TDAI_HOOK_LOG=/path/to/hooks.jsonl` to append lightweight diagnostics for
hook invocation tests. The Codex installer defaults this to
`~/.codex/tdai-memory/logs/hooks.jsonl`.

`session-start` does not write `AGENTS.md` or `CLAUDE.md`. Prompt-file updates
belong to an explicit installer/plugin step, not to runtime hooks. Other
commands send requests to the configured Gateway URL and report errors if
Gateway is unavailable.

Gateway request configuration:

```bash
TDAI_GATEWAY_URL=http://127.0.0.1:8420
TDAI_GATEWAY_API_KEY=
TDAI_SESSION_KEY=
TDAI_USER_ID=
TDAI_REQUEST_TIMEOUT_MS=30000
```

Run from source:

```bash
cd packages/tdai-memory-cli
python3 -m tdai_memory_cli prefetch --query "..."
```

Tests:

```bash
python3 -m pytest tests/unit -q
# Requires an already running Gateway at TDAI_GATEWAY_URL.
TDAI_MEMORY_CLI_E2E=1 python3 -m pytest tests/e2e -q
```
38 changes: 38 additions & 0 deletions packages/tdai-memory-cli/examples/claude-code/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"description": "TencentDB Agent Memory agent hooks for Claude Code",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=SessionStart TDAI_GATEWAY_URL=http://127.0.0.1:8421 TDAI_USER_ID=claude-code TDAI_HOOK_LOG=<home>/.claude/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook session-start",
"timeout": 60
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=UserPromptSubmit TDAI_GATEWAY_URL=http://127.0.0.1:8421 TDAI_USER_ID=claude-code TDAI_HOOK_LOG=<home>/.claude/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook prefetch",
"timeout": 30
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=Stop TDAI_GATEWAY_URL=http://127.0.0.1:8421 TDAI_USER_ID=claude-code TDAI_HOOK_LOG=<home>/.claude/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook sync-turn",
"timeout": 60
}
]
}
]
}
}
42 changes: 42 additions & 0 deletions packages/tdai-memory-cli/examples/codex/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"description": "TencentDB Agent Memory agent hooks for Codex",
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=SessionStart TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_USER_ID=codex TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook session-start",
"timeout": 60,
"statusMessage": "Checking TDAI memory Gateway"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=UserPromptSubmit TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_USER_ID=codex TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook prefetch",
"timeout": 30,
"statusMessage": "Prefetching TDAI memory"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_MEMORY_HOOK_MARKER=Stop TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_USER_ID=codex TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook sync-turn",
"timeout": 60,
"statusMessage": "Capturing TDAI memory turn"
}
]
}
]
}
}
37 changes: 37 additions & 0 deletions packages/tdai-memory-cli/examples/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook session-start",
"timeout": 60
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook prefetch",
"timeout": 30
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "TDAI_GATEWAY_URL=http://127.0.0.1:8420 TDAI_HOOK_LOG=<home>/.codex/tdai-memory/logs/hooks.jsonl PYTHONPATH=<repo>/packages/tdai-memory-cli python3 -m tdai_memory_cli.hook sync-turn",
"timeout": 60
}
]
}
]
}
}
57 changes: 57 additions & 0 deletions packages/tdai-memory-cli/examples/skills/tdai-memory/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: tdai-memory
description: Use when working with TencentDB Agent Memory, including memory recall, conversation capture, agent hooks, MCP lookup tools, and debugging the TDAI memory CLI.
version: 0.1.0
---

# TDAI Memory

TencentDB Agent Memory exposes long-term memory through two reusable surfaces:

- MCP tools for agent-facing memory lookup.
- Hook CLI commands for health checks, recall prefetch, capture, and flush.

## Choose The Surface

Use MCP tools for answering with memory:

- `tdai_memory_search`: search structured long-term memories.
- `tdai_conversation_search`: search raw conversation history.

Use CLI commands for hook behavior:

- `session-start`: check Gateway health for the hook runtime.
- `prefetch`: recall memory context for a user query.
- `sync-turn`: capture a completed user/assistant turn.
- `end-session`: flush session pipeline work.

Do not use CLI commands as a substitute for MCP lookup unless debugging the adapter.

## CLI Commands

```bash
tdai-memory session-start
tdai-memory prefetch --query "<user prompt>"
tdai-memory sync-turn \
--user-content "<user message>" \
--assistant-content "<assistant response>"
tdai-memory end-session
```

Use hook wrappers when reading agent hook JSON from stdin:

```bash
tdai-memory-hook session-start
tdai-memory-hook prefetch
tdai-memory-hook sync-turn
tdai-memory-hook end-session
```

Hook failures are non-blocking by default. Set `TDAI_HOOK_STRICT=1` only for tests or debugging.

## Rules

- Prefer MCP tools when using memory to answer a user question.
- Use CLI commands for health checks, capture, and flush.
- Keep `AGENTS.md` or `CLAUDE.md` updates in an explicit installer/plugin step, not runtime hooks.
- Do not store dynamic recall results in `AGENTS.md` or `CLAUDE.md`.
22 changes: 22 additions & 0 deletions packages/tdai-memory-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"

[project]
name = "tdai-memory-cli"
version = "0.1.0"
description = "Hook CLI adapter for TencentDB Agent Memory Gateway."
requires-python = ">=3.10"
dependencies = []

[project.scripts]
tdai-memory = "tdai_memory_cli.__main__:main"
tdai-memory-hook = "tdai_memory_cli.hook:main"

[tool.setuptools.packages.find]
include = ["tdai_memory_cli*"]
exclude = ["tests*", "vibe*"]

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["."]
3 changes: 3 additions & 0 deletions packages/tdai-memory-cli/tdai_memory_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""TencentDB Agent Memory hook CLI adapter."""

__version__ = "0.1.0"
Loading