universal-memory 0.1.0__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.
- universal_memory/__init__.py +8 -0
- universal_memory/__main__.py +4 -0
- universal_memory/application/__init__.py +1 -0
- universal_memory/application/host/__init__.py +25 -0
- universal_memory/application/host/drift_detector.py +93 -0
- universal_memory/application/host/setup_host_use_case.py +1153 -0
- universal_memory/application/host/sync_instructions_use_case.py +456 -0
- universal_memory/application/memory/__init__.py +61 -0
- universal_memory/application/memory/assemble_context_summary_use_case.py +360 -0
- universal_memory/application/memory/context_hygiene_use_case.py +50 -0
- universal_memory/application/memory/get_memory_status_use_case.py +217 -0
- universal_memory/application/memory/list_facts_use_case.py +24 -0
- universal_memory/application/memory/purge_fact_use_case.py +49 -0
- universal_memory/application/memory/remember_fact_use_case.py +85 -0
- universal_memory/application/memory/search_facts_use_case.py +78 -0
- universal_memory/application/onboarding/__init__.py +8 -0
- universal_memory/application/onboarding/setup_project.py +302 -0
- universal_memory/application/security/__init__.py +43 -0
- universal_memory/application/security/list_audit_log_use_case.py +48 -0
- universal_memory/application/security/list_snapshots_use_case.py +57 -0
- universal_memory/application/security/rollback_use_case.py +195 -0
- universal_memory/application/security/safe_write_use_case.py +252 -0
- universal_memory/application/skills/__init__.py +65 -0
- universal_memory/application/skills/generate_skill.py +369 -0
- universal_memory/application/skills/list_skills.py +315 -0
- universal_memory/application/skills/native_skill_sync.py +312 -0
- universal_memory/application/skills/propose_skill.py +203 -0
- universal_memory/application/skills/track_latent_skill.py +148 -0
- universal_memory/application/skills/update_skill.py +602 -0
- universal_memory/application/update/__init__.py +25 -0
- universal_memory/application/update/update_use_cases.py +619 -0
- universal_memory/bootstrap/__init__.py +1 -0
- universal_memory/bootstrap/cli.py +286 -0
- universal_memory/bootstrap/mcp.py +213 -0
- universal_memory/domain/__init__.py +75 -0
- universal_memory/domain/entities/__init__.py +62 -0
- universal_memory/domain/entities/audit_event.py +37 -0
- universal_memory/domain/entities/base.py +46 -0
- universal_memory/domain/entities/context_summary.py +24 -0
- universal_memory/domain/entities/fact.py +28 -0
- universal_memory/domain/entities/host.py +48 -0
- universal_memory/domain/entities/instruction_target.py +89 -0
- universal_memory/domain/entities/latent_skill.py +26 -0
- universal_memory/domain/entities/rule.py +24 -0
- universal_memory/domain/entities/runtime.py +382 -0
- universal_memory/domain/entities/safe_write_result.py +8 -0
- universal_memory/domain/entities/snapshot.py +42 -0
- universal_memory/domain/exceptions.py +37 -0
- universal_memory/domain/ports/__init__.py +21 -0
- universal_memory/domain/ports/audit_log_repository.py +50 -0
- universal_memory/domain/ports/config_validation_port.py +11 -0
- universal_memory/domain/ports/context_summary_repository.py +50 -0
- universal_memory/domain/ports/fact_repository.py +106 -0
- universal_memory/domain/ports/latent_skill_repository.py +70 -0
- universal_memory/domain/ports/project_layout_port.py +16 -0
- universal_memory/domain/ports/rule_repository.py +60 -0
- universal_memory/domain/ports/secret_scanner_port.py +14 -0
- universal_memory/domain/ports/snapshot_repository.py +68 -0
- universal_memory/domain/project_layout.py +8 -0
- universal_memory/infrastructure/__init__.py +1 -0
- universal_memory/infrastructure/config/__init__.py +27 -0
- universal_memory/infrastructure/config/adapters.py +23 -0
- universal_memory/infrastructure/config/project_layout.py +122 -0
- universal_memory/infrastructure/config/toml_loader.py +221 -0
- universal_memory/infrastructure/security/__init__.py +11 -0
- universal_memory/infrastructure/security/entropy_secret_scanner.py +112 -0
- universal_memory/infrastructure/security/local_audit_log_repository.py +137 -0
- universal_memory/infrastructure/security/local_snapshot_repository.py +249 -0
- universal_memory/infrastructure/storage/__init__.py +15 -0
- universal_memory/infrastructure/storage/local_context_summary_repository.py +183 -0
- universal_memory/infrastructure/storage/local_fact_repository.py +433 -0
- universal_memory/infrastructure/storage/local_latent_skill_repository.py +347 -0
- universal_memory/infrastructure/storage/local_rule_repository.py +256 -0
- universal_memory/interfaces/__init__.py +1 -0
- universal_memory/interfaces/cli/__init__.py +3 -0
- universal_memory/interfaces/cli/init_command.py +3617 -0
- universal_memory/interfaces/cli/message_catalog.py +55 -0
- universal_memory/interfaces/errors.py +208 -0
- universal_memory/interfaces/mcp/__init__.py +7 -0
- universal_memory/interfaces/mcp/server.py +940 -0
- universal_memory-0.1.0.dist-info/METADATA +195 -0
- universal_memory-0.1.0.dist-info/RECORD +84 -0
- universal_memory-0.1.0.dist-info/WHEEL +4 -0
- universal_memory-0.1.0.dist-info/entry_points.txt +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Application layer for universal-memory."""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from universal_memory.application.host.setup_host_use_case import (
|
|
2
|
+
ConfigureHostCommand,
|
|
3
|
+
ConfigureHostResult,
|
|
4
|
+
ConfigureHostUseCase,
|
|
5
|
+
InstructionBlock,
|
|
6
|
+
InstructionPartition,
|
|
7
|
+
partition_instruction_blocks,
|
|
8
|
+
)
|
|
9
|
+
from universal_memory.application.host.sync_instructions_use_case import (
|
|
10
|
+
SyncInstructionsCommand,
|
|
11
|
+
SyncInstructionsResult,
|
|
12
|
+
SyncInstructionsUseCase,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ConfigureHostCommand",
|
|
17
|
+
"ConfigureHostResult",
|
|
18
|
+
"ConfigureHostUseCase",
|
|
19
|
+
"InstructionBlock",
|
|
20
|
+
"InstructionPartition",
|
|
21
|
+
"SyncInstructionsCommand",
|
|
22
|
+
"SyncInstructionsResult",
|
|
23
|
+
"SyncInstructionsUseCase",
|
|
24
|
+
"partition_instruction_blocks",
|
|
25
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class InstructionDriftDetector:
|
|
7
|
+
def detect(self, *, agents_content: str, claude_content: str) -> list[str]:
|
|
8
|
+
if not agents_content or not claude_content:
|
|
9
|
+
return []
|
|
10
|
+
agents_lines = _instruction_lines(agents_content)
|
|
11
|
+
claude_lines = _instruction_lines(claude_content)
|
|
12
|
+
warnings: list[str] = []
|
|
13
|
+
|
|
14
|
+
agents_by_normalized = {_normalize_line(line): line for line in agents_lines}
|
|
15
|
+
for claude_line in claude_lines:
|
|
16
|
+
normalized = _normalize_line(claude_line)
|
|
17
|
+
if normalized in agents_by_normalized:
|
|
18
|
+
warnings.append(
|
|
19
|
+
"Instrucao duplicada em AGENTS.md e CLAUDE.md: "
|
|
20
|
+
f"{agents_by_normalized[normalized]}"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
contradiction_warnings = _detect_always_never_contradictions(
|
|
24
|
+
agents_lines,
|
|
25
|
+
claude_lines,
|
|
26
|
+
)
|
|
27
|
+
warnings.extend(contradiction_warnings)
|
|
28
|
+
return warnings
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _instruction_lines(content: str) -> list[str]:
|
|
32
|
+
lines: list[str] = []
|
|
33
|
+
for raw_line in content.splitlines():
|
|
34
|
+
line = raw_line.strip()
|
|
35
|
+
if not line or "<!--" in line or "-->" in line or line.startswith(("#", ">")):
|
|
36
|
+
continue
|
|
37
|
+
line = re.sub(r"^[-*]\s*", "", line)
|
|
38
|
+
line = re.sub(r"^\([a-z_-]+\)\s*", "", line).strip()
|
|
39
|
+
if line:
|
|
40
|
+
lines.append(line)
|
|
41
|
+
return lines
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _normalize_line(line: str) -> str:
|
|
45
|
+
return re.sub(r"\s+", " ", line).strip().rstrip(".").casefold()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _detect_always_never_contradictions(
|
|
49
|
+
agents_lines: list[str],
|
|
50
|
+
claude_lines: list[str],
|
|
51
|
+
) -> list[str]:
|
|
52
|
+
warnings: list[str] = []
|
|
53
|
+
agents_norms = [_normalize_line(line) for line in agents_lines]
|
|
54
|
+
agents_rules = {}
|
|
55
|
+
for line, norm in zip(agents_lines, agents_norms, strict=True):
|
|
56
|
+
if _rule_polarity(norm):
|
|
57
|
+
body = _rule_body(norm)
|
|
58
|
+
if body:
|
|
59
|
+
agents_rules[body] = (line, norm)
|
|
60
|
+
|
|
61
|
+
for claude_line in claude_lines:
|
|
62
|
+
norm = _normalize_line(claude_line)
|
|
63
|
+
claude_polarity = _rule_polarity(norm)
|
|
64
|
+
if claude_polarity is None:
|
|
65
|
+
continue
|
|
66
|
+
body = _rule_body(norm)
|
|
67
|
+
if not body:
|
|
68
|
+
continue
|
|
69
|
+
matched = agents_rules.get(body)
|
|
70
|
+
if matched is None:
|
|
71
|
+
continue
|
|
72
|
+
agents_line, agents_norm = matched
|
|
73
|
+
agents_polarity = _rule_polarity(agents_norm)
|
|
74
|
+
if agents_polarity != claude_polarity:
|
|
75
|
+
warnings.append(
|
|
76
|
+
f"Contradicao explicita entre AGENTS.md e CLAUDE.md: {agents_line} / {claude_line}"
|
|
77
|
+
)
|
|
78
|
+
return warnings
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _rule_polarity(normalized: str) -> str | None:
|
|
82
|
+
if normalized.startswith(("always ", "sempre ")):
|
|
83
|
+
return "positive"
|
|
84
|
+
if normalized.startswith(("never ", "nunca ")):
|
|
85
|
+
return "negative"
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _rule_body(normalized: str) -> str:
|
|
90
|
+
for prefix in ("always ", "never ", "sempre ", "nunca "):
|
|
91
|
+
if normalized.startswith(prefix):
|
|
92
|
+
return normalized.removeprefix(prefix)
|
|
93
|
+
return normalized
|