memory-cli 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.
Files changed (128) hide show
  1. memory_cli/__init__.py +1 -0
  2. memory_cli/__main__.py +49 -0
  3. memory_cli/capture/__init__.py +7 -0
  4. memory_cli/capture/codex_rollout.py +164 -0
  5. memory_cli/capture/event_lines.py +66 -0
  6. memory_cli/capture/extract.py +458 -0
  7. memory_cli/capture/state.py +183 -0
  8. memory_cli/commands/__init__.py +21 -0
  9. memory_cli/commands/admin.py +363 -0
  10. memory_cli/commands/common.py +609 -0
  11. memory_cli/commands/curate.py +1189 -0
  12. memory_cli/commands/diagnostics.py +126 -0
  13. memory_cli/commands/edit.py +1282 -0
  14. memory_cli/commands/hooks.py +730 -0
  15. memory_cli/commands/import_recovery.py +45 -0
  16. memory_cli/commands/install.py +152 -0
  17. memory_cli/commands/integrate.py +480 -0
  18. memory_cli/commands/memory.py +2152 -0
  19. memory_cli/commands/read.py +1290 -0
  20. memory_cli/commands/sources.py +766 -0
  21. memory_cli/commands/split.py +97 -0
  22. memory_cli/commands/split_plan.py +196 -0
  23. memory_cli/commands/split_transaction.py +230 -0
  24. memory_cli/commands/synthesis.py +1122 -0
  25. memory_cli/core/__init__.py +16 -0
  26. memory_cli/core/auto_state.py +30 -0
  27. memory_cli/core/codex_pass.py +109 -0
  28. memory_cli/core/config.py +87 -0
  29. memory_cli/core/file_journal.py +163 -0
  30. memory_cli/core/headless.py +130 -0
  31. memory_cli/core/jobs.py +130 -0
  32. memory_cli/core/resources.py +57 -0
  33. memory_cli/core/runner.py +398 -0
  34. memory_cli/core/safe_io.py +155 -0
  35. memory_cli/core/store_git.py +407 -0
  36. memory_cli/core/yaml_load.py +14 -0
  37. memory_cli/corroborate/__init__.py +11 -0
  38. memory_cli/corroborate/cli.py +267 -0
  39. memory_cli/corroborate/decide.py +893 -0
  40. memory_cli/corroborate/digest.py +425 -0
  41. memory_cli/corroborate/fill.py +744 -0
  42. memory_cli/corroborate/job.py +15 -0
  43. memory_cli/corroborate/reword.py +446 -0
  44. memory_cli/corroborate/run.py +1142 -0
  45. memory_cli/corroborate/state.py +300 -0
  46. memory_cli/digest/__init__.py +4 -0
  47. memory_cli/digest/lessons.py +483 -0
  48. memory_cli/entry/__init__.py +12 -0
  49. memory_cli/entry/auto.py +660 -0
  50. memory_cli/entry/capture.py +1403 -0
  51. memory_cli/entry/corroborate.py +214 -0
  52. memory_cli/entry/integrate.py +684 -0
  53. memory_cli/entry/integrate_self_check.py +203 -0
  54. memory_cli/entry/research.py +9 -0
  55. memory_cli/entry/settle.py +614 -0
  56. memory_cli/entry/split_auto.py +460 -0
  57. memory_cli/entry/synthesize.py +22 -0
  58. memory_cli/integrate/__init__.py +9 -0
  59. memory_cli/integrate/answers.py +42 -0
  60. memory_cli/integrate/briefs/check-brief.md +16 -0
  61. memory_cli/integrate/briefs/place-brief.md +26 -0
  62. memory_cli/integrate/log.py +43 -0
  63. memory_cli/integrate/plan.py +125 -0
  64. memory_cli/integrate/rows.py +99 -0
  65. memory_cli/integrate/state.py +158 -0
  66. memory_cli/integrate/undo.py +143 -0
  67. memory_cli/mem.py +1180 -0
  68. memory_cli/memories/__init__.py +16 -0
  69. memory_cli/memories/fingerprints.py +51 -0
  70. memory_cli/memories/journal.py +93 -0
  71. memory_cli/memories/locations.py +282 -0
  72. memory_cli/memories/matching.py +451 -0
  73. memory_cli/memories/model.py +205 -0
  74. memory_cli/memories/parse.py +237 -0
  75. memory_cli/memories/records.py +266 -0
  76. memory_cli/memories/rules.py +291 -0
  77. memory_cli/memories/sightings.py +314 -0
  78. memory_cli/memories/terms.py +148 -0
  79. memory_cli/memories/write.py +358 -0
  80. memory_cli/notes/__init__.py +13 -0
  81. memory_cli/notes/check.py +806 -0
  82. memory_cli/notes/due.py +260 -0
  83. memory_cli/notes/fields.py +217 -0
  84. memory_cli/notes/index.py +230 -0
  85. memory_cli/notes/links.py +170 -0
  86. memory_cli/notes/note.py +222 -0
  87. memory_cli/notes/search.py +391 -0
  88. memory_cli/notes/split_candidates.py +72 -0
  89. memory_cli/research/__init__.py +5 -0
  90. memory_cli/research/checks.py +1065 -0
  91. memory_cli/research/pipeline.py +952 -0
  92. memory_cli/session/__init__.py +5 -0
  93. memory_cli/session/handoff.py +139 -0
  94. memory_cli/session/notices.py +111 -0
  95. memory_cli/settle/__init__.py +5 -0
  96. memory_cli/settle/state.py +111 -0
  97. memory_cli/settle/verdicts.py +693 -0
  98. memory_cli/split/briefs/checker-brief.md +5 -0
  99. memory_cli/split/briefs/editor-brief.md +20 -0
  100. memory_cli/syntheses/__init__.py +8 -0
  101. memory_cli/syntheses/document.py +400 -0
  102. memory_cli/syntheses/edit.py +581 -0
  103. memory_cli/syntheses/project.py +384 -0
  104. memory_cli/syntheses/split_conservation.py +50 -0
  105. memory_cli/syntheses/units.py +427 -0
  106. memory_cli/synthesize/__init__.py +9 -0
  107. memory_cli/synthesize/backfill.py +431 -0
  108. memory_cli/synthesize/briefs/backfill-brief.md +26 -0
  109. memory_cli/synthesize/briefs/checker-brief.md +13 -0
  110. memory_cli/synthesize/briefs/fixer-brief.md +19 -0
  111. memory_cli/synthesize/briefs/memory-brief.md +30 -0
  112. memory_cli/synthesize/briefs/settle-brief.md +32 -0
  113. memory_cli/synthesize/briefs/verdict-brief.md +50 -0
  114. memory_cli/synthesize/briefs/web-brief.md +33 -0
  115. memory_cli/synthesize/cli.py +311 -0
  116. memory_cli/synthesize/pipeline.py +764 -0
  117. memory_cli/synthesize/references.py +164 -0
  118. memory_cli/synthesize/run.py +150 -0
  119. memory_cli/synthesize/topics.py +528 -0
  120. memory_cli/templates/knowledge.md +23 -0
  121. memory_cli/templates/literature.md +25 -0
  122. memory_cli/templates/research.md +23 -0
  123. memory_cli/templates/synthesis.md +6 -0
  124. memory_cli-0.1.0.dist-info/METADATA +102 -0
  125. memory_cli-0.1.0.dist-info/RECORD +128 -0
  126. memory_cli-0.1.0.dist-info/WHEEL +4 -0
  127. memory_cli-0.1.0.dist-info/entry_points.txt +9 -0
  128. memory_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,126 @@
