basic-memory 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of basic-memory might be problematic. Click here for more details.

@@ -1,5 +1,5 @@
1
1
  """Command module exports."""
2
2
 
3
- from . import init, status, sync, import_memory_json
3
+ from . import status, sync, import_memory_json
4
4
 
5
- __all__ = ["init", "status", "sync", "import_memory_json.py"]
5
+ __all__ = [ "status", "sync", "import_memory_json.py"]
basic_memory/cli/main.py CHANGED
@@ -5,11 +5,10 @@ import typer
5
5
  from loguru import logger
6
6
 
7
7
  from basic_memory.cli.app import app
8
- from basic_memory.cli.commands.init import init
9
8
 
10
9
  # Register commands
11
- from basic_memory.cli.commands import init, status, sync
12
- __all__ = ["init", "status", "sync"]
10
+ from basic_memory.cli.commands import status, sync
11
+ __all__ = ["status", "sync"]
13
12
 
14
13
  from basic_memory.config import config
15
14
 
basic_memory/db.py CHANGED
@@ -15,6 +15,8 @@ from sqlalchemy.ext.asyncio import (
15
15
  )
16
16
 
17
17
  from basic_memory.models import Base, SCHEMA_VERSION
18
+ from basic_memory.models.search import CREATE_SEARCH_INDEX
19
+ from basic_memory.repository.search_repository import SearchRepository
18
20
 
19
21
  # Module level state
20
22
  _engine: Optional[AsyncEngine] = None
@@ -77,7 +79,10 @@ async def init_db() -> None:
77
79
  await session.execute(text("PRAGMA foreign_keys=ON"))
78
80
  conn = await session.connection()
79
81
  await conn.run_sync(Base.metadata.create_all)
80
-
82
+
83
+ # recreate search index
84
+ await session.execute(CREATE_SEARCH_INDEX)
85
+
81
86
  await session.commit()
82
87
 
83
88
  async def drop_db():
@@ -70,6 +70,8 @@ class SearchRepository:
70
70
 
71
71
  async def init_search_index(self):
72
72
  """Create or recreate the search index."""
73
+
74
+ logger.info("Initializing search index")
73
75
  async with db.scoped_session(self.session_maker) as session:
74
76
  await session.execute(CREATE_SEARCH_INDEX)
75
77
  await session.commit()
@@ -13,6 +13,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
13
13
  from basic_memory import db
14
14
  from basic_memory.config import ProjectConfig
15
15
  from basic_memory.models import Base
16
+ from basic_memory.repository.search_repository import SearchRepository
16
17
 
17
18
 
18
19
  async def check_schema_matches_models(session: AsyncSession) -> Tuple[bool, List[str]]:
@@ -127,7 +128,7 @@ class DatabaseService:
127
128
  for diff in differences:
128
129
  logger.warning(f" {diff}")
129
130
  logger.info("Rebuilding database to match current models...")
130
- await self.initialize_db()
131
+ await self.initialize_db()
131
132
  return True
132
133
 
133
134
  logger.info("Database schema matches models")
@@ -4,6 +4,7 @@ from pathlib import Path
4
4
  from typing import Dict
5
5
 
6
6
  from loguru import logger
7
+ from sqlalchemy.exc import IntegrityError
7
8
 
8
9
  from basic_memory import file_utils
9
10
  from basic_memory.markdown import EntityParser, EntityMarkdown
@@ -153,10 +154,14 @@ class SyncService:
153
154
  # check we found a link that is not the source
154
155
  if target_entity and target_entity.id != relation.from_id:
155
156
  logger.debug(f"Resolved forward reference: {relation.to_name} -> {target_entity.permalink}")
156
- await self.relation_repository.update(relation.id, {
157
- "to_id": target_entity.id,
158
- "to_name": target_entity.title # Update to actual title
159
- })
157
+
158
+ try:
159
+ await self.relation_repository.update(relation.id, {
160
+ "to_id": target_entity.id,
161
+ "to_name": target_entity.title # Update to actual title
162
+ })
163
+ except IntegrityError as e:
164
+ logger.info(f"Ignoring duplicate relation {relation}")
160
165
 
161
166
  # update search index
162
167
  await self.search_service.index_entity(target_entity)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: basic-memory
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Local-first knowledge management combining Zettelkasten with knowledge graphs
5
5
  Project-URL: Homepage, https://github.com/basicmachines-co/basic-memory
6
6
  Project-URL: Repository, https://github.com/basicmachines-co/basic-memory
@@ -1,6 +1,6 @@
1
1
  basic_memory/__init__.py,sha256=5AdJrNglWu8gvlZPWZDKmrYbpOaJJ7KcdBfSQxBl3A8,121
2
2
  basic_memory/config.py,sha256=bmNBTbbl8YhEsHOI0fnC7EfxIuyKB25LhtNuXzFlXnY,1671
