apcore-cli 0.5.0__tar.gz → 0.7.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.
Files changed (138) hide show
  1. apcore_cli-0.7.0/.github/workflows/ci.yml +62 -0
  2. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/.gitignore +1 -0
  3. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/CHANGELOG.md +65 -0
  4. apcore_cli-0.7.0/CLAUDE.md +60 -0
  5. apcore_cli-0.7.0/LICENSE +193 -0
  6. apcore_cli-0.7.0/Makefile +30 -0
  7. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/PKG-INFO +187 -61
  8. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/README.md +180 -59
  9. apcore_cli-0.7.0/examples/README.md +137 -0
  10. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/run_examples.sh +33 -33
  11. apcore_cli-0.7.0/htmlcov/.gitignore +2 -0
  12. apcore_cli-0.7.0/htmlcov/class_index.html +551 -0
  13. apcore_cli-0.7.0/htmlcov/coverage_html_cb_bcae5fc4.js +735 -0
  14. apcore_cli-0.7.0/htmlcov/favicon_32_cb_58284776.png +0 -0
  15. apcore_cli-0.7.0/htmlcov/function_index.html +1931 -0
  16. apcore_cli-0.7.0/htmlcov/index.html +306 -0
  17. apcore_cli-0.7.0/htmlcov/keybd_closed_cb_ce680311.png +0 -0
  18. apcore_cli-0.7.0/htmlcov/status.json +1 -0
  19. apcore_cli-0.7.0/htmlcov/style_cb_a5a05ca4.css +389 -0
  20. apcore_cli-0.7.0/htmlcov/z_2a36de3398a45e2f___init___py.html +105 -0
  21. apcore_cli-0.7.0/htmlcov/z_2a36de3398a45e2f_audit_py.html +169 -0
  22. apcore_cli-0.7.0/htmlcov/z_2a36de3398a45e2f_auth_py.html +171 -0
  23. apcore_cli-0.7.0/htmlcov/z_2a36de3398a45e2f_config_encryptor_py.html +249 -0
  24. apcore_cli-0.7.0/htmlcov/z_2a36de3398a45e2f_sandbox_py.html +241 -0
  25. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca___init___py.html +184 -0
  26. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca__sandbox_runner_py.html +122 -0
  27. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_approval_py.html +352 -0
  28. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_builtin_group_py.html +475 -0
  29. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_cli_py.html +1173 -0
  30. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_config_py.html +238 -0
  31. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_discovery_py.html +545 -0
  32. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_display_helpers_py.html +127 -0
  33. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_exposure_py.html +227 -0
  34. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_factory_py.html +833 -0
  35. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_init_cmd_py.html +287 -0
  36. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_output_py.html +467 -0
  37. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_ref_resolver_py.html +227 -0
  38. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_schema_parser_py.html +295 -0
  39. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_shell_py.html +739 -0
  40. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_strategy_py.html +307 -0
  41. apcore_cli-0.7.0/htmlcov/z_4d276f71fa2bf6ca_system_cmd_py.html +566 -0
  42. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/approval-gate.md +3 -1
  43. apcore_cli-0.7.0/planning/exposure-filtering.md +236 -0
  44. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/state.json +18 -1
  45. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/pyproject.toml +12 -2
  46. apcore_cli-0.7.0/src/apcore_cli/__init__.py +87 -0
  47. apcore_cli-0.7.0/src/apcore_cli/__main__.py +71 -0
  48. apcore_cli-0.7.0/src/apcore_cli/approval.py +267 -0
  49. apcore_cli-0.7.0/src/apcore_cli/builtin_group.py +378 -0
  50. apcore_cli-0.7.0/src/apcore_cli/cli.py +1023 -0
  51. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/config.py +36 -8
  52. apcore_cli-0.7.0/src/apcore_cli/discovery.py +448 -0
  53. apcore_cli-0.7.0/src/apcore_cli/exposure.py +145 -0
  54. apcore_cli-0.7.0/src/apcore_cli/factory.py +736 -0
  55. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/init_cmd.py +50 -19
  56. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/output.py +127 -23
  57. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/ref_resolver.py +42 -25
  58. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/schema_parser.py +44 -0
  59. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/security/audit.py +5 -0
  60. apcore_cli-0.7.0/src/apcore_cli/security/auth.py +74 -0
  61. apcore_cli-0.7.0/src/apcore_cli/security/config_encryptor.py +152 -0
  62. apcore_cli-0.7.0/src/apcore_cli/security/sandbox.py +168 -0
  63. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/shell.py +22 -4
  64. apcore_cli-0.7.0/src/apcore_cli/strategy.py +210 -0
  65. apcore_cli-0.7.0/src/apcore_cli/system_cmd.py +469 -0
  66. apcore_cli-0.7.0/src/apcore_cli/validate.py +100 -0
  67. apcore_cli-0.7.0/tests/conformance/test_apcli_visibility.py +300 -0
  68. apcore_cli-0.7.0/tests/test_apcli_integration.py +551 -0
  69. apcore_cli-0.7.0/tests/test_approval.py +323 -0
  70. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_bugfixes.py +6 -6
  71. apcore_cli-0.7.0/tests/test_builtin_group.py +294 -0
  72. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_cli.py +359 -23
  73. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_config.py +74 -10
  74. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_discovery.py +145 -1
  75. apcore_cli-0.7.0/tests/test_discovery_fe13.py +279 -0
  76. apcore_cli-0.7.0/tests/test_display_helpers.py +21 -0
  77. apcore_cli-0.7.0/tests/test_exposure.py +180 -0
  78. apcore_cli-0.7.0/tests/test_factory_fe13.py +222 -0
  79. apcore_cli-0.7.0/tests/test_init_cmd.py +159 -0
  80. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_integration.py +42 -3
  81. apcore_cli-0.7.0/tests/test_list_command_filters.py +157 -0
  82. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_output.py +51 -0
  83. apcore_cli-0.7.0/tests/test_output_format_exec.py +99 -0
  84. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_ref_resolver.py +102 -6
  85. apcore_cli-0.7.0/tests/test_sandbox_runner.py +97 -0
  86. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_schema_parser.py +97 -5
  87. apcore_cli-0.7.0/tests/test_security/__init__.py +0 -0
  88. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_security/test_audit.py +35 -0
  89. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_security/test_auth.py +13 -0
  90. apcore_cli-0.7.0/tests/test_security/test_config_encryptor.py +170 -0
  91. apcore_cli-0.7.0/tests/test_security/test_sandbox.py +245 -0
  92. apcore_cli-0.7.0/tests/test_strategy.py +252 -0
  93. apcore_cli-0.7.0/tests/test_system_cmd.py +462 -0
  94. apcore_cli-0.7.0/tests/test_toolkit_integration.py +337 -0
  95. apcore_cli-0.5.0/.github/workflows/ci.yml +0 -46
  96. apcore_cli-0.5.0/CLAUDE.md +0 -30
  97. apcore_cli-0.5.0/src/apcore_cli/__init__.py +0 -27
  98. apcore_cli-0.5.0/src/apcore_cli/__main__.py +0 -285
  99. apcore_cli-0.5.0/src/apcore_cli/approval.py +0 -169
  100. apcore_cli-0.5.0/src/apcore_cli/cli.py +0 -635
  101. apcore_cli-0.5.0/src/apcore_cli/discovery.py +0 -102
  102. apcore_cli-0.5.0/src/apcore_cli/security/auth.py +0 -37
  103. apcore_cli-0.5.0/src/apcore_cli/security/config_encryptor.py +0 -94
  104. apcore_cli-0.5.0/src/apcore_cli/security/sandbox.py +0 -60
  105. apcore_cli-0.5.0/tests/test_approval.py +0 -158
  106. apcore_cli-0.5.0/tests/test_init_cmd.py +0 -82
  107. apcore_cli-0.5.0/tests/test_security/test_config_encryptor.py +0 -56
  108. apcore_cli-0.5.0/tests/test_security/test_sandbox.py +0 -50
  109. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/.github/CODEOWNERS +0 -0
  110. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/.github/copilot-ignore +0 -0
  111. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/.gitmessage +0 -0
  112. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/.pre-commit-config.yaml +0 -0
  113. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/commands/ops.py +0 -0
  114. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/math/add.py +0 -0
  115. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/math/multiply.py +0 -0
  116. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/sysutil/disk.py +0 -0
  117. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/sysutil/env.py +0 -0
  118. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/sysutil/info.py +0 -0
  119. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/text/reverse.py +0 -0
  120. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/text/upper.py +0 -0
  121. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/examples/extensions/text/wordcount.py +0 -0
  122. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/config-resolver.md +0 -0
  123. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/core-dispatcher.md +0 -0
  124. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/discovery.md +0 -0
  125. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/grouped-commands.md +0 -0
  126. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/output-formatter.md +0 -0
  127. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/overview.md +0 -0
  128. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/schema-parser.md +0 -0
  129. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/security-manager.md +0 -0
  130. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/planning/shell-integration.md +0 -0
  131. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/_sandbox_runner.py +0 -0
  132. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/display_helpers.py +0 -0
  133. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/src/apcore_cli/security/__init__.py +0 -0
  134. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/__init__.py +0 -0
  135. {apcore_cli-0.5.0/tests/test_security → apcore_cli-0.7.0/tests/conformance}/__init__.py +0 -0
  136. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/conftest.py +0 -0
  137. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_e2e.py +0 -0
  138. {apcore_cli-0.5.0 → apcore_cli-0.7.0}/tests/test_shell.py +0 -0
