Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Desktop MCP component
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
verify:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -e ".[dev]"
- run: python -m pytest -q
- run: python scripts/build_component.py
- uses: actions/upload-artifact@v4
with:
name: adh-component-${{ runner.os }}
path: dist/adh-*.zip*
6 changes: 6 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ Keep the upload token in `~/.config/pypi/token` on the release machine. Do not c
## License

[MIT](./LICENSE)

## DecryptHub desktop plugin

Install the official gateway from DecryptHub → Plugins, then configure your device service address. The component contains the PC CLI and a standard-library launcher and requires Python 3.10+. Device plugins and Host services are deployed separately.

Maintainers: run `python scripts/build_component.py` to build `dist/adh-<version>-any.zip`, including an API 1 manifest, source revision and per-file SHA-256 checksums. GitHub Releases tags `decrypthub-v<version>` distribute desktop components independently of PyPI releases.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ python -m twine upload --repository pypi dist/android_decrypt_hub-<version>*
## 协议

[MIT](./LICENSE)

## DecryptHub 桌面插件

在 DecryptHub 的「插件」入口安装官方网关,配置设备服务地址后即可启用 MCP。安装包只包含电脑端 CLI 和标准库启动器,要求 Python 3.10+;设备插件及 Host 服务仍按各自项目说明准备。

维护者构建组件:`python scripts/build_component.py`。输出 `dist/adh-<version>-any.zip`,包含 API 1 清单、源代码版本及逐文件 SHA-256,可独立通过 GitHub Releases 更新。`decrypthub-v<version>` 标签用于桌面组件分发,与 PyPI 发版独立。
51 changes: 51 additions & 0 deletions scripts/build_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import argparse
import hashlib
import json
import os
import pathlib
import re
import subprocess
import zipfile

root = pathlib.Path(__file__).resolve().parents[1]
parser = argparse.ArgumentParser(description='Build an independently installable DecryptHub MCP gateway component.')
parser.add_argument('--output', default=str(root / 'dist'))
args = parser.parse_args()
plugin = 'idh' if (root / 'src' / 'idh').is_dir() else 'adh'
metadata = (root / 'pyproject.toml').read_text(encoding='utf-8')
version = re.search(r'^version\s*=\s*"([^"]+)"', metadata, re.M).group(1)
if not re.fullmatch(r'\d+\.\d+\.\d+(?:-[\w.-]+)?', version):
raise SystemExit('Unsupported component version')
repository = f'decrypthub/{plugin}-cli'
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=root, text=True).strip()
launcher = ('import pathlib, runpy, sys\n'
'sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent / "src"))\n'
f'runpy.run_module("{plugin}", run_name="__main__")\n').encode()
files = []
contents = {'launch.py': launcher}
for name in ['src', 'LICENSE', 'README.md', 'pyproject.toml']:
source = root / name
candidates = sorted(source.rglob('*')) if source.is_dir() else [source]
for item in candidates:
if item.is_symlink():
raise SystemExit(f'Refusing linked source: {item}')
if not item.is_file() or '__pycache__' in item.parts or item.suffix in ['.pyc', '.pyo']:
continue
contents[item.relative_to(root).as_posix()] = item.read_bytes()
for name, data in sorted(contents.items()):
files.append({'path': name, 'size': len(data), 'sha256': hashlib.sha256(data).hexdigest()})
manifest = {'manifestVersion': 1, 'id': plugin, 'version': version, 'apiVersion': 1,
'runtime': 'python', 'python': '>=3.10', 'entrypoint': 'launch.py',
'platform': 'any', 'arch': 'any', 'source': {'repository': repository, 'commit': commit}, 'files': files}
output = pathlib.Path(args.output).resolve()
output.mkdir(parents=True, exist_ok=True)
archive = output / f'{plugin}-{version}-any.zip'
with zipfile.ZipFile(archive, 'w', compression=zipfile.ZIP_DEFLATED, compresslevel=9) as bundle:
bundle.writestr('component.json', json.dumps(manifest, indent=2) + '\n')
for name, data in sorted(contents.items()):
info = zipfile.ZipInfo(name, (2026, 1, 1, 0, 0, 0))
info.external_attr = 0o100644 << 16
bundle.writestr(info, data, compress_type=zipfile.ZIP_DEFLATED, compresslevel=9)
digest = hashlib.sha256(archive.read_bytes()).hexdigest()
(archive.with_suffix('.zip.sha256')).write_text(f'{digest} {archive.name}\n', encoding='utf-8')
print(json.dumps({'id': plugin, 'version': version, 'path': str(archive), 'sha256': digest, 'commit': commit}))
17 changes: 17 additions & 0 deletions tests/test_component_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import hashlib,json,pathlib,subprocess,sys,tempfile,unittest,zipfile
class ComponentBuildTest(unittest.TestCase):
def test_package_and_standard_library_launcher(self):
root=pathlib.Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory(prefix='decrypthub-component-test-') as directory:
subprocess.run([sys.executable,str(root/'scripts/build_component.py'),'--output',directory],check=True,capture_output=True)
archive=next(pathlib.Path(directory).glob('*.zip'))
with zipfile.ZipFile(archive) as bundle:
manifest=json.loads(bundle.read('component.json'))
self.assertEqual(manifest['runtime'],'python');self.assertEqual(manifest['platform'],'any')
self.assertEqual(set(bundle.namelist()),{'component.json'}|{f['path'] for f in manifest['files']})
for file in manifest['files']:
data=bundle.read(file['path']);self.assertEqual(len(data),file['size']);self.assertEqual(hashlib.sha256(data).hexdigest(),file['sha256'])
bundle.extractall(pathlib.Path(directory)/'installed')
result=subprocess.run([sys.executable,str(pathlib.Path(directory)/'installed/launch.py'),'--version'],check=True,capture_output=True,text=True)
self.assertIn(manifest['version'],result.stdout)
if __name__=='__main__':unittest.main()
Loading