claudesync 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 jahwag
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.1
2
+ Name: claudesync
3
+ Version: 0.1.0
4
+ Summary: A tool to synchronize local files with Claude.ai projects
5
+ Author-email: Jahziah Wagner <jahziah.wagner+pypi@gmail.com>
6
+ Project-URL: Homepage, https://github.com/jahwag/claudesync
7
+ Project-URL: Bug Tracker, https://github.com/jahwag/claudesync/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: watchdog
15
+ Requires-Dist: requests
16
+
17
+ # ClaudeSync
18
+ [![Python Package](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml)
19
+
20
+ ClaudeSync is a Python tool that automatically synchronizes your local filesystem with Claude.ai projects.
21
+
22
+ ## Installation
23
+
24
+ You can install ClaudeSync using pip:
25
+
26
+ ```bash
27
+ pip install claudesync
28
+ ```
29
+
30
+ ## Setup
31
+
32
+ 1. Create a `config.json` file in your working directory:
33
+ ```json
34
+ {
35
+ "user_id": "your-user-id-here",
36
+ "project_id": "your-project-id-here"
37
+ }
38
+ ```
39
+
40
+ 2. Ensure you have your Claude.ai session key ready.
41
+
42
+ ## Usage
43
+
44
+ After installation, you can use ClaudeSync as a command-line tool:
45
+
46
+ ```bash
47
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
48
+ ```
49
+
50
+ ### Parameters
51
+
52
+ - `--session-key`: Your Claude.ai session key (required)
53
+ - `--watch-dir`: Directory to watch for changes (required)
54
+ - `--user-id`: Override user ID from config
55
+ - `--project-id`: Override project ID from config
56
+ - `--delete-all`: Delete all project documents
57
+ - `--delay`: Delay in seconds before uploading (default: 5)
58
+
59
+ ### Examples
60
+
61
+ Watch a directory and sync changes:
62
+ ```bash
63
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
64
+ ```
65
+
66
+ Override config settings:
67
+ ```bash
68
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --user-id different-user-id --project-id different-project-id
69
+ ```
70
+
71
+ Delete all documents in the project:
72
+ ```bash
73
+ claudesync --session-key YOUR_SESSION_KEY --delete-all
74
+ ```
75
+
76
+ Set a custom delay for file uploads:
77
+ ```bash
78
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --delay 10
79
+ ```
80
+
81
+ ## Features
82
+
83
+ - Watch local directories for file changes
84
+ - Automatically upload new or modified files to Claude.ai
85
+ - Delete outdated versions of files in Claude.ai
86
+ - Option to clear all documents in a Claude.ai project
87
+ - Configurable delay to prevent frequent uploads during active editing
88
+
89
+ ## Development
90
+
91
+ To contribute to ClaudeSync:
92
+
93
+ 1. Clone the repository:
94
+ ```
95
+ git clone https://github.com/yourusername/claudesync.git
96
+ ```
97
+ 2. Install development dependencies:
98
+ ```
99
+ pip install -r requirements.txt
100
+ ```
101
+ 3. Make your changes and submit a pull request.
102
+
103
+ ## License
104
+
105
+ [MIT License](https://opensource.org/licenses/MIT)
106
+
107
+ ## Disclaimer
108
+
109
+ Ensure you have the necessary permissions to access and modify your Claude.ai projects. Keep your session key secure and do not share it publicly.
@@ -0,0 +1,93 @@
1
+ # ClaudeSync
2
+ [![Python Package](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml)
3
+
4
+ ClaudeSync is a Python tool that automatically synchronizes your local filesystem with Claude.ai projects.
5
+
6
+ ## Installation
7
+
8
+ You can install ClaudeSync using pip:
9
+
10
+ ```bash
11
+ pip install claudesync
12
+ ```
13
+
14
+ ## Setup
15
+
16
+ 1. Create a `config.json` file in your working directory:
17
+ ```json
18
+ {
19
+ "user_id": "your-user-id-here",
20
+ "project_id": "your-project-id-here"
21
+ }
22
+ ```
23
+
24
+ 2. Ensure you have your Claude.ai session key ready.
25
+
26
+ ## Usage
27
+
28
+ After installation, you can use ClaudeSync as a command-line tool:
29
+
30
+ ```bash
31
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
32
+ ```
33
+
34
+ ### Parameters
35
+
36
+ - `--session-key`: Your Claude.ai session key (required)
37
+ - `--watch-dir`: Directory to watch for changes (required)
38
+ - `--user-id`: Override user ID from config
39
+ - `--project-id`: Override project ID from config
40
+ - `--delete-all`: Delete all project documents
41
+ - `--delay`: Delay in seconds before uploading (default: 5)
42
+
43
+ ### Examples
44
+
45
+ Watch a directory and sync changes:
46
+ ```bash
47
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
48
+ ```
49
+
50
+ Override config settings:
51
+ ```bash
52
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --user-id different-user-id --project-id different-project-id
53
+ ```
54
+
55
+ Delete all documents in the project:
56
+ ```bash
57
+ claudesync --session-key YOUR_SESSION_KEY --delete-all
58
+ ```
59
+
60
+ Set a custom delay for file uploads:
61
+ ```bash
62
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --delay 10
63
+ ```
64
+
65
+ ## Features
66
+
67
+ - Watch local directories for file changes
68
+ - Automatically upload new or modified files to Claude.ai
69
+ - Delete outdated versions of files in Claude.ai
70
+ - Option to clear all documents in a Claude.ai project
71
+ - Configurable delay to prevent frequent uploads during active editing
72
+
73
+ ## Development
74
+
75
+ To contribute to ClaudeSync:
76
+
77
+ 1. Clone the repository:
78
+ ```
79
+ git clone https://github.com/yourusername/claudesync.git
80
+ ```
81
+ 2. Install development dependencies:
82
+ ```
83
+ pip install -r requirements.txt
84
+ ```
85
+ 3. Make your changes and submit a pull request.
86
+
87
+ ## License
88
+
89
+ [MIT License](https://opensource.org/licenses/MIT)
90
+
91
+ ## Disclaimer
92
+
93
+ Ensure you have the necessary permissions to access and modify your Claude.ai projects. Keep your session key secure and do not share it publicly.
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.1
2
+ Name: claudesync
3
+ Version: 0.1.0
4
+ Summary: A tool to synchronize local files with Claude.ai projects
5
+ Author-email: Jahziah Wagner <jahziah.wagner+pypi@gmail.com>
6
+ Project-URL: Homepage, https://github.com/jahwag/claudesync
7
+ Project-URL: Bug Tracker, https://github.com/jahwag/claudesync/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: watchdog
15
+ Requires-Dist: requests
16
+
17
+ # ClaudeSync
18
+ [![Python Package](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/jahwag/ClaudeSync/actions/workflows/publish-to-pypi.yml)
19
+
20
+ ClaudeSync is a Python tool that automatically synchronizes your local filesystem with Claude.ai projects.
21
+
22
+ ## Installation
23
+
24
+ You can install ClaudeSync using pip:
25
+
26
+ ```bash
27
+ pip install claudesync
28
+ ```
29
+
30
+ ## Setup
31
+
32
+ 1. Create a `config.json` file in your working directory:
33
+ ```json
34
+ {
35
+ "user_id": "your-user-id-here",
36
+ "project_id": "your-project-id-here"
37
+ }
38
+ ```
39
+
40
+ 2. Ensure you have your Claude.ai session key ready.
41
+
42
+ ## Usage
43
+
44
+ After installation, you can use ClaudeSync as a command-line tool:
45
+
46
+ ```bash
47
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
48
+ ```
49
+
50
+ ### Parameters
51
+
52
+ - `--session-key`: Your Claude.ai session key (required)
53
+ - `--watch-dir`: Directory to watch for changes (required)
54
+ - `--user-id`: Override user ID from config
55
+ - `--project-id`: Override project ID from config
56
+ - `--delete-all`: Delete all project documents
57
+ - `--delay`: Delay in seconds before uploading (default: 5)
58
+
59
+ ### Examples
60
+
61
+ Watch a directory and sync changes:
62
+ ```bash
63
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch
64
+ ```
65
+
66
+ Override config settings:
67
+ ```bash
68
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --user-id different-user-id --project-id different-project-id
69
+ ```
70
+
71
+ Delete all documents in the project:
72
+ ```bash
73
+ claudesync --session-key YOUR_SESSION_KEY --delete-all
74
+ ```
75
+
76
+ Set a custom delay for file uploads:
77
+ ```bash
78
+ claudesync --session-key YOUR_SESSION_KEY --watch-dir /path/to/watch --delay 10
79
+ ```
80
+
81
+ ## Features
82
+
83
+ - Watch local directories for file changes
84
+ - Automatically upload new or modified files to Claude.ai
85
+ - Delete outdated versions of files in Claude.ai
86
+ - Option to clear all documents in a Claude.ai project
87
+ - Configurable delay to prevent frequent uploads during active editing
88
+
89
+ ## Development
90
+
91
+ To contribute to ClaudeSync:
92
+
93
+ 1. Clone the repository:
94
+ ```
95
+ git clone https://github.com/yourusername/claudesync.git
96
+ ```
97
+ 2. Install development dependencies:
98
+ ```
99
+ pip install -r requirements.txt
100
+ ```
101
+ 3. Make your changes and submit a pull request.
102
+
103
+ ## License
104
+
105
+ [MIT License](https://opensource.org/licenses/MIT)
106
+
107
+ ## Disclaimer
108
+
109
+ Ensure you have the necessary permissions to access and modify your Claude.ai projects. Keep your session key secure and do not share it publicly.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ file_upload_tool.py
4
+ pyproject.toml
5
+ setup.py
6
+ claudesync.egg-info/PKG-INFO
7
+ claudesync.egg-info/SOURCES.txt
8
+ claudesync.egg-info/dependency_links.txt
9
+ claudesync.egg-info/entry_points.txt
10
+ claudesync.egg-info/requires.txt
11
+ claudesync.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ claudesync = claudesync.claudesync:main
@@ -0,0 +1,2 @@
1
+ watchdog
2
+ requests
@@ -0,0 +1 @@
1
+ file_upload_tool
@@ -0,0 +1,145 @@
1
+ import time
2
+ import os
3
+ import argparse
4
+ import sys
5
+ import json
6
+ from watchdog.observers import Observer
7
+ from watchdog.events import FileSystemEventHandler
8
+ import requests
9
+ from threading import Timer
10
+
11
+ class DebounceHandler:
12
+ def __init__(self, delay):
13
+ self.delay = delay
14
+ self.timer = None
15
+
16
+ def debounce(self, func, *args):
17
+ def debounced_func():
18
+ self.timer = None
19
+ func(*args)
20
+
21
+ if self.timer is not None:
22
+ self.timer.cancel()
23
+ self.timer = Timer(self.delay, debounced_func)
24
+ self.timer.start()
25
+
26
+ class FileUploadHandler(FileSystemEventHandler):
27
+ def __init__(self, api_endpoint, session_key, base_path, delay=5):
28
+ self.api_endpoint = api_endpoint
29
+ self.session_key = session_key
30
+ self.base_path = base_path
31
+ self.headers = {
32
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0',
33
+ 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Content-Type': 'application/json',
34
+ 'Referer': f'https://claude.ai/project/{api_endpoint.split("/")[-2]}',
35
+ 'Origin': 'https://claude.ai', 'Connection': 'keep-alive'
36
+ }
37
+ self.cookies = {'sessionKey': session_key, 'lastActiveOrg': api_endpoint.split("/")[4]}
38
+ self.debouncer = DebounceHandler(delay)
39
+
40
+ def on_modified(self, event):
41
+ if not event.is_directory:
42
+ self.debouncer.debounce(self.upload_file, event.src_path)
43
+
44
+ def on_created(self, event):
45
+ if not event.is_directory:
46
+ self.debouncer.debounce(self.upload_file, event.src_path)
47
+
48
+ def api_request(self, method, url, **kwargs):
49
+ try:
50
+ response = requests.request(method, url, headers=self.headers, cookies=self.cookies, **kwargs)
51
+ response.raise_for_status()
52
+ return response.json() if response.text else None
53
+ except requests.RequestException as e:
54
+ print(f"API request error: {str(e)}")
55
+ return None
56
+
57
+ def get_documents(self):
58
+ return self.api_request('GET', self.api_endpoint) or []
59
+
60
+ def delete_document(self, uuid):
61
+ if self.api_request('DELETE', f"{self.api_endpoint}/{uuid}"):
62
+ print(f"Deleted document: {uuid}")
63
+
64
+ def delete_all_documents(self):
65
+ for doc in self.get_documents():
66
+ self.delete_document(doc['uuid'])
67
+ print("All documents deleted.")
68
+
69
+ def upload_file(self, file_path):
70
+ if not os.path.isfile(file_path):
71
+ return
72
+ if os.path.getsize(file_path) == 0:
73
+ print(f"Skipping empty file: {file_path}")
74
+ return
75
+ try:
76
+ with open(file_path, 'r', encoding='utf-8') as file:
77
+ content = file.read()
78
+ if not content.strip():
79
+ print(f"Skipping file with only whitespace: {file_path}")
80
+ return
81
+
82
+ rel_path = os.path.relpath(file_path, self.base_path)
83
+ file_name = rel_path.replace(os.path.sep, '/')
84
+
85
+ for doc in self.get_documents():
86
+ if doc['file_name'] == file_name:
87
+ self.delete_document(doc['uuid'])
88
+ payload = {"file_name": file_name, "content": content}
89
+ if self.api_request('POST', self.api_endpoint, json=payload):
90
+ print(f"Uploaded: {file_name}")
91
+ except Exception as e:
92
+ print(f"Error processing file {file_path}: {str(e)}")
93
+
94
+ def watch_directory(path, api_endpoint, session_key, delay):
95
+ observer = Observer()
96
+ handler = FileUploadHandler(api_endpoint, session_key, path, delay)
97
+ observer.schedule(handler, path, recursive=True)
98
+ observer.start()
99
+ try:
100
+ while True:
101
+ time.sleep(1)
102
+ except KeyboardInterrupt:
103
+ observer.stop()
104
+ observer.join()
105
+
106
+ def load_config():
107
+ try:
108
+ with open('config.json', 'r') as f:
109
+ return json.load(f)
110
+ except FileNotFoundError:
111
+ print("config.json not found. Please create it with your user_id and project_id.")
112
+ sys.exit(1)
113
+ except json.JSONDecodeError:
114
+ print("Invalid JSON in config.json. Please check the file format.")
115
+ sys.exit(1)
116
+
117
+ def main():
118
+ config = load_config()
119
+
120
+ parser = argparse.ArgumentParser(description="Sync local files with Claude.ai projects.")
121
+ parser.add_argument("--session-key", required=True, help="Session key for authentication")
122
+ parser.add_argument("--watch-dir", required=True, help="Directory to watch for changes")
123
+ parser.add_argument("--user-id", default=config.get('user_id'), help="User ID for Claude API")
124
+ parser.add_argument("--project-id", default=config.get('project_id'), help="Project ID for Claude API")
125
+ parser.add_argument("--delete-all", action="store_true", help="Delete all documents in the project")
126
+ parser.add_argument("--delay", type=int, default=5, help="Delay in seconds before uploading (default: 5)")
127
+ args = parser.parse_args()
128
+
129
+ if not args.user_id or not args.project_id:
130
+ print("user_id and project_id must be provided in config.json or as command-line arguments.")
131
+ sys.exit(1)
132
+
133
+ api_endpoint = f"https://claude.ai/api/organizations/{args.user_id}/projects/{args.project_id}/docs"
134
+
135
+ if args.delete_all:
136
+ handler = FileUploadHandler(api_endpoint, args.session_key, args.watch_dir)
137
+ handler.delete_all_documents()
138
+ sys.exit(0)
139
+ else:
140
+ print(f"Watching directory: {args.watch_dir}")
141
+ print(f"Upload delay: {args.delay} seconds")
142
+ watch_directory(args.watch_dir, api_endpoint, args.session_key, args.delay)
143
+
144
+ if __name__ == "__main__":
145
+ main()
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "claudesync"
7
+ version = "0.1.0"
8
+ authors = [
9
+ {name = "Jahziah Wagner", email = "jahziah.wagner+pypi@gmail.com"},
10
+ ]
11
+ description = "A tool to synchronize local files with Claude.ai projects"
12
+ readme = "README.md"
13
+ requires-python = ">=3.6"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "watchdog",
21
+ "requests",
22
+ ]
23
+
24
+ [project.urls]
25
+ "Homepage" = "https://github.com/jahwag/claudesync"
26
+ "Bug Tracker" = "https://github.com/jahwag/claudesync/issues"
27
+
28
+ [project.scripts]
29
+ claudesync = "claudesync.claudesync:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from setuptools import setup
2
+
3
+ setup()