-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_session_memory.py
More file actions
75 lines (64 loc) · 2.02 KB
/
Copy pathinit_session_memory.py
File metadata and controls
75 lines (64 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
from __future__ import annotations
import argparse
from pathlib import Path
from session_memory_common import (
iter_resolution_summary,
read_text,
resolve_memory_paths,
write_if_missing,
)
def main() -> int:
parser = argparse.ArgumentParser(
description="Initialize session memory files with project-aware scoping."
)
parser.add_argument(
"--workspace",
default=".",
help="Starting directory used to resolve the target location.",
)
parser.add_argument(
"--scope",
choices=("auto", "workspace", "global"),
default="auto",
help="auto=shared project memory, optionally routed by config.toml; workspace=current path only; global=${SESSION_MEMORY_HOME:-$HOME/.session-memory}/global",
)
parser.add_argument(
"--force",
action="store_true",
help="Overwrite existing memory files.",
)
args = parser.parse_args()
script_dir = Path(__file__).resolve().parent
skill_dir = script_dir.parent
refs_dir = skill_dir / "references"
workspace = Path(args.workspace).resolve()
paths = resolve_memory_paths(workspace, args.scope)
target_dir = Path(paths["target_dir"])
current_path = Path(paths["current"])
history_path = Path(paths["history"])
research_path = Path(paths["research"])
target_dir.mkdir(parents=True, exist_ok=True)
write_if_missing(
current_path,
read_text(refs_dir / "current-template.md"),
force=args.force,
)
write_if_missing(
history_path,
read_text(refs_dir / "history-template.md"),
force=args.force,
)
write_if_missing(
research_path,
read_text(refs_dir / "research-template.md"),
force=args.force,
)
for line in iter_resolution_summary(paths):
print(line)
print(f"current={current_path}")
print(f"history={history_path}")
print(f"research={research_path}")
return 0
if __name__ == "__main__":
raise SystemExit(main())