stata-agent 0.1.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 (71) hide show
  1. stata_agent-0.1.0/.github/workflows/build-test.yml +101 -0
  2. stata_agent-0.1.0/.github/workflows/publish.yml +62 -0
  3. stata_agent-0.1.0/.github/workflows/release.yml +67 -0
  4. stata_agent-0.1.0/.gitignore +29 -0
  5. stata_agent-0.1.0/CHANGELOG.md +15 -0
  6. stata_agent-0.1.0/CONTRIBUTING.md +149 -0
  7. stata_agent-0.1.0/FEATURES_AND_FLOWS.md +309 -0
  8. stata_agent-0.1.0/LICENSE +661 -0
  9. stata_agent-0.1.0/PKG-INFO +67 -0
  10. stata_agent-0.1.0/README.md +24 -0
  11. stata_agent-0.1.0/assumptions.md +45 -0
  12. stata_agent-0.1.0/benchmarks/benchmark_arrow_export.py +606 -0
  13. stata_agent-0.1.0/benchmarks/create_large_dataset.py +143 -0
  14. stata_agent-0.1.0/benchmarks/profile_arrow.py +145 -0
  15. stata_agent-0.1.0/benchmarks/profile_graph_export_formats.py +114 -0
  16. stata_agent-0.1.0/benchmarks/profile_graph_ops.py +307 -0
  17. stata_agent-0.1.0/benchmarks/test_correctness.py +328 -0
  18. stata_agent-0.1.0/docs/graph-detection-optimization.md +137 -0
  19. stata_agent-0.1.0/docs/performance-optimizations.md +802 -0
  20. stata_agent-0.1.0/install.ps1 +308 -0
  21. stata_agent-0.1.0/install.sh +385 -0
  22. stata_agent-0.1.0/pyproject.toml +109 -0
  23. stata_agent-0.1.0/scripts/install/verify.py +348 -0
  24. stata_agent-0.1.0/src/stata_agent/__init__.py +1 -0
  25. stata_agent-0.1.0/src/stata_agent/__main__.py +6 -0
  26. stata_agent-0.1.0/src/stata_agent/cli.py +1177 -0
  27. stata_agent-0.1.0/src/stata_agent/daemon.py +357 -0
  28. stata_agent-0.1.0/src/stata_agent/discovery.py +209 -0
  29. stata_agent-0.1.0/src/stata_agent/error_extractor.py +329 -0
  30. stata_agent-0.1.0/src/stata_agent/graph_handler.py +59 -0
  31. stata_agent-0.1.0/src/stata_agent/linter.py +152 -0
  32. stata_agent-0.1.0/src/stata_agent/log_manager.py +253 -0
  33. stata_agent-0.1.0/src/stata_agent/mock_backend.py +572 -0
  34. stata_agent-0.1.0/src/stata_agent/models.py +72 -0
  35. stata_agent-0.1.0/src/stata_agent/plugin/.agents/plugins/marketplace.json +14 -0
  36. stata_agent-0.1.0/src/stata_agent/plugin/.claude-plugin/marketplace.json +14 -0
  37. stata_agent-0.1.0/src/stata_agent/plugin/.claude-plugin/plugin.json +15 -0
  38. stata_agent-0.1.0/src/stata_agent/plugin/.codex-plugin/plugin.json +15 -0
  39. stata_agent-0.1.0/src/stata_agent/plugin/AGENTS.md +43 -0
  40. stata_agent-0.1.0/src/stata_agent/plugin/README.md +17 -0
  41. stata_agent-0.1.0/src/stata_agent/plugin/agents/hooks.json +16 -0
  42. stata_agent-0.1.0/src/stata_agent/plugin/agents/stata-analyst.md +30 -0
  43. stata_agent-0.1.0/src/stata_agent/plugin/agents/stata-debugger.md +26 -0
  44. stata_agent-0.1.0/src/stata_agent/plugin/gemini-extension.json +7 -0
  45. stata_agent-0.1.0/src/stata_agent/plugin/hooks/hooks.json +16 -0
  46. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-graph/SKILL.md +20 -0
  47. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-help/SKILL.md +18 -0
  48. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-inspect/SKILL.md +16 -0
  49. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-lint/SKILL.md +19 -0
  50. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-log/SKILL.md +21 -0
  51. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-results/SKILL.md +14 -0
  52. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-run/SKILL.md +23 -0
  53. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-setup/SKILL.md +26 -0
  54. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-test/SKILL.md +33 -0
  55. stata_agent-0.1.0/src/stata_agent/plugin/skills/stata-toolkit/SKILL.md +25 -0
  56. stata_agent-0.1.0/src/stata_agent/rpc_client.py +111 -0
  57. stata_agent-0.1.0/src/stata_agent/session.py +182 -0
  58. stata_agent-0.1.0/src/stata_agent/skills_installer.py +559 -0
  59. stata_agent-0.1.0/src/stata_agent/stata_client.py +556 -0
  60. stata_agent-0.1.0/src/stata_agent/statest/__init__.py +4 -0
  61. stata_agent-0.1.0/src/stata_agent/statest/junit.py +53 -0
  62. stata_agent-0.1.0/src/stata_agent/statest/models.py +36 -0
  63. stata_agent-0.1.0/src/stata_agent/statest/runner.py +343 -0
  64. stata_agent-0.1.0/src/stata_agent/statest/statest.mata +159 -0
  65. stata_agent-0.1.0/src/stata_agent/worker.py +228 -0
  66. stata_agent-0.1.0/testdata/big_trace_with_buried_error.do +83 -0
  67. stata_agent-0.1.0/worker/dashboard/index.html +643 -0
  68. stata_agent-0.1.0/worker/package.json +13 -0
  69. stata_agent-0.1.0/worker/src/index.js +463 -0
  70. stata_agent-0.1.0/worker/tests/telemetry.test.mjs +604 -0
  71. stata_agent-0.1.0/worker/wrangler.toml +12 -0
