import json, os, textwrap, zipfile, datetime, sys, re base = "/mnt/data/calvin_ip_rollout_kit" os.makedirs(base, exist_ok=True)
tag_injector = r'''#!/usr/bin/env python3 """ tag_injector.py — Calvin IP rollout helper Add an '@' mention form next to every hashtag (#tag → #tag @tag) Optionally, annotate Python comments so "# comment" becomes "#@ comment". Also works across Markdown (.md) and Jupyter notebooks (.ipynb).
USAGE (common): python tag_injector.py path_or_folder --mode hashtags_only python tag_injector.py my_notebook.ipynb --mode comments_too --add-header "CALVIN THOMAS — MY IP — NOTHING ELSE — @sama"
FILES SUPPORTED:
BEHAVIOR:
HASHTAG_RX = re.compile(r'(?<!\w)#([A-Za-z0-9_]{1,64})')
def tag_hashtags(text: str, touch_headings: bool=False) -> str: lines = text.splitlines(keepends=False) out_lines = [] for ln in lines: if not touch_headings and ln.lstrip().startswith("# "): out_lines.append(ln) continue
def repl(m): tag = m.group(1) return f"#{tag} @{tag}" out_lines.append(HASHTAG_RX.sub(repl, ln)) return "\n".join(out_lines)