Skip to content

Commit 3218a99

Browse files
committed
feat: Initialize apcore-cli-python project with core components, examples, tests, and development setup.
0 parents  commit 3218a99

62 files changed

Lines changed: 6600 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# all workflow and CODEOWNERS itself modification must be approved by repository owner or core maintainer
2+
.github/workflows/ @tercel
3+
.github/CODEOWNERS @tercel

.github/copilot-ignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Environment variables (sensitive data)
2+
.env
3+
.data
4+
5+
# Secrets
6+
secrets/
7+
*.pem
8+
*.key
9+
10+
.claude/
11+
CLAUDE.md
12+
.cursor/
13+

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
# container:
17+
# image: python:${{ matrix.python-version }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
# Pin CI to a single, consistent Python version to reduce version-related
22+
# test flakiness. Use 3.12 for CI stability; expand matrix later if desired.
23+
python-version: ["3.12"]
24+
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
35+
36+
- name: Install dependencies
37+
run: |
38+
uv sync --extra dev
39+
40+
- name: Lint with Ruff
41+
run: |
42+
uv run ruff check src/ tests/
43+
44+
- name: Run tests
45+
run: |
46+
uv run pytest

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.egg-info/
4+
dist/
5+
build/
6+
.eggs/
7+
.claude/
8+
.idea/
9+
.vscode/
10+
.DS_Store
11+
.ruff_cache/
12+
.pytest_cache/
13+
.coverage
14+
.venv/
15+
venv/
16+
env/
17+
.env
18+
.forge

.gitmessage

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# <type>(<scope>): <subject>
2+
#
3+
# <body>
4+
#
5+
# <footer>
6+
7+
# Type must be one of the following:
8+
# feat: A new feature
9+
# fix: A bug fix
10+
# docs: Documentation only changes
11+
# style: Changes that do not affect the meaning of the code
12+
# refactor: A code change that neither fixes a bug nor adds a feature
13+
# perf: A code change that improves performance
14+
# test: Adding missing tests or correcting existing tests
15+
# chore: Changes to the build process or auxiliary tools
16+
# ci: Changes to CI configuration files and scripts
17+
18+
# Scope is optional and can be anything specifying the place of the commit change.
19+
# Examples: api, core, storage, cli, stdio, etc.
20+
21+
# Subject should be:
22+
# - Use imperative, present tense: "change" not "changed" nor "changes"
23+
# - Don't capitalize first letter
24+
# - No dot (.) at the end
25+
# - Maximum 72 characters
26+
27+
# Body should include:
28+
# - Motivation for the change and contrast with previous behavior
29+
# - What changed and why
30+
# - Any breaking changes
31+
32+
# Footer should contain:
33+
# - Breaking changes (start with BREAKING CHANGE:)
34+
# - Issue references (Closes #123, Fixes #456)
35+
36+
# Examples:
37+
# feat(stdio): add stdio executor for process execution
38+
#
39+
# Implement a new stdio executor that allows executing system commands
40+
# and processes via stdin/stdout communication, similar to MCP stdio
41+
# transport mode. This enables flexible task execution through shell
42+
# commands and Python scripts.
43+
#
44+
# - Add StdioExecutor class with command execution support
45+
# - Add system resource monitoring (CPU, memory, disk)
46+
# - Support async process communication
47+
# - Add comprehensive error handling and logging
48+
#
49+
# Closes #123
50+
51+
# refactor(core): extract shared types to core.types module
52+
#
53+
# Move common type definitions from various modules to a centralized
54+
# core.types module to avoid circular dependencies and improve code
55+
# organization.
56+
#
57+
# - Add TaskPreHook and TaskPostHook type aliases
58+
# - Move TaskStatus enum to core.types
59+
# - Update imports across affected modules
60+

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
3+
# apdev hooks
4+
- repo: local
5+
hooks:
6+
- id: check-chars
7+
name: apdev check-chars
8+
entry: apdev check-chars
9+
language: system
10+
types_or: [text, python]
11+
12+
- id: check-imports
13+
name: apdev check-imports
14+
entry: apdev check-imports
15+
language: system
16+
pass_filenames: false
17+
always_run: true
18+
19+
# Ruff linter and formatter
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.8.4
22+
hooks:
23+
- id: ruff
24+
args: [--fix]
25+
files: ^(src|tests)/
26+
- id: ruff-format
27+
files: ^(src|tests)/

