codelux 0.1.0a2__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.
- codelux-0.1.0a2/LICENSE +21 -0
- codelux-0.1.0a2/PKG-INFO +175 -0
- codelux-0.1.0a2/README.md +74 -0
- codelux-0.1.0a2/README.zh-CN.md +73 -0
- codelux-0.1.0a2/pyproject.toml +66 -0
- codelux-0.1.0a2/src/codelux/__init__.py +12 -0
- codelux-0.1.0a2/src/codelux/adapters/__init__.py +7 -0
- codelux-0.1.0a2/src/codelux/adapters/base.py +47 -0
- codelux-0.1.0a2/src/codelux/adapters/claude.py +245 -0
- codelux-0.1.0a2/src/codelux/adapters/codex.py +649 -0
- codelux-0.1.0a2/src/codelux/cli.py +1486 -0
- codelux-0.1.0a2/src/codelux/coordinator.py +99 -0
- codelux-0.1.0a2/src/codelux/errors.py +21 -0
- codelux-0.1.0a2/src/codelux/locking.py +44 -0
- codelux-0.1.0a2/src/codelux/models.py +202 -0
- codelux-0.1.0a2/src/codelux/registry.py +177 -0
- codelux-0.1.0a2/src/codelux/registry_io.py +34 -0
- codelux-0.1.0a2/src/codelux/safe_files.py +67 -0
- codelux-0.1.0a2/src/codelux/sessions.py +155 -0
- codelux-0.1.0a2/src/codelux/snapshots.py +288 -0
- codelux-0.1.0a2/src/codelux/sync.py +1166 -0
- codelux-0.1.0a2/src/codelux/sync_transport.py +264 -0
codelux-0.1.0a2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Codelux AI Initiative
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
codelux-0.1.0a2/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codelux
|
|
3
|
+
Version: 0.1.0a2
|
|
4
|
+
Summary: Unified Provider management CLI for AI coding assistants
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: ai,llm,provider,claude,codex
|
|
8
|
+
Author: Codelux AI Initiative
|
|
9
|
+
Requires-Python: >=3.9,<4.0
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: click (>=8.1.0,<9.0.0)
|
|
22
|
+
Requires-Dist: cryptography (>=41,<47)
|
|
23
|
+
Project-URL: Homepage, https://github.com/codelux-io/codelux
|
|
24
|
+
Project-URL: Repository, https://github.com/codelux-io/codelux
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Codelux
|
|
28
|
+
|
|
29
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
30
|
+
|
|
31
|
+
Codelux is a command-line tool for managing LLM Provider configurations across AI coding
|
|
32
|
+
assistants. It provides explicit Provider switching, recoverable local changes, and encrypted
|
|
33
|
+
cross-machine synchronization.
|
|
34
|
+
|
|
35
|
+
**Website and Provider API:** [https://codelux.io](https://codelux.io)
|
|
36
|
+
|
|
37
|
+
## Capabilities
|
|
38
|
+
|
|
39
|
+
- Provider management for Claude Code and Codex
|
|
40
|
+
- Read-only configuration and health inspection
|
|
41
|
+
- Snapshot-backed restoration of official configurations
|
|
42
|
+
- Fail-closed recovery for incomplete local transactions
|
|
43
|
+
- Encrypted offline export/import and OpenSSH-based synchronization
|
|
44
|
+
- Explicit conflict handling for synchronized configuration and session data
|
|
45
|
+
|
|
46
|
+
## Security model
|
|
47
|
+
|
|
48
|
+
Codelux stores Provider credentials in local files protected by operating-system file permissions.
|
|
49
|
+
These files are not encrypted at rest. They are not protected from processes running as the same
|
|
50
|
+
user, privileged administrators, malware, compromised accounts, backups, or physical disk access.
|
|
51
|
+
|
|
52
|
+
Cross-machine archives are encrypted with a user-provided password. Active client configuration is
|
|
53
|
+
not applied on another machine unless the user explicitly requests it.
|
|
54
|
+
|
|
55
|
+
See [SECURITY.md](SECURITY.md) for vulnerability reporting and security boundaries.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
Codelux is currently in alpha and has not been published to the production Python Package Index.
|
|
60
|
+
Install the development checkout with:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
python3 -m pip install -e .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
codelux version
|
|
70
|
+
codelux status --client claude
|
|
71
|
+
codelux list
|
|
72
|
+
codelux add codelux-io --url https://codelux.io --client claude
|
|
73
|
+
codelux switch codelux-io --client claude
|
|
74
|
+
codelux switch official --client claude
|
|
75
|
+
codelux recover --dry-run
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Synchronization commands support explicit content selection:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
codelux sync export --output codelux-sync.enc --providers --sessions
|
|
82
|
+
codelux sync import codelux-sync.enc
|
|
83
|
+
codelux sync push --ssh user@host.example --providers
|
|
84
|
+
codelux sync pull --ssh user@host.example --providers
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use `--help` on any command to inspect its current options and safety prompts.
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python3 -m pip install . pytest==7.4.4 coverage==7.10.7
|
|
93
|
+
coverage run -m pytest -q
|
|
94
|
+
coverage report
|
|
95
|
+
python scripts/check_public_repository.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
|
101
|
+
|
|
102
|
+
# Codelux
|
|
103
|
+
|
|
104
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
105
|
+
|
|
106
|
+
Codelux 是一个用于在多种 AI 编程助手之间管理大模型 Provider 配置的命令行工具,提供
|
|
107
|
+
明确的 Provider 切换、可恢复的本地修改和加密跨机器同步。
|
|
108
|
+
|
|
109
|
+
**官网与 Provider API:** [https://codelux.io](https://codelux.io)
|
|
110
|
+
|
|
111
|
+
## 主要能力
|
|
112
|
+
|
|
113
|
+
- 管理 Claude Code 和 Codex 的 Provider
|
|
114
|
+
- 只读检查配置与健康状态
|
|
115
|
+
- 通过快照恢复官方配置
|
|
116
|
+
- 对未完成的本地事务执行失败关闭式恢复
|
|
117
|
+
- 加密离线导入导出和基于 OpenSSH 的同步
|
|
118
|
+
- 对同步配置和会话数据执行明确的冲突处理
|
|
119
|
+
|
|
120
|
+
## 安全模型
|
|
121
|
+
|
|
122
|
+
Codelux 将 Provider 凭据保存在受操作系统文件权限保护的本地文件中。这些文件并未进行
|
|
123
|
+
静态加密,无法防御以同一用户身份运行的进程、特权管理员、恶意软件、账号失陷、备份
|
|
124
|
+
泄露或物理磁盘访问。
|
|
125
|
+
|
|
126
|
+
跨机器归档使用用户提供的密码加密。除非用户明确要求,否则不会在另一台机器上应用
|
|
127
|
+
活动客户端配置。
|
|
128
|
+
|
|
129
|
+
漏洞报告方式和详细安全边界见 [SECURITY.zh-CN.md](SECURITY.zh-CN.md)。
|
|
130
|
+
|
|
131
|
+
## 安装
|
|
132
|
+
|
|
133
|
+
Codelux 当前处于 Alpha 阶段,尚未发布到正式 Python Package Index。开发环境可从当前
|
|
134
|
+
代码目录安装:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
python3 -m pip install -e .
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 使用方法
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
codelux version
|
|
144
|
+
codelux status --client claude
|
|
145
|
+
codelux list
|
|
146
|
+
codelux add codelux-io --url https://codelux.io --client claude
|
|
147
|
+
codelux switch codelux-io --client claude
|
|
148
|
+
codelux switch official --client claude
|
|
149
|
+
codelux recover --dry-run
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
同步命令支持明确选择传输内容:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
codelux sync export --output codelux-sync.enc --providers --sessions
|
|
156
|
+
codelux sync import codelux-sync.enc
|
|
157
|
+
codelux sync push --ssh user@host.example --providers
|
|
158
|
+
codelux sync pull --ssh user@host.example --providers
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
可以对任意命令使用 `--help` 查看当前选项和安全提示。
|
|
162
|
+
|
|
163
|
+
## 开发验证
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
python3 -m pip install . pytest==7.4.4 coverage==7.10.7
|
|
167
|
+
coverage run -m pytest -q
|
|
168
|
+
coverage report
|
|
169
|
+
python scripts/check_public_repository.py
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 许可证
|
|
173
|
+
|
|
174
|
+
MIT
|
|
175
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Codelux
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Codelux is a command-line tool for managing LLM Provider configurations across AI coding
|
|
6
|
+
assistants. It provides explicit Provider switching, recoverable local changes, and encrypted
|
|
7
|
+
cross-machine synchronization.
|
|
8
|
+
|
|
9
|
+
**Website and Provider API:** [https://codelux.io](https://codelux.io)
|
|
10
|
+
|
|
11
|
+
## Capabilities
|
|
12
|
+
|
|
13
|
+
- Provider management for Claude Code and Codex
|
|
14
|
+
- Read-only configuration and health inspection
|
|
15
|
+
- Snapshot-backed restoration of official configurations
|
|
16
|
+
- Fail-closed recovery for incomplete local transactions
|
|
17
|
+
- Encrypted offline export/import and OpenSSH-based synchronization
|
|
18
|
+
- Explicit conflict handling for synchronized configuration and session data
|
|
19
|
+
|
|
20
|
+
## Security model
|
|
21
|
+
|
|
22
|
+
Codelux stores Provider credentials in local files protected by operating-system file permissions.
|
|
23
|
+
These files are not encrypted at rest. They are not protected from processes running as the same
|
|
24
|
+
user, privileged administrators, malware, compromised accounts, backups, or physical disk access.
|
|
25
|
+
|
|
26
|
+
Cross-machine archives are encrypted with a user-provided password. Active client configuration is
|
|
27
|
+
not applied on another machine unless the user explicitly requests it.
|
|
28
|
+
|
|
29
|
+
See [SECURITY.md](SECURITY.md) for vulnerability reporting and security boundaries.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Codelux is currently in alpha and has not been published to the production Python Package Index.
|
|
34
|
+
Install the development checkout with:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python3 -m pip install -e .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
codelux version
|
|
44
|
+
codelux status --client claude
|
|
45
|
+
codelux list
|
|
46
|
+
codelux add codelux-io --url https://codelux.io --client claude
|
|
47
|
+
codelux switch codelux-io --client claude
|
|
48
|
+
codelux switch official --client claude
|
|
49
|
+
codelux recover --dry-run
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Synchronization commands support explicit content selection:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
codelux sync export --output codelux-sync.enc --providers --sessions
|
|
56
|
+
codelux sync import codelux-sync.enc
|
|
57
|
+
codelux sync push --ssh user@host.example --providers
|
|
58
|
+
codelux sync pull --ssh user@host.example --providers
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `--help` on any command to inspect its current options and safety prompts.
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python3 -m pip install . pytest==7.4.4 coverage==7.10.7
|
|
67
|
+
coverage run -m pytest -q
|
|
68
|
+
coverage report
|
|
69
|
+
python scripts/check_public_repository.py
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Codelux
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Codelux 是一个用于在多种 AI 编程助手之间管理大模型 Provider 配置的命令行工具,提供
|
|
6
|
+
明确的 Provider 切换、可恢复的本地修改和加密跨机器同步。
|
|
7
|
+
|
|
8
|
+
**官网与 Provider API:** [https://codelux.io](https://codelux.io)
|
|
9
|
+
|
|
10
|
+
## 主要能力
|
|
11
|
+
|
|
12
|
+
- 管理 Claude Code 和 Codex 的 Provider
|
|
13
|
+
- 只读检查配置与健康状态
|
|
14
|
+
- 通过快照恢复官方配置
|
|
15
|
+
- 对未完成的本地事务执行失败关闭式恢复
|
|
16
|
+
- 加密离线导入导出和基于 OpenSSH 的同步
|
|
17
|
+
- 对同步配置和会话数据执行明确的冲突处理
|
|
18
|
+
|
|
19
|
+
## 安全模型
|
|
20
|
+
|
|
21
|
+
Codelux 将 Provider 凭据保存在受操作系统文件权限保护的本地文件中。这些文件并未进行
|
|
22
|
+
静态加密,无法防御以同一用户身份运行的进程、特权管理员、恶意软件、账号失陷、备份
|
|
23
|
+
泄露或物理磁盘访问。
|
|
24
|
+
|
|
25
|
+
跨机器归档使用用户提供的密码加密。除非用户明确要求,否则不会在另一台机器上应用
|
|
26
|
+
活动客户端配置。
|
|
27
|
+
|
|
28
|
+
漏洞报告方式和详细安全边界见 [SECURITY.zh-CN.md](SECURITY.zh-CN.md)。
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
Codelux 当前处于 Alpha 阶段,尚未发布到正式 Python Package Index。开发环境可从当前
|
|
33
|
+
代码目录安装:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
python3 -m pip install -e .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使用方法
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
codelux version
|
|
43
|
+
codelux status --client claude
|
|
44
|
+
codelux list
|
|
45
|
+
codelux add codelux-io --url https://codelux.io --client claude
|
|
46
|
+
codelux switch codelux-io --client claude
|
|
47
|
+
codelux switch official --client claude
|
|
48
|
+
codelux recover --dry-run
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
同步命令支持明确选择传输内容:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
codelux sync export --output codelux-sync.enc --providers --sessions
|
|
55
|
+
codelux sync import codelux-sync.enc
|
|
56
|
+
codelux sync push --ssh user@host.example --providers
|
|
57
|
+
codelux sync pull --ssh user@host.example --providers
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
可以对任意命令使用 `--help` 查看当前选项和安全提示。
|
|
61
|
+
|
|
62
|
+
## 开发验证
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python3 -m pip install . pytest==7.4.4 coverage==7.10.7
|
|
66
|
+
coverage run -m pytest -q
|
|
67
|
+
coverage report
|
|
68
|
+
python scripts/check_public_repository.py
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 许可证
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "codelux"
|
|
3
|
+
version = "0.1.0a2"
|
|
4
|
+
description = "Unified Provider management CLI for AI coding assistants"
|
|
5
|
+
authors = ["Codelux AI Initiative"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = ["README.md", "README.zh-CN.md"]
|
|
8
|
+
homepage = "https://github.com/codelux-io/codelux"
|
|
9
|
+
repository = "https://github.com/codelux-io/codelux"
|
|
10
|
+
keywords = ["ai", "llm", "provider", "claude", "codex"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.9",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.poetry.dependencies]
|
|
24
|
+
python = "^3.9"
|
|
25
|
+
click = "^8.1.0"
|
|
26
|
+
cryptography = ">=41,<47"
|
|
27
|
+
|
|
28
|
+
[tool.poetry.group.dev.dependencies]
|
|
29
|
+
pytest = "^7.4.0"
|
|
30
|
+
black = "^23.0.0"
|
|
31
|
+
ruff = "^0.1.0"
|
|
32
|
+
mypy = "^1.7.0"
|
|
33
|
+
coverage = "^7.6.0"
|
|
34
|
+
tomli = { version = "^2.0.0", python = "<3.11" }
|
|
35
|
+
|
|
36
|
+
[tool.poetry.scripts]
|
|
37
|
+
codelux = "codelux.cli:main"
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["poetry-core==2.2.1"]
|
|
41
|
+
build-backend = "poetry.core.masonry.api"
|
|
42
|
+
|
|
43
|
+
[tool.black]
|
|
44
|
+
line-length = 100
|
|
45
|
+
target-version = ["py39"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
target-version = "py39"
|
|
50
|
+
|
|
51
|
+
[tool.mypy]
|
|
52
|
+
python_version = "3.9"
|
|
53
|
+
warn_return_any = true
|
|
54
|
+
warn_unused_configs = true
|
|
55
|
+
disallow_untyped_defs = true
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
pythonpath = ["src"]
|
|
59
|
+
|
|
60
|
+
[tool.coverage.run]
|
|
61
|
+
source = ["src/codelux"]
|
|
62
|
+
|
|
63
|
+
[tool.coverage.report]
|
|
64
|
+
fail_under = 90
|
|
65
|
+
precision = 2
|
|
66
|
+
show_missing = true
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Codelux - Unified Provider management CLI for AI coding assistants.
|
|
2
|
+
|
|
3
|
+
Codelux provides a unified interface for managing LLM Provider credentials
|
|
4
|
+
across multiple AI coding assistants (Claude Code, Codex, and future platforms).
|
|
5
|
+
|
|
6
|
+
The public package contains product behavior only; internal development records are maintained
|
|
7
|
+
outside the distribution repository.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0a2"
|
|
11
|
+
__author__ = "Codelux AI Initiative"
|
|
12
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Shared adapter interface."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Mapping
|
|
6
|
+
|
|
7
|
+
from codelux.models import ConfigFile, ObservedConfig, PreparedChange, ProcessState
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ClientAdapter(ABC):
|
|
11
|
+
name: str
|
|
12
|
+
|
|
13
|
+
@abstractmethod
|
|
14
|
+
def is_installed(self) -> bool:
|
|
15
|
+
"""Return whether the client can be addressed on this machine."""
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def is_running(self) -> ProcessState:
|
|
19
|
+
"""Return a conservative process state."""
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def inspect(self) -> ObservedConfig:
|
|
23
|
+
"""Read actual client configuration without using registry cache."""
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def prepare_provider(self, binding: Mapping[str, object]) -> PreparedChange:
|
|
27
|
+
"""Build a change without modifying live files."""
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def prepare_snapshot_restore(self, manifest: Mapping[str, object]) -> PreparedChange:
|
|
31
|
+
"""Build a full-file restore from a validated snapshot manifest."""
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def validate_files(self, files: tuple[ConfigFile, ...]) -> None:
|
|
35
|
+
"""Parse and validate candidate files."""
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def commit(self, change: PreparedChange) -> None:
|
|
39
|
+
"""Commit a prepared change atomically for this client."""
|
|
40
|
+
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def rollback(self, change: PreparedChange) -> None:
|
|
43
|
+
"""Restore the before files; repeated calls must be harmless."""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def config_file(path: Path, content: bytes, mode: int = 0o600) -> ConfigFile:
|
|
47
|
+
return ConfigFile(path=path, content=content, mode=mode & 0o777)
|