rex-machine 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 (32) hide show
  1. rex_machine-0.1.0/.claude/settings.local.json +8 -0
  2. rex_machine-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +60 -0
  3. rex_machine-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +23 -0
  4. rex_machine-0.1.0/.github/workflows/ci.yml +61 -0
  5. rex_machine-0.1.0/.github/workflows/release.yml +19 -0
  6. rex_machine-0.1.0/.gitignore +69 -0
  7. rex_machine-0.1.0/CHANGELOG.md +15 -0
  8. rex_machine-0.1.0/CLAUDE.md +65 -0
  9. rex_machine-0.1.0/CONTRIBUTING.md +42 -0
  10. rex_machine-0.1.0/LICENSE +190 -0
  11. rex_machine-0.1.0/PKG-INFO +136 -0
  12. rex_machine-0.1.0/README.md +102 -0
  13. rex_machine-0.1.0/pyproject.toml +64 -0
  14. rex_machine-0.1.0/src/rex_machine/__init__.py +3 -0
  15. rex_machine-0.1.0/src/rex_machine/__main__.py +3 -0
  16. rex_machine-0.1.0/src/rex_machine/agents.py +638 -0
  17. rex_machine-0.1.0/src/rex_machine/cli.py +542 -0
  18. rex_machine-0.1.0/src/rex_machine/config.py +63 -0
  19. rex_machine-0.1.0/src/rex_machine/models.py +67 -0
  20. rex_machine-0.1.0/src/rex_machine/py.typed +0 -0
  21. rex_machine-0.1.0/src/rex_machine/renderer.py +184 -0
  22. rex_machine-0.1.0/src/rex_machine/scanner.py +274 -0
  23. rex_machine-0.1.0/src/rex_machine/templates/prompts/code_pattern_analyzer.j2 +16 -0
  24. rex_machine-0.1.0/src/rex_machine/templates/prompts/config_analyzer.j2 +16 -0
  25. rex_machine-0.1.0/src/rex_machine/templates/prompts/doc_analyzer.j2 +15 -0
  26. rex_machine-0.1.0/src/rex_machine/templates/prompts/main.j2 +24 -0
  27. rex_machine-0.1.0/src/rex_machine/templates/prompts/structure_analyzer.j2 +14 -0
  28. rex_machine-0.1.0/src/rex_machine/templates/prompts/synthesis.j2 +27 -0
  29. rex_machine-0.1.0/src/rex_machine/templates/report.md.j2 +85 -0
  30. rex_machine-0.1.0/tests/__init__.py +0 -0
  31. rex_machine-0.1.0/tests/test_models.py +193 -0
  32. rex_machine-0.1.0/tests/test_scanner.py +224 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(tribl --version)",
