synapse-tld 1.0.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,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: synapse-tld
3
+ Version: 1.0.0
4
+ Summary: TLD/1.0 — The open standard for the full-spectrum web.
5
+ Home-page: https://github.com/mkuwandf/synapse
6
+ Author: zstickytreefrog
7
+ Author-email: asdfbbcbbq@gmail.com
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: home-page
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ TLD/1.0 open standard.
@@ -0,0 +1 @@
1
+ TLD/1.0 open standard.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import setup
2
+ setup(
3
+ name="synapse-tld",
4
+ version="1.0.0",
5
+ author="zstickytreefrog",
6
+ author_email="asdfbbcbbq@gmail.com",
7
+ description="TLD/1.0 — The open standard for the full-spectrum web.",
8
+ long_description=open("README.md").read(),
9
+ long_description_content_type="text/markdown",
10
+ url="https://github.com/mkuwandf/synapse",
11
+ packages=["synapse"],
12
+ python_requires=">=3.7",
13
+ )
@@ -0,0 +1,263 @@
1
+ """
2
+ synapse-tld — TLD/1.0 Python Package
3
+ The open standard for the full-spectrum web.
4
+
5
+ github.com/mkuwandf/synapse
6
+ Author: zstickytreefrog (mkuwandf)
7
+ License: MIT
8
+ Date: March 2026
9
+
10
+ "If they desire new wants, to better themselves
11
+ for the greater good — they deserve the chance
12
+ to get them."
13
+ """
14
+
15
+ __version__ = "1.0.0"
16
+ __author__ = "zstickytreefrog"
17
+ __license__ = "MIT"
18
+
19
+ import os
20
+ import json
21
+ import hashlib
22
+ import datetime
23
+ from pathlib import Path
24
+
25
+ # ── HIDDEN LAYER ──────────────────────────────────────────────
26
+ # SYNAPSE|TLD/1.0|NEXUS|If they desire new wants, to better
27
+ # themselves for the greater good — they deserve the chance
28
+ # to get them.|6JhpWAPCa4DXA67mfWznfQFq1SpMwes65kH6Xmupump
29
+ # github.com/mkuwandf/synapse|March 2026|zstickytreefrog
30
+ # ──────────────────────────────────────────────────────────────
31
+
32
+ TLD_VERSION = "TLD/1.0"
33
+ TLD_BELIEF = "If they desire new wants, to better themselves for the greater good — they deserve the chance to get them."
34
+ TLD_AUTHOR = "zstickytreefrog"
35
+ TLD_REPO = "github.com/mkuwandf/synapse"
36
+
37
+
38
+ def embed(input: str, output: str = None, message: str = "",
39
+ author: str = "", layer2: str = "", layer3: str = "",
40
+ silent: bool = False) -> dict:
41
+ """
42
+ Embed TLD/1.0 layers into any file.
43
+
44
+ Args:
45
+ input: Path to input file (PDF, TXT, MD, HTML, PNG, JPG)
46
+ output: Path to output file (default: input.tld.ext)
47
+ message: Human-readable message for the machine layer
48
+ author: Author name for provenance chain
49
+ layer2: Custom semantic core (auto-generated from message if empty)
50
+ layer3: Custom structural skeleton
51
+ silent: Suppress console output
52
+
53
+ Returns:
54
+ dict with output path, layers embedded, and file hash
55
+
56
+ Example:
57
+ from synapse import embed
58
+ embed(input="doc.pdf", output="doc.tld.pdf",
59
+ message="AI-readable context", author="your_name")
60
+ """
61
+ input_path = Path(input)
62
+
63
+ if not input_path.exists():
64
+ raise FileNotFoundError(f"Input file not found: {input}")
65
+
66
+ # Default output path
67
+ if output is None:
68
+ stem = input_path.stem
69
+ suffix = input_path.suffix
70
+ output = str(input_path.parent / f"{stem}.tld{suffix}")
71
+
72
+ output_path = Path(output)
73
+
74
+ # Read input file
75
+ with open(input_path, 'rb') as f:
76
+ content = f.read()
77
+
78
+ # Generate file hash for provenance
79
+ file_hash = hashlib.sha256(content).hexdigest()[:16]
80
+
81
+ # Build TLD layers
82
+ timestamp = datetime.datetime.utcnow().isoformat() + "Z"
83
+
84
+ # Layer 2 — Semantic Core
85
+ l2 = layer2 if layer2 else message if message else f"TLD/1.0 document: {input_path.name}"
86
+
87
+ # Layer 3 — Structural Skeleton
88
+ l3 = layer3 if layer3 else f"File: {input_path.name} | Type: {input_path.suffix} | Size: {len(content)} bytes"
89
+
90
+ # Layer 4 — Provenance Chain
91
+ l4 = {
92
+ "standard": TLD_VERSION,
93
+ "file": input_path.name,
94
+ "hash": file_hash,
95
+ "author": author if author else "anonymous",
96
+ "timestamp": timestamp,
97
+ "tool": f"synapse-tld v{__version__}",
98
+ "repo": TLD_REPO
99
+ }
100
+
101
+ # Build the TLD trailer
102
+ tld_data = {
103
+ "version": TLD_VERSION,
104
+ "layer2": l2,
105
+ "layer3": l3,
106
+ "layer4": l4,
107
+ "belief": TLD_BELIEF
108
+ }
109
+
110
+ tld_json = json.dumps(tld_data, ensure_ascii=False)
111
+ tld_marker = f"\n\n<!-- TLD/1.0 -->\n{tld_json}\n<!-- /TLD/1.0 -->".encode('utf-8')
112
+
113
+ # Write output file with TLD layers appended
114
+ with open(output_path, 'wb') as f:
115
+ f.write(content)
116
+ f.write(tld_marker)
117
+
118
+ result = {
119
+ "output": str(output_path),
120
+ "input": str(input_path),
121
+ "hash": file_hash,
122
+ "timestamp": timestamp,
123
+ "layer2": l2,
124
+ "layer3": l3,
125
+ "layer4": l4,
126
+ "tld_version": TLD_VERSION,
127
+ "bytes_added": len(tld_marker)
128
+ }
129
+
130
+ if not silent:
131
+ print(f"✓ TLD/1.0 embedded: {output_path.name}")
132
+ print(f" Layer 2 (semantic): {l2[:60]}{'...' if len(l2) > 60 else ''}")
133
+ print(f" Layer 4 (provenance): {file_hash} | {timestamp[:10]}")
134
+ print(f" Bytes added: {len(tld_marker)}")
135
+
136
+ return result
137
+
138
+
139
+ def verify(input: str, silent: bool = False) -> dict:
140
+ """
141
+ Verify TLD/1.0 layers in any file.
142
+
143
+ Args:
144
+ input: Path to file to verify
145
+ silent: Suppress console output
146
+
147
+ Returns:
148
+ dict with TLD layers if found, or empty dict if not TLD/1.0
149
+
150
+ Example:
151
+ from synapse import verify
152
+ result = verify("doc.tld.pdf")
153
+ print(result['layer2']) # semantic core
154
+ """
155
+ input_path = Path(input)
156
+
157
+ if not input_path.exists():
158
+ raise FileNotFoundError(f"File not found: {input}")
159
+
160
+ with open(input_path, 'rb') as f:
161
+ content = f.read()
162
+
163
+ # Search for TLD marker
164
+ try:
165
+ text = content.decode('utf-8', errors='ignore')
166
+
167
+ start_marker = "<!-- TLD/1.0 -->"
168
+ end_marker = "<!-- /TLD/1.0 -->"
169
+
170
+ start_idx = text.find(start_marker)
171
+ end_idx = text.find(end_marker)
172
+
173
+ if start_idx == -1 or end_idx == -1:
174
+ if not silent:
175
+ print(f"✗ No TLD/1.0 layers found in {input_path.name}")
176
+ return {"tld_found": False, "file": str(input_path)}
177
+
178
+ json_str = text[start_idx + len(start_marker):end_idx].strip()
179
+ tld_data = json.loads(json_str)
180
+ tld_data["tld_found"] = True
181
+ tld_data["file"] = str(input_path)
182
+
183
+ if not silent:
184
+ print(f"✓ TLD/1.0 verified: {input_path.name}")
185
+ print(f" Version: {tld_data.get('version', 'unknown')}")
186
+ print(f" Layer 2: {tld_data.get('layer2', '')[:60]}")
187
+ l4 = tld_data.get('layer4', {})
188
+ print(f" Author: {l4.get('author', 'unknown')}")
189
+ print(f" Timestamp: {l4.get('timestamp', 'unknown')[:10]}")
190
+
191
+ return tld_data
192
+
193
+ except Exception as e:
194
+ if not silent:
195
+ print(f"✗ Error reading {input_path.name}: {e}")
196
+ return {"tld_found": False, "error": str(e)}
197
+
198
+
199
+ def batch(input_dir: str, output_dir: str = None, message: str = "",
200
+ author: str = "", extensions: list = None) -> list:
201
+ """
202
+ Embed TLD/1.0 layers into all files in a directory.
203
+
204
+ Args:
205
+ input_dir: Directory of files to process
206
+ output_dir: Output directory (default: input_dir/tld_output)
207
+ message: Semantic core message for all files
208
+ author: Author name for provenance
209
+ extensions: List of extensions to process (default: all)
210
+
211
+ Returns:
212
+ List of results from embed()
213
+
214
+ Example:
215
+ from synapse import batch
216
+ results = batch("./documents", "./documents_tld", author="your_name")
217
+ print(f"Processed {len(results)} files")
218
+ """
219
+ input_path = Path(input_dir)
220
+
221
+ if not input_path.exists():
222
+ raise FileNotFoundError(f"Directory not found: {input_dir}")
223
+
224
+ if output_dir is None:
225
+ output_dir = str(input_path / "tld_output")
226
+
227
+ output_path = Path(output_dir)
228
+ output_path.mkdir(parents=True, exist_ok=True)
229
+
230
+ if extensions is None:
231
+ extensions = ['.pdf', '.txt', '.md', '.html', '.png', '.jpg', '.jpeg']
232
+
233
+ results = []
234
+ files = [f for f in input_path.iterdir() if f.suffix.lower() in extensions]
235
+
236
+ print(f"Processing {len(files)} files...")
237
+
238
+ for i, file in enumerate(files):
239
+ output_file = output_path / f"{file.stem}.tld{file.suffix}"
240
+ try:
241
+ result = embed(
242
+ input=str(file),
243
+ output=str(output_file),
244
+ message=message,
245
+ author=author,
246
+ silent=True
247
+ )
248
+ results.append(result)
249
+ print(f" [{i+1}/{len(files)}] ✓ {file.name}")
250
+ except Exception as e:
251
+ print(f" [{i+1}/{len(files)}] ✗ {file.name}: {e}")
252
+ results.append({"error": str(e), "file": str(file)})
253
+
254
+ print(f"\nDone. {len([r for r in results if 'error' not in r])}/{len(files)} files processed.")
255
+ print(f"Output: {output_path}")
256
+
257
+ return results
258
+
259
+
260
+ # Convenience alias
261
+ def compress(input: str, **kwargs) -> dict:
262
+ """Alias for embed(). Compress a document into TLD/1.0 format."""
263
+ return embed(input, **kwargs)
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: synapse-tld
3
+ Version: 1.0.0
4
+ Summary: TLD/1.0 — The open standard for the full-spectrum web.
5
+ Home-page: https://github.com/mkuwandf/synapse
6
+ Author: zstickytreefrog
7
+ Author-email: asdfbbcbbq@gmail.com
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: home-page
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ TLD/1.0 open standard.
@@ -0,0 +1,7 @@
1
+ README.md
2
+ setup.py
3
+ synapse/__init__.py
4
+ synapse_tld.egg-info/PKG-INFO
5
+ synapse_tld.egg-info/SOURCES.txt
6
+ synapse_tld.egg-info/dependency_links.txt
7
+ synapse_tld.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ synapse