@@ -0,0 +1,62 @@
1
+ name: CI
2
+
3
+ permissions:
4
+ contents: read
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ test:
14
+ name: Test on Python ${{ matrix.python-version }}
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ # Pin CI to a single, consistent Python version to reduce version-related
20
+ # test flakiness. Use 3.12 for CI stability; expand matrix later if desired.
21
+ python-version: ["3.12"]
22
+
23
+ steps:
24
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25
+
26
+ - name: Checkout apcore-cli spec repo (conformance fixtures)
27
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28
+ with:
29
+ repository: aiperceivable/apcore-cli
30
+ path: .apcore-cli-spec
31
+
32
+ - name: Set up Python
33
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+
37
+ - name: Install uv
38
+ uses: astral-sh/setup-uv@v5
39
+
40
+ # `--extra dev` pulls pytest, ruff, pre-commit, mypy, apdev; `--extra toolkit`
41
+ # brings in apcore-toolkit >= 0.5.0. apcore >= 0.19.0 comes from the main
42
+ # `dependencies` section and is installed unconditionally. Toolkit must be
43
+ # importable for tests/test_toolkit_integration.py (which uses
44
+ # `patch("apcore_toolkit.BindingLoader", ...)` — patch resolves the target
45
+ # at import time and fails if the module is absent).
46
+ - name: Install dependencies (apcore, apcore-toolkit, dev extras)
47
+ run: |
48
+ uv sync --extra dev --extra toolkit
49
+
50
+ # Single pre-commit invocation covers ruff lint + ruff-format + apdev
51
+ # (check-chars, check-imports). Matches the TypeScript CI pattern at
52
+ # ../apcore-cli-typescript/.github/workflows/ci.yml which likewise runs
53
+ # `pre-commit run --all-files` as the lint gate.
54
+ - name: Run pre-commit (ruff + apdev hooks)
55
+ run: |
56
+ uv run pre-commit run --all-files
57
+
58
+ - name: Run tests
59
+ env:
60
+ APCORE_CLI_SPEC_REPO: ${{ github.workspace }}/.apcore-cli-spec
61
+ run: |
62
+ uv run pytest
@@ -16,3 +16,4 @@ venv/
16
16
  env/
