tamcoder 0.1.89__tar.gz → 0.1.92__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.

Potentially problematic release.


This version of tamcoder might be problematic. Click here for more details.

@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -1,11 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tamcoder
3
- Version: 0.1.89
3
+ Version: 0.1.92
4
4
  Summary: Tamcoder — TypeScript coding agent runtime (PyPI shim that installs the official Linux x86_64 release)
5
5
  Project-URL: Homepage, https://gpt.tamfitronics.com/tamcoder
6
- Project-URL: Repository, https://gpt.tamfitronics.com/tamcoder
6
+ Project-URL: Repository, https://github.com/tamfitronics/tamcoder
7
7
  Project-URL: Documentation, https://gpt.tamfitronics.com/tamcoder
8
- Project-URL: Changelog, https://gpt.tamfitronics.com/tamcoder/releases/
9
8
  License: MIT
10
9
  License-File: LICENSE
11
10
  Keywords: ai,cli,coding-agent,tamcoder,typescript
@@ -20,8 +19,6 @@ Classifier: Programming Language :: Python :: 3.12
20
19
  Classifier: Programming Language :: Python :: 3.13
21
20
  Classifier: Topic :: Software Development :: Build Tools
22
21
  Requires-Python: >=3.10
23
- Requires-Dist: requests>=2.31.0
24
- Requires-Dist: tqdm>=4.66.0
25
22
  Provides-Extra: dev
26
23
  Requires-Dist: build>=1.2.0; extra == 'dev'
27
24
  Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
@@ -66,4 +63,4 @@ The `tamcoder` command checks the public release version at startup. No workspac
66
63
 
67
64
  ## License
68
65
 
69
- MIT
66
+ MIT
@@ -33,4 +33,4 @@ The `tamcoder` command checks the public release version at startup. No workspac
33
33
 
34
34
  ## License
35
35
 
36
- MIT
36
+ MIT
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["hatchling"]
2
+ requires = ["hatchling>=1.0.0"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "tamcoder"
7
- version = "0.1.89"
7
+ version = "0.1.92"
8
8
  description = "Tamcoder — TypeScript coding agent runtime (PyPI shim that installs the official Linux x86_64 release)"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -21,17 +21,12 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.13",
22
22
  "Topic :: Software Development :: Build Tools",
23
23
  ]
24
- dependencies = [
25
- "requests>=2.31.0",
26
- "tqdm>=4.66.0",
27
- ]
28
24
  keywords = ["tamcoder", "coding-agent", "typescript", "cli", "ai"]
29
25
 
30
26
  [project.urls]
31
27
  Homepage = "https://gpt.tamfitronics.com/tamcoder"
32
- Repository = "https://gpt.tamfitronics.com/tamcoder"
28
+ Repository = "https://github.com/tamfitronics/tamcoder"
33
29
  Documentation = "https://gpt.tamfitronics.com/tamcoder"
34
- Changelog = "https://gpt.tamfitronics.com/tamcoder/releases/"
35
30
 
36
31
  [project.scripts]
37
32
  tamcoder = "tamcoder.__main__:main"
@@ -48,11 +43,7 @@ dev = [
48
43
  ]
49
44
 
50
45
  [tool.hatch.build.targets.sdist]
51
- include = [
52
- "/tamcoder",
53
- "/README.md",
54
- "/LICENSE",
55
- ]
46
+ # Use default selection; Hatch will include the "src/tamcoder" package.
56
47
 
57
48
  [tool.hatch.build.targets.wheel]
58
49
  packages = ["src/tamcoder"]
