diff --git a/src/void_tools/cli.py b/src/void_tools/cli.py index da10dbc..567fd33 100644 --- a/src/void_tools/cli.py +++ b/src/void_tools/cli.py @@ -95,7 +95,7 @@ def cmd_sync(args): latest_seen_timestamp = "" while not stop_pagination: - params = {'limit': min(50, args.limit) if not args.unread_only else 50} + params = {'limit': 50} if cursor: params['cursor'] = cursor @@ -105,14 +105,21 @@ def cmd_sync(args): break for notif in response.notifications: + # Filter out passive engagement (likes and non-quote reposts) + if notif.reason in ['like', 'repost']: + # We still update the latest seen timestamp to not break the sync marker + if not latest_seen_timestamp or notif.indexed_at > latest_seen_timestamp: + latest_seen_timestamp = notif.indexed_at + continue + if args.unread_only and notif.is_read: stop_pagination = True break - if not args.unread_only and len(inbox) >= args.limit: + if not args.unread_only and len(inbox) >= 100: stop_pagination = True break - + # Capture the timestamp of the most recent notification we fetched if not latest_seen_timestamp or notif.indexed_at > latest_seen_timestamp: latest_seen_timestamp = notif.indexed_at @@ -135,7 +142,6 @@ def cmd_sync(args): try: with open(memory_file, 'r') as mf: content = mf.read() - # Very basic frontmatter stripping if content.startswith("---"): parts = content.split("---", 2) if len(parts) >= 3: @@ -144,34 +150,40 @@ def cmd_sync(args): except Exception as e: item["memory_block"] = f"Error reading memory: {e}" else: - item["memory_block"] = "No prior records found." - - # Fetch thread context for replies, quotes, or mentions - if notif.reason in ['reply', 'quote', 'mention']: - try: - thread_uri = notif.uri - if notif.reason == 'quote' and hasattr(notif.record, 'embed') and hasattr(notif.record.embed, 'record'): - pass - - thread_resp = client.app.bsky.feed.get_post_thread({'uri': thread_uri, 'depth': 0, 'parent_height': 5}) - - context = [] - curr = thread_resp.thread - while hasattr(curr, 'parent') and curr.parent: - curr = curr.parent - if hasattr(curr, 'post') and hasattr(curr.post, 'record') and hasattr(curr.post.record, 'text'): - context.insert(0, { - "author": f"@{curr.post.author.handle}", - "text": curr.post.record.text - }) - - if context: - item["thread_context"] = context - except Exception as e: - item["thread_context"] = f"Failed to fetch context: {str(e)}" + item["memory_block"] = "No prior records found. Auto-creating stub." + try: + import datetime + today = datetime.datetime.utcnow().strftime('%Y-%m-%d') + stub_content = f"---\ndescription: User block for {safe_handle}\n---\n# User: @{handle}\n\n## Interaction History\n- **{today}:** Profile initialized via automated sync discovery.\n" + with open(memory_file, 'w') as mf: + mf.write(stub_content) + print(f" [+] Auto-created core memory block for @{handle}") + except Exception as e: + print(f" [!] Failed to auto-create block for @{handle}: {e}") - inbox.append(item) - mapping[local_id] = notif.uri + # Fetch thread context for replies, quotes, or mentions + if notif.reason in ['reply', 'quote', 'mention']: + try: + thread_uri = notif.uri + thread_resp = client.app.bsky.feed.get_post_thread({'uri': thread_uri, 'depth': 0, 'parent_height': 5}) + + context = [] + curr = thread_resp.thread + while hasattr(curr, 'parent') and curr.parent: + curr = curr.parent + if hasattr(curr, 'post') and hasattr(curr.post, 'record') and hasattr(curr.post.record, 'text'): + context.insert(0, { + "author": f"@{curr.post.author.handle}", + "text": curr.post.record.text + }) + + if context: + item["thread_context"] = context + except Exception as e: + item["thread_context"] = f"Failed to fetch context: {str(e)}" + + inbox.append(item) + mapping[local_id] = notif.uri if stop_pagination or not response.cursor: break @@ -566,7 +578,6 @@ def main(): # Sync sync_parser = subparsers.add_parser("sync", help="Sync unread notifications to inbox.yaml") - sync_parser.add_argument("--limit", type=int, default=20, help="Number of notifications to fetch") sync_parser.add_argument("--all", dest="unread_only", action="store_false", help="Fetch read notifications as well") sync_parser.set_defaults(unread_only=True) @@ -592,7 +603,6 @@ def main(): update_parser.add_argument("--description", help="New description/bio") update_parser.add_argument("--display-name", help="New display name") - # Dispatch dispatch_parser = subparsers.add_parser("dispatch", help="Dispatch posts from an outbox YAML file") dispatch_parser.add_argument("file", nargs="?", default="outbox.yaml", help="Path to outbox YAML file")