3
- basic_memory/db.py,sha256=JA51udB4wg6HePJB1mnOqxaQCCoQAFVWf9gSSpZo9TY,4433
3
+ basic_memory/db.py,sha256=rTNI7_rP5sGEpJvIGwk3VXEPbGwqoyKaSXxNgDAxxZQ,4639
4
4
  basic_memory/deps.py,sha256=YeDwqEmqUTPOc-JdItE1NEj3iunB2j6thYotweHXq98,5316
5
5
  basic_memory/file_utils.py,sha256=-B-ixIGo4kf27nXE7mlyO5SljK-BhXvSN9rsXfJu0HQ,5814
6
6
  basic_memory/utils.py,sha256=FCXR_jQxr8qBtHSHkWoESEvSVwPiWjn5xfAPmyqYW0g,2321
@@ -13,10 +13,9 @@ basic_memory/api/routers/resource_router.py,sha256=_Gp5HSJr-L-GUkQKbEP2bAZvCY8Sm
13
13
  basic_memory/api/routers/search_router.py,sha256=eKUibpJGuniLgTxXI_C28CjMrSNoXIrEwrlTBTkf1y4,1168
14
14
  basic_memory/cli/__init__.py,sha256=Hs6p69LnxlgO41EYFY0zMDCsbB3QxvPH9duNZz0hROs,32
15
15
  basic_memory/cli/app.py,sha256=gevKtdiAIlsJCbvegd1Pt7NID96Bq7yM1Hv2irHS0tY,35
16
- basic_memory/cli/main.py,sha256=lLX_K5stSd96HKUbNk24BQ__nq7TPQI7IUqeFnwHVzE,1139
17
- basic_memory/cli/commands/__init__.py,sha256=HAYxxI1wPPX6QfwuuLMmh_9wmND_U6-_tGtxcSIsF24,147
16
+ basic_memory/cli/main.py,sha256=E54Cl4gvHGijiY0UmNSLa-Dlm66EHxfvd2Tr4bB1XIY,1077
17
+ basic_memory/cli/commands/__init__.py,sha256=18zCHPanlry0a-5C2bRa-ydwQ8Ki40D2A3M6j7zVmKE,134
18
18
  basic_memory/cli/commands/import_memory_json.py,sha256=jpGJpEx8QuARi3ZurH4bvDSF-c3c_hTktNLps-0YsSo,5207
19
- basic_memory/cli/commands/init.py,sha256=5UmOasPd_65Evcw8QYWNZcrViBhWhrlFWCXOHtlrA1E,1189
20
19
  basic_memory/cli/commands/status.py,sha256=Dqp8mGR7vFpB-bVkIBRKvWeIkfDN7KyYaAKdtoAEYY4,5691
21
20
  basic_memory/cli/commands/sync.py,sha256=ycyD9yuZdKrtSd6L6sPQU1N3ang9FDIt5w-BHpqoD-c,8482
22
21
  basic_memory/markdown/__init__.py,sha256=DdzioCWtDnKaq05BHYLgL_78FawEHLpLXnp-kPSVfIc,501
@@ -45,7 +44,7 @@ basic_memory/repository/entity_repository.py,sha256=Nn_ZS4K2cakMD_LVGJfGqQ-0SZ2W
45
44
  basic_memory/repository/observation_repository.py,sha256=BOcy4wARqCXu-thYyt7mPxt2A2C8TW0le3s_X9wrK6I,1701
46
45
  basic_memory/repository/relation_repository.py,sha256=mHZj3Uhapm9OG7NyTldIspJ7BdNKXKKjJD1lextQKGk,3234
47
46
  basic_memory/repository/repository.py,sha256=UCMy7VXjtkxkKCI3ZuQm4_RFRKJT0NBDhEvt_ueqjzc,12945
48
- basic_memory/repository/search_repository.py,sha256=V49xaEVGBTbZ-Tf1y8NaflQGAOQMupANtJ-RFFYou2w,9368
47
+ basic_memory/repository/search_repository.py,sha256=Q0v8MIsyQS_M9WD6mHIyRwFlMGanjgkBIAEGEbPR6J8,9426
49
48
  basic_memory/schemas/__init__.py,sha256=m1Pou5ue1BNmHBm13WPBf3BJKKPsLaIYVnnGmgs2iwo,1618
50
49
  basic_memory/schemas/base.py,sha256=4O_uxXX_JDpMqPNk7jXduA3Ut3Uz1wjmrf27JlkI-e8,6694
51
50
  basic_memory/schemas/delete.py,sha256=_tSyTHAujVxkSUy5Cu3s6yHw-n3JmokjeMR6gZqJhG4,1198
@@ -56,7 +55,7 @@ basic_memory/schemas/response.py,sha256=7oWk3GDS626pdgN2MF__tp9c7WU-_9K7hs1F2quB
56
55
  basic_memory/schemas/search.py,sha256=7xlUc0HE13-v7iKy3eFs0IKasGbXVxCaq8GZ8qiUBTQ,3395