@@ -0,0 +1,101 @@
1
+ name: Build & Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ - '**'
8
+ pull_request:
9
+ branches:
10
+ - main
11
+ workflow_dispatch:
12
+
13
+ concurrency:
14
+ group: ${{ github.workflow }}-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ test:
19
+ name: Test (py${{ matrix.python-version }}, ${{ matrix.os }})
20
+ runs-on: ${{ matrix.os }}
21
+ strategy:
22
+ matrix:
23
+ os: [ubuntu-latest, macos-latest, windows-latest]
24
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
25
+ fail-fast: false
26
+
27
+ steps:
28
+ - name: Checkout code
29
+ uses: actions/checkout@v4
30
+ with:
31
+ fetch-depth: 0 # Fetch all history including tags
32
+
33
+ - name: Setup uv
34
+ uses: astral-sh/setup-uv@v5
35
+ with:
36
+ enable-cache: true
37
+ cache-dependency-glob: "**/uv.lock"
38
+
39
+ - name: Set up Python ${{ matrix.python-version }}
40
+ run: uv python install ${{ matrix.python-version }}
41
+
42
+ - name: Install dependencies
43
+ run: |
44
+ uv sync --python ${{ matrix.python-version }} --all-extras --dev
45
+ timeout-minutes: 10
46
+
47
+ - name: Run tests that don't require Stata
48
+ run: |
49
+ uv run pytest -v -m "not requires_stata"
50
+ timeout-minutes: 15
51
+
52
+ - name: Build package
53
+ run: |
54
+ uv build
55
+ timeout-minutes: 5
56
+
57
+ - name: Test installation in clean environment
58
+ shell: bash
59
+ run: |
60
+ # Create fresh venv using the uv-managed Python
61
+ uv run python -m venv test_venv
62
+
63
+ # Activate and install
64
+ if [[ "$RUNNER_OS" == "Windows" ]]; then
65
+ source test_venv/Scripts/activate
66
+ else
67
+ source test_venv/bin/activate
68
+ fi
69
+
70
+ # Install built wheel
71
+ pip install dist/*.whl
72
+
73
+ # Test critical imports and version (dynamic check)
74
+ python -c "
75
+ import importlib.resources
76
+ import importlib.metadata
77
+ import stata_agent
78
+ _v = importlib.metadata.version('stata-agent')
79
+ print(f'[OK] Import successful (v{_v})')
80
+ # Verify plugin/skills are bundled
81
+ p = importlib.resources.files('stata_agent') / 'plugin'
82
+ print(f'[OK] Plugin dir: {p}')
83
+ assert p.is_dir(), 'Plugin directory missing from wheel'
84
+ skills = list((p / 'skills').iterdir())
85
+ print(f'[OK] Skills: {[s.name for s in skills]}')
86
+ "
87
+
88
+ # Verify entry point
89
+ which stata-agent || where stata-agent
90
+ echo "[OK] Entry point installed"
91
+ timeout-minutes: 10
92
+
93
+ - name: Upload build artifacts
94
+ if: failure()
95
+ uses: actions/upload-artifact@v4
96
+ with:
97
+ name: build-artifacts-${{ matrix.os }}-py${{ matrix.python-version }}
98
+ path: |
99
+ dist/
100
+ *.log
101
+ retention-days: 7
@@ -0,0 +1,62 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ # release:
5
+ # types: [published]
6
+ # workflow_dispatch disabled — manual publish blocked until versioning is fixed.
7
+ # workflow_dispatch:
8
+ # inputs:
9
+ # ref:
10
+ # description: "Tag or branch to publish"
11
+ # required: true
12
+ # default: "main"
13
+
14
+ jobs:
15
+ build-and-publish:
16
+ name: Build and publish to PyPI
17
+ runs-on: ubuntu-latest
18
+ environment:
19
+ name: pypi
20
+ url: https://pypi.org/p/stata-agent
21
+ permissions:
22
+ id-token: write # required for OIDC trusted publishing
23
+ contents: read
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - name: Setup uv
29
+ uses: astral-sh/setup-uv@v5
30
+ with:
31
+ enable-cache: true
32
+ cache-dependency-glob: "**/uv.lock"
33
+
34
+ - name: Set up Python
35
+ run: uv python install 3.14
36
+
37
+ - name: Build distributions
38
+ run: uv build
39
+
40
+ - name: Verify wheel contents (plugin/skills bundling)
41
+ shell: bash
42
+ run: |
43
+ # Create fresh venv and install wheel
44
+ uv run python -m venv /tmp/test-venv
45
+ source /tmp/test-venv/bin/activate
46
+ pip install dist/*.whl
47
+ python -c "
48
+ import importlib.resources
49
+ import importlib.metadata
50
+ import stata_agent
51
+ _v = importlib.metadata.version('stata-agent')
52
+ print(f'[OK] Import successful (v{_v})')
53
+ # Verify plugin/skills are bundled in the wheel
54
+ p = importlib.resources.files('stata_agent') / 'plugin'
55
+ print(f'Plugin dir: {p}')
56
+ assert p.is_dir(), 'Plugin directory missing from wheel'
57
+ skills = list((p / 'skills').iterdir())
58
+ print(f'Skills: {[s.name for s in skills]}')
59
+ "
60
+
61
+ - name: Publish package distributions to PyPI
62
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,67 @@
1
+ name: Release
2
+
3
+ on:
4
+ # push trigger disabled — manual workflow_dispatch only.
5
+ # Automatic releases kept bumping version incorrectly.
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ actions: write
10
+ contents: write
11
+ issues: write
12
+ pull-requests: write
13
+
14
+ concurrency:
15
+ group: ${{ github.workflow }}-${{ github.ref }}
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ release:
20
+ name: Release
21
+ runs-on: ubuntu-latest
22
+ environment:
23
+ name: pypi
24
+ url: https://pypi.org/p/stata-agent
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v4
28
+ with:
29
+ fetch-depth: 0
30
+
31
+ - name: Setup uv
32
+ uses: astral-sh/setup-uv@v5
33
+ with:
34
+ enable-cache: true
35
+ cache-dependency-glob: "**/uv.lock"
36
+
37
+ - name: Set up Python
38
+ run: uv python install 3.14
39
+
40
+ - name: Install Hatch (version tooling)
41
+ run: uv tool install hatch
42
+
43
+ - name: Install release dependencies
44
+ run: |
45
+ uv sync --python 3.14 --all-extras --dev
46
+
47
+ - name: Run tests that don't require Stata
48
+ run: uv run pytest -v -m "not requires_stata"
49
+
50
+ - name: Build package
51
+ run: uv build
52
+
53
+ - name: Release
54
+ env:
55
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56
+ run: uv run semantic-release version
57
+
58
+ - name: Trigger PyPI publish
59
+ uses: actions/github-script@v7
60
+ with:
61
+ script: |
62
+ await github.rest.actions.createWorkflowDispatch({
63
+ owner: context.repo.owner,
64
+ repo: context.repo.repo,
65
+ workflow_id: "publish.yml",
66
+ ref: context.ref
67
+ })
@@ -0,0 +1,29 @@
1
+ .DS_Store
2
+ __pycache__/
3
+ .pytest_cache/
4
+ *.pyc
5
+ *.egg-info/
6
+ build/
7
+ dist/
8
+ wheels/
9
+ .venv
10
+ .coverage
11
+ htmlcov/
12
+
13
+ # Stata log files
14
+ *.log
15
+ *.smcl
16
+ stata.log
17
+
18
+ # Random artifact files from fuzz testing
19
+ benchmarks/history/
20
+
21
+ # Bool-as-path bug artifacts (historical)
22
+ True.log
23
+ False.log
24
+
25
+ # pi agent workspace — not part of the project
26
+ .pi/
27
+
28
+ # Generated benchmark dataset (90+ MB)
29
+ testdata/large_benchmark.dta
@@ -0,0 +1,15 @@
1
+ # CHANGELOG
2
+
3
+ <!-- version list -->
4
+
5
+ ## v0.1.0 (2026-05-15)
6
+
7
+ ### Features
8
+
9
+ - Initial release of stata-agent: CLI-native Stata integration for AI agents.
10
+ - Run Stata code, inspect data, retrieve results, export graphs, and test do-files.
11
+ - Daemon mode for persistent Stata sessions.
12
+ - Mock backend for testing without a Stata license.
13
+ - Statest: Stata-native test runner with JUnit output.
14
+ - Plugin system with skills for AI agent integration (Claude Code, Codex, Gemini).
15
+ - Cross-platform installer scripts (macOS, Linux, Windows).
@@ -0,0 +1,149 @@
1
+ # Contributing to stata-agent
2
+
3
+ Thank you for your interest in contributing to stata-agent! This guide will help you set up your development environment, run tests, and understand the project structure.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Development Setup](#development-setup)
8
+ - [Building the Project](#building-the-project)
9
+ - [Testing](#testing)
10
+ - [Submitting Changes](#submitting-changes)
11
+
12
+ ## Development Setup
13
+
14
+ ### Prerequisites
15
+
16
+ - **Stata 17+** (Required for integration tests)
17
+ - **Python 3.11+**
18
+ - **uv** (Recommended) or pip
19
+
20
+ ### Installation
21
+
22
+ 1. Clone the repository:
23
+ ```bash
24
+ git clone https://github.com/tmonk/stata-agent.git
25
+ cd stata-agent
26
+ ```
27
+
28
+ 2. Install dependencies with uv:
29
+ ```bash
30
+ uv sync --dev
31
+ ```
32
+
33
+ Or with pip:
34
+ ```bash
35
+ pip install -e .[dev]
36
+ ```
37
+
38
+ ## Building the Project
39
+
40
+ The project uses **hatchling** as the Python build backend. To build wheels:
41
+
42
+ ```bash
43
+ uv build
44
+ ```
45
+
46
+ Or using the build module directly:
47
+
48
+ ```bash
49
+ python -m build
50
+ ```
51
+
52
+ ## Testing
53
+
54
+ The test suite is organised with pytest markers.
55
+
56
+ ### All Tests (Requires Stata)
57
+
58
+ ```bash
59
+ uv run pytest
60
+ ```
61
+
62
+ ### Tests Without Stata (Fast/CI)
63
+
64
+ ```bash
65
+ uv run pytest -v -m "not requires_stata"
66
+ ```
67
+
68
+ ### Test Coverage
69
+
70
+ Generate a coverage report:
71
+
72
+ ```bash
73
+ uv run pytest --cov=stata_agent --cov-report=term-missing
74
+ ```
75
+
76
+ Or generate an HTML report:
77
+
78
+ ```bash
79
+ uv run pytest --cov=stata_agent --cov-report=html
80
+ open htmlcov/index.html # View the report
81
+ ```
82
+
83
+ ### Writing Tests
84
+
85
+ When adding new tests:
86
+
87
+ 1. **Mark Stata-dependent tests**:
88
+ ```python
89
+ import pytest
90
+
91
+ # At module level for all tests
92
+ pytestmark = pytest.mark.requires_stata
93
+
94
+ # Or for individual tests
95
+ @pytest.mark.requires_stata
96
+ def test_my_stata_feature():
97
+ pass
98
+ ```
99
+
100
+ 2. **Mark slow tests**:
101
+ ```python
102
+ @pytest.mark.slow
103
+ def test_expensive_operation():
104
+ pass
105
+ ```
106
+
107
+ ## Submitting Changes
108
+
109
+ ### Pull Request Process
110
+
111
+ 1. **Create a feature branch**:
112
+ ```bash
113
+ git checkout -b feature/my-feature
114
+ ```
115
+
116
+ 2. **Develop and Test**:
117
+ - Add tests in `tests/`.
118
+ - Ensure `pytest -v -m "not requires_stata"` passes.
119
+
120
+ 3. **Commit with clear messages**:
121
+ Follow conventional commits (`feat:`, `fix:`, `docs:`, `chore:`, `refactor:`, `perf:`, `test:`).
122
+
123
+ 4. **Push and create a pull request**:
124
+ ```bash
125
+ git push origin feature/my-feature
126
+ ```
127
+
128
+ ### CI/CD
129
+
130
+ GitHub Actions automatically runs on all PRs:
131
+ - Runs all non-Stata tests (`pytest -v -m "not requires_stata"`)
132
+ - Tests on Ubuntu, macOS, and Windows with Python 3.11–3.14
133
+ - Builds the package and tests entry points
134
+
135
+ ## Project Structure
136
+
137
+ - `src/stata_agent/`: Python source code.
138
+ - `tests/`: Test suite (unit, integration, benchmarks, statest, install).
139
+ - `scripts/`: Utilities for installation and version syncing.
140
+ - `worker/`: Cloudflare Worker for update checks.
141
+
142
+ ## Getting Help
143
+
144
+ - **Issues**: [GitHub Issues](https://github.com/tmonk/stata-agent/issues)
145
+ - **Author**: [Thomas Monk](https://tdmonk.com)
146
+
147
+ ## License
148
+
149
+ By contributing to stata-agent, you agree that your contributions will be licensed under the GNU Affero General Public License v3.0.