17
17
  .env
18
18
  .forge
19
+ .mypy_cache/
@@ -6,6 +6,71 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
 
9
+ ## [0.7.0] - 2026-04-23
10
+
11
+ ### Changed
12
+
13
+ - **Dependency bump**: requires `apcore >= 0.18.0` (was `>= 0.17.1`). Aligns with upstream `apcore 0.18.0` and `apcore-toolkit 0.4.2` breaking changes.
14
+ - **`MAX_MODULE_ID_LENGTH` 128 → 192**: `validate_module_id()` and all references updated to the new 192-character limit introduced in `apcore 0.18.0` (`apcore.registry.registry.MAX_MODULE_ID_LENGTH`).
15
+ - **`describe-pipeline` renders `StrategyInfo`**: `executor.describe_pipeline(strategy)` now returns a `StrategyInfo` dataclass (`name`, `step_count`, `step_names`, `description`). `strategy.py` updated to use `StrategyInfo` fields; header line is `Pipeline: {info.name} ({info.step_count} steps)`. Falls back gracefully to the legacy `_resolve_strategy_name` path when `describe_pipeline` is unavailable.
16
+ - **CI — spec-repo checkout**: `.github/workflows/ci.yml` now checks out `aiperceivable/apcore-cli` into `.apcore-cli-spec/` and exposes it to `pytest` via `APCORE_CLI_SPEC_REPO`. Mirrors the pattern established in `apcore-python` / `apcore-cli-typescript`.
17
+
18
+ ### Added
19
+
20
+ - **`create_cli(app=...)` parameter**: `create_cli()` accepts an optional `app: APCore` unified client (introduced in `apcore 0.18.0`). `app` is mutually exclusive with `registry`/`executor` (raises `ValueError`). When `app` is provided, `registry` and `executor` are extracted from `app.registry` and `app.executor`. Filesystem discovery is skipped if `app.registry` already contains registered modules; otherwise normal discovery proceeds into `app.registry`.
21
+ - **Cross-language conformance test harness** (`tests/conformance/`) consuming the shared apcli-visibility fixtures from the `aiperceivable/apcore-cli` spec repo (`conformance/fixtures/apcli-visibility/`). Behavioral assertions (apcli group visibility, registered subcommand set for `include`/`exclude` modes, always-registered `exec`) run today across all five canonical scenarios (`standalone-default`, `embedded-default`, `cli-override`, `env-override`, `yaml-include`). Byte-matching against `expected_help.txt` is marked `xfail` until Click's `HelpFormatter` is replaced with a canonical clap v4 / GNU-style emitter, tracked for parity with `apcore-cli-typescript/src/canonical-help.ts`.
22
+ - **`APCORE_CLI_SPEC_REPO` env var** — overrides the spec-repo lookup path for conformance fixtures. Defaults to a sibling checkout (`../apcore-cli/`). Tests are skipped (not failed) when the spec repo is absent.
23
+ - **FE-12: Module Exposure Filtering** — Declarative control over which discovered modules are exposed as CLI commands.
24
+ - `ExposureFilter` class in `exposure.py` with `is_exposed(module_id)` and `filter_modules(ids)` methods.
25
+ - Three modes: `all` (default), `include` (whitelist), `exclude` (blacklist) with glob-pattern matching.
26
+ - `ExposureFilter.from_config(dict)` classmethod for loading from `apcore.yaml` `expose` section.
27
+ - `create_cli(expose=...)` parameter accepting `dict` or `ExposureFilter` instance.
28
+ - `list --exposure {exposed,hidden,all}` filter flag in discovery commands.
29
+ - `GroupedModuleGroup._build_group_map()` integration: calls `ExposureFilter.is_exposed()` to filter command registration.
30
+ - `ConfigResolver` gains `expose.*` config keys.
31
+ - 4-tier config precedence: `CliConfig.expose` > `--expose-mode` CLI flag > env var > `apcore.yaml`.
32
+ - Hidden modules remain invocable via `exec <module_id>`.
33
+ - New file: `exposure.py`.
34
+
35
+ ---
36
+
37
+ ## [0.6.0] - 2026-04-06
38
+
39
+ ### Changed
40
+
41
+ - **Dependency bump**: requires `apcore >= 0.17.1` (was `>= 0.15.1`). Adds Execution Pipeline Strategy, Config Bus enhancements, Pipeline v2 declarative step metadata, `minimal` strategy preset.
42
+ - **Schema parser**: Required schema properties now correctly enforced at CLI option level (was silently optional).
43
+ - **Approval gate**: Fixed inverted logic in annotation type guard; `check_approval()` now accepts `timeout` parameter.
44
+
45
+ ### Added
46
+
47
+ - **FE-11: Usability Enhancements** — 11 new capabilities:
48
+ - `--dry-run` preflight mode via `Executor.validate()`. Standalone `validate` command.
49
+ - System management commands: `health`, `usage`, `enable`, `disable`, `reload`, `config get`/`config set`. Graceful no-op when system modules unavailable.
50
+ - Enhanced error output: structured JSON with `ai_guidance`, `suggestion`, `retryable`, `user_fixable`, `details`. TTY hides machine-only fields.
51
+ - `--trace` pipeline visualization via `call_with_trace()`.
52
+ - `CliApprovalHandler` class implementing apcore `ApprovalHandler` protocol, wired to `Executor.set_approval_handler()`. `--approval-timeout`, `--approval-token` flags.
53
+ - `--stream` JSONL output via `Executor.stream()`.
54
+ - Enhanced `list` command: `--search`, `--status`, `--annotation`, `--sort`, `--reverse`, `--deprecated`, `--deps`.
55
+ - `--strategy` selection: `standard`, `internal`, `testing`, `performance`, `minimal`. `describe-pipeline` command.
56
+ - Output format extensions: `--format csv|yaml|jsonl`, `--fields` dot-path field selection.
57
+ - Multi-level grouping: `cli.group_depth` config key.
58
+ - Custom command extension: `create_cli(extra_commands=[...])` with collision detection.
59
+ - New error code: `CONFIG_ENV_MAP_CONFLICT`.
60
+ - New config keys: `cli.approval_timeout` (60), `cli.strategy` ("standard"), `cli.group_depth` (1).
61
+ - New environment variables: `APCORE_CLI_APPROVAL_TIMEOUT`, `APCORE_CLI_STRATEGY`, `APCORE_CLI_GROUP_DEPTH`.
62
+ - New files: `system_cmd.py`, `strategy.py`.
63
+
64
+ ---
65
+
66
+ ## [0.5.1] - 2026-04-03
67
+
68
+ ### Added
69
+ - **Pre-populated registry support** — `create_cli()` accepts optional `registry` and `executor` parameters. When a pre-populated `Registry` is provided, filesystem discovery is skipped entirely. This enables frameworks that register modules at runtime (e.g. apflow's bridge) to generate CLI commands from their existing registry without requiring an extensions directory.
70
+ - Passing `registry` alone auto-builds an `Executor`; passing `executor` without `registry` raises `ValueError`.
71
+
72
+ ---
73
+
9
74
  ## [0.4.1] - 2026-03-30
10
75
 
11
76
  ### Fixed
@@ -0,0 +1,60 @@
1
+ # CLAUDE.md — apcore-cli-python
2
+
3
+ ## Build & Test
4
+
5
+ - `pytest` — run all tests. **Must pass before considering any task complete.**
6
+ - `pytest --cov` — run with coverage report.
7
+ - `ruff check .` — lint check.
8
+ - `ruff format .` — format all code. **Run after every code change.**
9
+
10
+ ## Code Style
11
+
12
+ - Python 3.11+ with `from __future__ import annotations`.
13
+ - All code must pass `ruff check` and `ruff format --check`.
14
+ - Type annotations on all public function signatures.
15
+ - Use `click.echo()` for user-facing output, `logger.*` for debug/diagnostic output.
16
+ - Prefer `sys.exit(code)` with exit code constants over raising exceptions for CLI errors.
17
+
18
+ ## Project Conventions
19
+
20
+ - Spec repo (single source of truth): `../apcore-cli/docs/`
21
+ - Package structure: `src/apcore_cli/` with `__init__.py` exporting `__version__` only.
22
+ - Entry point: `apcore_cli.__main__:main`.
23
+ - Security modules live in `src/apcore_cli/security/` sub-package.
24
+ - ConfigResolver.DEFAULTS values are Python-typed (str, int, bool).
25
+ - Tests organized by module: `tests/test_<module>.py`, security tests in `tests/test_security/`.
26
+
27
+ ## Environment
28
+
29
+ - Python >= 3.11
30
+ - Key dependencies: click >= 8.1, rich >= 13.0, jsonschema >= 4.20, pyyaml >= 6.0, keyring >= 24, cryptography >= 41
31
+ - Runtime: apcore >= 0.19.0 (v0.7.0 bump, was 0.17.1)
32
+ - Optional: apcore-toolkit >= 0.4 (install via `pip install apcore-cli[toolkit]`)
33
+ - Dev: pytest, pytest-asyncio, pytest-cov, mypy, ruff
34
+
35
+ ## v0.7.0 Conventions
36
+
37
+ - Public surface (`__init__.py`): `__version__`, `create_cli`, `ExposureFilter`,
38
+ `ApcliGroup`, `ApcliMode`, `RESERVED_GROUP_NAMES`, `CliApprovalHandler`,
39
+ `resolve_refs`, `schema_to_click_options`, `format_exec_result`,
40
+ `ConfigResolver`, `AuditLogger`, `AuthProvider`, `ConfigEncryptor`, `Sandbox`,
41
+ plus error classes (AuthenticationError, ConfigDecryptionError,
42
+ ModuleExecutionError, ApprovalTimeoutError, ApprovalDeniedError).
43
+ Non-listed symbols (e.g. `GroupedModuleGroup`) must be imported via full
44
+ submodule path (e.g., `from apcore_cli.cli import GroupedModuleGroup`).
45
+ - ExposureFilter + `expose=` kwarg on create_cli (FE-12).
46
+ - `extra_commands=[...]` kwarg on create_cli as the FE-11 extension point (with
47
+ collision detection against RESERVED_GROUP_NAMES — `BUILTIN_COMMANDS` retired v0.7.0).
48
+ - Default click Group class is `GroupedModuleGroup` (multi-level grouping since v0.3.0).
49
+ - All apcore-cli commands live under the `apcli` group (FE-13). Deprecation shims
50
+ remain at root level for back-compat until v0.8.
51
+ - `system_cmd` module registers runtime system commands (health/usage/enable/disable/
52
+ reload/config) — FE-11.
53
+ - `strategy` module registers describe-pipeline + --strategy flag — FE-11.
54
+ - `validate` module + --dry-run flag — FE-11.
55
+ - `CliApprovalHandler` async protocol (request_approval/check_approval) — FE-11 §3.5.1.
56
+ - Config Bus namespace registration at package import time (apcore >= 0.15.0).
57
+ - New env vars (v0.6.0): APCORE_CLI_APPROVAL_TIMEOUT, APCORE_CLI_STRATEGY, APCORE_CLI_GROUP_DEPTH.
58
+ - New config keys (v0.6.0): cli.approval_timeout, cli.strategy, cli.group_depth.
59
+ - New exit codes from apcore 0.17.1: CONFIG_BIND_ERROR (65), CONFIG_MOUNT_ERROR (66),
60
+ ERROR_FORMATTER_DUPLICATE (70), CONFIG_NAMESPACE_* (78).
@@ -0,0 +1,193 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combined work (in which such
78
+ Contribution(s) has been submitted). If You institute patent litigation
79
+ against any entity (including a cross-claim or counterclaim in a
80
+ lawsuit) alleging that the Work or any other Work constitutes direct
81
+ or contributory patent infringement, then any patent licenses
82
+ granted to You under this License for that Work shall terminate
83
+ as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative
91
+ Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or in addition to the
114
+ NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the
116
+ License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution(s) and such Derivative Works.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, without limitation, any conditions of TITLE,
141
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
142
+ PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or reproducing the Work and assume any
144
+ risks associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate and grossly
149
+ negligent acts) or agreed to in writing, shall any Contributor be
150
+ liable to You for damages, including any direct, indirect, special,
151
+ incidental, or exemplary damages of any character arising as a
152
+ result of this License or out of the use or inability to use the
153
+ Work (including but not limited to damages for loss of goodwill,
154
+ work stoppage, computer failure or malfunction, or all other
155
+ commercial damages or losses), even if such Contributor has been
156
+ advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability. While redistributing
159
+ the Work or Derivative Works thereof, You may offer, and charge a
160
+ fee for, acceptance of support, warranty, indemnity, or other
161
+ liability obligations and/or rights consistent with this License.
162
+ However, in accepting such obligations, You may offer such
163
+ obligations only on Your own behalf and on Your sole responsibility,
164
+ not on behalf of any other Contributor, and only if You agree to
165
+ indemnify, defend, and hold each Contributor harmless for any
166
+ liability incurred by, or claims asserted against, such Contributor
167
+ by reason of your accepting any warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ APPENDIX: How to apply the Apache License to your work.
172
+
173
+ To apply the Apache License to your work, attach the following
174
+ boilerplate notice, with the fields enclosed by brackets "[]"
175
+ replaced with your own identifying information. (Don't include
176
+ the brackets!) The text should be enclosed in the appropriate
177
+ comment syntax for the format in use. Please also attach a
178
+ separate file called "NOTICE" with the information required
179
+ by Section 4(d).
180
+
181
+ Copyright 2024 APCore Contributors
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
@@ -0,0 +1,30 @@
1
+ .PHONY: test test-cov lint fmt fmt-check check clean
2
+
3
+ # Run all tests (no coverage; same as `pytest`).
4
+ test:
5
+ pytest --tb=short -q
6
+
7
+ # Run tests with coverage report (D5-002 cross-SDK coverage wiring).
8
+ # Mirrors apcore-cli-rust `make coverage` and apcore-cli-typescript
9
+ # `pnpm run test:cov`. Configuration lives in pyproject.toml under
10
+ # [tool.coverage.*] (source, fail_under, show_missing).
11
+ test-cov:
12
+ pytest --cov=apcore_cli --cov-report=term-missing --cov-report=html
13
+
14
+ # Lint with ruff.
15
+ lint:
16
+ ruff check src tests
17
+
18
+ # Format code with ruff. Run after every code change (CLAUDE.md).
19
+ fmt:
20
+ ruff format src tests
21
+
22
+ # Check formatting without writing.
23
+ fmt-check:
24
+ ruff format --check src tests
25
+
26
+ # Pre-commit / pre-merge gate.
27
+ check: fmt-check lint test
28
+
29
+ clean:
30
+ rm -rf .coverage htmlcov build dist *.egg-info .pytest_cache .ruff_cache