5
+ "Bash(echo \"EXIT_CODE=$?\")"
6
+ ]
7
+ }
8
+ }
@@ -0,0 +1,60 @@
1
+ name: Bug Report
2
+ description: Something isn't working as expected
3
+ labels: ["bug"]
4
+ body:
5
+ - type: textarea
6
+ id: description
7
+ attributes:
8
+ label: What happened?
9
+ description: A clear description of the bug.
10
+ validations:
11
+ required: true
12
+ - type: textarea
13
+ id: reproduce
14
+ attributes:
15
+ label: Steps to reproduce
16
+ description: Minimal steps to reproduce the issue.
17
+ placeholder: |
18
+ 1. rex extract /path/to/repo
19
+ 2. ...
20
+ validations:
21
+ required: true
22
+ - type: textarea
23
+ id: expected
24
+ attributes:
25
+ label: Expected behavior
26
+ description: What did you expect to happen?
27
+ validations:
28
+ required: true
29
+ - type: input
30
+ id: version
31
+ attributes:
32
+ label: rex-machine version
33
+ description: Output of `rex --version`
34
+ placeholder: "0.1.0"
35
+ validations:
36
+ required: true
37
+ - type: dropdown
38
+ id: provider
39
+ attributes:
40
+ label: Provider
41
+ options:
42
+ - Anthropic (direct)
43
+ - Azure AI Foundry
44
+ - AWS Bedrock
45
+ - Google Vertex AI
46
+ validations:
47
+ required: true
48
+ - type: input
49
+ id: python
50
+ attributes:
51
+ label: Python version
52
+ placeholder: "3.12"
53
+ validations:
54
+ required: true
55
+ - type: textarea
56
+ id: logs
57
+ attributes:
58
+ label: Verbose logs
59
+ description: Run with `-v` and paste relevant output.
60
+ render: shell
@@ -0,0 +1,23 @@
1
+ name: Feature Request
2
+ description: Suggest an improvement or new feature
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: textarea
6
+ id: problem
7
+ attributes:
8
+ label: Problem or use case
9
+ description: What problem would this solve?
10
+ validations:
11
+ required: true
12
+ - type: textarea
13
+ id: solution
14
+ attributes:
15
+ label: Proposed solution
16
+ description: How do you think this should work?
17
+ validations:
18
+ required: true
19
+ - type: textarea
20
+ id: alternatives
21
+ attributes:
22
+ label: Alternatives considered
23
+ description: Any other approaches you've thought of?
@@ -0,0 +1,61 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ branches: [master]
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: pip
25
+
26
+ - name: Install dependencies
27
+ run: pip install -e ".[dev]"
28
+
29
+ - name: Lint
30
+ run: ruff check src/ tests/
31
+
32
+ - name: Format check
33
+ run: ruff format --check src/ tests/
34
+
35
+ - name: Test
36
+ run: pytest tests/ -v
37
+
38
+ publish:
39
+ needs: test
40
+ runs-on: ubuntu-latest
41
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
42
+
43
+ permissions:
44
+ id-token: write
45
+
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+
49
+ - name: Set up Python
50
+ uses: actions/setup-python@v5
51
+ with:
52
+ python-version: "3.12"
53
+
54
+ - name: Install build tools
55
+ run: pip install build
56
+
57
+ - name: Build package
58
+ run: python -m build
59
+
60
+ - name: Publish to PyPI
61
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,19 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ github-release:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Create GitHub Release
17
+ uses: softprops/action-gh-release@v2
18
+ with:
19
+ generate_release_notes: true
@@ -0,0 +1,69 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .nox/
39
+ .coverage
40
+ .coverage.*
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+ *.cover
45
+ *.py,cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Environments
50
+ .env
51
+ .venv
52
+ env/
53
+ venv/
54
+ ENV/
55
+
56
+ # IDE
57
+ .vscode/
58
+ .idea/
59
+ *.swp
60
+ *.swo
61
+ *~
62
+
63
+ # OS
64
+ .DS_Store
65
+ Thumbs.db
66
+
67
+ # Project specific
68
+ output/
69
+ *.json.bak
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (Unreleased)
4
+
5
+ Initial release.
6
+
7
+ - Agentic analysis pipeline with 4 parallel sub-agents (structure, patterns, docs, config)
8
+ - Each sub-agent autonomously navigates the repo via `read_file`, `list_files`, `grep`
9
+ - Synthesis agent merges findings into a structured `RexReport` via forced `tool_use`
10
+ - Output formats: Rich console, Markdown (Jinja2), JSON
11
+ - Multi-provider support: Anthropic direct, Azure AI Foundry, AWS Bedrock, Google Vertex AI
12
+ - Two-level configuration (global credentials + per-project settings)
13
+ - `.gitignore`-aware file scanner with binary detection
14
+ - Safety cap on tool calls per sub-agent (default 30)
15
+ - French and English output (`--lang fr`)
@@ -0,0 +1,65 @@
1
+ # rex-machine
2
+
3
+ A Python CLI tool that extracts technical lessons learned (REX - Retours d'EXperience) from code repositories using the Claude API.
4
+
5
+ ## Architecture
6
+
7
+ **Agentic tool-use pipeline** — each sub-agent navigates the repo autonomously via tool calls (like Claude Code):
8
+
9
+ 1. **Scanner** (`src/rex_machine/scanner.py`) - Walks the local repo, respects .gitignore, skips binaries, builds a file tree map.
10
+ 2. **Sub-agents** (`src/rex_machine/agents.py`) - Four parallel Claude API calls, each with an autonomous `while stop_reason == "tool_use"` loop. Claude calls `list_files`, `read_file`, `grep` to explore the codebase and decides what to read based on what it finds.
11
+ 3. **Synthesis** (`src/rex_machine/agents.py`) - A final Claude API call merges all sub-agent findings into a structured `RexReport` using tool_use for structured JSON output.
12
+ 4. **Renderer** (`src/rex_machine/renderer.py`) - Outputs the report as Rich console, Markdown (via Jinja2), or JSON.
13
+
14
+ ## Key Design Decisions
15
+
16
+ - Uses the official `anthropic` Python SDK (not any agent framework).
17
+ - Sub-agents navigate the repo via read-only tools (`list_files`, `read_file`, `grep`) — all scoped to the repo directory, no path traversal.
18
+ - Structured output is enforced via the `tool_use` / `tool_choice` pattern (not `response_format`).
19
+ - Parallel sub-agent execution uses `anyio` task groups.
20
+ - Default model: `claude-sonnet-4-6` (cost-effective for analysis).
21
+ - Safety cap: `max_tool_calls` per sub-agent (default 30) prevents runaway loops.
22
+
23
+ ## Commands
24
+
25
+ ```bash
26
+ # Install in dev mode
27
+ pip install -e ".[dev]"
28
+
29
+ # Extract REX from a repo
30
+ rex extract /path/to/repo
31
+ rex extract /path/to/repo -o markdown -f report.md
32
+ rex extract /path/to/repo -o json -f report.json
33
+ rex extract /path/to/repo -m claude-sonnet-4-6 -v
34
+ rex extract /path/to/repo --lang fr
35
+
36
+ # Run tests
37
+ pytest
38
+
39
+ # Lint
40
+ ruff check src/ tests/
41
+ ruff format src/ tests/
42
+ ```
43
+
44
+ ## Environment Variables
45
+
46
+ - `ANTHROPIC_API_KEY` - Required. Your Anthropic API key.
47
+
48
+ ## Project Layout
49
+
50
+ ```
51
+ src/rex_machine/
52
+ __init__.py - Package version
53
+ models.py - Pydantic v2 models (RexReport, RexItem, etc.)
54
+ scanner.py - Local repo file scanner (builds file tree, SKIP_DIRS)
55
+ agents.py - Agentic pipeline (tool-use loop, ToolExecutor, synthesis)
56
+ renderer.py - Output renderers (console, markdown, json)
57
+ config.py - Two-level config management (global + project)
58
+ cli.py - Typer CLI entry point
59
+ templates/
60
+ prompts/ - Jinja2 prompt templates for each agent
61
+ report.md.j2 - Jinja2 markdown report template
62
+ tests/
63
+ test_models.py - Model validation tests
64
+ test_scanner.py - Scanner and ToolExecutor tests
65
+ ```
@@ -0,0 +1,42 @@
1
+ # Contributing to rex-machine
2
+
3
+ Thanks for your interest! Here's how to get started.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/NicoJuiced/rex-machine.git
9
+ cd rex-machine
10
+ pip install -e ".[dev]"
11
+ ```
12
+
13
+ ## Development workflow
14
+
15
+ ```bash
16
+ # Run tests
17
+ pytest
18
+
19
+ # Lint + format
20
+ ruff check src/ tests/
21
+ ruff format src/ tests/
22
+ ```
23
+
24
+ All checks must pass before merging. CI runs them automatically on every PR.
25
+
26
+ ## Pull requests
27
+
28
+ 1. Fork the repo and create a branch from `main`
29
+ 2. Make your changes
30
+ 3. Add or update tests if applicable
31
+ 4. Ensure `pytest` and `ruff check` pass
32
+ 5. Open a PR with a clear description of *what* and *why*
33
+
34
+ ## Architecture overview
35
+
36
+ See [CLAUDE.md](CLAUDE.md) for the full architecture and design decisions.
37
+
38
+ The key thing to understand: rex-machine uses an **agentic tool-use loop** where Claude autonomously navigates the repo via `read_file`, `list_files`, and `grep` tools. If you're adding a new tool or sub-agent, follow the existing patterns in `src/rex_machine/agents.py`.
39
+
40
+ ## Reporting bugs
41
+
42
+ Use [GitHub Issues](https://github.com/NicoJuiced/rex-machine/issues) with the bug report template. Include `rex extract --verbose` output when possible.
@@ -0,0 +1,190 @@
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, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 NicolasJULIEN
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.