CHANGELOG.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Changelog
2+
3+
All notable changes to apcore-cli (Python SDK) will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- `--sandbox` flag for subprocess-isolated module execution (FE-05)
12+
- `ModuleExecutionError` exception class for sandbox failures
13+
- Windows approval timeout support via `threading.Timer` + `ctypes` (FE-03)
14+
- Approval timeout clamping to 1..3600 seconds range (FE-03)
15+
- Tag format validation (`^[a-z][a-z0-9_-]*$`) in `list --tag` (FE-04)
16+
- `cli.auto_approve` config key with `False` default (FE-07)
17+
- Extensions directory readability check with exit code 47 (FE-01)
18+
- Missing required property warning in schema parser (FE-02)
19+
- DEBUG log `"Loading extensions from {path}"` before registry discovery (FE-01)
20+
- `TYPE_CHECKING` imports for proper type annotations (`Registry`, `Executor`, `ModuleDescriptor`, `ConfigResolver`, `AuditLogger`)
21+
- `_get_module_id()` helper for `canonical_id`/`module_id` resolution
22+
- `APCORE_AUTH_API_KEY` and `APCORE_CLI_SANDBOX` to README environment variables table
23+
- `--sandbox` to README module execution options table
24+
- CHANGELOG.md
25+
26+
### Changed
27+
- AES-GCM wire format from `nonce + ciphertext + tag` to `nonce + tag + ciphertext` (spec-aligned, **breaking** for pre-existing encrypted configs)
28+
- AES-GCM implementation from high-level `AESGCM` API to low-level `Cipher(AES, GCM)` API for explicit tag control
29+
- ConfigEncryptor exception catching narrowed from bare `Exception` to `(InvalidTag, ValueError)`
30+
- Sandbox error type from `RuntimeError` to `ModuleExecutionError`
31+
- Sandbox catches `subprocess.TimeoutExpired` with formatted error message
32+
- Extensions directory missing now exits 47 immediately instead of deferring via null stubs
33+
- Removed `_NullRegistry` and `_NullExecutor` stub classes
34+
- AuthProvider `get_api_key()` uses direct `self._config.encryptor.retrieve()` instead of defensive `getattr`
35+
- Output formatter parameter names from `fmt` to `format` (3 functions)
36+
- Output formatter extension metadata reads from both `module_def.metadata` and `vars(module_def)`
37+
- `build_module_command` prefers `canonical_id` over `module_id`
38+
- `resolve_refs` called with explicit `max_depth=32`
39+
- `config.resolve()` called with `cli_flag="--extensions-dir"`
40+
- Error audit logging passes actual `merged` inputs instead of `{}`
41+
42+
### Fixed
43+
- `UnboundLocalError` when `collect_input()` raises before `merged` is assigned
44+
- Removed stale fix-reference comments (`HIGH-1 fix`, `MED-1 fix`, `LOW-1 fix`)
45+
46+
## [0.1.0] - 2026-03-14
47+
48+
### Added
49+
- Core Dispatcher (FE-01): `LazyModuleGroup`, `build_module_command`, `collect_input`, `validate_module_id`
50+
- Schema Parser (FE-02): `schema_to_click_options`, `_map_type`, `_extract_help`, `reconvert_enum_values`
51+
- Ref Resolver (FE-02): `resolve_refs`, `_resolve_node` with `$ref`, `allOf`, `anyOf`, `oneOf` support
52+
- Config Resolver (FE-07): `ConfigResolver` with 4-tier precedence (CLI > Env > File > Default)
53+
- Approval Gate (FE-03): `check_approval`, `_prompt_with_timeout` with TTY detection and Unix SIGALRM
54+
- Discovery (FE-04): `list` and `describe` commands with tag filtering and TTY-adaptive output
55+
- Output Formatter (FE-08): `format_module_list`, `format_module_detail`, `format_exec_result` with Rich rendering
56+
- Security Manager (FE-05): `AuthProvider`, `ConfigEncryptor` (keyring + AES-256-GCM), `AuditLogger` (JSON Lines), `Sandbox` (subprocess isolation)
57+
- Shell Integration (FE-06): bash/zsh/fish completion generators, roff man page generator
58+
- 8 example modules: `math.add`, `math.multiply`, `text.upper`, `text.reverse`, `text.wordcount`, `sysutil.info`, `sysutil.env`, `sysutil.disk`
59+
- 244 tests (unit, integration, end-to-end)
60+
- CI workflow with pytest and coverage
61+
- Pre-commit hooks configuration

0 commit comments

Comments
 (0)