fx-tool 1.0.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.
fx_tool-1.0.0/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ ## LICENSE
2
+ Copyright (c) [2026] Charles DeFreese
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6
+
fx_tool-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: fx-tool
3
+ Version: 1.0.0
4
+ Summary: Functionals FX project and DevOps operations CLI.
5
+ Author: Charles DeFreese
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/nexustech101/fx
8
+ Project-URL: Repository, https://github.com/nexustech101/fx
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: registers>=6.0.0
21
+ Requires-Dist: tqdm<5,>=4.66
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest<8,>=7.4; extra == "dev"
24
+ Requires-Dist: pytest-cov<5,>=4.1; extra == "dev"
25
+ Requires-Dist: pytest-asyncio<1,>=0.23; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # fx-tool
29
+
30
+ `fx` is the standalone project manager and operations CLI for the
31
+ Functionals framework.
32
+
33
+ It is focused on developer and DevOps workflows around Functionals apps:
34
+
35
+ - project scaffolding (`cli` and `db` project types)
36
+ - module and plugin structure management
37
+ - runtime operations (`run`, `install`, `update`, `pull`)
38
+ - cron workspace, workflow registration, and runtime control
39
+ - local control-plane state and operational history
40
+
41
+ `fx-tool` is intentionally separate from the core framework package now, but it
42
+ still manages projects built on the Functionals runtime (`registers`).
43
+
44
+ Runtime package note: the framework package/import namespace is now `registers`
45
+ (renamed from `decorates`/`registers`).
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install fx-tool
51
+ ```
52
+
53
+ `fx-tool` depends on [`registers`](https://pypi.org/project/registers/) for the
54
+ framework runtime modules (`registers.cli`, `registers.db`,
55
+ `registers.cron`).
56
+
57
+ ## Run
58
+
59
+ ```bash
60
+ fx --version
61
+ fx --help
62
+ fx --interactive
63
+ python -m fx --help
64
+ ```
65
+
66
+ ## Quick Example
67
+
68
+ ```bash
69
+ # Initialize a Functionals project
70
+ fx init cli MyService
71
+
72
+ # Validate project structure and plugin wiring
73
+ fx status MyService
74
+ fx health MyService
75
+
76
+ # Operate cron workflows
77
+ fx cron workspace MyService
78
+ fx cron jobs MyService
79
+ fx cron start MyService
80
+ ```
81
+
82
+ ## Documentation
83
+
84
+ - Usage guide: [`src/fx/USAGE.md`](C:/Users/charl/Documents/Python/framework/fx/src/fx/USAGE.md)
85
+
@@ -0,0 +1,58 @@
1
+ # fx-tool
2
+
3
+ `fx` is the standalone project manager and operations CLI for the
4
+ Functionals framework.
5
+
6
+ It is focused on developer and DevOps workflows around Functionals apps:
7
+
8
+ - project scaffolding (`cli` and `db` project types)
9
+ - module and plugin structure management
10
+ - runtime operations (`run`, `install`, `update`, `pull`)
11
+ - cron workspace, workflow registration, and runtime control
12
+ - local control-plane state and operational history
13
+
14
+ `fx-tool` is intentionally separate from the core framework package now, but it
15
+ still manages projects built on the Functionals runtime (`registers`).
16
+
17
+ Runtime package note: the framework package/import namespace is now `registers`
18
+ (renamed from `decorates`/`registers`).
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install fx-tool
24
+ ```
25
+
26
+ `fx-tool` depends on [`registers`](https://pypi.org/project/registers/) for the
27
+ framework runtime modules (`registers.cli`, `registers.db`,
28
+ `registers.cron`).
29
+
30
+ ## Run
31
+
32
+ ```bash
33
+ fx --version
34
+ fx --help
35
+ fx --interactive
36
+ python -m fx --help
37
+ ```
38
+
39
+ ## Quick Example
40
+
41
+ ```bash
42
+ # Initialize a Functionals project
43
+ fx init cli MyService
44
+
45
+ # Validate project structure and plugin wiring
46
+ fx status MyService
47
+ fx health MyService
48
+
49
+ # Operate cron workflows
50
+ fx cron workspace MyService
51
+ fx cron jobs MyService
52
+ fx cron start MyService
53
+ ```
54
+
55
+ ## Documentation
56
+
57
+ - Usage guide: [`src/fx/USAGE.md`](C:/Users/charl/Documents/Python/framework/fx/src/fx/USAGE.md)
58
+
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fx-tool"
7
+ version = "1.0.0"
8
+ description = "Functionals FX project and DevOps operations CLI."
9
+ readme = { file = "README.md", content-type = "text/markdown" }
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+
13
+ authors = [
14
+ { name = "Charles DeFreese" }
15
+ ]
16
+
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Intended Audience :: Developers",
25
+ "Topic :: Software Development :: Libraries",
26
+ ]
27
+
28
+ dependencies = [
29
+ "registers>=6.0.0",
30
+ "tqdm>=4.66,<5",
31
+ ]
32
+
33
+ [project.scripts]
34
+ fx = "fx.commands:main"
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=7.4,<8",
39
+ "pytest-cov>=4.1,<5",
40
+ "pytest-asyncio>=0.23,<1",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/nexustech101/fx"
45
+ Repository = "https://github.com/nexustech101/fx"
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ addopts = "-v --tb=short"
50
+ asyncio_mode = "auto"
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+ include = ["fx*"]
55
+ namespaces = true
56
+
57
+ [tool.setuptools]
58
+ package-dir = {"" = "src"}
59
+
60
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ """
2
+ FX: project structuring and management tooling built on the
3
+ registers CLI + DB framework.
4
+ """
5
+
6
+ from fx.commands import FX_VERSION, get_registry, main, run
7
+
8
+ __version__ = FX_VERSION
9
+
10
+ __all__ = ["run", "main", "get_registry", "__version__"]
@@ -0,0 +1,4 @@
1
+ from fx.commands import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,177 @@
1
+ """
2
+ Public FX command surface.
3
+
4
+ This module owns the FX command registry and runtime entrypoints. Command
5
+ implementations are split into plugin modules under ``fx.plugins``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from collections.abc import Sequence
11
+ from importlib.metadata import PackageNotFoundError, version as resolve_distribution_version
12
+ from threading import Lock
13
+ from typing import Any
14
+
15
+ from registers.cli.plugins import load_plugins
16
+ from registers.cli.registry import CommandRegistry
17
+
18
+ try:
19
+ from registers.cli.registry import MISSING # type: ignore[attr-defined]
20
+ except ImportError:
21
+ # Older/incompatible runtime builds may not export MISSING.
22
+ MISSING = object()
23
+
24
+ _registry = CommandRegistry()
25
+ _FX_DISTRIBUTION_NAME = "fx-tool"
26
+ _PLUGINS_PACKAGE = "fx.plugins"
27
+ _REQUIRED_COMMANDS = frozenset(
28
+ {
29
+ "init",
30
+ "status",
31
+ "module",
32
+ "plugin",
33
+ "version",
34
+ "cron",
35
+ "run",
36
+ "install",
37
+ "update",
38
+ "pull",
39
+ "health",
40
+ "history",
41
+ }
42
+ )
43
+ _plugins_lock = Lock()
44
+ _plugins_loaded = False
45
+ _plugin_load_error: Exception | None = None
46
+
47
+
48
+ def _resolve_fx_version() -> str:
49
+ try:
50
+ return resolve_distribution_version(_FX_DISTRIBUTION_NAME)
51
+ except PackageNotFoundError:
52
+ return "dev"
53
+
54
+
55
+ FX_VERSION = _resolve_fx_version()
56
+
57
+
58
+ def argument(
59
+ name: str,
60
+ *,
61
+ type: Any = str,
62
+ help: str = "",
63
+ default: Any = MISSING,
64
+ ):
65
+ def decorator(fn):
66
+ if not hasattr(_registry, "stage_argument"):
67
+ raise RuntimeError(
68
+ "Incompatible 'registers' runtime: CommandRegistry.stage_argument is required."
69
+ )
70
+ _registry.stage_argument(fn, name, arg_type=type, help_text=help, default=default)
71
+ return fn
72
+
73
+ return decorator
74
+
75
+
76
+ def option(flag: str, *, help: str = ""):
77
+ def decorator(fn):
78
+ if not hasattr(_registry, "stage_option"):
79
+ raise RuntimeError(
80
+ "Incompatible 'registers' runtime: CommandRegistry.stage_option is required."
81
+ )
82
+ _registry.stage_option(fn, flag, help_text=help)
83
+ return fn
84
+
85
+ return decorator
86
+
87
+
88
+ def register(name: str | None = None, *, description: str = "", help: str = ""):
89
+ def decorator(fn):
90
+ if not hasattr(_registry, "finalize_command"):
91
+ raise RuntimeError(
92
+ "Incompatible 'registers' runtime: CommandRegistry.finalize_command is required."
93
+ )
94
+ _registry.finalize_command(fn, name=name, description=description, help_text=help)
95
+ return fn
96
+
97
+ return decorator
98
+
99
+
100
+ def ensure_plugins_loaded() -> None:
101
+ global _plugins_loaded, _plugin_load_error
102
+
103
+ if _plugins_loaded:
104
+ return
105
+ if _plugin_load_error is not None:
106
+ raise RuntimeError("FX command plugins failed to load.") from _plugin_load_error
107
+
108
+ with _plugins_lock:
109
+ if _plugins_loaded:
110
+ return
111
+ if _plugin_load_error is not None:
112
+ raise RuntimeError("FX command plugins failed to load.") from _plugin_load_error
113
+
114
+ try:
115
+ load_plugins(_PLUGINS_PACKAGE, _registry)
116
+ missing = sorted(name for name in _REQUIRED_COMMANDS if not _registry.has(name))
117
+ if missing:
118
+ raise RuntimeError(
119
+ "FX command plugins loaded incompletely. Missing commands: "
120
+ + ", ".join(missing)
121
+ )
122
+ _plugins_loaded = True
123
+ except Exception as exc:
124
+ _plugin_load_error = exc
125
+ raise
126
+
127
+
128
+ def run(
129
+ argv: Sequence[str] | None = None,
130
+ *,
131
+ print_result: bool = True,
132
+ shell_prompt: str = "fx > ",
133
+ shell_input_fn=None,
134
+ shell_banner: bool = True,
135
+ shell_banner_text: str | None = None,
136
+ shell_title: str = "Functionals FX",
137
+ shell_description: str = "Manage Functionals projects, modules, and plugin structures.",
138
+ shell_colors: bool | None = None,
139
+ shell_usage: bool = True,
140
+ ) -> Any:
141
+ ensure_plugins_loaded()
142
+ return _registry.run(
143
+ argv,
144
+ print_result=print_result,
145
+ shell_prompt=shell_prompt,
146
+ shell_input_fn=shell_input_fn,
147
+ shell_banner=shell_banner,
148
+ shell_banner_text=shell_banner_text,
149
+ shell_title=shell_title,
150
+ shell_description=shell_description,
151
+ shell_version=f"Version: {FX_VERSION}",
152
+ shell_colors=shell_colors,
153
+ shell_usage=shell_usage,
154
+ )
155
+
156
+
157
+ def get_registry() -> CommandRegistry:
158
+ ensure_plugins_loaded()
159
+ return _registry
160
+
161
+
162
+ def main(argv: Sequence[str] | None = None) -> int:
163
+ run(argv)
164
+ return 0
165
+
166
+
167
+ __all__ = [
168
+ "FX_VERSION",
169
+ "argument",
170
+ "option",
171
+ "register",
172
+ "ensure_plugins_loaded",
173
+ "run",
174
+ "get_registry",
175
+ "main",
176
+ ]
177
+
@@ -0,0 +1,72 @@
1
+ """
2
+ Plugin pull/sync helpers for ``fx``.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+ import shutil
10
+
11
+ from fx.structure import normalize_identifier
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class SyncReport:
16
+ created: tuple[str, ...] = ()
17
+ updated: tuple[str, ...] = ()
18
+ skipped: tuple[str, ...] = ()
19
+
20
+ @property
21
+ def synced_aliases(self) -> tuple[str, ...]:
22
+ return tuple(dict.fromkeys([*self.created, *self.updated]))
23
+
24
+
25
+ def sync_plugins_from_checkout(
26
+ *,
27
+ checkout_root: Path,
28
+ subdir: str,
29
+ target_plugins_dir: Path,
30
+ force: bool = False,
31
+ ) -> SyncReport:
32
+ source_dir = (checkout_root / subdir).resolve()
33
+ if not source_dir.exists() or not source_dir.is_dir():
34
+ raise FileNotFoundError(
35
+ f"Plugin source directory '{subdir}' not found in checkout."
36
+ )
37
+
38
+ created: list[str] = []
39
+ updated: list[str] = []
40
+ skipped: list[str] = []
41
+
42
+ target_plugins_dir.mkdir(parents=True, exist_ok=True)
43
+
44
+ for candidate in sorted(source_dir.iterdir()):
45
+ if not candidate.is_dir():
46
+ continue
47
+ if not (candidate / "__init__.py").exists():
48
+ continue
49
+
50
+ alias = normalize_identifier(candidate.name)
51
+ target = target_plugins_dir / alias
52
+ existed = target.exists()
53
+
54
+ if existed and not force:
55
+ skipped.append(alias)
56
+ continue
57
+
58
+ if existed and force:
59
+ shutil.rmtree(target)
60
+ updated.append(alias)
61
+ else:
62
+ created.append(alias)
63
+
64
+ shutil.copytree(candidate, target)
65
+
66
+ return SyncReport(
67
+ created=tuple(created),
68
+ updated=tuple(updated),
69
+ skipped=tuple(skipped),
70
+ )
71
+
72
+
@@ -0,0 +1,7 @@
1
+ """
2
+ FX command plugins.
3
+
4
+ Modules in this package are auto-imported by ``fx.commands`` to register
5
+ commands against the shared FX command registry.
6
+ """
7
+