cli-memory-os 0.1.19__tar.gz → 0.1.20__tar.gz
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.
- {cli_memory_os-0.1.19/cli_memory_os.egg-info → cli_memory_os-0.1.20}/PKG-INFO +1 -1
- cli_memory_os-0.1.20/cli/commands/ask.py +108 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/backup.py +31 -8
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/export.py +2 -20
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/import_cmd.py +57 -14
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/sync.py +14 -3
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/workspace.py +7 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/parser.py +4 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/tui/app.py +138 -103
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20/cli_memory_os.egg-info}/PKG-INFO +1 -1
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli_memory_os.egg-info/SOURCES.txt +3 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/github.py +62 -2
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/gmail.py +14 -3
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/notion.py +85 -30
- cli_memory_os-0.1.20/core/chat.py +971 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/chunker.py +3 -3
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/context_builder.py +125 -7
- cli_memory_os-0.1.20/core/embedder.py +68 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/llm.py +45 -30
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/ranking.py +18 -3
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/vector_store.py +30 -14
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/config.py +48 -5
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/workspace.py +12 -9
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/pyproject.toml +1 -1
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/storage/db.py +23 -22
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/storage/graph.py +55 -41
- cli_memory_os-0.1.20/tests/test_audit_remediation.py +379 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_cli_integration.py +60 -3
- cli_memory_os-0.1.20/tests/test_conversational_chat.py +622 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_production_readiness.py +2 -0
- cli_memory_os-0.1.19/cli/commands/ask.py +0 -67
- cli_memory_os-0.1.19/core/embedder.py +0 -47
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/LICENSE +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/MANIFEST.in +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/README.md +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/benchmark.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/config_cmd.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/doctor.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/graph.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/init.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/logs.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/migrate.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/monitor.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/plugins.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/restart.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/restore.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/start.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/status.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/stop.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/update.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/commands/version.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/main.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli/tui/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli_memory_os.egg-info/dependency_links.txt +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli_memory_os.egg-info/entry_points.txt +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli_memory_os.egg-info/requires.txt +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/cli_memory_os.egg-info/top_level.txt +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/base.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/connectors/registry.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/core/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/compose.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/docker.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/health.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/infrastructure/observability.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/models/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/models/memory.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/setup.cfg +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/storage/__init__.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/storage/schema.sql +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/storage/tech_detector.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_commands_phase2.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_compose_manager.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_composio_connectors.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_concurrent_db.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_core_rag_pipeline.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_first_time_user_experience.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_infrastructure_stabilization.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_load_stress.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_sync_ask_cli.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_tui.py +0 -0
- {cli_memory_os-0.1.19 → cli_memory_os-0.1.20}/tests/test_v1_features.py +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command: memory-os ask
|
|
3
|
+
|
|
4
|
+
Queries the RAG pipeline with a question.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
import json
|
|
9
|
+
import time
|
|
10
|
+
import sqlite3
|
|
11
|
+
from typing import Optional
|
|
12
|
+
from core.llm import run_hybrid_rag
|
|
13
|
+
from core.chat import ConversationSession, orchestrate_chat
|
|
14
|
+
from storage.db import init_db
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _load_cli_session() -> ConversationSession:
|
|
18
|
+
"""Load recent transient CLI session history from cache if available."""
|
|
19
|
+
session = ConversationSession()
|
|
20
|
+
try:
|
|
21
|
+
from infrastructure.workspace import get_workspace_root
|
|
22
|
+
cache_file = get_workspace_root() / "cache" / "cli_session.json"
|
|
23
|
+
if cache_file.exists():
|
|
24
|
+
data = json.loads(cache_file.read_text(encoding="utf-8"))
|
|
25
|
+
mtime = cache_file.stat().st_mtime
|
|
26
|
+
if time.time() - mtime < 3600:
|
|
27
|
+
session.turns = data.get("turns", [])
|
|
28
|
+
except Exception:
|
|
29
|
+
pass
|
|
30
|
+
return session
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _save_cli_session(session: ConversationSession) -> None:
|
|
34
|
+
"""Save transient CLI session history to cache."""
|
|
35
|
+
try:
|
|
36
|
+
from infrastructure.workspace import get_workspace_root
|
|
37
|
+
cache_dir = get_workspace_root() / "cache"
|
|
38
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
cache_file = cache_dir / "cli_session.json"
|
|
40
|
+
cache_file.write_text(json.dumps({"turns": session.turns}), encoding="utf-8")
|
|
41
|
+
except Exception:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def run_and_print_ask(query: str, session: Optional[ConversationSession] = None):
|
|
46
|
+
"""Run unified chat orchestration pipeline and print the structured result."""
|
|
47
|
+
if session is None:
|
|
48
|
+
session = _load_cli_session()
|
|
49
|
+
|
|
50
|
+
rag_res = orchestrate_chat(query, session=session, rag_fn=run_hybrid_rag)
|
|
51
|
+
_save_cli_session(session)
|
|
52
|
+
mode = rag_res.get("mode", "rag")
|
|
53
|
+
sources = rag_res.get("sources", [])
|
|
54
|
+
repos = rag_res.get("repositories", [])
|
|
55
|
+
confidence = rag_res.get("confidence", 0.0)
|
|
56
|
+
|
|
57
|
+
print("========================================")
|
|
58
|
+
print("ANSWER")
|
|
59
|
+
print("========================================")
|
|
60
|
+
print(rag_res["answer"])
|
|
61
|
+
|
|
62
|
+
if bool(sources) or bool(repos):
|
|
63
|
+
print("\n========================================")
|
|
64
|
+
print("SOURCES")
|
|
65
|
+
print("========================================")
|
|
66
|
+
if sources:
|
|
67
|
+
for s in sources:
|
|
68
|
+
print(f"- {s}")
|
|
69
|
+
else:
|
|
70
|
+
print("None")
|
|
71
|
+
print("\n========================================")
|
|
72
|
+
print("REPOSITORIES USED")
|
|
73
|
+
print("========================================")
|
|
74
|
+
if repos:
|
|
75
|
+
for r in repos:
|
|
76
|
+
print(f"- {r}")
|
|
77
|
+
else:
|
|
78
|
+
print("None")
|
|
79
|
+
print("\n========================================")
|
|
80
|
+
print(f"Confidence: {confidence:.2f}")
|
|
81
|
+
print("========================================")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def execute(args):
|
|
85
|
+
"""Run the ask command parser handler."""
|
|
86
|
+
# Ensure database is initialized
|
|
87
|
+
try:
|
|
88
|
+
init_db()
|
|
89
|
+
except sqlite3.OperationalError as e:
|
|
90
|
+
print("----------------------------------")
|
|
91
|
+
print("Workspace has not been initialized.")
|
|
92
|
+
print("")
|
|
93
|
+
print("Run:")
|
|
94
|
+
print("memory-os init")
|
|
95
|
+
print("----------------------------------")
|
|
96
|
+
sys.exit(1)
|
|
97
|
+
|
|
98
|
+
if not args.question:
|
|
99
|
+
print("Usage: memory-os ask <question>")
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
|
|
102
|
+
query = " ".join(args.question)
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
run_and_print_ask(query)
|
|
106
|
+
except Exception as e:
|
|
107
|
+
print(f"❌ Error executing query: {e}")
|
|
108
|
+
sys.exit(1)
|
|
@@ -36,6 +36,7 @@ def execute(args):
|
|
|
36
36
|
|
|
37
37
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
38
38
|
backup_file = backups_dir / f"backup_{active}_{timestamp}.zip"
|
|
39
|
+
tmp_backup_file = backups_dir / f".backup_{active}_{timestamp}.zip.tmp"
|
|
39
40
|
|
|
40
41
|
print(f"Creating backup of active workspace profile '{active}'...")
|
|
41
42
|
try:
|
|
@@ -48,13 +49,20 @@ def execute(args):
|
|
|
48
49
|
"storage_size_bytes": get_workspace_size(active),
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
with zipfile.ZipFile(
|
|
52
|
+
with zipfile.ZipFile(tmp_backup_file, "w", zipfile.ZIP_DEFLATED) as zipf:
|
|
52
53
|
# Metadata
|
|
53
54
|
zipf.writestr("metadata.json", json.dumps(metadata, indent=2))
|
|
54
55
|
|
|
55
|
-
# Configuration
|
|
56
|
+
# Configuration (sanitized by default unless --include-secrets is passed)
|
|
56
57
|
if config_path.exists():
|
|
57
|
-
|
|
58
|
+
include_secrets = getattr(args, "include_secrets", False)
|
|
59
|
+
if include_secrets:
|
|
60
|
+
zipf.write(config_path, arcname="config.toml")
|
|
61
|
+
print(" ⚠️ Packed config.toml (including plaintext credentials)")
|
|
62
|
+
else:
|
|
63
|
+
from infrastructure.config import sanitize_toml_config
|
|
64
|
+
zipf.writestr("config.toml", sanitize_toml_config(config_path))
|
|
65
|
+
print(" ✓ Packed config.toml (credentials sanitized for security)")
|
|
58
66
|
|
|
59
67
|
# SQLite Database
|
|
60
68
|
if db_path.exists():
|
|
@@ -76,12 +84,18 @@ def execute(args):
|
|
|
76
84
|
arcname = Path("neo4j") / file_path.relative_to(neo4j_path)
|
|
77
85
|
zipf.write(file_path, arcname=arcname)
|
|
78
86
|
|
|
79
|
-
#
|
|
87
|
+
# Remaining workspace files (excluding already-packed db/qdrant/neo4j)
|
|
80
88
|
if profile_path.exists():
|
|
81
|
-
for root,
|
|
89
|
+
for root, dirs, files in os.walk(profile_path):
|
|
90
|
+
rel_root = Path(root).relative_to(profile_path)
|
|
91
|
+
if rel_root == Path("."):
|
|
92
|
+
dirs[:] = [d for d in dirs if d not in ("qdrant", "neo4j")]
|
|
82
93
|
for f in files:
|
|
83
94
|
fp = Path(root) / f
|
|
84
|
-
|
|
95
|
+
rel_fp = fp.relative_to(profile_path)
|
|
96
|
+
if rel_fp == Path("workspace.db"):
|
|
97
|
+
continue
|
|
98
|
+
arcname = Path("workspace") / rel_fp
|
|
85
99
|
zipf.write(fp, arcname=arcname)
|
|
86
100
|
|
|
87
101
|
include_logs = getattr(args, "include_logs", False)
|
|
@@ -94,10 +108,19 @@ def execute(args):
|
|
|
94
108
|
arcname = Path("logs") / fp.relative_to(logs_path)
|
|
95
109
|
zipf.write(fp, arcname=arcname)
|
|
96
110
|
|
|
111
|
+
os.replace(tmp_backup_file, backup_file)
|
|
97
112
|
print("──────────────────────────────────────────────────")
|
|
98
113
|
print(f"🎉 Backup created successfully!")
|
|
99
114
|
print(f"File: {backup_file.resolve()}")
|
|
100
115
|
print("──────────────────────────────────────────────────")
|
|
101
|
-
except Exception as e:
|
|
102
|
-
|
|
116
|
+
except (Exception, KeyboardInterrupt) as e:
|
|
117
|
+
if tmp_backup_file.exists():
|
|
118
|
+
try:
|
|
119
|
+
tmp_backup_file.unlink()
|
|
120
|
+
except OSError:
|
|
121
|
+
pass
|
|
122
|
+
if isinstance(e, KeyboardInterrupt):
|
|
123
|
+
print("\n❌ Backup cancelled by user.")
|
|
124
|
+
else:
|
|
125
|
+
print(f"❌ Backup failed: {e}")
|
|
103
126
|
sys.exit(1)
|
|
@@ -66,26 +66,8 @@ def execute(args):
|
|
|
66
66
|
zipf.write(config_path, arcname="config.toml")
|
|
67
67
|
print(" ⚠️ Packed config.toml (including plaintext credentials)")
|
|
68
68
|
else:
|
|
69
|
-
import
|
|
70
|
-
|
|
71
|
-
with open(config_path, "rb") as f:
|
|
72
|
-
cfg = tomllib.load(f)
|
|
73
|
-
if "groq" in cfg and "api_key" in cfg["groq"]:
|
|
74
|
-
cfg["groq"]["api_key"] = ""
|
|
75
|
-
if "composio" in cfg and "api_key" in cfg["composio"]:
|
|
76
|
-
cfg["composio"]["api_key"] = ""
|
|
77
|
-
if "neo4j" in cfg and "password" in cfg["neo4j"]:
|
|
78
|
-
cfg["neo4j"]["password"] = ""
|
|
79
|
-
|
|
80
|
-
sanitized_lines = []
|
|
81
|
-
for k, v in cfg.items():
|
|
82
|
-
if isinstance(v, dict):
|
|
83
|
-
sanitized_lines.append(f"\n[{k}]")
|
|
84
|
-
for subk, subv in v.items():
|
|
85
|
-
sanitized_lines.append(f'{subk} = {_toml_value(subv)}')
|
|
86
|
-
else:
|
|
87
|
-
sanitized_lines.append(f'{k} = {_toml_value(v)}')
|
|
88
|
-
zipf.writestr("config.toml", "\n".join(sanitized_lines) + "\n")
|
|
69
|
+
from infrastructure.config import sanitize_toml_config
|
|
70
|
+
zipf.writestr("config.toml", sanitize_toml_config(config_path))
|
|
89
71
|
print(" ✓ Packed config.toml (credentials sanitized for security)")
|
|
90
72
|
|
|
91
73
|
# C. SQLite Database
|
|
@@ -6,6 +6,7 @@ into the active workspace profile.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import sys
|
|
9
|
+
import stat
|
|
9
10
|
import json
|
|
10
11
|
import zipfile
|
|
11
12
|
import shutil
|
|
@@ -88,7 +89,7 @@ def execute(args):
|
|
|
88
89
|
# 4. Unpack files
|
|
89
90
|
print("Unpacking files from archive...")
|
|
90
91
|
|
|
91
|
-
# Helper to validate relative path against Zip Slip
|
|
92
|
+
# Helper to validate relative path against Zip Slip & symlinks
|
|
92
93
|
def _is_safe_path(base_dir: Path, rel_str: str) -> Path | None:
|
|
93
94
|
p = Path(rel_str)
|
|
94
95
|
if ".." in p.parts or p.is_absolute():
|
|
@@ -101,24 +102,40 @@ def execute(args):
|
|
|
101
102
|
except ValueError:
|
|
102
103
|
return None
|
|
103
104
|
|
|
105
|
+
def _is_symlink_info(info: zipfile.ZipInfo) -> bool:
|
|
106
|
+
return stat.S_ISLNK(info.external_attr >> 16)
|
|
107
|
+
|
|
104
108
|
# config.toml
|
|
105
109
|
if "config.toml" in zipf.namelist() and config_path:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
info = zipf.getinfo("config.toml")
|
|
111
|
+
if not _is_symlink_info(info):
|
|
112
|
+
with open(config_path, "wb") as f:
|
|
113
|
+
f.write(zipf.read("config.toml"))
|
|
114
|
+
from infrastructure.config import secure_file_permissions
|
|
115
|
+
secure_file_permissions(config_path)
|
|
116
|
+
print(" ✓ Restored config.toml")
|
|
117
|
+
|
|
118
|
+
# workspace.db (root or legacy workspace/workspace.db fallback)
|
|
119
|
+
if db_path:
|
|
120
|
+
db_entry = None
|
|
121
|
+
if "workspace.db" in zipf.namelist():
|
|
122
|
+
db_entry = "workspace.db"
|
|
123
|
+
elif "workspace/workspace.db" in zipf.namelist():
|
|
124
|
+
db_entry = "workspace/workspace.db"
|
|
125
|
+
if db_entry and not _is_symlink_info(zipf.getinfo(db_entry)):
|
|
126
|
+
db_path.parent.mkdir(parents=True, exist_ok=True)
|
|
127
|
+
with open(db_path, "wb") as f:
|
|
128
|
+
f.write(zipf.read(db_entry))
|
|
129
|
+
print(" ✓ Restored SQLite database")
|
|
117
130
|
|
|
118
131
|
# Qdrant files
|
|
119
132
|
qdrant_restored = 0
|
|
120
|
-
for
|
|
133
|
+
for info in zipf.infolist():
|
|
134
|
+
name = info.filename
|
|
121
135
|
if name.startswith("qdrant/") and not name.endswith("/"):
|
|
136
|
+
if _is_symlink_info(info):
|
|
137
|
+
print(f" ⚠️ Warning: Skipping symlink archive entry '{name}'")
|
|
138
|
+
continue
|
|
122
139
|
target_file = _is_safe_path(qdrant_path, name[7:])
|
|
123
140
|
if target_file is None:
|
|
124
141
|
print(f" ⚠️ Warning: Skipping suspicious archive entry '{name}' (path traversal detected)")
|
|
@@ -132,8 +149,12 @@ def execute(args):
|
|
|
132
149
|
|
|
133
150
|
# Neo4j files
|
|
134
151
|
neo4j_restored = 0
|
|
135
|
-
for
|
|
152
|
+
for info in zipf.infolist():
|
|
153
|
+
name = info.filename
|
|
136
154
|
if name.startswith("neo4j/") and not name.endswith("/"):
|
|
155
|
+
if _is_symlink_info(info):
|
|
156
|
+
print(f" ⚠️ Warning: Skipping symlink archive entry '{name}'")
|
|
157
|
+
continue
|
|
137
158
|
target_file = _is_safe_path(neo4j_path, name[6:])
|
|
138
159
|
if target_file is None:
|
|
139
160
|
print(f" ⚠️ Warning: Skipping suspicious archive entry '{name}' (path traversal detected)")
|
|
@@ -145,6 +166,28 @@ def execute(args):
|
|
|
145
166
|
if neo4j_restored > 0:
|
|
146
167
|
print(f" ✓ Restored {neo4j_restored} Neo4j database files")
|
|
147
168
|
|
|
169
|
+
# Workspace custom files (workspace/*)
|
|
170
|
+
ws_restored = 0
|
|
171
|
+
for info in zipf.infolist():
|
|
172
|
+
name = info.filename
|
|
173
|
+
if name.startswith("workspace/") and not name.endswith("/"):
|
|
174
|
+
rel_ws = name[len("workspace/"):]
|
|
175
|
+
if rel_ws == "workspace.db":
|
|
176
|
+
continue
|
|
177
|
+
if _is_symlink_info(info):
|
|
178
|
+
print(f" ⚠️ Warning: Skipping symlink archive entry '{name}'")
|
|
179
|
+
continue
|
|
180
|
+
target_file = _is_safe_path(profile_path, rel_ws)
|
|
181
|
+
if target_file is None:
|
|
182
|
+
print(f" ⚠️ Warning: Skipping suspicious archive entry '{name}' (path traversal detected)")
|
|
183
|
+
continue
|
|
184
|
+
target_file.parent.mkdir(parents=True, exist_ok=True)
|
|
185
|
+
with open(target_file, "wb") as f:
|
|
186
|
+
f.write(zipf.read(name))
|
|
187
|
+
ws_restored += 1
|
|
188
|
+
if ws_restored > 0:
|
|
189
|
+
print(f" ✓ Restored {ws_restored} workspace files")
|
|
190
|
+
|
|
148
191
|
# 5. Restart Services
|
|
149
192
|
print("\nStarting local services...")
|
|
150
193
|
load_config() # reload config from file
|
|
@@ -43,16 +43,27 @@ def execute(args):
|
|
|
43
43
|
run_reindexing()
|
|
44
44
|
GraphStore().clear_graph()
|
|
45
45
|
|
|
46
|
-
# Sync based on source selection
|
|
46
|
+
# Sync based on source selection and scope incremental reindexing
|
|
47
|
+
target_repo_names = None
|
|
47
48
|
if source == "github":
|
|
48
49
|
print("Syncing GitHub source...")
|
|
49
50
|
sync_github()
|
|
51
|
+
if not rebuild:
|
|
52
|
+
from storage.db import get_all_repositories
|
|
53
|
+
target_repo_names = [
|
|
54
|
+
r["repo_name"] for r in get_all_repositories()
|
|
55
|
+
if r.get("repo_name") and r["repo_name"] != "Notion"
|
|
56
|
+
]
|
|
50
57
|
elif source == "gmail":
|
|
51
58
|
print("Syncing Gmail source...")
|
|
52
59
|
sync_gmail()
|
|
60
|
+
if not rebuild:
|
|
61
|
+
target_repo_names = ["__emails__"]
|
|
53
62
|
elif source == "notion":
|
|
54
63
|
print("Syncing Notion source...")
|
|
55
64
|
sync_notion()
|
|
65
|
+
if not rebuild:
|
|
66
|
+
target_repo_names = ["Notion"]
|
|
56
67
|
else:
|
|
57
68
|
print("Syncing all sources (GitHub, Gmail, Notion)...")
|
|
58
69
|
sync_github()
|
|
@@ -60,10 +71,10 @@ def execute(args):
|
|
|
60
71
|
sync_notion()
|
|
61
72
|
|
|
62
73
|
print("Running document chunking and vector reindexing...")
|
|
63
|
-
run_reindexing()
|
|
74
|
+
run_reindexing(repo_names=target_repo_names)
|
|
64
75
|
|
|
65
76
|
print("Extracting and syncing knowledge graph relationships...")
|
|
66
|
-
GraphStore().extract_and_sync_graph()
|
|
77
|
+
GraphStore().extract_and_sync_graph(repo_names=target_repo_names)
|
|
67
78
|
|
|
68
79
|
duration = time.perf_counter() - start_time
|
|
69
80
|
print(f"\nSync complete. Total Duration: {duration:.2f}s")
|
|
@@ -47,6 +47,13 @@ def execute(args):
|
|
|
47
47
|
name = args.name
|
|
48
48
|
try:
|
|
49
49
|
set_active_profile(name)
|
|
50
|
+
try:
|
|
51
|
+
from infrastructure.config import _get_config_path, set_dotted, load_config
|
|
52
|
+
if _get_config_path().exists():
|
|
53
|
+
set_dotted("active_profile", name)
|
|
54
|
+
load_config()
|
|
55
|
+
except Exception:
|
|
56
|
+
pass
|
|
50
57
|
print(f"✓ Switched active workspace profile to '{name}'.")
|
|
51
58
|
except Exception as e:
|
|
52
59
|
print(f"❌ Failed to switch workspace profile: {e}")
|
|
@@ -68,6 +68,10 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
68
68
|
"--include-logs", action="store_true",
|
|
69
69
|
help="Include log files in the backup",
|
|
70
70
|
)
|
|
71
|
+
backup_parser.add_argument(
|
|
72
|
+
"--include-secrets", action="store_true", default=False,
|
|
73
|
+
help="Include sensitive credentials (API keys, passwords) in backup archive",
|
|
74
|
+
)
|
|
71
75
|
|
|
72
76
|
# ── export ────────────────────────────────────────────────
|
|
73
77
|
export_parser = subparsers.add_parser(
|