1
+ """Read-only report of local memory configuration and observed hook delivery."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import shutil
8
+ from collections import deque
9
+ from datetime import datetime
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from memory_cli.commands import common
14
+ from memory_cli.core import config, resources, runner
15
+
16
+ PLUGIN = resources.plugin_root() # None when the engine runs outside the plugin
17
+ ROLES = (
18
+ "memory-curator",
19
+ "memory-recorder",
20
+ "memory-researcher",
21
+ "memory-status-checker",
22
+ "memory-synthesizer",
23
+ )
24
+
25
+
26
+ def _hook_stamp(line: str, host: str) -> dict[str, str] | None:
27
+ try:
28
+ record = json.loads(line)
29
+ if not isinstance(record, dict) or record.get("host") != host:
30
+ return None
31
+ hook = record.get("hook")
32
+ if hook not in {"session-index", "session-end", "post-compact", "signal"}:
33
+ return None
34
+ stamp = datetime.fromisoformat(record["t"]).isoformat()
35
+ return {"hook": hook, "time": stamp}
36
+ except (TypeError, ValueError, KeyError, RecursionError):
37
+ return None
38
+
39
+
40
+ def _last_hook(data: Path | None, host: str) -> dict[str, str] | None:
41
+ if data is None:
42
+ return None
43
+ try:
44
+ with (data / "hooks" / "log.jsonl").open(encoding="utf-8") as stream:
45
+ recent = deque(stream, maxlen=1000)
46
+ except (OSError, UnicodeError):
47
+ return None
48
+ return next((stamp for line in reversed(recent) if (stamp := _hook_stamp(line, host))), None)
49
+
50
+
51
+ def cmd_diagnostics(args: Any) -> int:
52
+ env = os.environ
53
+ host = (
54
+ args.host or env.get("MEM_HOST") or ("codex" if env.get("CODEX_THREAD_ID") else "unknown")
55
+ )
56
+ if host not in {"codex", "claude"}:
57
+ host = "unknown"
58
+ hooks_dir = PLUGIN / "hooks" if PLUGIN else None
59
+ manifest = (
60
+ hooks_dir / ("codex.json" if host == "codex" else "hooks.json") if hooks_dir else None
61
+ )
62
+ plugin_present = hooks_dir is not None and any(
63
+ (hooks_dir / name).is_file() for name in ("codex.json", "hooks.json")
64
+ )
65
+ configured: dict[str, bool] = {}
66
+ if host != "unknown" and manifest is not None:
67
+ try:
68
+ hooks = json.loads(manifest.read_text(encoding="utf-8")).get("hooks", {})
69
+ configured = {
70
+ key: bool(hooks.get(key))
71
+ for key in (
72
+ "SessionStart",
73
+ "SessionEnd",
74
+ "SubagentStart",
75
+ "PreCompact",
76
+ "PostCompact",
77
+ )
78
+ }
79
+ except (OSError, ValueError, AttributeError):
80
+ pass
81
+ home = Path(env["HOME"]) if env.get("HOME") else None
82
+ codex_home = (
83
+ Path(env["CODEX_HOME"]) if env.get("CODEX_HOME") else (home / ".codex" if home else None)
84
+ )
85
+ roles = {
86
+ name: bool(codex_home and (codex_home / "agents" / (name + ".toml")).is_file())
87
+ for name in ROLES
88
+ }
89
+ root = config.resolve_store(args.root, env)
90
+ result = {
91
+ "plugin_path": str(PLUGIN) if plugin_present else None,
92
+ "host": host,
93
+ "hooks": {
94
+ "manifest": str(manifest)
95
+ if host != "unknown" and manifest is not None and manifest.is_file()
96
+ else None,
97
+ "configured": configured,
98
+ "trust": "unknown",
99
+ "last_observed": _last_hook(common.data_dir(env), host),
100
+ },
101
+ "roles": {"installed": roles, "session_visibility": "unknown"},
102
+ "store": {
103
+ "path": str(root) if root else None,
104
+ "source": config.store_source(args.root, env),
105
+ "readable": bool(root and root.is_dir() and os.access(root, os.R_OK | os.X_OK)),
106
+ },
107
+ "dependencies": {
108
+ "uv": shutil.which("uv"),
109
+ "claude": shutil.which("claude"),
110
+ "codex": runner.find_codex(env),
111
+ },
112
+ }
113
+ print(json.dumps(result, indent=2))
114
+ return 0
115
+
116
+
117
+ def add_parser(sub: Any) -> None:
118
+ parser = sub.add_parser(
119
+ "diagnostics", help="report local host configuration and observed hook delivery"
120
+ )
121
+ parser.add_argument(
122
+ "--host",
123
+ choices=("claude", "codex"),
124
+ help="host to inspect (otherwise detected where possible)",
125
+ )
126
+ parser.set_defaults(func=cmd_diagnostics)