-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
144 lines (120 loc) · 2.79 KB
/
agent.py
File metadata and controls
144 lines (120 loc) · 2.79 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import os
import sys
from datetime import date
from openai import OpenAI
BASE_DIR = os.path.dirname(__file__)
FILES = {
"today": os.path.join(BASE_DIR, "today.md"),
"backlog": os.path.join(BASE_DIR, "backlog.md"),
"log": os.path.join(BASE_DIR, "log.md"),
}
def read(path):
if not os.path.exists(path):
return ""
with open(path, "r", encoding="utf-8") as f:
return f.read()
def append(path, text):
with open(path, "a", encoding="utf-8") as f:
f.write(text)
def multiline_input(prompt):
print(prompt)
lines = []
while True:
line = input("> ").strip()
if not line:
break
lines.append(line)
return "\n".join(lines)
client = OpenAI()
today_str = str(date.today())
MODE = "morning"
if "--midday" in sys.argv:
MODE = "midday"
elif "--done" in sys.argv:
MODE = "done"
SYSTEM_PROMPTS = {
"morning": """
You are a daily work planning assistant.
Rules:
- Be realistic about time and energy
- Never plan more than ~70% of available time
- Always choose ONE top priority
- Prefer finishing over starting
- Explicitly suggest what to drop
- No motivational fluff
Output format:
Top priority:
Proposed plan:
Drop if needed:
Rule:
""",
"midday": """
You are a pragmatic midday replanning assistant.
Rules:
- Assume interruptions happened
- Adjust expectations downward if needed
- Protect the top priority if possible
- Explicitly drop tasks if necessary
- No guilt, no motivation, just reality
Output format:
Updated focus:
Revised plan:
Drop:
Rule for rest of day:
""",
"done": """
You summarize the workday outcome.
Rules:
- Be factual, not emotional
- Identify what is DONE
- Identify what should carry over
- Keep it short
Output format:
Done:
Partially done:
Carry over:
Notes:
"""
}
user_update = ""
if MODE in ("midday", "done"):
user_update = multiline_input(
f"Enter {'midday update' if MODE == 'midday' else 'end-of-day notes'} (finish with empty line):"
)
USER_PROMPTS = {
"morning": f"""
TODAY ({today_str}):
{read(FILES["today"])}
BACKLOG:
{read(FILES["backlog"])}
""",
"midday": f"""
MIDDAY UPDATE ({today_str}):
Planned context:
{read(FILES["today"])}
What actually happened so far:
{user_update}
""",
"done": f"""
END OF DAY ({today_str}):
Planned context:
{read(FILES["today"])}
What actually happened today:
{user_update}
"""
}
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": SYSTEM_PROMPTS[MODE]},
{"role": "user", "content": USER_PROMPTS[MODE]},
],
)
output = response.choices[0].message.content.strip()
print(f"\n=== {MODE.upper()} OUTPUT ===\n")
print(output)
print("\n===========================\n")
append(
FILES["log"],
f"\n## {today_str} — {MODE.capitalize()}\n{output}\n"
)