Skip to content

[FEATURE] show which entities do not have relations #762

Description

@phernandez

Add a cli utility to show which entities do not have relations

Activity

  1. claude commented on Apr 23, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 9m 29s —— View job • claude/issue-762-20260423-0204 • Create PR ➔


    Triage & Implementation Complete

    Classification: Feature request | Component: CLI + API | Priority: Medium | Complexity: Medium

    • Analyze issue and classify request
    • Explore codebase (CLI structure, entity/relation models)
    • Add find_without_relations method to EntityRepository
    • Add OrphanEntitiesResponse schema to schemas/v2/graph.py
    • Add GET /knowledge/orphans API endpoint
    • Add get_orphans method to KnowledgeClient
    • Create cli/commands/orphans.py CLI command
    • Register command in main.py and __init__.py
    • Add tests (repository, API endpoint, CLI)
    • Commit and push

    What was implemented

    New command: basic-memory orphans [--project NAME] [--json] [--local] [--cloud]

    Displays a table of entities that have no incoming or outgoing relations — isolated nodes in the knowledge graph. These may be newly created notes not yet linked to other entities, or notes whose relations were removed.

    Example output:

    test-project: Entities Without Relations (3 total)
    ┌──────────────────┬─────────────────────────┬───────┐
    │ Title            │ File Path               │ Type  │
    ├──────────────────┼─────────────────────────┼───────┤
    │ Meeting Notes    │ meetings/2024-01-15.md  │ note  │
    │ Draft Ideas      │ drafts/ideas.md         │       │
    │ Temp Scratch     │ scratch/temp.md         │ note  │
    └──────────────────┴─────────────────────────┴───────┘
    

    Files changed:

    • src/basic_memory/repository/entity_repository.py — find_without_relations() using SQL EXISTS
    • src/basic_memory/schemas/v2/graph.py — OrphanEntitiesResponse schema
    • src/basic_memory/schemas/v2/__init__.py — export new schema
    • src/basic_memory/api/v2/routers/knowledge_router.py — GET /knowledge/orphans endpoint
    • src/basic_memory/mcp/clients/knowledge.py — get_orphans() client method
    • src/basic_memory/cli/commands/orphans.py — new CLI command (created)
    • src/basic_memory/cli/commands/__init__.py + cli/main.py — register command
    • tests/repository/test_entity_repository.py — 3 new repository tests
    • tests/api/v2/test_orphan_router.py — 4 new API endpoint tests (created)
    • tests/cli/test_orphans_command.py — 3 new CLI tests (created)

    |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions