removed migration
This commit is contained in:
@@ -98,7 +98,6 @@ chmod +x email-processor.sh
|
|||||||
|
|
||||||
# --- Other ---
|
# --- Other ---
|
||||||
./email-processor.sh stats # show decision history
|
./email-processor.sh stats # show decision history
|
||||||
./email-processor.sh migrate # import old decisions
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or call Python directly: `python main.py scan --dry-run`
|
Or call Python directly: `python main.py scan --dry-run`
|
||||||
@@ -176,7 +175,7 @@ ollama list # should show kamekichi128/qwen3-4b-instruct-2507:latest
|
|||||||
|
|
||||||
```
|
```
|
||||||
email_processor/
|
email_processor/
|
||||||
main.py # Entry point — scan/review/stats/migrate subcommands
|
main.py # Entry point — scan/review/stats subcommands
|
||||||
classifier.py # LLM prompt builder + response parser
|
classifier.py # LLM prompt builder + response parser
|
||||||
decision_store.py # Decision history storage + few-shot retrieval
|
decision_store.py # Decision history storage + few-shot retrieval
|
||||||
config.json # Ollama + automation settings
|
config.json # Ollama + automation settings
|
||||||
|
|||||||
@@ -204,50 +204,3 @@ def get_all_stats():
|
|||||||
"by_source": dict(by_source),
|
"by_source": dict(by_source),
|
||||||
"top_domains": top_domains,
|
"top_domains": top_domains,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Migration
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def migrate_pending():
|
|
||||||
"""One-time migration: import 'done' entries from pending_emails.json.
|
|
||||||
|
|
||||||
Converts old-style action names ("archived" -> "archive", etc.) and
|
|
||||||
records them as user decisions in the history file. Safe to run
|
|
||||||
multiple times (will create duplicates though, so run once only).
|
|
||||||
"""
|
|
||||||
if not PENDING_FILE.exists():
|
|
||||||
print("No pending_emails.json found, nothing to migrate.")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
with open(PENDING_FILE, "r", encoding="utf-8") as f:
|
|
||||||
pending = json.load(f)
|
|
||||||
|
|
||||||
# Map old action names to new ones
|
|
||||||
action_map = {
|
|
||||||
"archived": "archive",
|
|
||||||
"kept": "keep",
|
|
||||||
"deleted": "delete",
|
|
||||||
}
|
|
||||||
|
|
||||||
migrated = 0
|
|
||||||
for msg_id, data in pending.items():
|
|
||||||
if data.get("status") != "done":
|
|
||||||
continue
|
|
||||||
old_action = data.get("action", "")
|
|
||||||
action = action_map.get(old_action, old_action)
|
|
||||||
if not action:
|
|
||||||
continue
|
|
||||||
|
|
||||||
email_data = {
|
|
||||||
"sender": data.get("sender", ""),
|
|
||||||
"recipient": data.get("recipient", ""),
|
|
||||||
"subject": data.get("subject", ""),
|
|
||||||
"summary": data.get("summary", ""),
|
|
||||||
}
|
|
||||||
record_decision(email_data, action, source="user")
|
|
||||||
migrated += 1
|
|
||||||
|
|
||||||
print(f"Migrated {migrated} decisions from pending_emails.json")
|
|
||||||
return migrated
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
# ./email-processor.sh review all delete # act on all pending
|
# ./email-processor.sh review all delete # act on all pending
|
||||||
# ./email-processor.sh review accept # accept all suggestions
|
# ./email-processor.sh review accept # accept all suggestions
|
||||||
# ./email-processor.sh stats # show history stats
|
# ./email-processor.sh stats # show history stats
|
||||||
# ./email-processor.sh migrate # import old decisions
|
|
||||||
#
|
#
|
||||||
# Requires: Python 3.8+, himalaya, Ollama running with model.
|
# Requires: Python 3.8+, himalaya, Ollama running with model.
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Subcommands:
|
|||||||
python main.py review all <action> # act on all pending
|
python main.py review all <action> # act on all pending
|
||||||
python main.py review accept # accept all suggestions
|
python main.py review accept # accept all suggestions
|
||||||
python main.py stats # show decision history
|
python main.py stats # show decision history
|
||||||
python main.py migrate # import old decisions
|
|
||||||
|
|
||||||
Action mapping (what each classification does to the email):
|
Action mapping (what each classification does to the email):
|
||||||
delete -> himalaya message delete <id> (moves to Trash)
|
delete -> himalaya message delete <id> (moves to Trash)
|
||||||
@@ -632,19 +631,6 @@ def cmd_stats():
|
|||||||
print(f"\nKnown labels: {', '.join(sorted(labels))}")
|
print(f"\nKnown labels: {', '.join(sorted(labels))}")
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Subcommand: migrate
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def cmd_migrate():
|
|
||||||
"""Import old pending_emails.json 'done' entries into decision history.
|
|
||||||
|
|
||||||
Run once after upgrading from the old system. Converts old action
|
|
||||||
names (archived/kept/deleted) to new ones (archive/keep/delete).
|
|
||||||
"""
|
|
||||||
decision_store.migrate_pending()
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Entry point & argument parsing
|
# Entry point & argument parsing
|
||||||
#
|
#
|
||||||
@@ -703,10 +689,7 @@ if __name__ == "__main__":
|
|||||||
elif subcommand == "stats":
|
elif subcommand == "stats":
|
||||||
cmd_stats()
|
cmd_stats()
|
||||||
|
|
||||||
elif subcommand == "migrate":
|
|
||||||
cmd_migrate()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"Unknown subcommand: {subcommand}")
|
print(f"Unknown subcommand: {subcommand}")
|
||||||
print("Usage: python main.py [scan|review|stats|migrate] [--recent N] [--dry-run]")
|
print("Usage: python main.py [scan|review|stats] [--recent N] [--dry-run]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user