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: idh-component-${{ runner.os }}
path: dist/idh-*.zip*
6 changes: 6 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,9 @@ Search **DecryptHub** in WeChat, or scan the QR below.

- Telegram: https://t.me/decrypthubteam
- X: https://x.com/decrypthub_

## 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/idh-<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 @@ -250,3 +250,9 @@ MCP 网关暴露 `idh_list_skills` 和 `idh_get_skill`;提示词与 skills 的

- Telegram:https://t.me/decrypthubteam
- X:https://x.com/decrypthub_

## DecryptHub 桌面插件

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

维护者构建组件:`python scripts/build_component.py`。输出 `dist/idh-<version>-any.zip`,包含 API 1 清单、源代码版本及逐文件 SHA-256,可独立通过 GitHub Releases 更新。`decrypthub-v<version>` 标签用于桌面组件分发,与 PyPI 发版独立。
52 changes: 52 additions & 0 deletions scripts/build_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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'
+ ('if "--no-auto-update" not in sys.argv: sys.argv.insert(1, "--no-auto-update")\n' if plugin == 'idh' else '') +
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()
5 changes: 4 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import json

import pytest
Expand All @@ -18,7 +19,9 @@ def test_saved_endpoints_round_trip_and_deduplicate(tmp_path) -> None:
"http://192.168.100.65:8088/api/mcp"
]
assert json.loads(path.read_text())["version"] == 1
assert path.stat().st_mode & 0o777 == 0o600
# Windows does not represent POSIX permission bits; its user ACL is separate.
if os.name != "nt":
assert path.stat().st_mode & 0o777 == 0o600


def test_remove_and_clear_saved_endpoints(tmp_path) -> None:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import os

from idh.settings import load_settings, save_settings


Expand All @@ -13,7 +15,9 @@ def test_settings_defaults_and_round_trip(tmp_path) -> None:
loaded = load_settings(path)
assert loaded["auto_update"] is False
assert loaded["update_interval"] == 60
assert path.stat().st_mode & 0o777 == 0o600
# Windows does not represent POSIX permission bits; its user ACL is separate.
if os.name != "nt":
assert path.stat().st_mode & 0o777 == 0o600


def test_settings_env_override(monkeypatch, tmp_path) -> None:
Expand Down
Loading