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.
- memory_cli/__init__.py +1 -0
- memory_cli/__main__.py +49 -0
- memory_cli/capture/__init__.py +7 -0
- memory_cli/capture/codex_rollout.py +164 -0
- memory_cli/capture/event_lines.py +66 -0
- memory_cli/capture/extract.py +458 -0
- memory_cli/capture/state.py +183 -0
- memory_cli/commands/__init__.py +21 -0
- memory_cli/commands/admin.py +363 -0
- memory_cli/commands/common.py +609 -0
- memory_cli/commands/curate.py +1189 -0
- memory_cli/commands/diagnostics.py +126 -0
- memory_cli/commands/edit.py +1282 -0
- memory_cli/commands/hooks.py +730 -0
- memory_cli/commands/import_recovery.py +45 -0
- memory_cli/commands/install.py +152 -0
- memory_cli/commands/integrate.py +480 -0
- memory_cli/commands/memory.py +2152 -0
- memory_cli/commands/read.py +1290 -0
- memory_cli/commands/sources.py +766 -0
- memory_cli/commands/split.py +97 -0
- memory_cli/commands/split_plan.py +196 -0
- memory_cli/commands/split_transaction.py +230 -0
- memory_cli/commands/synthesis.py +1122 -0
- memory_cli/core/__init__.py +16 -0
- memory_cli/core/auto_state.py +30 -0
- memory_cli/core/codex_pass.py +109 -0
- memory_cli/core/config.py +87 -0
- memory_cli/core/file_journal.py +163 -0
- memory_cli/core/headless.py +130 -0
- memory_cli/core/jobs.py +130 -0
- memory_cli/core/resources.py +57 -0
- memory_cli/core/runner.py +398 -0
- memory_cli/core/safe_io.py +155 -0
- memory_cli/core/store_git.py +407 -0
- memory_cli/core/yaml_load.py +14 -0
- memory_cli/corroborate/__init__.py +11 -0
- memory_cli/corroborate/cli.py +267 -0
- memory_cli/corroborate/decide.py +893 -0
- memory_cli/corroborate/digest.py +425 -0
- memory_cli/corroborate/fill.py +744 -0
- memory_cli/corroborate/job.py +15 -0
- memory_cli/corroborate/reword.py +446 -0
- memory_cli/corroborate/run.py +1142 -0
- memory_cli/corroborate/state.py +300 -0
- memory_cli/digest/__init__.py +4 -0
- memory_cli/digest/lessons.py +483 -0
- memory_cli/entry/__init__.py +12 -0
- memory_cli/entry/auto.py +660 -0
- memory_cli/entry/capture.py +1403 -0
- memory_cli/entry/corroborate.py +214 -0
- memory_cli/entry/integrate.py +684 -0
- memory_cli/entry/integrate_self_check.py +203 -0
- memory_cli/entry/research.py +9 -0
- memory_cli/entry/settle.py +614 -0
- memory_cli/entry/split_auto.py +460 -0
- memory_cli/entry/synthesize.py +22 -0
- memory_cli/integrate/__init__.py +9 -0
- memory_cli/integrate/answers.py +42 -0
- memory_cli/integrate/briefs/check-brief.md +16 -0
- memory_cli/integrate/briefs/place-brief.md +26 -0
- memory_cli/integrate/log.py +43 -0
- memory_cli/integrate/plan.py +125 -0
- memory_cli/integrate/rows.py +99 -0
- memory_cli/integrate/state.py +158 -0
- memory_cli/integrate/undo.py +143 -0
- memory_cli/mem.py +1180 -0
- memory_cli/memories/__init__.py +16 -0
- memory_cli/memories/fingerprints.py +51 -0
- memory_cli/memories/journal.py +93 -0
- memory_cli/memories/locations.py +282 -0
- memory_cli/memories/matching.py +451 -0
- memory_cli/memories/model.py +205 -0
- memory_cli/memories/parse.py +237 -0
- memory_cli/memories/records.py +266 -0
- memory_cli/memories/rules.py +291 -0
- memory_cli/memories/sightings.py +314 -0
- memory_cli/memories/terms.py +148 -0
- memory_cli/memories/write.py +358 -0
- memory_cli/notes/__init__.py +13 -0
- memory_cli/notes/check.py +806 -0
- memory_cli/notes/due.py +260 -0
- memory_cli/notes/fields.py +217 -0
- memory_cli/notes/index.py +230 -0
- memory_cli/notes/links.py +170 -0
- memory_cli/notes/note.py +222 -0
- memory_cli/notes/search.py +391 -0
- memory_cli/notes/split_candidates.py +72 -0
- memory_cli/research/__init__.py +5 -0
- memory_cli/research/checks.py +1065 -0
- memory_cli/research/pipeline.py +952 -0
- memory_cli/session/__init__.py +5 -0
- memory_cli/session/handoff.py +139 -0
- memory_cli/session/notices.py +111 -0
- memory_cli/settle/__init__.py +5 -0
- memory_cli/settle/state.py +111 -0
- memory_cli/settle/verdicts.py +693 -0
- memory_cli/split/briefs/checker-brief.md +5 -0
- memory_cli/split/briefs/editor-brief.md +20 -0
- memory_cli/syntheses/__init__.py +8 -0
- memory_cli/syntheses/document.py +400 -0
- memory_cli/syntheses/edit.py +581 -0
- memory_cli/syntheses/project.py +384 -0
- memory_cli/syntheses/split_conservation.py +50 -0
- memory_cli/syntheses/units.py +427 -0
- memory_cli/synthesize/__init__.py +9 -0
- memory_cli/synthesize/backfill.py +431 -0
- memory_cli/synthesize/briefs/backfill-brief.md +26 -0
- memory_cli/synthesize/briefs/checker-brief.md +13 -0
- memory_cli/synthesize/briefs/fixer-brief.md +19 -0
- memory_cli/synthesize/briefs/memory-brief.md +30 -0
- memory_cli/synthesize/briefs/settle-brief.md +32 -0
- memory_cli/synthesize/briefs/verdict-brief.md +50 -0
- memory_cli/synthesize/briefs/web-brief.md +33 -0
- memory_cli/synthesize/cli.py +311 -0
- memory_cli/synthesize/pipeline.py +764 -0
- memory_cli/synthesize/references.py +164 -0
- memory_cli/synthesize/run.py +150 -0
- memory_cli/synthesize/topics.py +528 -0
- memory_cli/templates/knowledge.md +23 -0
- memory_cli/templates/literature.md +25 -0
- memory_cli/templates/research.md +23 -0
- memory_cli/templates/synthesis.md +6 -0
- memory_cli-0.1.0.dist-info/METADATA +102 -0
- memory_cli-0.1.0.dist-info/RECORD +128 -0
- memory_cli-0.1.0.dist-info/WHEEL +4 -0
- memory_cli-0.1.0.dist-info/entry_points.txt +9 -0
- 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)
|