type-rename-move 0.14.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.
- type_rename_move-0.14.0/LICENSE +21 -0
- type_rename_move-0.14.0/PKG-INFO +51 -0
- type_rename_move-0.14.0/README.md +15 -0
- type_rename_move-0.14.0/pyproject.toml +81 -0
- type_rename_move-0.14.0/pyproject.toml.orig +78 -0
- type_rename_move-0.14.0/src/trmv/__init__.py +8 -0
- type_rename_move-0.14.0/src/trmv/changes/__init__.py +120 -0
- type_rename_move-0.14.0/src/trmv/cli/__init__.py +1 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_compliance.py +8 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_config.py +13 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_doctor.py +20 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_mock_lint.py +6 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_refactor.py +17 -0
- type_rename_move-0.14.0/src/trmv/cli/trmv_typecheck.py +14 -0
- type_rename_move-0.14.0/src/trmv/config/__init__.py +82 -0
- type_rename_move-0.14.0/src/trmv/config/command.py +48 -0
- type_rename_move-0.14.0/src/trmv/config/format.py +183 -0
- type_rename_move-0.14.0/src/trmv/config/languages.py +61 -0
- type_rename_move-0.14.0/src/trmv/config/load.py +213 -0
- type_rename_move-0.14.0/src/trmv/config/values.py +112 -0
- type_rename_move-0.14.0/src/trmv/contract/__init__.py +74 -0
- type_rename_move-0.14.0/src/trmv/contract/data/CONTRACT_HASH +1 -0
- type_rename_move-0.14.0/src/trmv/contract/data/README.md +69 -0
- type_rename_move-0.14.0/src/trmv/contract/data/cli.yaml +239 -0
- type_rename_move-0.14.0/src/trmv/contract/data/config.yaml +8 -0
- type_rename_move-0.14.0/src/trmv/contract/data/findings.yaml +212 -0
- type_rename_move-0.14.0/src/trmv/contract/data/languages.yaml +146 -0
- type_rename_move-0.14.0/src/trmv/contract/data/regex-subset.md +28 -0
- type_rename_move-0.14.0/src/trmv/contract/data/schema/rename-map.schema.json +51 -0
- type_rename_move-0.14.0/src/trmv/contract/data/schema/trmv.schema.json +92 -0
- type_rename_move-0.14.0/src/trmv/contract/data/schema/word-table.schema.json +55 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/cli.yaml +216 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/command-split.yaml +69 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/diff.yaml +287 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/format.yaml +160 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/glob.yaml +148 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/materialize.yaml +51 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/os-errors.yaml +123 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/refactor-symbols.yaml +220 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/refactor-text.yaml +186 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/refactor-words.yaml +83 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/regex-subset.yaml +40 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/repr.yaml +118 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/skill-leaks.yaml +6 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/test-files.yaml +135 -0
- type_rename_move-0.14.0/src/trmv/contract/data/vectors/yaml.yaml +858 -0
- type_rename_move-0.14.0/src/trmv/contract/glob.py +24 -0
- type_rename_move-0.14.0/src/trmv/contract/os_error.py +56 -0
- type_rename_move-0.14.0/src/trmv/contract/parser.py +73 -0
- type_rename_move-0.14.0/src/trmv/contract/plugin.py +92 -0
- type_rename_move-0.14.0/src/trmv/contract/regex.py +107 -0
- type_rename_move-0.14.0/src/trmv/contract/render.py +50 -0
- type_rename_move-0.14.0/src/trmv/contract/schema.py +87 -0
- type_rename_move-0.14.0/src/trmv/contract/snapshot.py +154 -0
- type_rename_move-0.14.0/src/trmv/contract/yaml_profile.py +125 -0
- type_rename_move-0.14.0/src/trmv/doctor/__init__.py +72 -0
- type_rename_move-0.14.0/src/trmv/lang/__init__.py +87 -0
- type_rename_move-0.14.0/src/trmv/lang/baseline.py +93 -0
- type_rename_move-0.14.0/src/trmv/lang/edges.py +216 -0
- type_rename_move-0.14.0/src/trmv/lang/language_server.py +557 -0
- type_rename_move-0.14.0/src/trmv/lang/position_map.py +25 -0
- type_rename_move-0.14.0/src/trmv/lang/pyright_export.cjs +463 -0
- type_rename_move-0.14.0/src/trmv/lang/pyright_patch.cjs +57 -0
- type_rename_move-0.14.0/src/trmv/lang/realign.py +132 -0
- type_rename_move-0.14.0/src/trmv/lang/source.py +207 -0
- type_rename_move-0.14.0/src/trmv/lang/typecheck.py +91 -0
- type_rename_move-0.14.0/src/trmv/lang/units.py +198 -0
- type_rename_move-0.14.0/src/trmv/refactor/__init__.py +20 -0
- type_rename_move-0.14.0/src/trmv/refactor/baseline_align.py +308 -0
- type_rename_move-0.14.0/src/trmv/refactor/bindings.py +660 -0
- type_rename_move-0.14.0/src/trmv/refactor/carve_outs.py +201 -0
- type_rename_move-0.14.0/src/trmv/refactor/compliance.py +218 -0
- type_rename_move-0.14.0/src/trmv/refactor/compound.py +47 -0
- type_rename_move-0.14.0/src/trmv/refactor/diff_render.py +22 -0
- type_rename_move-0.14.0/src/trmv/refactor/entry_location.py +481 -0
- type_rename_move-0.14.0/src/trmv/refactor/explicit_any.py +184 -0
- type_rename_move-0.14.0/src/trmv/refactor/generate_map.py +274 -0
- type_rename_move-0.14.0/src/trmv/refactor/hierarchy.py +154 -0
- type_rename_move-0.14.0/src/trmv/refactor/index_cache.py +301 -0
- type_rename_move-0.14.0/src/trmv/refactor/keyed.py +828 -0
- type_rename_move-0.14.0/src/trmv/refactor/keyword_links.py +556 -0
- type_rename_move-0.14.0/src/trmv/refactor/literal_rename.py +431 -0
- type_rename_move-0.14.0/src/trmv/refactor/literal_sources.py +253 -0
- type_rename_move-0.14.0/src/trmv/refactor/locators.py +70 -0
- type_rename_move-0.14.0/src/trmv/refactor/map_file.py +91 -0
- type_rename_move-0.14.0/src/trmv/refactor/member_namespace.py +133 -0
- type_rename_move-0.14.0/src/trmv/refactor/member_scan.py +708 -0
- type_rename_move-0.14.0/src/trmv/refactor/members.py +181 -0
- type_rename_move-0.14.0/src/trmv/refactor/mention_scope.py +186 -0
- type_rename_move-0.14.0/src/trmv/refactor/mentions.py +184 -0
- type_rename_move-0.14.0/src/trmv/refactor/mock_spec_lint.py +157 -0
- type_rename_move-0.14.0/src/trmv/refactor/module_move.py +133 -0
- type_rename_move-0.14.0/src/trmv/refactor/module_rename.py +371 -0
- type_rename_move-0.14.0/src/trmv/refactor/move_edits.py +466 -0
- type_rename_move-0.14.0/src/trmv/refactor/move_project.py +137 -0
- type_rename_move-0.14.0/src/trmv/refactor/move_verify.py +460 -0
- type_rename_move-0.14.0/src/trmv/refactor/moved_imports.py +251 -0
- type_rename_move-0.14.0/src/trmv/refactor/moved_symbol.py +123 -0
- type_rename_move-0.14.0/src/trmv/refactor/name_follow.py +118 -0
- type_rename_move-0.14.0/src/trmv/refactor/occurrence_index.py +484 -0
- type_rename_move-0.14.0/src/trmv/refactor/outcomes.py +191 -0
- type_rename_move-0.14.0/src/trmv/refactor/output_check.py +55 -0
- type_rename_move-0.14.0/src/trmv/refactor/patch_targets.py +195 -0
- type_rename_move-0.14.0/src/trmv/refactor/progress.py +100 -0
- type_rename_move-0.14.0/src/trmv/refactor/python_project.py +299 -0
- type_rename_move-0.14.0/src/trmv/refactor/python_source.py +278 -0
- type_rename_move-0.14.0/src/trmv/refactor/rename_map.py +1240 -0
- type_rename_move-0.14.0/src/trmv/refactor/rename_union.py +1214 -0
- type_rename_move-0.14.0/src/trmv/refactor/retarget.py +594 -0
- type_rename_move-0.14.0/src/trmv/refactor/retarget_imports.py +188 -0
- type_rename_move-0.14.0/src/trmv/refactor/rope_patches.py +477 -0
- type_rename_move-0.14.0/src/trmv/refactor/rope_refactor.py +222 -0
- type_rename_move-0.14.0/src/trmv/refactor/routing.py +249 -0
- type_rename_move-0.14.0/src/trmv/refactor/sites.py +232 -0
- type_rename_move-0.14.0/src/trmv/refactor/static_resolver.py +480 -0
- type_rename_move-0.14.0/src/trmv/refactor/symbol_move.py +394 -0
- type_rename_move-0.14.0/src/trmv/refactor/symbol_path.py +380 -0
- type_rename_move-0.14.0/src/trmv/refactor/text_edits.py +62 -0
- type_rename_move-0.14.0/src/trmv/refactor/text_tables.py +97 -0
- type_rename_move-0.14.0/src/trmv/refactor/timings.py +95 -0
- type_rename_move-0.14.0/src/trmv/refactor/word_table.py +118 -0
- type_rename_move-0.14.0/src/trmv/refactor/writer.py +152 -0
- type_rename_move-0.14.0/src/trmv/twin/__init__.py +252 -0
- type_rename_move-0.14.0/src/trmv/typecheck/__init__.py +388 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MotleyAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: type-rename-move
|
|
3
|
+
Version: 0.14.0
|
|
4
|
+
Summary: Verified renames and moves for Python and TypeScript code: every import and reference rewritten, checked by a type-check gate against a committed baseline.
|
|
5
|
+
Keywords: claude-code,claude-code-plugin,agent-skills,coding-agents,ai-coding,refactoring,rename,type-checking,move,refactor,typecheck,python,typescript,verified,imports
|
|
6
|
+
Author: MotleyAI
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: JavaScript
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Requires-Dist: rope>=1.15
|
|
22
|
+
Requires-Dist: pydantic>=2.6
|
|
23
|
+
Requires-Dist: pyyaml>=6
|
|
24
|
+
Requires-Dist: jsonschema>=4.18
|
|
25
|
+
Requires-Dist: referencing>=0.28.4
|
|
26
|
+
Requires-Dist: typing-extensions>=4.4
|
|
27
|
+
Requires-Dist: basedpyright==1.40.2
|
|
28
|
+
Maintainer: Egor Kraev
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Project-URL: Homepage, https://github.com/MotleyAI/living-architecture
|
|
31
|
+
Project-URL: Documentation, https://github.com/MotleyAI/living-architecture/blob/main/docs/rename-and-move.md
|
|
32
|
+
Project-URL: Repository, https://github.com/MotleyAI/living-architecture
|
|
33
|
+
Project-URL: Issues, https://github.com/MotleyAI/living-architecture/issues
|
|
34
|
+
Project-URL: Changelog, https://github.com/MotleyAI/living-architecture/releases
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# type-rename-move
|
|
38
|
+
|
|
39
|
+
Verified renames and moves for Python and TypeScript code. `trmv-refactor` rewrites every import and reference, and
|
|
40
|
+
`trmv-typecheck` checks the result against the repo's committed type-check baseline, so a refactor that missed a
|
|
41
|
+
reference fails instead of slipping through. `trmv-compliance` reports the constructs that would make a refactor
|
|
42
|
+
unverifiable, and `trmv-mock-lint` the test doubles not bound to the real type.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv tool install type-rename-move # Python repos (Python >= 3.11)
|
|
46
|
+
npm install -g type-rename-move # TypeScript/JavaScript repos (Node >= 22)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
A repo configures it in `trmv.yaml`, or in `living-architecture.yaml` when it also uses
|
|
50
|
+
[living-architecture](https://github.com/MotleyAI/living-architecture), which builds on this package. The Claude Code
|
|
51
|
+
plugin `trmv` drives the commands; see [Renames and moves](https://github.com/MotleyAI/living-architecture/blob/main/docs/rename-and-move.md).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# type-rename-move
|
|
2
|
+
|
|
3
|
+
Verified renames and moves for Python and TypeScript code. `trmv-refactor` rewrites every import and reference, and
|
|
4
|
+
`trmv-typecheck` checks the result against the repo's committed type-check baseline, so a refactor that missed a
|
|
5
|
+
reference fails instead of slipping through. `trmv-compliance` reports the constructs that would make a refactor
|
|
6
|
+
unverifiable, and `trmv-mock-lint` the test doubles not bound to the real type.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
uv tool install type-rename-move # Python repos (Python >= 3.11)
|
|
10
|
+
npm install -g type-rename-move # TypeScript/JavaScript repos (Node >= 22)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
A repo configures it in `trmv.yaml`, or in `living-architecture.yaml` when it also uses
|
|
14
|
+
[living-architecture](https://github.com/MotleyAI/living-architecture), which builds on this package. The Claude Code
|
|
15
|
+
plugin `trmv` drives the commands; see [Renames and moves](https://github.com/MotleyAI/living-architecture/blob/main/docs/rename-and-move.md).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "type-rename-move"
|
|
3
|
+
version = "0.14.0"
|
|
4
|
+
description = "Verified renames and moves for Python and TypeScript code: every import and reference rewritten, checked by a type-check gate against a committed baseline."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
keywords = [
|
|
10
|
+
"claude-code",
|
|
11
|
+
"claude-code-plugin",
|
|
12
|
+
"agent-skills",
|
|
13
|
+
"coding-agents",
|
|
14
|
+
"ai-coding",
|
|
15
|
+
"refactoring",
|
|
16
|
+
"rename",
|
|
17
|
+
"type-checking",
|
|
18
|
+
"move",
|
|
19
|
+
"refactor",
|
|
20
|
+
"typecheck",
|
|
21
|
+
"python",
|
|
22
|
+
"typescript",
|
|
23
|
+
"verified",
|
|
24
|
+
"imports",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Environment :: Console",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Operating System :: POSIX",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Programming Language :: Python :: 3.14",
|
|
37
|
+
"Programming Language :: JavaScript",
|
|
38
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
39
|
+
]
|
|
40
|
+
dependencies = [
|
|
41
|
+
"rope>=1.15",
|
|
42
|
+
"pydantic>=2.6",
|
|
43
|
+
"pyyaml>=6",
|
|
44
|
+
"jsonschema>=4.18",
|
|
45
|
+
"referencing>=0.28.4",
|
|
46
|
+
"typing-extensions>=4.4",
|
|
47
|
+
"basedpyright==1.40.2",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[[project.authors]]
|
|
51
|
+
name = "MotleyAI"
|
|
52
|
+
|
|
53
|
+
[[project.maintainers]]
|
|
54
|
+
name = "Egor Kraev"
|
|
55
|
+
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/MotleyAI/living-architecture"
|
|
58
|
+
Documentation = "https://github.com/MotleyAI/living-architecture/blob/main/docs/rename-and-move.md"
|
|
59
|
+
Repository = "https://github.com/MotleyAI/living-architecture"
|
|
60
|
+
Issues = "https://github.com/MotleyAI/living-architecture/issues"
|
|
61
|
+
Changelog = "https://github.com/MotleyAI/living-architecture/releases"
|
|
62
|
+
|
|
63
|
+
[project.scripts]
|
|
64
|
+
trmv-refactor = "trmv.cli.trmv_refactor:trmv_refactor"
|
|
65
|
+
trmv-mock-lint = "trmv.cli.trmv_mock_lint:trmv_mock_lint"
|
|
66
|
+
trmv-compliance = "trmv.cli.trmv_compliance:trmv_compliance"
|
|
67
|
+
trmv-config = "trmv.cli.trmv_config:trmv_config"
|
|
68
|
+
trmv-doctor = "trmv.cli.trmv_doctor:trmv_doctor"
|
|
69
|
+
trmv-typecheck = "trmv.cli.trmv_typecheck:trmv_typecheck"
|
|
70
|
+
|
|
71
|
+
[build-system]
|
|
72
|
+
requires = ["uv_build>=0.9,<0.13"]
|
|
73
|
+
build-backend = "uv_build"
|
|
74
|
+
|
|
75
|
+
[tool.uv.build-backend]
|
|
76
|
+
module-name = "trmv"
|
|
77
|
+
|
|
78
|
+
[tool.pytest.ini_options]
|
|
79
|
+
testpaths = ["tests"]
|
|
80
|
+
addopts = "-n auto --dist worksteal -m 'not integration'"
|
|
81
|
+
markers = ["integration: runs a real external checker; select with -m integration"]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "type-rename-move"
|
|
3
|
+
version = "0.14.0"
|
|
4
|
+
description = "Verified renames and moves for Python and TypeScript code: every import and reference rewritten, checked by a type-check gate against a committed baseline."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [{ name = "MotleyAI" }]
|
|
10
|
+
maintainers = [{ name = "Egor Kraev" }]
|
|
11
|
+
keywords = [
|
|
12
|
+
"claude-code",
|
|
13
|
+
"claude-code-plugin",
|
|
14
|
+
"agent-skills",
|
|
15
|
+
"coding-agents",
|
|
16
|
+
"ai-coding",
|
|
17
|
+
"refactoring",
|
|
18
|
+
"rename",
|
|
19
|
+
"type-checking",
|
|
20
|
+
"move",
|
|
21
|
+
"refactor",
|
|
22
|
+
"typecheck",
|
|
23
|
+
"python",
|
|
24
|
+
"typescript",
|
|
25
|
+
"verified",
|
|
26
|
+
"imports",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Environment :: Console",
|
|
31
|
+
"Intended Audience :: Developers",
|
|
32
|
+
"Operating System :: POSIX",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
"Programming Language :: Python :: 3.13",
|
|
38
|
+
"Programming Language :: Python :: 3.14",
|
|
39
|
+
"Programming Language :: JavaScript",
|
|
40
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
41
|
+
]
|
|
42
|
+
dependencies = [
|
|
43
|
+
"rope>=1.15",
|
|
44
|
+
"pydantic>=2.6",
|
|
45
|
+
"pyyaml>=6",
|
|
46
|
+
"jsonschema>=4.18",
|
|
47
|
+
"referencing>=0.28.4",
|
|
48
|
+
"typing-extensions>=4.4",
|
|
49
|
+
"basedpyright==1.40.2",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Homepage = "https://github.com/MotleyAI/living-architecture"
|
|
54
|
+
Documentation = "https://github.com/MotleyAI/living-architecture/blob/main/docs/rename-and-move.md"
|
|
55
|
+
Repository = "https://github.com/MotleyAI/living-architecture"
|
|
56
|
+
Issues = "https://github.com/MotleyAI/living-architecture/issues"
|
|
57
|
+
Changelog = "https://github.com/MotleyAI/living-architecture/releases"
|
|
58
|
+
|
|
59
|
+
# Must equal trmv's command set in the shared CLI manifest.
|
|
60
|
+
[project.scripts]
|
|
61
|
+
trmv-refactor = "trmv.cli.trmv_refactor:trmv_refactor"
|
|
62
|
+
trmv-mock-lint = "trmv.cli.trmv_mock_lint:trmv_mock_lint"
|
|
63
|
+
trmv-compliance = "trmv.cli.trmv_compliance:trmv_compliance"
|
|
64
|
+
trmv-config = "trmv.cli.trmv_config:trmv_config"
|
|
65
|
+
trmv-doctor = "trmv.cli.trmv_doctor:trmv_doctor"
|
|
66
|
+
trmv-typecheck = "trmv.cli.trmv_typecheck:trmv_typecheck"
|
|
67
|
+
|
|
68
|
+
[build-system]
|
|
69
|
+
requires = ["uv_build>=0.9,<0.13"]
|
|
70
|
+
build-backend = "uv_build"
|
|
71
|
+
|
|
72
|
+
[tool.uv.build-backend]
|
|
73
|
+
module-name = "trmv"
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
testpaths = ["tests"]
|
|
77
|
+
addopts = "-n auto --dist worksteal -m 'not integration'"
|
|
78
|
+
markers = ["integration: runs a real external checker; select with -m integration"]
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""What a branch changed against its base: base-ref resolution and the NUL-delimited git change listing."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import os
|
|
7
|
+
import signal
|
|
8
|
+
import subprocess
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from trmv.config import ConfigError
|
|
12
|
+
from trmv.contract import base_fetch_timeout, message
|
|
13
|
+
|
|
14
|
+
__all__ = ["base_paths", "changed_paths", "commit_id", "file_at", "git_paths", "is_commit", "merge_base", "resolve_base_ref"]
|
|
15
|
+
|
|
16
|
+
# Neither git nor ssh may prompt during the fetch: no terminal prompt and no askpass helper.
|
|
17
|
+
_NO_PROMPT = {"GIT_TERMINAL_PROMPT": "0", "GIT_ASKPASS": "", "SSH_ASKPASS": "", "SSH_ASKPASS_REQUIRE": "never"}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _failed(args: list[str]) -> str:
|
|
21
|
+
return message("changes.git-failed", args=" ".join(args))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _started(args: list[str], *, cwd: Path) -> subprocess.CompletedProcess[bytes]:
|
|
25
|
+
try:
|
|
26
|
+
return subprocess.run(["git", *args], cwd=cwd, capture_output=True, check=False)
|
|
27
|
+
except OSError as exc:
|
|
28
|
+
raise ConfigError(_failed(args)) from exc
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _git(args: list[str], *, cwd: Path) -> bytes:
|
|
32
|
+
proc = _started(args, cwd=cwd)
|
|
33
|
+
if proc.returncode != 0:
|
|
34
|
+
raise ConfigError(proc.stderr.decode("utf-8", "replace").strip() or _failed(args))
|
|
35
|
+
return proc.stdout
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def git_paths(args: list[str], *, repo_root: Path) -> list[str]:
|
|
39
|
+
"""The NUL-delimited paths a git listing prints; undecodable bytes kept as surrogate escapes."""
|
|
40
|
+
return [p.decode("utf-8", "surrogateescape") for p in _git(args, cwd=repo_root).split(b"\0") if p]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _bounded_fetch(base: str, repo_root: Path, timeout: float) -> None:
|
|
44
|
+
"""`git fetch origin <base>` in its own process group, the whole group killed after `timeout` seconds."""
|
|
45
|
+
env = {**os.environ, **_NO_PROMPT}
|
|
46
|
+
try:
|
|
47
|
+
proc = subprocess.Popen(["git", "fetch", "origin", base, "--quiet"], cwd=repo_root, stdin=subprocess.DEVNULL,
|
|
48
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env, start_new_session=True)
|
|
49
|
+
except OSError:
|
|
50
|
+
return
|
|
51
|
+
try:
|
|
52
|
+
proc.wait(timeout=timeout)
|
|
53
|
+
except subprocess.TimeoutExpired:
|
|
54
|
+
if hasattr(os, "killpg"):
|
|
55
|
+
with contextlib.suppress(ProcessLookupError):
|
|
56
|
+
os.killpg(proc.pid, signal.SIGKILL)
|
|
57
|
+
else:
|
|
58
|
+
proc.kill()
|
|
59
|
+
proc.wait()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def resolve_base_ref(*, base: str, repo_root: Path, fetch_timeout: float | None = None) -> str:
|
|
63
|
+
"""`origin/<base>` after a best-effort, bounded, non-prompting fetch; ConfigError when it does not resolve."""
|
|
64
|
+
_bounded_fetch(base, repo_root, base_fetch_timeout() if fetch_timeout is None else fetch_timeout)
|
|
65
|
+
ref = f"origin/{base}"
|
|
66
|
+
_git(["rev-parse", "--verify", "--quiet", ref], cwd=repo_root)
|
|
67
|
+
return ref
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def changed_paths(*, base_ref: str, repo_root: Path, deletions: bool, untracked: bool) -> list[str]:
|
|
71
|
+
"""Paths changed since the merge base with `base_ref`, committed or not, in code-point order; renames split."""
|
|
72
|
+
diff = ["diff", "-z", "--name-only", "--no-renames"] + ([] if deletions else ["--diff-filter=ACMR"])
|
|
73
|
+
out: set[str] = set()
|
|
74
|
+
for target in (f"{base_ref}...HEAD", "HEAD"):
|
|
75
|
+
out.update(git_paths([*diff, target, "--"], repo_root=repo_root))
|
|
76
|
+
if untracked:
|
|
77
|
+
out.update(git_paths(["ls-files", "-z", "--others", "--exclude-standard"], repo_root=repo_root))
|
|
78
|
+
return sorted(out)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def merge_base(*, base_ref: str, repo_root: Path) -> str:
|
|
82
|
+
"""The merge base of `base_ref` and HEAD."""
|
|
83
|
+
return _git(["merge-base", base_ref, "HEAD"], cwd=repo_root).decode().strip()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def commit_id(*, ref: str, repo_root: Path) -> str | None:
|
|
87
|
+
"""The id of the commit `ref` names, None when it names none; ConfigError when git fails."""
|
|
88
|
+
proc = _started(["rev-parse", "--verify", "--quiet", "--end-of-options", f"{ref}^{{commit}}"], cwd=repo_root)
|
|
89
|
+
if proc.returncode == 0:
|
|
90
|
+
return proc.stdout.decode().strip()
|
|
91
|
+
detail = proc.stderr.decode("utf-8", "replace").strip()
|
|
92
|
+
if detail:
|
|
93
|
+
raise ConfigError(detail)
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def is_commit(*, ref: str, repo_root: Path) -> bool:
|
|
98
|
+
"""Whether `ref` names a commit."""
|
|
99
|
+
return commit_id(ref=ref, repo_root=repo_root) is not None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def file_at(*, ref: str, path: str, repo_root: Path) -> bytes | None:
|
|
103
|
+
"""The bytes of repo-relative `path` at `ref`, None when it is not there."""
|
|
104
|
+
proc = subprocess.run(["git", "cat-file", "blob", f"{ref}:{path}"], cwd=repo_root, capture_output=True, check=False)
|
|
105
|
+
return proc.stdout if proc.returncode == 0 else None
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def base_paths(*, ref: str, repo_root: Path) -> dict[str, str]:
|
|
109
|
+
"""Each path renamed since `ref` (tracked files of the working tree), mapped to its path at `ref`."""
|
|
110
|
+
fields = git_paths(["diff", "-z", "--name-status", "-M", ref, "--"], repo_root=repo_root)
|
|
111
|
+
out: dict[str, str] = {}
|
|
112
|
+
i = 0
|
|
113
|
+
while i < len(fields):
|
|
114
|
+
status = fields[i]
|
|
115
|
+
if status.startswith("R"):
|
|
116
|
+
out[fields[i + 2]] = fields[i + 1]
|
|
117
|
+
i += 3
|
|
118
|
+
else:
|
|
119
|
+
i += 2
|
|
120
|
+
return out
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The trmv commands' entry modules (`cli/<command>.py`)."""
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from trmv import refactor
|
|
2
|
+
from trmv.config.command import command_argv, run_command
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def trmv_compliance(argv: list[str] | None = None) -> int:
|
|
6
|
+
return run_command(
|
|
7
|
+
"trmv-compliance", command_argv(argv), lambda args: refactor.run_compliance(paths=args.paths, select=args.select, attrs=args.attr)
|
|
8
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from trmv.config import run_get, run_show, trmv_view
|
|
4
|
+
from trmv.config.command import command_argv, command_root, run_command
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _config(args: argparse.Namespace) -> int:
|
|
8
|
+
root = command_root(args.root)
|
|
9
|
+
return run_show("trmv-config", root, trmv_view) if args.subcommand == "show" else run_get("trmv-config", root, args.key, trmv_view)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def trmv_config(argv: list[str] | None = None) -> int:
|
|
13
|
+
return run_command("trmv-config", command_argv(argv), _config)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from trmv import doctor, twin
|
|
4
|
+
from trmv.config.command import command_argv, command_root, run_command
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _doctor(args: argparse.Namespace) -> int:
|
|
8
|
+
if args.twin:
|
|
9
|
+
print(twin.identity())
|
|
10
|
+
return 0
|
|
11
|
+
return doctor.run(
|
|
12
|
+
root=command_root(args.root),
|
|
13
|
+
plugin=args.plugin,
|
|
14
|
+
print_hash=args.contract_hash,
|
|
15
|
+
require_config=args.require_config,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def trmv_doctor(argv: list[str] | None = None) -> int:
|
|
20
|
+
return run_command("trmv-doctor", command_argv(argv), _doctor)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from trmv import refactor
|
|
2
|
+
from trmv.config.command import command_argv, run_command
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def trmv_mock_lint(argv: list[str] | None = None) -> int:
|
|
6
|
+
return run_command("trmv-mock-lint", command_argv(argv), lambda args: refactor.run_mock_lint(paths=args.paths, base=args.base))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from trmv import refactor
|
|
4
|
+
from trmv.config.command import command_argv, run_command
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _refactor(raw: list[str], args: argparse.Namespace) -> int:
|
|
8
|
+
return refactor.route_refactor(
|
|
9
|
+
raw,
|
|
10
|
+
args,
|
|
11
|
+
lambda: refactor.run_refactor(project_root=args.project, command=args.subcommand, apply=args.apply, options=vars(args)),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def trmv_refactor(argv: list[str] | None = None) -> int:
|
|
16
|
+
raw = command_argv(argv)
|
|
17
|
+
return run_command("trmv-refactor", raw, lambda args: _refactor(raw, args))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from trmv import typecheck
|
|
4
|
+
from trmv.config.command import command_argv, run_command
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def trmv_typecheck(argv: list[str] | None = None) -> int:
|
|
8
|
+
return run_command(
|
|
9
|
+
"trmv-typecheck",
|
|
10
|
+
command_argv(argv),
|
|
11
|
+
lambda args: typecheck.run(
|
|
12
|
+
cwd=Path.cwd(), write=args.write_baseline, language_id=args.language, realign_from=args.realign_from
|
|
13
|
+
),
|
|
14
|
+
)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Per-repo config: the committed file trmv reads, validated and completed by trmv's schema; the shared loading, format
|
|
2
|
+
check, language detection and config-command machinery la's config builds on."""
|
|
3
|
+
|
|
4
|
+
from trmv.config.format import (
|
|
5
|
+
FORMAT_KEY,
|
|
6
|
+
Committed,
|
|
7
|
+
check_format,
|
|
8
|
+
compare_versions,
|
|
9
|
+
current_format,
|
|
10
|
+
format_problem,
|
|
11
|
+
is_version,
|
|
12
|
+
read_committed,
|
|
13
|
+
released_formats,
|
|
14
|
+
stamp_format,
|
|
15
|
+
)
|
|
16
|
+
from trmv.config.languages import language_fact, repo_languages, source_files
|
|
17
|
+
from trmv.config.load import (
|
|
18
|
+
ConfigError,
|
|
19
|
+
LanguageSettings,
|
|
20
|
+
RefactorConfig,
|
|
21
|
+
RefactorPythonConfig,
|
|
22
|
+
TrmvCommandsConfig,
|
|
23
|
+
TrmvConfig,
|
|
24
|
+
TypecheckConfig,
|
|
25
|
+
both_files_problem,
|
|
26
|
+
check_string_forms,
|
|
27
|
+
config_source,
|
|
28
|
+
explicit_typecheck,
|
|
29
|
+
find_repo_root,
|
|
30
|
+
language_settings,
|
|
31
|
+
load_config,
|
|
32
|
+
load_dr_data,
|
|
33
|
+
load_with_languages,
|
|
34
|
+
own_file,
|
|
35
|
+
parse_config,
|
|
36
|
+
read_config,
|
|
37
|
+
read_config_text,
|
|
38
|
+
resolve,
|
|
39
|
+
)
|
|
40
|
+
from trmv.config.values import ConfigView, format_value, run_get, run_show, trmv_view
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"FORMAT_KEY",
|
|
44
|
+
"Committed",
|
|
45
|
+
"ConfigError",
|
|
46
|
+
"ConfigView",
|
|
47
|
+
"LanguageSettings",
|
|
48
|
+
"RefactorConfig",
|
|
49
|
+
"RefactorPythonConfig",
|
|
50
|
+
"TrmvCommandsConfig",
|
|
51
|
+
"TrmvConfig",
|
|
52
|
+
"TypecheckConfig",
|
|
53
|
+
"both_files_problem",
|
|
54
|
+
"check_format",
|
|
55
|
+
"check_string_forms",
|
|
56
|
+
"compare_versions",
|
|
57
|
+
"config_source",
|
|
58
|
+
"current_format",
|
|
59
|
+
"explicit_typecheck",
|
|
60
|
+
"find_repo_root",
|
|
61
|
+
"format_problem",
|
|
62
|
+
"format_value",
|
|
63
|
+
"is_version",
|
|
64
|
+
"language_fact",
|
|
65
|
+
"language_settings",
|
|
66
|
+
"load_config",
|
|
67
|
+
"load_dr_data",
|
|
68
|
+
"load_with_languages",
|
|
69
|
+
"own_file",
|
|
70
|
+
"parse_config",
|
|
71
|
+
"read_committed",
|
|
72
|
+
"read_config",
|
|
73
|
+
"read_config_text",
|
|
74
|
+
"released_formats",
|
|
75
|
+
"repo_languages",
|
|
76
|
+
"resolve",
|
|
77
|
+
"run_get",
|
|
78
|
+
"run_show",
|
|
79
|
+
"source_files",
|
|
80
|
+
"stamp_format",
|
|
81
|
+
"trmv_view",
|
|
82
|
+
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Running a command: parse argv per its manifest, check the config file, dispatch to the handler."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from trmv import config
|
|
12
|
+
from trmv.contract import manifest
|
|
13
|
+
from trmv.contract.parser import parse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def run_command(
|
|
17
|
+
command: str,
|
|
18
|
+
argv: list[str],
|
|
19
|
+
handler: Callable[[argparse.Namespace], int],
|
|
20
|
+
commands: dict[str, Any] | None = None,
|
|
21
|
+
config_file: str | None = None,
|
|
22
|
+
) -> int:
|
|
23
|
+
"""Parse `argv` per `commands` (default: trmv's manifest; not for a passthrough command), refuse both config files
|
|
24
|
+
and check the format of `config_file` (default: the one trmv reads) unless exempt, then run `handler`."""
|
|
25
|
+
spec = (commands or manifest())[command]
|
|
26
|
+
args = argparse.Namespace() if spec.get("passthrough") else parse(command, argv, commands)
|
|
27
|
+
if spec.get("format") != "exempt":
|
|
28
|
+
root = _checked_root(args)
|
|
29
|
+
problem = config.both_files_problem(root) or config.check_format(root, config_file)
|
|
30
|
+
if problem is not None:
|
|
31
|
+
print(problem, file=sys.stderr)
|
|
32
|
+
return 2
|
|
33
|
+
return handler(args)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _checked_root(args: argparse.Namespace) -> Path:
|
|
37
|
+
"""The repo whose format a command checks: `--root`, else the git root of `--project`, else of the cwd."""
|
|
38
|
+
root: str | None = getattr(args, "root", None)
|
|
39
|
+
project: str | None = getattr(args, "project", None)
|
|
40
|
+
return command_root(root) if root or not project else config.find_repo_root(Path(project))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def command_root(root: str | None) -> Path:
|
|
44
|
+
return Path(root).resolve() if root else config.find_repo_root(Path.cwd())
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def command_argv(argv: list[str] | None) -> list[str]:
|
|
48
|
+
return list(sys.argv[1:] if argv is None else argv)
|