teammem-memberkit 0.1.0__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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: teammem-memberkit
3
+ Version: 0.1.0
4
+ Summary: Draft, review, and share local activity with a team-memory hub
5
+ Author: Team Memory Agent contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/xiongxhc/team-memory-agent
8
+ Project-URL: Documentation, https://github.com/xiongxhc/team-memory-agent#member-setup
9
+ Project-URL: Issues, https://github.com/xiongxhc/team-memory-agent/issues
10
+ Project-URL: Repository, https://github.com/xiongxhc/team-memory-agent
11
+ Keywords: agents,local-first,privacy,team-memory
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Office/Business
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # Team Memory MemberKit
27
+
28
+ MemberKit is the member-facing client for
29
+ [Team Memory Agent](https://github.com/xiongxhc/team-memory-agent). Members install
30
+ this package directly; they do not clone the repository or install the hub.
31
+ MemberKit is a standalone command-line package, not a skill.
32
+
33
+ MemberKit prepares reviewable local drafts from configured observations. Scheduled
34
+ runs create drafts and reminders only. Nothing is transmitted until the member
35
+ explicitly runs `memberkit push`.
36
+
37
+ ## Before installing
38
+
39
+ MemberKit requires Python 3.11 or newer, `pipx`, Git, and a local
40
+ [`claude-mem`](https://github.com/thedotmack/claude-mem) observations database. Ask
41
+ the team-memory operator for your roster slug, the inbox Git URL, and push access.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pipx install teammem-memberkit
47
+ memberkit --help
48
+ ```
49
+
50
+ Installing the package does not create a schedule or transmit anything. Configure
51
+ it separately:
52
+
53
+ ```bash
54
+ memberkit setup
55
+ ```
56
+
57
+ Setup asks for the roster slug and inbox URL. On macOS it then offers a daily 17:30
58
+ local reminder. Press Enter to accept, enter another `HH:MM`, or enter `no` to
59
+ decline. It stores private configuration at
60
+ `~/.config/teammem/memberkit.env`.
61
+
62
+ ## Review workflow
63
+
64
+ ```bash
65
+ memberkit review --date YYYY-MM-DD
66
+ memberkit push --date YYYY-MM-DD
67
+ ```
68
+
69
+ The date defaults to today. Drafts are stored at
70
+ `~/.memberkit/out/bundle-<member>-<YYYY-MM-DD>.json`. Remove a private item from
71
+ the JSON `events` list, save valid JSON, and run `memberkit review` again before
72
+ pushing. Editing only `journal_md` does not remove an event because that preview is
73
+ regenerated from `events` at push time.
74
+
75
+ To exclude an unfinished date without transmitting it:
76
+
77
+ ```bash
78
+ memberkit dismiss --date YYYY-MM-DD
79
+ ```
80
+
81
+ Removed events stay excluded from catch-up drafts. Invalid member-edited drafts are
82
+ left untouched, and MemberKit never pushes automatically.
83
+
84
+ ## Schedule
85
+
86
+ ```bash
87
+ memberkit schedule status
88
+ memberkit schedule install --time 17:30
89
+ memberkit schedule remove
90
+ memberkit scheduled-run
91
+ ```
92
+
93
+ MemberKit supports macOS launchd for automatic schedule installation. Other
94
+ platforms can schedule the portable `memberkit scheduled-run` command. A scheduled
95
+ run checks yesterday and today. Late work remains attributed to its original local
96
+ date, work after midnight belongs to the new day, and unfinished dates remain in
97
+ later reminders.
98
+
99
+ ## Upgrade and uninstall
100
+
101
+ ```bash
102
+ pipx upgrade teammem-memberkit
103
+ memberkit schedule remove
104
+ pipx uninstall teammem-memberkit
105
+ ```
106
+
107
+ Remove the schedule before uninstalling. Package removal does not delete
108
+ member-owned configuration, drafts, state, or the local inbox clone.
109
+
110
+ For configuration options, non-interactive setup, file locations, timing examples,
111
+ and troubleshooting, see the
112
+ [complete MemberKit guide](https://github.com/xiongxhc/team-memory-agent/blob/master/docs/member-guide.md).
113
+
114
+ Licensed under Apache-2.0.
@@ -0,0 +1,89 @@
1
+ # Team Memory MemberKit
2
+
3
+ MemberKit is the member-facing client for
4
+ [Team Memory Agent](https://github.com/xiongxhc/team-memory-agent). Members install
5
+ this package directly; they do not clone the repository or install the hub.
6
+ MemberKit is a standalone command-line package, not a skill.
7
+
8
+ MemberKit prepares reviewable local drafts from configured observations. Scheduled
9
+ runs create drafts and reminders only. Nothing is transmitted until the member
10
+ explicitly runs `memberkit push`.
11
+
12
+ ## Before installing
13
+
14
+ MemberKit requires Python 3.11 or newer, `pipx`, Git, and a local
15
+ [`claude-mem`](https://github.com/thedotmack/claude-mem) observations database. Ask
16
+ the team-memory operator for your roster slug, the inbox Git URL, and push access.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pipx install teammem-memberkit
22
+ memberkit --help
23
+ ```
24
+
25
+ Installing the package does not create a schedule or transmit anything. Configure
26
+ it separately:
27
+
28
+ ```bash
29
+ memberkit setup
30
+ ```
31
+
32
+ Setup asks for the roster slug and inbox URL. On macOS it then offers a daily 17:30
33
+ local reminder. Press Enter to accept, enter another `HH:MM`, or enter `no` to
34
+ decline. It stores private configuration at
35
+ `~/.config/teammem/memberkit.env`.
36
+
37
+ ## Review workflow
38
+
39
+ ```bash
40
+ memberkit review --date YYYY-MM-DD
41
+ memberkit push --date YYYY-MM-DD
42
+ ```
43
+
44
+ The date defaults to today. Drafts are stored at
45
+ `~/.memberkit/out/bundle-<member>-<YYYY-MM-DD>.json`. Remove a private item from
46
+ the JSON `events` list, save valid JSON, and run `memberkit review` again before
47
+ pushing. Editing only `journal_md` does not remove an event because that preview is
48
+ regenerated from `events` at push time.
49
+
50
+ To exclude an unfinished date without transmitting it:
51
+
52
+ ```bash
53
+ memberkit dismiss --date YYYY-MM-DD
54
+ ```
55
+
56
+ Removed events stay excluded from catch-up drafts. Invalid member-edited drafts are
57
+ left untouched, and MemberKit never pushes automatically.
58
+
59
+ ## Schedule
60
+
61
+ ```bash
62
+ memberkit schedule status
63
+ memberkit schedule install --time 17:30
64
+ memberkit schedule remove
65
+ memberkit scheduled-run
66
+ ```
67
+
68
+ MemberKit supports macOS launchd for automatic schedule installation. Other
69
+ platforms can schedule the portable `memberkit scheduled-run` command. A scheduled
70
+ run checks yesterday and today. Late work remains attributed to its original local
71
+ date, work after midnight belongs to the new day, and unfinished dates remain in
72
+ later reminders.
73
+
74
+ ## Upgrade and uninstall
75
+
76
+ ```bash
77
+ pipx upgrade teammem-memberkit
78
+ memberkit schedule remove
79
+ pipx uninstall teammem-memberkit
80
+ ```
81
+
82
+ Remove the schedule before uninstalling. Package removal does not delete
83
+ member-owned configuration, drafts, state, or the local inbox clone.
84
+
85
+ For configuration options, non-interactive setup, file locations, timing examples,
86
+ and troubleshooting, see the
87
+ [complete MemberKit guide](https://github.com/xiongxhc/team-memory-agent/blob/master/docs/member-guide.md).
88
+
89
+ Licensed under Apache-2.0.
File without changes
@@ -0,0 +1,75 @@
1
+ """Draft a teammem-bundle/v1 from the local claude-mem observations db (read-only)."""
2
+
3
+ import os
4
+ import sqlite3
5
+ from datetime import datetime, time, timedelta
6
+ from pathlib import Path
7
+ from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
8
+
9
+ SCHEMA = "teammem-bundle/v1"
10
+
11
+
12
+ def render_journal(events: list[dict], date: str) -> str:
13
+ by_project: dict[str, list[str]] = {}
14
+ for e in events:
15
+ by_project.setdefault(e["project"] or "general", []).append(e["summary"])
16
+ lines = [f"## {date}"]
17
+ for project in sorted(by_project):
18
+ lines.append(f"\n### {project}")
19
+ lines.extend(f"- {s}" for s in by_project[project])
20
+ return "\n".join(lines)
21
+
22
+
23
+ def _local_timezone():
24
+ configured = os.environ.get("MEMBERKIT_TIMEZONE") or os.environ.get("TZ")
25
+ if configured:
26
+ try:
27
+ return ZoneInfo(configured.removeprefix(":"))
28
+ except ZoneInfoNotFoundError:
29
+ pass
30
+
31
+ try:
32
+ resolved = Path("/etc/localtime").resolve()
33
+ parts = resolved.parts
34
+ marker = parts.index("zoneinfo")
35
+ return ZoneInfo("/".join(parts[marker + 1:]))
36
+ except (OSError, ValueError, ZoneInfoNotFoundError):
37
+ return datetime.now().astimezone().tzinfo
38
+
39
+
40
+ def _day_epochs(date: str) -> tuple[int, int]:
41
+ day = datetime.strptime(date, "%Y-%m-%d").date()
42
+ zone = _local_timezone()
43
+ start = datetime.combine(day, time.min, tzinfo=zone)
44
+ end = datetime.combine(day + timedelta(days=1), time.min, tzinfo=zone)
45
+ return int(start.timestamp()), int(end.timestamp())
46
+
47
+
48
+ def draft(db_path: Path, member: str, date: str) -> dict:
49
+ lo, hi = _day_epochs(date)
50
+ con = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
51
+ con.row_factory = sqlite3.Row
52
+ try:
53
+ rows = con.execute(
54
+ "SELECT project, title, narrative, created_at FROM observations"
55
+ " WHERE created_at_epoch >= ? AND created_at_epoch < ?"
56
+ " ORDER BY created_at_epoch",
57
+ (lo, hi),
58
+ ).fetchall()
59
+ finally:
60
+ con.close()
61
+
62
+ events = [
63
+ {
64
+ "ts": r["created_at"],
65
+ "kind": "journal-highlight",
66
+ "summary": (r["title"] or (r["narrative"] or "").strip()[:120]),
67
+ "project": r["project"],
68
+ "refs": None,
69
+ }
70
+ for r in rows
71
+ if r["title"] or (r["narrative"] or "").strip()
72
+ ]
73
+
74
+ return {"schema": SCHEMA, "member": member, "date": date,
75
+ "events": events, "journal_md": render_journal(events, date)}
@@ -0,0 +1,135 @@
1
+ """memberkit CLI: draft -> review -> push. Push only after the member reviews."""
2
+
3
+ import argparse
4
+ import json
5
+ from datetime import date as _date
6
+ from pathlib import Path
7
+
8
+ from . import bundle, config
9
+ from .schedule import (DEFAULT_TIME, install_schedule, remove_schedule,
10
+ schedule_status, scheduled_run)
11
+ from .state import DraftState
12
+
13
+
14
+ def main(argv: list[str] | None = None) -> int:
15
+ parser = argparse.ArgumentParser(prog="memberkit",
16
+ description="Review and share local activity with team memory")
17
+ sub = parser.add_subparsers(dest="cmd", required=True)
18
+ for name in ("draft", "review", "push", "dismiss"):
19
+ p = sub.add_parser(name)
20
+ p.add_argument("--date", default=_date.today().isoformat(),
21
+ help="YYYY-MM-DD (default: today)")
22
+ sub.choices["draft"].add_argument("--force", action="store_true",
23
+ help="overwrite an existing bundle")
24
+ p_setup = sub.add_parser("setup", help="configure MemberKit and its local reminder")
25
+ p_setup.add_argument("--member")
26
+ p_setup.add_argument("--inbox-url")
27
+ p_setup.add_argument("--time")
28
+ p_setup.add_argument("--no-schedule", action="store_true")
29
+ p_setup.add_argument("--db", default="~/.claude-mem/claude-mem.db")
30
+ p_setup.add_argument("--workdir", default="~/.memberkit")
31
+ p_schedule = sub.add_parser("schedule", help="manage the local draft reminder")
32
+ schedule_sub = p_schedule.add_subparsers(dest="schedule_cmd", required=True)
33
+ p_install = schedule_sub.add_parser("install")
34
+ p_install.add_argument("--time", default=DEFAULT_TIME)
35
+ schedule_sub.add_parser("status")
36
+ schedule_sub.add_parser("remove")
37
+ sub.add_parser("scheduled-run", help="prepare local drafts for the scheduler")
38
+ args = parser.parse_args(argv)
39
+
40
+ if args.cmd == "setup":
41
+ member = args.member or input("Member slug: ").strip()
42
+ inbox_url = args.inbox_url or input("Inbox Git URL: ").strip()
43
+ if not member or not inbox_url:
44
+ raise SystemExit("member slug and inbox URL are required")
45
+ config.CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
46
+ config.CONFIG_FILE.write_text(
47
+ "\n".join([
48
+ f"MEMBERKIT_MEMBER={member}",
49
+ f"MEMBERKIT_INBOX_URL={inbox_url}",
50
+ f"MEMBERKIT_DB={Path(args.db).expanduser()}",
51
+ f"MEMBERKIT_WORKDIR={Path(args.workdir).expanduser()}",
52
+ "",
53
+ ]),
54
+ encoding="utf-8",
55
+ )
56
+ config.CONFIG_FILE.chmod(0o600)
57
+ cfg = config.load({})
58
+ schedule_time = args.time
59
+ if not args.no_schedule and schedule_time is None:
60
+ choice = input(
61
+ f"Daily reminder time [{DEFAULT_TIME}], or 'no' to decline: "
62
+ ).strip()
63
+ if choice.lower() in {"n", "no", "none", "off", "decline"}:
64
+ args.no_schedule = True
65
+ else:
66
+ schedule_time = choice or DEFAULT_TIME
67
+ if args.no_schedule:
68
+ print(f"configured {config.CONFIG_FILE}; schedule disabled")
69
+ else:
70
+ path = install_schedule(cfg, time=schedule_time)
71
+ print(
72
+ f"configured {config.CONFIG_FILE}; daily reminder "
73
+ f"{schedule_time} -> {path}"
74
+ )
75
+ return 0
76
+
77
+ cfg = config.load()
78
+ if args.cmd == "schedule":
79
+ if args.schedule_cmd == "install":
80
+ path = install_schedule(cfg, time=args.time)
81
+ print(f"installed {args.time} -> {path}")
82
+ elif args.schedule_cmd == "status":
83
+ status = schedule_status()
84
+ print(f"{'installed' if status.installed else 'not installed'}"
85
+ f"{f' at {status.time}' if status.time else ''}")
86
+ else:
87
+ print("removed" if remove_schedule() else "not installed")
88
+ return 0
89
+ if args.cmd == "scheduled-run":
90
+ dates = scheduled_run(cfg)
91
+ print(f"drafts ready: {', '.join(dates) if dates else 'none'}")
92
+ return 0
93
+
94
+ out = cfg.workdir / "out" / f"bundle-{cfg.member}-{args.date}.json"
95
+
96
+ if args.cmd == "dismiss":
97
+ DraftState(cfg.workdir / "state.json").dismiss(args.date)
98
+ print(f"dismissed {args.date}; pending events excluded")
99
+ elif args.cmd == "draft":
100
+ if not cfg.db.exists():
101
+ raise SystemExit(f"no claude-mem db at {cfg.db} — is claude-mem installed?")
102
+ if out.exists() and not args.force:
103
+ raise SystemExit(f"{out} exists (possibly member-edited) — use --force to overwrite")
104
+ data = bundle.draft(cfg.db, cfg.member, args.date)
105
+ data["events"] = DraftState(cfg.workdir / "state.json").refresh(
106
+ args.date, data["events"], current=None
107
+ )
108
+ data["journal_md"] = bundle.render_journal(data["events"], args.date)
109
+ out.parent.mkdir(parents=True, exist_ok=True)
110
+ out.write_text(
111
+ json.dumps(data, indent=2, ensure_ascii=False) + "\n",
112
+ encoding="utf-8",
113
+ )
114
+ print(f"drafted {len(data['events'])} events -> {out}")
115
+ print("review before pushing: memberkit review")
116
+ elif args.cmd == "review":
117
+ if not out.exists():
118
+ raise SystemExit(f"no bundle at {out} — run `memberkit draft` first")
119
+ data = json.loads(out.read_text(encoding="utf-8"))
120
+ print(bundle.render_journal(data["events"], data["date"]))
121
+ print()
122
+ for e in data["events"]:
123
+ print(f" [{e['ts']}] {e['project'] or 'general'}: {e['summary']}")
124
+ print(f"\n[{len(data['events'])} events — remove private items by deleting them from"
125
+ f" the 'events' list in {out}; journal_md is regenerated from events at push]")
126
+ else:
127
+ from . import push as push_mod
128
+
129
+ dest = push_mod.push(cfg, args.date)
130
+ print(f"pushed -> {dest}")
131
+ return 0
132
+
133
+
134
+ if __name__ == "__main__":
135
+ raise SystemExit(main())
@@ -0,0 +1,43 @@
1
+ """MEMBERKIT_* config: process env overrides ~/.config/teammem/memberkit.env."""
2
+
3
+ import os
4
+ from dataclasses import dataclass
5
+ from pathlib import Path
6
+
7
+ CONFIG_FILE = Path.home() / ".config" / "teammem" / "memberkit.env"
8
+
9
+
10
+ @dataclass(frozen=True)
11
+ class Config:
12
+ member: str
13
+ db: Path
14
+ inbox_url: str
15
+ workdir: Path
16
+
17
+
18
+ def _read_env_file(path: Path) -> dict[str, str]:
19
+ if not path.exists():
20
+ return {}
21
+ pairs = {}
22
+ for line in path.read_text(encoding="utf-8").splitlines():
23
+ line = line.strip()
24
+ if line and not line.startswith("#") and "=" in line:
25
+ key, val = line.split("=", 1)
26
+ pairs[key.strip()] = val.strip()
27
+ return pairs
28
+
29
+
30
+ def load(env: dict[str, str] | None = None) -> Config:
31
+ merged = {**_read_env_file(CONFIG_FILE), **(dict(os.environ) if env is None else env)}
32
+
33
+ def need(key: str) -> str:
34
+ if not merged.get(key):
35
+ raise SystemExit(f"missing {key}: set it in {CONFIG_FILE} or the environment")
36
+ return merged[key]
37
+
38
+ return Config(
39
+ member=need("MEMBERKIT_MEMBER"),
40
+ db=Path(merged.get("MEMBERKIT_DB", "~/.claude-mem/claude-mem.db")).expanduser(),
41
+ inbox_url=need("MEMBERKIT_INBOX_URL"),
42
+ workdir=Path(merged.get("MEMBERKIT_WORKDIR", "~/.memberkit")).expanduser(),
43
+ )