makeless 0.1.0__py3-none-any.whl
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.
- agent/planner.py +11 -0
- agent/runtime.py +0 -0
- agent/state.py +40 -0
- app/main.py +0 -0
- execution/executor.py +0 -0
- main.py +272 -0
- makeless-0.1.0.dist-info/METADATA +133 -0
- makeless-0.1.0.dist-info/RECORD +28 -0
- makeless-0.1.0.dist-info/WHEEL +5 -0
- makeless-0.1.0.dist-info/entry_points.txt +2 -0
- makeless-0.1.0.dist-info/licenses/LICENSE +1 -0
- makeless-0.1.0.dist-info/top_level.txt +8 -0
- memory/store.py +40 -0
- observability/logger.py +0 -0
- security/permissions.py +0 -0
- tools/app_finder.py +80 -0
- tools/app_launcher.py +15 -0
- tools/builtin.py +0 -0
- tools/filesystem.py +103 -0
- tools/indexer.py +133 -0
- tools/launcher.py +125 -0
- tools/locations.py +60 -0
- tools/open_router.py +93 -0
- tools/opener.py +10 -0
- tools/reader.py +48 -0
- tools/registry.py +0 -0
- tools/selector.py +56 -0
- tools/watcher.py +178 -0
tools/watcher.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sqlite3
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from watchdog.events import FileSystemEventHandler
|
|
6
|
+
from watchdog.observers import Observer
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
10
|
+
DATABASE_PATH = PROJECT_ROOT / "data" / "agentcore.db"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_database_connection():
|
|
14
|
+
return sqlite3.connect(DATABASE_PATH)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def add_to_index(path):
|
|
18
|
+
path = os.path.abspath(path)
|
|
19
|
+
|
|
20
|
+
if not os.path.exists(path):
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
item_type = "folder" if os.path.isdir(path) else "file"
|
|
24
|
+
name = os.path.basename(path)
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
connection = get_database_connection()
|
|
28
|
+
cursor = connection.cursor()
|
|
29
|
+
|
|
30
|
+
cursor.execute(
|
|
31
|
+
"""
|
|
32
|
+
INSERT OR REPLACE INTO file_index
|
|
33
|
+
(path, name, item_type)
|
|
34
|
+
VALUES (?, ?, ?)
|
|
35
|
+
""",
|
|
36
|
+
(path, name, item_type)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
connection.commit()
|
|
40
|
+
connection.close()
|
|
41
|
+
|
|
42
|
+
print(f"[INDEX] Added: {path}")
|
|
43
|
+
|
|
44
|
+
except sqlite3.Error as error:
|
|
45
|
+
print(f"[WATCHER ERROR] Could not add {path}: {error}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def remove_from_index(path):
|
|
49
|
+
path = os.path.abspath(path)
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
connection = get_database_connection()
|
|
53
|
+
cursor = connection.cursor()
|
|
54
|
+
|
|
55
|
+
cursor.execute(
|
|
56
|
+
"DELETE FROM file_index WHERE path = ?",
|
|
57
|
+
(path,)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
connection.commit()
|
|
61
|
+
connection.close()
|
|
62
|
+
|
|
63
|
+
print(f"[INDEX] Removed: {path}")
|
|
64
|
+
|
|
65
|
+
except sqlite3.Error as error:
|
|
66
|
+
print(f"[WATCHER ERROR] Could not remove {path}: {error}")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class AgentCoreFileHandler(FileSystemEventHandler):
|
|
70
|
+
|
|
71
|
+
def on_created(self, event):
|
|
72
|
+
add_to_index(event.src_path)
|
|
73
|
+
|
|
74
|
+
def on_deleted(self, event):
|
|
75
|
+
remove_from_index(event.src_path)
|
|
76
|
+
|
|
77
|
+
def on_moved(self, event):
|
|
78
|
+
remove_from_index(event.src_path)
|
|
79
|
+
add_to_index(event.dest_path)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_windows_folder(folder_name):
|
|
83
|
+
"""
|
|
84
|
+
Ask Windows for the actual location of a special user folder.
|
|
85
|
+
This supports folders redirected to OneDrive.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
import winreg
|
|
90
|
+
|
|
91
|
+
registry_key = (
|
|
92
|
+
r"Software\Microsoft\Windows\CurrentVersion"
|
|
93
|
+
r"\Explorer\User Shell Folders"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
with winreg.OpenKey(
|
|
97
|
+
winreg.HKEY_CURRENT_USER,
|
|
98
|
+
registry_key
|
|
99
|
+
) as key:
|
|
100
|
+
value, _ = winreg.QueryValueEx(
|
|
101
|
+
key,
|
|
102
|
+
folder_name
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
expanded_path = os.path.expandvars(value)
|
|
106
|
+
|
|
107
|
+
return Path(expanded_path)
|
|
108
|
+
|
|
109
|
+
except (FileNotFoundError, OSError):
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def get_watch_paths():
|
|
114
|
+
home = Path.home()
|
|
115
|
+
|
|
116
|
+
# Ask Windows for these locations instead of guessing.
|
|
117
|
+
desktop = get_windows_folder("Desktop")
|
|
118
|
+
documents = get_windows_folder("Personal")
|
|
119
|
+
|
|
120
|
+
# Downloads is usually stored under the user's home folder.
|
|
121
|
+
# We'll make this dynamically discoverable in the next improvement.
|
|
122
|
+
downloads = home / "Downloads"
|
|
123
|
+
|
|
124
|
+
paths = [
|
|
125
|
+
downloads,
|
|
126
|
+
desktop,
|
|
127
|
+
documents
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
valid_paths = []
|
|
131
|
+
|
|
132
|
+
for path in paths:
|
|
133
|
+
if (
|
|
134
|
+
path
|
|
135
|
+
and path.exists()
|
|
136
|
+
and path not in valid_paths
|
|
137
|
+
):
|
|
138
|
+
valid_paths.append(path)
|
|
139
|
+
|
|
140
|
+
return valid_paths
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def start_watcher():
|
|
144
|
+
observer = Observer()
|
|
145
|
+
handler = AgentCoreFileHandler()
|
|
146
|
+
|
|
147
|
+
watch_paths = get_watch_paths()
|
|
148
|
+
|
|
149
|
+
print("\nAgentCore File Watcher")
|
|
150
|
+
print("----------------------")
|
|
151
|
+
|
|
152
|
+
for path in watch_paths:
|
|
153
|
+
observer.schedule(
|
|
154
|
+
handler,
|
|
155
|
+
str(path),
|
|
156
|
+
recursive=True
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
print(f"[WATCHING] {path}")
|
|
160
|
+
|
|
161
|
+
observer.start()
|
|
162
|
+
|
|
163
|
+
return observer
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if __name__ == "__main__":
|
|
167
|
+
observer = start_watcher()
|
|
168
|
+
|
|
169
|
+
try:
|
|
170
|
+
print("\nWatcher is running. Press Ctrl + C to stop.")
|
|
171
|
+
|
|
172
|
+
while True:
|
|
173
|
+
pass
|
|
174
|
+
|
|
175
|
+
except KeyboardInterrupt:
|
|
176
|
+
observer.stop()
|
|
177
|
+
|
|
178
|
+
observer.join()
|