tamcoder 0.1.97__tar.gz → 0.2.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.

Potentially problematic release.


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

@@ -0,0 +1,3 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.tgz
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Tamfitronics Ltd.
3
+ Copyright (c) 2026 Tamfis Nig. Ltd.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.5
2
+ Name: tamcoder
3
+ Version: 0.2.0
4
+ Summary: Tamcoder installer for the official TypeScript coding-agent runtime
5
+ Project-URL: Homepage, https://gpt.tamfitronics.com/tamcoder/
6
+ Project-URL: Repository, https://github.com/tbtamfit/tamcoder
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Tamcoder
13
+
14
+ Installs the official Tamcoder TypeScript runtime for Linux x86_64. Requires Node.js 22+ and tar. The installer downloads the release matching the package version from https://gpt.tamfitronics.com/tamcoder/ and verifies its SHA-256 checksum. It uses your user installation directory and does not change system artifact permissions.
15
+
16
+ Run `tamcoder login`, then `tamcoder` in your project. Use `tamcoder --resume` to resume a session. Upgrade this package to receive a newer runtime.
17
+
18
+ `TAMCODER_INSTALL_PREFIX` changes the default `~/.local` installation prefix. `TAMCODER_RELEASE_BASE` selects an alternate release host for testing. No workspace, session or account data is sent during installation.
@@ -0,0 +1,7 @@
1
+ # Tamcoder
2
+
3
+ Installs the official Tamcoder TypeScript runtime for Linux x86_64. Requires Node.js 22+ and tar. The installer downloads the release matching the package version from https://gpt.tamfitronics.com/tamcoder/ and verifies its SHA-256 checksum. It uses your user installation directory and does not change system artifact permissions.
4
+
5
+ Run `tamcoder login`, then `tamcoder` in your project. Use `tamcoder --resume` to resume a session. Upgrade this package to receive a newer runtime.
6
+
7
+ `TAMCODER_INSTALL_PREFIX` changes the default `~/.local` installation prefix. `TAMCODER_RELEASE_BASE` selects an alternate release host for testing. No workspace, session or account data is sent during installation.
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.0.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tamcoder"
7
+ version = "0.2.0"
8
+ description = "Tamcoder installer for the official TypeScript coding-agent runtime"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+
13
+ [project.urls]
14
+ Homepage = "https://gpt.tamfitronics.com/tamcoder/"
15
+ Repository = "https://github.com/tbtamfit/tamcoder"
16
+
17
+ [project.scripts]
18
+ tamcoder = "tamcoder.__main__:main"
19
+ tamcoder-bin = "tamcoder.__main__:main"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/tamcoder"]
@@ -0,0 +1 @@
1
+ __version__ = "0.2.0"
@@ -0,0 +1,63 @@
1
+ """Install the matching official runtime, then hand all arguments to it."""
2
+ import hashlib
3
+ import os
4
+ import platform
5
+ import shutil
6
+ import subprocess
7
+ import sys
8
+ import tempfile
9
+ from pathlib import Path
10
+ from urllib.request import Request, urlopen
11
+ from . import __version__
12
+
13
+ BASE = os.environ.get('TAMCODER_RELEASE_BASE', 'https://gpt.tamfitronics.com/tamcoder').rstrip('/')
14
+ PREFIX = Path(os.environ.get('TAMCODER_INSTALL_PREFIX', Path.home() / '.local'))
15
+
16
+
17
+ def ensure_runtime():
18
+ if sys.platform != 'linux' or platform.machine() not in ('x86_64', 'amd64'):
19
+ raise RuntimeError('Tamcoder currently requires Linux x86_64.')
20
+ node = shutil.which('node')
21
+ if not node or int(subprocess.check_output([node, '--version'], text=True).strip().lstrip('v').split('.')[0]) < 22:
22
+ raise RuntimeError('Node.js 22 or newer is required.')
23
+ release = PREFIX / 'share' / 'tamcoder' / 'releases' / __version__
24
+ binary = release / 'app' / 'bin' / 'tamcoder'
25
+ if binary.is_file():
26
+ return binary
27
+ asset = f'tamcoder-{__version__}-linux-x64.tar.gz'
28
+ release.parent.mkdir(parents=True, exist_ok=True)
29
+ with tempfile.TemporaryDirectory(prefix='.install-', dir=release.parent) as temporary:
30
+ temporary = Path(temporary)
31
+ with urlopen(Request(f'{BASE}/releases/{asset}.sha256', headers={'User-Agent': f'tamcoder/{__version__}'}), timeout=60) as response:
32
+ expected = response.read().decode().split()[0].lower()
33
+ if len(expected) != 64 or any(c not in '0123456789abcdef' for c in expected):
34
+ raise RuntimeError('Invalid release checksum.')
35
+ archive = temporary / asset
36
+ digest = hashlib.sha256()
37
+ with urlopen(Request(f'{BASE}/releases/{asset}', headers={'User-Agent': f'tamcoder/{__version__}'}), timeout=120) as response, archive.open('wb') as output:
38
+ while block := response.read(1024 * 1024):
39
+ digest.update(block)
40
+ output.write(block)
41
+ if digest.hexdigest() != expected:
42
+ raise RuntimeError('Release checksum mismatch.')
43
+ staged = temporary / 'release'
44
+ staged.mkdir()
45
+ subprocess.run(['tar', '-xzf', str(archive), '-C', str(staged)], check=True)
46
+ if not (staged / 'app/bin/tamcoder').is_file() or not (staged / 'app/dist/appServerMain.js').is_file():
47
+ raise RuntimeError('Release archive is missing its entrypoints.')
48
+ if not release.exists():
49
+ staged.rename(release)
50
+ return binary
51
+
52
+
53
+ def main():
54
+ try:
55
+ binary = ensure_runtime()
56
+ os.execv(str(binary), [str(binary), *sys.argv[1:]])
57
+ except (OSError, ValueError, RuntimeError, subprocess.CalledProcessError) as error:
58
+ print(f'tamcoder: {error}', file=sys.stderr)
59
+ return 1
60
+
61
+
62
+ if __name__ == '__main__':
63
+ sys.exit(main())
@@ -0,0 +1,29 @@
1
+ import hashlib
2
+ import io
3
+ import tempfile
4
+ import unittest
5
+ from pathlib import Path
6
+ from unittest.mock import patch
7
+ from tamcoder import __main__ as shim
8
+
9
+
10
+ class InstallerTests(unittest.TestCase):
11
+ def test_corrupt_archive_is_rejected_before_extraction(self):
12
+ with tempfile.TemporaryDirectory() as directory:
13
+ responses = [io.BytesIO(b'0' * 64), io.BytesIO(b'corrupt archive')]
14
+ with patch.object(shim, 'PREFIX', Path(directory)), patch.object(shim, 'urlopen', side_effect=responses) as fetch:
15
+ with self.assertRaisesRegex(RuntimeError, 'checksum mismatch'):
16
+ shim.ensure_runtime()
17
+ self.assertIn('tamcoder-0.1.98-linux-x64.tar.gz', fetch.call_args_list[1].args[0].full_url)
18
+ self.assertEqual(fetch.call_args_list[1].args[0].get_header('User-agent'), 'tamcoder/0.1.98')
19
+ self.assertFalse((Path(directory) / 'share/tamcoder/releases/0.1.98').exists())
20
+
21
+ def test_installed_runtime_receives_all_arguments(self):
22
+ binary = Path('/tmp/runtime/app/bin/tamcoder')
23
+ with patch.object(shim, 'ensure_runtime', return_value=binary), patch.object(shim.os, 'execv') as execute, patch.object(shim.sys, 'argv', ['tamcoder', '--resume', 'thread-123']):
24
+ shim.main()
25
+ execute.assert_called_once_with(str(binary), [str(binary), '--resume', 'thread-123'])
26
+
27
+
28
+ if __name__ == '__main__':
29
+ unittest.main()
tamcoder-0.1.97/PKG-INFO DELETED
@@ -1,66 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: tamcoder
3
- Version: 0.1.97
4
- Summary: Tamcoder — TypeScript coding agent runtime (PyPI shim that installs the official Linux x86_64 release)
5
- Project-URL: Homepage, https://gpt.tamfitronics.com/tamcoder
6
- Project-URL: Repository, https://github.com/tamfitronics/tamcoder
7
- Project-URL: Documentation, https://gpt.tamfitronics.com/tamcoder
8
- License: MIT
9
- License-File: LICENSE
10
- Keywords: ai,cli,coding-agent,tamcoder,typescript
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: POSIX :: Linux
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Topic :: Software Development :: Build Tools
21
- Requires-Python: >=3.10
22
- Provides-Extra: dev
23
- Requires-Dist: build>=1.2.0; extra == 'dev'
24
- Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
25
- Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
26
- Requires-Dist: pytest>=8.0.0; extra == 'dev'
27
- Requires-Dist: requests-mock>=1.12.0; extra == 'dev'
28
- Requires-Dist: twine>=6.0.0; extra == 'dev'
29
- Description-Content-Type: text/markdown
30
-
31
- # Tamcoder
32
-
33
- Tamcoder is the TypeScript coding-agent runtime for TamfisGPT. This Python package is a lightweight PyPI shim that downloads and installs the official, pre-built Linux x86_64 release.
34
-
35
- ## Install
36
-
37
- ```bash
38
- pip install tamcoder
39
- ```
40
-
41
- ## Requirements
42
-
43
- - Python 3.10+
44
- - Linux x86_64
45
- - Node.js 22 or newer at `/usr/bin/node`
46
-
47
- ## What the shim does
48
-
49
- On first run, the package fetches the current release metadata from `https://gpt.tamfitronics.com/tamcoder/latest.json`, downloads the matching tarball, verifies its SHA-256 checksum, and installs the Tamcoder CLI into `~/.local/share/tamcoder/releases/<version>/`. A symlink is created in `~/.local/bin/tamcoder` (and `tamcoder-bin`) so the command is available on `$PATH`.
50
-
51
- ## Usage
52
-
53
- ```bash
54
- tamcoder --version
55
- tamcoder update
56
- ```
57
-
58
- Tamcoder opens a full-screen terminal workspace for project work. See the upstream page for full documentation: <https://gpt.tamfitronics.com/tamcoder>.
59
-
60
- ## Privacy note
61
-
62
- The `tamcoder` command checks the public release version at startup. No workspace, session, or account data is sent. Set `TAMCODER_UPDATE_CHECK=0` to disable this.
63
-
64
- ## License
65
-
66
- MIT
tamcoder-0.1.97/README.md DELETED
@@ -1,36 +0,0 @@
1
- # Tamcoder
2
-
3
- Tamcoder is the TypeScript coding-agent runtime for TamfisGPT. This Python package is a lightweight PyPI shim that downloads and installs the official, pre-built Linux x86_64 release.
4
-
5
- ## Install
6
-
7
- ```bash
8
- pip install tamcoder
9
- ```
10
-
11
- ## Requirements
12
-
13
- - Python 3.10+
14
- - Linux x86_64
15
- - Node.js 22 or newer at `/usr/bin/node`
16
-
17
- ## What the shim does
18
-
19
- On first run, the package fetches the current release metadata from `https://gpt.tamfitronics.com/tamcoder/latest.json`, downloads the matching tarball, verifies its SHA-256 checksum, and installs the Tamcoder CLI into `~/.local/share/tamcoder/releases/<version>/`. A symlink is created in `~/.local/bin/tamcoder` (and `tamcoder-bin`) so the command is available on `$PATH`.
20
-
21
- ## Usage
22
-
23
- ```bash
24
- tamcoder --version
25
- tamcoder update
26
- ```
27
-
28
- Tamcoder opens a full-screen terminal workspace for project work. See the upstream page for full documentation: <https://gpt.tamfitronics.com/tamcoder>.
29
-
30
- ## Privacy note
31
-
32
- The `tamcoder` command checks the public release version at startup. No workspace, session, or account data is sent. Set `TAMCODER_UPDATE_CHECK=0` to disable this.
33
-
34
- ## License
35
-
36
- MIT
@@ -1,58 +0,0 @@
1
- [build-system]
2
- requires = ["hatchling>=1.0.0"]
3
- build-backend = "hatchling.build"
4
-
5
- [project]
6
- name = "tamcoder"
7
- version = "0.1.97"
8
- description = "Tamcoder — TypeScript coding agent runtime (PyPI shim that installs the official Linux x86_64 release)"
9
- readme = "README.md"
10
- license = {text = "MIT"}
11
- requires-python = ">=3.10"
12
- classifiers = [
13
- "Development Status :: 4 - Beta",
14
- "Intended Audience :: Developers",
15
- "License :: OSI Approved :: MIT License",
16
- "Operating System :: POSIX :: Linux",
17
- "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.10",
19
- "Programming Language :: Python :: 3.11",
20
- "Programming Language :: Python :: 3.12",
21
- "Programming Language :: Python :: 3.13",
22
- "Topic :: Software Development :: Build Tools",
23
- ]
24
- keywords = ["tamcoder", "coding-agent", "typescript", "cli", "ai"]
25
-
26
- [project.urls]
27
- Homepage = "https://gpt.tamfitronics.com/tamcoder"
28
- Repository = "https://github.com/tamfitronics/tamcoder"
29
- Documentation = "https://gpt.tamfitronics.com/tamcoder"
30
-
31
- [project.scripts]
32
- tamcoder = "tamcoder.__main__:main"
33
- tamcoder-bin = "tamcoder.__main__:main"
34
-
35
- [project.optional-dependencies]
36
- dev = [
37
- "pytest>=8.0.0",
38
- "pytest-cov>=5.0.0",
39
- "pytest-mock>=3.14.0",
40
- "requests-mock>=1.12.0",
41
- "build>=1.2.0",
42
- "twine>=6.0.0",
43
- ]
44
-
45
- [tool.hatch.build.targets.sdist]
46
- # Use default selection; Hatch will include the "src/tamcoder" package.
47
-
48
- [tool.hatch.build.targets.wheel]
49
- packages = ["src/tamcoder"]
50
-
51
- [tool.pytest.ini_options]
52
- testpaths = ["tests"]
53
- python_files = ["test_*.py"]
54
- python_functions = ["test_*"]
55
-
56
- [tool.coverage.run]
57
- source = ["src/tamcoder"]
58
- branch = true
@@ -1,3 +0,0 @@
1
- """Tamcoder PyPI shim — installs the official TypeScript release."""
2
- __version__ = "0.1.97"
3
- __all__ = ["__version__"]
@@ -1,205 +0,0 @@
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())
@@ -1,55 +0,0 @@
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()