@@ -0,0 +1,3 @@
1
+ """Tamcoder PyPI shim — installs the official TypeScript release."""
2
+ __version__ = "0.1.92"
3
+ __all__ = ["__version__"]
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env python3
2
+ """Tamcoder PyPI shim entry point — downloads and installs the official TypeScript release."""
3
+
4
+ import json
5
+ import os
6
+ import hashlib
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+ import tempfile
11
+ from pathlib import Path
12
+ from urllib.parse import urljoin
13
+
14
+ try:
15
+ import requests
16
+ from tqdm import tqdm
17
+ except ImportError as e:
18
+ print(f"Missing dependency: {e}", file=sys.stderr)
19
+ print("Run: pip install requests tqdm", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ RELEASE_BASE = os.environ.get("TAMCODER_RELEASE_BASE", "https://gpt.tamfitronics.com/tamcoder")
23
+ INSTALL_PREFIX = Path(os.environ.get("TAMCODER_INSTALL_PREFIX", Path.home() / ".local"))
24
+ ARTIFACT_ROOT = Path("/mnt/tamcoder/users")
25
+
26
+
27
+ def fetch_latest() -> dict:
28
+ """Fetch latest.json from the release server."""
29
+ url = urljoin(RELEASE_BASE.rstrip("/") + "/", "latest.json")
30
+ resp = requests.get(url, headers={"Cache-Control": "no-cache"}, timeout=30)
31
+ resp.raise_for_status()
32
+ return resp.json()
33
+
34
+
35
+ def download_file(url: str, dest: Path, desc: str = "Downloading") -> None:
36
+ """Download a file with progress bar."""
37
+ resp = requests.get(url, stream=True, timeout=60)
38
+ resp.raise_for_status()
39
+ total = int(resp.headers.get("content-length", 0))
40
+ with open(dest, "wb") as f:
41
+ if total > 0:
42
+ for chunk in tqdm(resp.iter_content(chunk_size=8192), total=total // 8192, unit="B", unit_scale=True, desc=desc):
43
+ f.write(chunk)
44
+ else:
45
+ f.write(resp.content)
46
+
47
+
48
+ def verify_sha256(path: Path, expected: str) -> bool:
49
+ """Verify SHA-256 checksum of a file."""
50
+ actual = hashlib.sha256(path.read_bytes()).hexdigest()
51
+ return actual == expected
52
+
53
+
54
+ def check_node() -> None:
55
+ """Check that Node.js 22 or newer is available."""
56
+ try:
57
+ result = subprocess.run(
58
+ ["node", "--version"],
59
+ capture_output=True,
60
+ text=True,
61
+ check=True,
62
+ )
63
+ version_str = result.stdout.strip()
64
+ if version_str.startswith("v"):
65
+ version_str = version_str[1:]
66
+ major = int(version_str.split(".")[0])
67
+ if major < 22:
68
+ print(f"Node.js 22 or newer is required (found {major})", file=sys.stderr)
69
+ sys.exit(1)
70
+ except (subprocess.CalledProcessError, ValueError, IndexError):
71
+ print("Could not determine Node.js version", file=sys.stderr)
72
+ sys.exit(1)
73
+
74
+
75
+ def install_release(version: str, asset_name: str) -> Path:
76
+ """Download, verify, and install a specific release."""
77
+ asset_url = urljoin(RELEASE_BASE.rstrip("/") + "/", f"releases/{asset_name}")
78
+ sha256_url = urljoin(RELEASE_BASE.rstrip("/") + "/", f"releases/{asset_name}.sha256")
79
+
80
+ with tempfile.TemporaryDirectory() as tmpdir:
81
+ tmp = Path(tmpdir)
82
+ asset_path = tmp / asset_name
83
+ sha256_path = tmp / f"{asset_name}.sha256"
84
+
85
+ print(f"Downloading {asset_name}...")
86
+ download_file(asset_url, asset_path, desc=asset_name)
87
+ download_file(sha256_url, sha256_path, desc="checksum")
88
+
89
+ expected_sha256 = sha256_path.read_text().strip().split()[0]
90
+ print(f"Verifying SHA-256...")
91
+ if not verify_sha256(asset_path, expected_sha256):
92
+ print("Checksum mismatch!", file=sys.stderr)
93
+ sys.exit(1)
94
+
95
+ release_dir = INSTALL_PREFIX / "share" / "tamcoder" / "releases" / version
96
+ release_dir.mkdir(parents=True, exist_ok=True)
97
+
98
+ print(f"Extracting to {release_dir}...")
99
+ shutil.unpack_archive(asset_path, release_dir)
100
+
101
+ # Verify entrypoints
102
+ bin_path = release_dir / "app" / "bin" / "tamcoder"
103
+ main_path = release_dir / "app" / "dist" / "appServerMain.js"
104
+ if not bin_path.exists() or not bin_path.is_file():
105
+ print(f"Missing entrypoint: {bin_path}", file=sys.stderr)
106
+ sys.exit(1)
107
+ if not main_path.exists():
108
+ print(f"Missing server: {main_path}", file=sys.stderr)
109
+ sys.exit(1)
110
+
111
+ # Symlinks
112
+ bin_dir = INSTALL_PREFIX / "bin"
113
+ bin_dir.mkdir(parents=True, exist_ok=True)
114
+ for name in ("tamcoder", "tamcoder-bin"):
115
+ link = bin_dir / name
116
+ link.unlink(missing_ok=True)
117
+ link.symlink_to(bin_path)
118
+
119
+ # Artifact directories
120
+ ensure_artifact_directory(ARTIFACT_ROOT, 0o755)
121
+ ensure_artifact_directory(Path("/mnt/tamcoder/users"), 0o1777)
122
+ ensure_sticky_mode(ARTIFACT_ROOT)
123
+
124
+ if not os.access(ARTIFACT_ROOT, os.W_OK):
125
+ print(f"{ARTIFACT_ROOT} is not writable; run 'sudo chmod 1777 {ARTIFACT_ROOT}'", file=sys.stderr)
126
+ sys.exit(1)
127
+
128
+ return release_dir
129
+
130
+
131
+ def ensure_artifact_directory(path: Path, mode: int) -> None:
132
+ """Create artifact directory if missing with requested mode."""
133
+ if not path.exists():
134
+ path.mkdir(parents=True, exist_ok=True)
135
+ os.chmod(str(path), mode)
136
+
137
+
138
+ def ensure_sticky_mode(path: Path) -> None:
139
+ """Ensure the sticky bit is set."""
140
+ if os.name != "posix":
141
+ return
142
+ try:
143
+ current = os.stat(str(path)).st_mode
144
+ if not (current & 0o1000):
145
+ os.chmod(str(path), current | 0o1000)
146
+ except OSError:
147
+ pass
148
+
149
+
150
+ def main() -> int:
151
+ """Main entry point."""
152
+ # Handle update check flag
153
+ if os.environ.get("TAMCODER_UPDATE_CHECK") == "0":
154
+ pass # skip update check
155
+
156
+ # If called with --version, show PyPI shim version
157
+ if len(sys.argv) > 1 and sys.argv[1] in ("--version", "-V"):
158
+ from tamcoder import __version__
159
+ print(f"tamcoder (PyPI shim) {__version__}")
160
+ return 0
161
+
162
+ # If called with update, just re-run installation
163
+ if len(sys.argv) > 1 and sys.argv[1] == "update":
164
+ print("Checking for updates...")
165
+ # Falls through to normal install
166
+
167
+ check_node()
168
+
169
+ print("Fetching latest release info...")
170
+ latest = fetch_latest()
171
+ version = latest.get("version")
172
+ asset = latest.get("asset")
173
+ if not version or not asset:
174
+ print("Invalid release metadata", file=sys.stderr)
175
+ sys.exit(1)
176
+
177
+ release_dir = INSTALL_PREFIX / "share" / "tamcoder" / "releases" / version
178
+ if release_dir.exists() and (release_dir / "app" / "bin" / "tamcoder").exists():
179
+ # Already installed, just verify symlinks
180
+ bin_dir = INSTALL_PREFIX / "bin"
181
+ for name in ("tamcoder", "tamcoder-bin"):
182
+ link = bin_dir / name
183
+ target = release_dir / "app" / "bin" / "tamcoder"
184
+ if link.exists() and not link.is_symlink():
185
+ link.unlink()
186
+ link.unlink(missing_ok=True)
187
+ link.symlink_to(target)
188
+ print(f"Tamcoder {version} already installed at {bin_dir}/tamcoder")
189
+ else:
190
+ print(f"Installing Tamcoder {version}...")
191
+ install_release(version, asset)
192
+ print(f"Installed Tamcoder {version} to {INSTALL_PREFIX}/bin/tamcoder")
193
+ print(f"User artifacts will be stored under {ARTIFACT_ROOT}/<user-id-hash>")
194
+
195
+ # If invoked as tamcoder (not tamcoder-bin), forward to the real binary
196
+ if sys.argv[0].endswith("tamcoder") and not sys.argv[0].endswith("tamcoder-bin"):
197
+ real_bin = INSTALL_PREFIX / "bin" / "tamcoder"
198
+ if real_bin.exists():
199
+ os.execv(str(real_bin), [str(real_bin)] + sys.argv[1:])
200
+
201
+ return 0
202
+
203
+
204
+ if __name__ == "__main__":
205
+ sys.exit(main())
@@ -0,0 +1,55 @@
1
+ """Unit tests for the Tamcoder PyPI shim."""
2
+
3
+ import hashlib
4
+ import json
5
+ import os
6
+ import tempfile
7
+ from pathlib import Path
8
+ from unittest import mock
9
+
10
+ import pytest
11
+
12
+ from tamcoder.__main__ import verify_sha256, fetch_latest, install_release
13
+
14
+
15
+ def make_test_archive(tmp_path: Path) -> Path:
16
+ """Create a fake tamcoder tarball."""
17
+ app_dir = tmp_path / "app"
18
+ bin_dir = app_dir / "bin"
19
+ dist_dir = app_dir / "dist"
20
+ bin_dir.mkdir(parents=True)
21
+ dist_dir.mkdir(parents=True)
22
+ (bin_dir / "tamcoder").write_text("#!/bin/sh\necho fake tamcoder\n")
23
+ (bin_dir / "tamcoder").chmod(0o755)
24
+ (dist_dir / "appServerMain.js").write_text("console.log('ok')\n")
25
+
26
+ archive = tmp_path / "tamcoder-0.1.92-linux-x64.tar.gz"
27
+ import tarfile
28
+ with tarfile.open(archive, "w:gz") as tar:
29
+ tar.add(app_dir, arcname="app")
30
+ return archive
31
+
32
+
33
+ def test_verify_sha256_ok():
34
+ with tempfile.NamedTemporaryFile(delete=False) as f:
35
+ f.write(b"hello")
36
+ path = Path(f.name)
37
+ expected = hashlib.sha256(b"hello").hexdigest()
38
+ assert verify_sha256(path, expected)
39
+ assert not verify_sha256(path, "0" * 64)
40
+ path.unlink()
41
+
42
+
43
+ def test_fetch_latest_success(requests_mock):
44
+ requests_mock.get(
45
+ "https://gpt.tamfitronics.com/tamcoder/latest.json",
46
+ json={"version": "0.1.92", "asset": "tamcoder-0.1.92-linux-x64.tar.gz"},
47
+ )
48
+ data = fetch_latest()
49
+ assert data["version"] == "0.1.92"
50
+
51
+
52
+ def test_fetch_latest_failure(requests_mock):
53
+ requests_mock.get("https://gpt.tamfitronics.com/tamcoder/latest.json", status_code=500)
54
+ with pytest.raises(Exception):
55
+ fetch_latest()