57
56
  basic_memory/services/__init__.py,sha256=5yx4U7iCi5gLjHxmkjeQ9JJoftWqy6P2gX2uV3ouMd0,279
58
57
  basic_memory/services/context_service.py,sha256=9DWryOhHfowelk4JVNIAlOycjblocTw38FSEP2kDkGI,8095
59
- basic_memory/services/database_service.py,sha256=qDeL2VL_bUExI30KS4xawKt3vS110QmcEbZav1gyOUE,5574
58
+ basic_memory/services/database_service.py,sha256=WIyGEC4B8v5Z0_XdzkfVACBhtSmjn-ch0JbFzP8giOo,5665
60
59
  basic_memory/services/entity_service.py,sha256=Lh63SEt-PCwGgazMx-KIVz-oEsNqX1JC7ktWZtvrVWw,12594
61
60
  basic_memory/services/exceptions.py,sha256=Z9cizi05f7QBY4HX6c0ywfzKk0_sie3283CP7gzy-dY,287
62
61
  basic_memory/services/file_service.py,sha256=oiS33BhD5zs7YgF6vMAgAvBBkHiLbUJ6g2cvN2JwymA,7166
@@ -65,11 +64,11 @@ basic_memory/services/search_service.py,sha256=yLXYs-PNimELM_5E44O25-fbD4PDzISsA
65
64
  basic_memory/services/service.py,sha256=oHsHKMTC2ojRsxeNdnC4nA5YdTL72VYjDzWI_dbmzyA,1134
66
65
  basic_memory/sync/__init__.py,sha256=5BzfbvY-DKi-gswcjNzVqtNj4I0yXZ82CaupFiPihws,138
67
66
  basic_memory/sync/file_change_scanner.py,sha256=x2xFaxCzPy5seNLqK-TcN106U2--UKvAR7qoBeq8M84,5919
68
- basic_memory/sync/sync_service.py,sha256=fNBQtJwhLEdFcTTnSpLVnV-QWppETwXzhlsAMqODdnY,7026
67
+ basic_memory/sync/sync_service.py,sha256=Her8oQxRXuQkxAK1f_EhN9uQXDIq_KRkBNX9PMucXdc,7229
69
68
  basic_memory/sync/utils.py,sha256=6P5-dvR5X-lA-BE3IZOzoC54uyiq9c_p9figRKaPq5E,2453
70
69
  basic_memory/sync/watch_service.py,sha256=HIronKujbBTbbosz0HAqLBLkP5IK3zH6gQKoTCrrA9o,6744
71
- basic_memory-0.1.0.dist-info/METADATA,sha256=j9Y6XhZAMMQZ-DehSV4Im7wuTfu4uOHKTWTaBnLDExw,7771
72
- basic_memory-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
73
- basic_memory-0.1.0.dist-info/entry_points.txt,sha256=IDQa_VmVTzmvMrpnjhEfM0S3F--XsVGEj3MpdJfuo-Q,59
74
- basic_memory-0.1.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
75
- basic_memory-0.1.0.dist-info/RECORD,,
70
+ basic_memory-0.1.1.dist-info/METADATA,sha256=4ooHFh_c3uKUWIeLJn5JuH5ICrzZ7DOBpHGhyzqxud8,7771
71
+ basic_memory-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
72
+ basic_memory-0.1.1.dist-info/entry_points.txt,sha256=IDQa_VmVTzmvMrpnjhEfM0S3F--XsVGEj3MpdJfuo-Q,59
73
+ basic_memory-0.1.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
74
+ basic_memory-0.1.1.dist-info/RECORD,,
@@ -1,38 +0,0 @@
1
- """Initialize command for basic-memory CLI."""
2
-
3
- import asyncio
4
- from pathlib import Path
5
-
6
- import typer
7
- from loguru import logger
8
-
9
- from basic_memory.cli.app import app
10
- from basic_memory.db import engine_session_factory, DatabaseType
11
- from basic_memory.config import config
12
-
13
-
14
- async def _init(force: bool = False):
15
- """Initialize the database."""
16
- db_path = config.database_path
17
-
18
- if db_path.exists() and not force:
19
- typer.echo(f"Database already exists at {db_path}. Use --force to reinitialize.")
20
- raise typer.Exit(1)
21
-
22
- # Create data directory if needed
23
- db_path.parent.mkdir(parents=True, exist_ok=True)
24
-
25
- try:
26
- async with engine_session_factory(db_path, db_type=DatabaseType.FILESYSTEM, init=True):
27
- typer.echo(f"Initialized database at {db_path}")
28
- except Exception as e:
29
- logger.error(f"Error initializing database: {e}")
30
- typer.echo(f"Error initializing database: {e}")
31
- raise typer.Exit(1)
32
-
33
- @app.command()
34
- def init(
35
- force: bool = typer.Option(False, "--force", "-f", help="Force reinitialization if database exists")
36
- ):
37
- """Initialize a new basic-memory database."""
38
- asyncio.run(_init(force))